diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerCaseController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerCaseController.java index 7ac7dd7d4..02164aad6 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerCaseController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerCaseController.java @@ -81,7 +81,7 @@ public class SysCustomerCaseController extends BaseController @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { - return AjaxResult.success(sysCustomerCaseService.selectSysCustomerCaseById(id)); + return AjaxResult.success(sysCustomerCaseService.selectSysCustomerCaseById(id, true)); } /** @@ -134,6 +134,7 @@ public class SysCustomerCaseController extends BaseController int index = 0; for (String downUrl : downUrlList) { list.get(index).setDownUrl(downUrl); + index++; } } return getDataTable(list); diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWxSaleAccountController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWxSaleAccountController.java index 5eeaeb636..cf02a80f8 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWxSaleAccountController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWxSaleAccountController.java @@ -5,14 +5,7 @@ import java.util.List; import com.stdiet.common.utils.StringUtils; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import com.stdiet.common.annotation.Log; import com.stdiet.common.core.controller.BaseController; import com.stdiet.common.core.domain.AjaxResult; @@ -40,9 +33,11 @@ public class SysWxSaleAccountController extends BaseController */ @PreAuthorize("@ss.hasPermi('custom:wxAccount:list')") @GetMapping("/list") - public TableDataInfo list(SysWxSaleAccount sysWxSaleAccount) + public TableDataInfo list(SysWxSaleAccount sysWxSaleAccount, @RequestParam(value = "pageFlag", required = false, defaultValue = "true")boolean pageFlag) { - startPage(); + if(pageFlag){ + startPage(); + } List list = sysWxSaleAccountService.selectSysWxSaleAccountList(sysWxSaleAccount); return getDataTable(list); } diff --git a/stdiet-common/src/main/java/com/stdiet/common/utils/oss/AliyunOSSUtils.java b/stdiet-common/src/main/java/com/stdiet/common/utils/oss/AliyunOSSUtils.java index 0d063a081..8fc50e3c2 100644 --- a/stdiet-common/src/main/java/com/stdiet/common/utils/oss/AliyunOSSUtils.java +++ b/stdiet-common/src/main/java/com/stdiet/common/utils/oss/AliyunOSSUtils.java @@ -15,7 +15,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import java.net.URL; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -74,10 +73,10 @@ public class AliyunOSSUtils { //去尾 String tail = oranName.substring(cutPoint); //返回正确的带路径的图片名称 - return prefix + head + uuid + "_" + tail; + return prefix + head + tail + "_" + uuid; } //不存在 直接返回 - return prefix + uuid + "_" + oranName; + return prefix + oranName + "_" + uuid; } /** diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomerCase.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomerCase.java index 8fd166cc9..4a4cfc4f8 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomerCase.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomerCase.java @@ -4,6 +4,8 @@ import com.stdiet.common.annotation.Excel; import com.stdiet.common.core.domain.BaseEntity; import lombok.Data; +import java.util.List; + /** * 客户案例管理对象 sys_customer_case * @@ -35,6 +37,11 @@ public class SysCustomerCase extends BaseEntity /** 删除标识 0未删除 1已删除,默认0 */ private Long delFlag; + /** + * 文件列表 + */ + private List caseFileList; + //案例文件名称数组 private String[] caseFileName; diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysCustomerCaseService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysCustomerCaseService.java index 76dc9dc7e..149c833ef 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysCustomerCaseService.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysCustomerCaseService.java @@ -17,7 +17,7 @@ public interface ISysCustomerCaseService { * @param id 客户案例管理ID * @return 客户案例管理 */ - public SysCustomerCase selectSysCustomerCaseById(Long id); + public SysCustomerCase selectSysCustomerCaseById(Long id, boolean fileListFlag); /** * 查询客户案例管理列表 diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerCaseServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerCaseServiceImpl.java index dc91d3e1d..2b2c18ed5 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerCaseServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysCustomerCaseServiceImpl.java @@ -35,9 +35,13 @@ public class SysCustomerCaseServiceImpl implements ISysCustomerCaseService * @return 客户案例管理 */ @Override - public SysCustomerCase selectSysCustomerCaseById(Long id) + public SysCustomerCase selectSysCustomerCaseById(Long id, boolean fileListFlag) { - return sysCustomerCaseMapper.selectSysCustomerCaseById(id); + SysCustomerCase customerCase = sysCustomerCaseMapper.selectSysCustomerCaseById(id); + if(customerCase != null && fileListFlag){ + customerCase.setCaseFileList(sysCustomerCaseFileMapper.selectSysCustomerCaseFileListByCaseId(customerCase.getId())); + } + return customerCase; } /** @@ -64,19 +68,7 @@ public class SysCustomerCaseServiceImpl implements ISysCustomerCaseService sysCustomerCase.setCreateTime(DateUtils.getNowDate()); int rows = sysCustomerCaseMapper.insertSysCustomerCase(sysCustomerCase); if(rows > 0){ - //批量添加文件对应列表 - SysCustomerCaseFile caseFile = null; - if(sysCustomerCase.getCaseFileUrl() != null && sysCustomerCase.getCaseFileUrl().length > 0){ - List caseFileList = new ArrayList<>(); - for (String url : sysCustomerCase.getCaseFileUrl()) { - caseFile = new SysCustomerCaseFile(); - caseFile.setCaseId(sysCustomerCase.getId()); - caseFile.setFileName(sysCustomerCase.getCaseFileName()[caseFileList.size()]); - caseFile.setFileUrl(url); - caseFileList.add(caseFile); - } - rows = sysCustomerCaseFileMapper.insertBatch(caseFileList); - } + rows = addCaseFile(sysCustomerCase); } return rows; } @@ -91,7 +83,38 @@ public class SysCustomerCaseServiceImpl implements ISysCustomerCaseService public int updateSysCustomerCase(SysCustomerCase sysCustomerCase) { sysCustomerCase.setUpdateTime(DateUtils.getNowDate()); - return sysCustomerCaseMapper.updateSysCustomerCase(sysCustomerCase); + int rows = sysCustomerCaseMapper.updateSysCustomerCase(sysCustomerCase); + if(rows > 0){ + rows = addCaseFile(sysCustomerCase); + } + return rows; + } + + /** + * 批量添加文件对应列表 + * @param sysCustomerCase + * @return + */ + private int addCaseFile(SysCustomerCase sysCustomerCase){ + int rows = 0; + //批量添加文件对应列表 + SysCustomerCaseFile caseFile = null; + if(sysCustomerCase.getCaseFileUrl() != null && sysCustomerCase.getCaseFileUrl().length > 0){ + List caseFileList = new ArrayList<>(); + for (String url : sysCustomerCase.getCaseFileUrl()) { + caseFile = new SysCustomerCaseFile(); + caseFile.setCaseId(sysCustomerCase.getId()); + caseFile.setFileName(sysCustomerCase.getCaseFileName()[caseFileList.size()]); + caseFile.setFileUrl(url); + caseFileList.add(caseFile); + } + //如果是修改操作直接先删除全部,再添加 + if(sysCustomerCase.getId() != null){ + sysCustomerCaseFileMapper.deleteSysCustomerCaseFileByCaseId(sysCustomerCase.getId()); + } + rows = sysCustomerCaseFileMapper.insertBatch(caseFileList); + } + return rows; } /** diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysWxSaleAccountMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysWxSaleAccountMapper.xml index 91140b19a..83a5e355d 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysWxSaleAccountMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysWxSaleAccountMapper.xml @@ -28,6 +28,7 @@ and wx_nick_name like concat('%', #{wxNickName}, '%') and wx_account like concat('%', #{wxAccount}, '%') and wx_phone like concat('%', #{wxPhone}, '%') + order by id desc