|
|
@@ -0,0 +1,151 @@
|
|
|
+package cn.iocoder.yudao.module.customer.controller.admin.info;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.module.customer.controller.admin.businessopportunity.vo.CustomerBusinessOpportunityRespVO;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+
|
|
|
+import javax.validation.constraints.*;
|
|
|
+import javax.validation.*;
|
|
|
+import javax.servlet.http.*;
|
|
|
+import java.util.*;
|
|
|
+import java.io.IOException;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.module.customer.controller.admin.info.vo.*;
|
|
|
+import cn.iocoder.yudao.module.customer.dal.dataobject.info.CustomerInfoDO;
|
|
|
+import cn.iocoder.yudao.module.customer.service.info.CustomerInfoService;
|
|
|
+
|
|
|
+@Tag(name = "管理后台 - 客户信息")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/customer/info")
|
|
|
+@Validated
|
|
|
+public class CustomerInfoController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private CustomerInfoService infoService;
|
|
|
+ @Resource
|
|
|
+ private DeptApi deptApi;
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ @Operation(summary = "创建客户信息")
|
|
|
+ @PreAuthorize("@ss.hasPermission('customer:info:create')")
|
|
|
+ public CommonResult<Long> createInfo(@Valid @RequestBody CustomerInfoSaveReqVO createReqVO) {
|
|
|
+ return success(infoService.createInfo(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update")
|
|
|
+ @Operation(summary = "更新客户信息")
|
|
|
+ @PreAuthorize("@ss.hasPermission('customer:info:update')")
|
|
|
+ public CommonResult<Boolean> updateInfo(@Valid @RequestBody CustomerInfoSaveReqVO updateReqVO) {
|
|
|
+ infoService.updateInfo(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @Operation(summary = "删除客户信息")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ @PreAuthorize("@ss.hasPermission('customer:info:delete')")
|
|
|
+ public CommonResult<Boolean> deleteInfo(@RequestParam("id") Long id) {
|
|
|
+ infoService.deleteInfo(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ @Operation(summary = "获得客户信息")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('customer:info:query')")
|
|
|
+ public CommonResult<CustomerInfoRespVO> getInfo(@RequestParam("id") Long id) {
|
|
|
+ return success(infoService.getById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ @Operation(summary = "获得客户信息分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('customer:info:query')")
|
|
|
+ public CommonResult<PageResult<CustomerInfoRespVO>> getInfoPage(@Valid CustomerInfoPageReqVO pageReqVO) {
|
|
|
+ PageResult<CustomerInfoDO> pageResult = infoService.getInfoPage(pageReqVO);
|
|
|
+ PageResult<CustomerInfoRespVO> result = BeanUtils.toBean(pageResult, CustomerInfoRespVO.class);
|
|
|
+ if (result != null && result.getList() != null && result.getList().size() > 0) {
|
|
|
+ result.getList().forEach(respVO -> {
|
|
|
+ // 部门
|
|
|
+ if (respVO.getDeptId() != null) {
|
|
|
+ DeptRespDTO dept = deptApi.getDept(respVO.getDeptId());
|
|
|
+ respVO.setDeptName(dept.getName());
|
|
|
+ if (dept != null && StringUtils.isNotBlank(dept.getName())) {
|
|
|
+ respVO.setDeptName(dept.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export-excel")
|
|
|
+ @Operation(summary = "导出客户信息 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('customer:info:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportInfoExcel(@Valid CustomerInfoPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<CustomerInfoDO> list = infoService.getInfoPage(pageReqVO).getList();
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "客户信息.xls", "数据", CustomerInfoRespVO.class,
|
|
|
+ BeanUtils.toBean(list, CustomerInfoRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/getCustomerCode")
|
|
|
+ @Operation(summary = "获取客户编号")
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
+ public CommonResult<String> getCustomerCode() {
|
|
|
+ return success(infoService.getCustomerCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update-open-status")
|
|
|
+ @Operation(summary = "修改用户状态")
|
|
|
+ @PreAuthorize("@ss.hasPermission('system:user:update')")
|
|
|
+ public CommonResult<Boolean> updateOpenStatus(@Valid @RequestBody CustomerInfoOpenStatusReqVO reqVO) {
|
|
|
+ infoService.updateOpenStatus(reqVO.getId(), reqVO.getStatus());
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/list")
|
|
|
+ @Operation(summary = "获得客户信息列表")
|
|
|
+ @PreAuthorize("@ss.hasPermission('customer:info:query')")
|
|
|
+ public CommonResult<List<CustomerInfoRespVO>> getInfoList(@Valid CustomerInfoPageReqVO pageReqVO) {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<CustomerInfoDO> pageResult = infoService.getInfoPage(pageReqVO).getList();
|
|
|
+ List<CustomerInfoRespVO> result = BeanUtils.toBean(pageResult, CustomerInfoRespVO.class);
|
|
|
+ if (result != null && result.size() > 0) {
|
|
|
+ result.forEach(respVO -> {
|
|
|
+ // 部门
|
|
|
+ if (respVO.getDeptId() != null) {
|
|
|
+ DeptRespDTO dept = deptApi.getDept(respVO.getDeptId());
|
|
|
+ respVO.setDeptName(dept.getName());
|
|
|
+ if (dept != null && StringUtils.isNotBlank(dept.getName())) {
|
|
|
+ respVO.setDeptName(dept.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|