| | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.credit.vo.CrmCreditRatingImportExcelVO; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.credit.vo.CrmCreditRatingImportReqVO; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.credit.vo.CrmCreditRatingImportRespVO; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.credit.vo.CrmCreditRatingPageReqVO; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.credit.vo.CrmCreditRatingRespVO; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.credit.vo.CrmCreditRatingSaveReqVO; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得客户信用评级") |
| | | @Parameter(name = "id", description = "编号", required = true) |
| | | @PreAuthorize("@ss.hasPermission('crm:credit-rating:query')") |
| | | public CommonResult<CrmCreditRatingRespVO> getCreditRating(@RequestParam("id") Long id) { |
| | | return success(creditRatingService.getCreditRating(id)); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得客户信用评级分页") |
| | | @PreAuthorize("@ss.hasPermission('crm:credit-rating:query')") |
| | | public CommonResult<PageResult<CrmCreditRatingRespVO>> getCreditRatingPage(@Valid CrmCreditRatingPageReqVO pageReqVO) { |
| | | return success(creditRatingService.getCreditRatingPage(pageReqVO)); |
| | | } |
| | |
| | | @GetMapping("/latest-by-customer") |
| | | @Operation(summary = "获取客户最新信用评级") |
| | | @Parameter(name = "customerId", description = "客户ID", required = true) |
| | | @PreAuthorize("@ss.hasPermission('crm:credit-rating:query')") |
| | | public CommonResult<CrmCreditRatingRespVO> getLatestByCustomer(@RequestParam("customerId") Long customerId) { |
| | | return success(creditRatingService.getLatestByCustomerId(customerId)); |
| | | } |
| | | |
| | | } |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得导入客户信用评级模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | List<CrmCreditRatingImportExcelVO> list = Arrays.asList( |
| | | CrmCreditRatingImportExcelVO.builder().customerName("示例客户").level(null) |
| | | .score(null).evalType("").evalReason("").operatorName("") |
| | | .operateTime(null).validUntil(null).remark("").build() |
| | | ); |
| | | ExcelUtils.writeTemplate(response, "客户信用评级导入模板.xls", "客户信用评级列表", CrmCreditRatingImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入客户信用评级") |
| | | @PreAuthorize("@ss.hasPermission('crm:credit-rating:import')") |
| | | public CommonResult<CrmCreditRatingImportRespVO> importExcel(@Valid CrmCreditRatingImportReqVO importReqVO) |
| | | throws Exception { |
| | | List<CrmCreditRatingImportExcelVO> list = ExcelUtils.read(importReqVO.getFile(), CrmCreditRatingImportExcelVO.class); |
| | | return success(creditRatingService.importCreditRatingList(list, importReqVO)); |
| | | } |
| | | |
| | | } |