| | |
| | | import com.ruoyi.system.query.TMerchantQuery; |
| | | import com.ruoyi.system.service.TMerchantService; |
| | | import com.ruoyi.system.service.TMerchantTypeService; |
| | | import com.ruoyi.system.vo.TMerchantVO; |
| | | import com.ruoyi.web.controller.tool.ExcelUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @ApiOperation(value = "获取商户信息管理分页列表") |
| | | @PostMapping(value = "/pageList") |
| | | public R<PageInfo<TMerchant>> pageList(@RequestBody TMerchantQuery query) { |
| | | public R<PageInfo<TMerchantVO>> pageList(@RequestBody TMerchantQuery query) { |
| | | return R.ok(merchantService.pageList(query)); |
| | | } |
| | | |
| | |
| | | @GetMapping("/import-template") |
| | | public void importTemplate() { |
| | | List<MerchantImport> merchantImports = new ArrayList<>(); |
| | | MerchantImport merchantImport = new MerchantImport(); |
| | | merchantImports.add(merchantImport); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), MerchantImport.class, merchantImports); |
| | | // 查询分类列表 |
| | | List<TMerchantType> merchantTypes = merchantTypeService.list(Wrappers.lambdaQuery(TMerchantType.class).orderByDesc(TMerchantType::getCreateTime)); |
| | | List<String> dataList = new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(merchantTypes)) { |
| | | dataList = merchantTypes.stream().map(TMerchantType::getTypeName).collect(Collectors.toList()); |
| | | } |
| | | ExcelUtil.selectList(workbook, 1, 65535, 2, 2, dataList.toArray(new String[dataList.size()]), 1); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | |
| | | for (MerchantImport merchantImport : merchantImports) { |
| | | if (!StringUtils.hasLength(merchantImport.getMerchantName())){ |
| | | result.append("第"+i+"行:[", "商户名称"+"]不能为空"); |
| | | i++; |
| | | continue; |
| | | } |
| | | if (!StringUtils.hasLength(merchantImport.getMerchantPhone())){ |
| | | result.append("第"+i+"行:[", "商户电话"+"]不能为空"); |
| | | i++; |
| | | continue; |
| | | } |
| | | if (!StringUtils.hasLength(merchantImport.getTypeName())){ |
| | | result.append("第"+i+"行:[", "商户分类"+"]不能为空"); |
| | | i++; |
| | | continue; |
| | | } |
| | | if (!StringUtils.hasLength(merchantImport.getAddress())){ |
| | | result.append("第"+i+"行:[", "商户地址"+"]不能为空"); |
| | | i++; |
| | | continue; |
| | | } |
| | | TMerchantType merchantType = merchantTypeService.getOne(Wrappers.lambdaQuery(TMerchantType.class) |
| | |
| | | .last("LIMIT 1")); |
| | | if(Objects.isNull(merchantType)){ |
| | | result.append("第"+i+"行:[", "商户分类"+"]不存在"); |
| | | i++; |
| | | continue; |
| | | } |
| | | TMerchant merchant = new TMerchant(); |