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 38ff8e102..099d0afa9 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 @@ -141,6 +141,20 @@ public class SysCustomerCaseController extends BaseController return getDataTable(list); } + /** + * 修改客户案例是否微信展示状态 + */ + //@PreAuthorize("@ss.hasPermi('custom:customerCase:wxShow')") + @Log(title = "微信展示状态修改", businessType = BusinessType.UPDATE) + @PostMapping("/updateWxShow") + public AjaxResult updateWxShow(@RequestBody SysCustomerCase sysCustomerCase) + { + if(sysCustomerCase.getWxShow() == null || sysCustomerCase.getIds() == null || sysCustomerCase.getIds().length == 0){ + return AjaxResult.error(); + } + return toAjax(sysCustomerCaseService.updateWxShowByIds(sysCustomerCase.getWxShow() ? 1 : 0, sysCustomerCase.getIds())); + } + // 转移到SysFileUploadController.java // /** // * 上传文件到OSS返回URL diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WxCustomerCaseController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WxCustomerCaseController.java index dd45de035..f9cdad085 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WxCustomerCaseController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WxCustomerCaseController.java @@ -5,6 +5,7 @@ import com.stdiet.common.core.domain.AjaxResult; import com.stdiet.common.core.page.TableDataInfo; import com.stdiet.common.utils.StringUtils; import com.stdiet.common.utils.oss.AliyunOSSUtils; +import com.stdiet.common.utils.sign.AesUtils; import com.stdiet.custom.domain.SysCustomerCase; import com.stdiet.custom.domain.SysCustomerCaseFile; import com.stdiet.custom.dto.response.CustomerCaseResponse; @@ -33,9 +34,9 @@ public class WxCustomerCaseController extends BaseController{ { startPage(); sysCustomerCase.setKeywordArray(StringUtils.isNotEmpty(sysCustomerCase.getKeyword()) ? sysCustomerCase.getKeyword().split(",") : null); - //sysCustomerCase.setWxShow(1); - List<SysCustomerCase> list = sysCustomerCaseService.selectSysCustomerCaseList(sysCustomerCase); - //List<CustomerCaseResponse> resultList = dealSysCustomerCase(list); + List<CustomerCaseResponse> list = sysCustomerCaseService.getWxCustomerCaseList(sysCustomerCase); + //处理ID加密 + dealIdEnc(list); return getDataTable(list); } @@ -43,34 +44,33 @@ public class WxCustomerCaseController extends BaseController{ * 查询客户案例文件列表 */ @GetMapping("/getFileByCaseId") - public AjaxResult getFileByCaseId(@RequestParam("caseId")Long caseId) + public AjaxResult getFileByCaseId(@RequestParam("caseId")String caseId) { + Long id = StringUtils.isNotEmpty(caseId) ? Long.parseLong(AesUtils.decrypt(caseId, null)) : null; CustomerCaseResponse customerCaseResponse = new CustomerCaseResponse(); - List<SysCustomerCaseFile> list = sysCustomerCaseService.getFileListByCaseId(caseId); - List<String> fileUrl = new ArrayList<>(); - for (SysCustomerCaseFile caseFile : list) { - fileUrl.add(caseFile.getFileUrl()); + customerCaseResponse.setId(caseId); + if(id != null){ + List<SysCustomerCaseFile> list = sysCustomerCaseService.getFileListByCaseId(id); + List<String> fileUrl = new ArrayList<>(); + for (SysCustomerCaseFile caseFile : list) { + fileUrl.add(caseFile.getFileUrl()); + } + List<String> downUrlList = AliyunOSSUtils.generatePresignedUrl(fileUrl); + customerCaseResponse.setFileList(downUrlList); + }else{ + customerCaseResponse.setFileList(new ArrayList<>()); } - List<String> downUrlList = AliyunOSSUtils.generatePresignedUrl(fileUrl); - customerCaseResponse.setFileList(downUrlList); return AjaxResult.success(customerCaseResponse); } /** - * 处理返回值 + * 处理返回值的ID加密 * @param list * @return */ - private List<CustomerCaseResponse> dealSysCustomerCase(List<SysCustomerCase> list){ - List<CustomerCaseResponse> resultList = new ArrayList<>(); - for (SysCustomerCase customerCase : list) { - CustomerCaseResponse customerCaseResponse = new CustomerCaseResponse(); - customerCaseResponse.setId(customerCase.getId()); - customerCaseResponse.setKeyword(customerCase.getKeyword()); - customerCaseResponse.setName(customerCase.getName()); - customerCaseResponse.setRemark(customerCase.getRemark()); - resultList.add(customerCaseResponse); + private void dealIdEnc(List<CustomerCaseResponse> list){ + for (CustomerCaseResponse cus : list) { + cus.setId(AesUtils.encrypt(cus.getId()+"", null)); } - return resultList; } } 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 7c8e0a51d..4cb800dff 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 @@ -20,6 +20,8 @@ public class SysCustomerCase extends BaseEntity /** $column.columnComment */ private Long id; + private Long[] ids; + /** 案例名称 */ @Excel(name = "案例名称") private String name; @@ -37,7 +39,7 @@ public class SysCustomerCase extends BaseEntity private String customerName; //是否显示到微信小程序 - private Integer wxShow; + private Boolean wxShow; /** 删除标识 0未删除 1已删除,默认0 */ private Long delFlag; diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/dto/response/CustomerCaseResponse.java b/stdiet-custom/src/main/java/com/stdiet/custom/dto/response/CustomerCaseResponse.java index be3f224fa..08a6a8d65 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/dto/response/CustomerCaseResponse.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/dto/response/CustomerCaseResponse.java @@ -7,7 +7,7 @@ import java.util.List; @Data public class CustomerCaseResponse { - private Long id; + private String id; private String name; @@ -15,5 +15,7 @@ public class CustomerCaseResponse { private String remark; + private Boolean wxShow; + private List<String> fileList; } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysCustomerCaseMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysCustomerCaseMapper.java index 0cc4a0b97..9a5927622 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysCustomerCaseMapper.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysCustomerCaseMapper.java @@ -2,6 +2,8 @@ package com.stdiet.custom.mapper; import java.util.List; import com.stdiet.custom.domain.SysCustomerCase; +import com.stdiet.custom.dto.response.CustomerCaseResponse; +import org.apache.ibatis.annotations.Param; /** * 客户案例管理Mapper接口 @@ -58,4 +60,19 @@ public interface SysCustomerCaseMapper * @return 结果 */ public int deleteSysCustomerCaseByIds(Long[] ids); + + /** + * 查询微信小程序上展示的客户案例 + * @param sysCustomerCase + * @return + */ + public List<CustomerCaseResponse> getWxCustomerCaseList(SysCustomerCase sysCustomerCase); + + /** + * 更新微信展示状态 + * @param wxShow 是否展示 0不展示 1展示 + * @param ids id数组 + * @return + */ + public int updateWxShowByIds(@Param("wxShow")Integer wxShow, @Param("array") Long[] ids); } \ No newline at end of file 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 149c833ef..f17e6518e 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 @@ -3,6 +3,7 @@ package com.stdiet.custom.service; import java.util.List; import com.stdiet.custom.domain.SysCustomerCase; import com.stdiet.custom.domain.SysCustomerCaseFile; +import com.stdiet.custom.dto.response.CustomerCaseResponse; /** * 客户案例管理Service接口 @@ -66,4 +67,19 @@ public interface ISysCustomerCaseService { */ List<SysCustomerCaseFile> getFileListByCaseId(Long caseId); + /** + * 查询微信小程序上展示的客户案例 + * @param sysCustomerCase + * @return + */ + List<CustomerCaseResponse> getWxCustomerCaseList(SysCustomerCase sysCustomerCase); + + /** + * 更新微信展示状态 + * @param wxShow 是否展示 0不展示 1展示 + * @param ids id数组 + * @return + */ + int updateWxShowByIds(Integer wxShow, Long[] ids); + } \ No newline at end of file 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 2b2c18ed5..bcd95bc91 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 @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import com.stdiet.common.utils.DateUtils; import com.stdiet.custom.domain.SysCustomerCaseFile; +import com.stdiet.custom.dto.response.CustomerCaseResponse; import com.stdiet.custom.mapper.SysCustomerCaseFileMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -154,7 +155,29 @@ public class SysCustomerCaseServiceImpl implements ISysCustomerCaseService * @param caseId * @return */ + @Override public List<SysCustomerCaseFile> getFileListByCaseId(Long caseId){ return sysCustomerCaseFileMapper.selectSysCustomerCaseFileListByCaseId(caseId); } + + /** + * 查询微信小程序上展示的客户案例 + * @param sysCustomerCase + * @return + */ + @Override + public List<CustomerCaseResponse> getWxCustomerCaseList(SysCustomerCase sysCustomerCase){ + return sysCustomerCaseMapper.getWxCustomerCaseList(sysCustomerCase); + } + + /** + * 更新微信展示状态 + * @param wxShow 是否展示 0不展示 1展示 + * @param ids id数组 + * @return + */ + @Override + public int updateWxShowByIds(Integer wxShow, Long[] ids){ + return sysCustomerCaseMapper.updateWxShowByIds(wxShow, ids); + } } \ No newline at end of file diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysCustomerCaseMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysCustomerCaseMapper.xml index 5783a7191..7ed96cf76 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysCustomerCaseMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysCustomerCaseMapper.xml @@ -10,6 +10,7 @@ <result property="keyword" column="keyword" /> <result property="remark" column="remark" /> <result property="customerId" column="customer_id" /> + <result property="wxShow" column="wx_show" /> <result property="createTime" column="create_time" /> <result property="createBy" column="create_by" /> <result property="updateTime" column="update_time" /> @@ -19,8 +20,16 @@ <result property="customerName" column="customer_name"></result> </resultMap> + <resultMap type="com.stdiet.custom.dto.response.CustomerCaseResponse" id="SysCustomerCaseResponseResult"> + <result property="id" column="id" /> + <result property="name" column="name" /> + <result property="keyword" column="keyword" /> + <result property="remark" column="remark" /> + <result property="wxShow" column="wx_show" /> + </resultMap> + <sql id="selectSysCustomerCaseVo"> - select id, name, keyword, remark, customer_id, create_time from sys_customer_case + select id, name, keyword, remark, customer_id, wx_show, create_time from sys_customer_case </sql> <sql id="searchKey"> @@ -34,7 +43,7 @@ </sql> <select id="selectSysCustomerCaseList" parameterType="SysCustomerCase" resultMap="SysCustomerCaseResult"> - select scc.id, scc.name, scc.keyword, scc.remark, scc.customer_id, scc.create_time,sc.name as customer_name from sys_customer_case scc + select scc.id, scc.name, scc.keyword, scc.remark, scc.customer_id, scc.wx_show, scc.create_time,sc.name as customer_name from sys_customer_case scc left join sys_customer sc on sc.id = scc.customer_id and sc.del_flag = 0 where scc.del_flag = 0 <include refid="searchKey"> @@ -50,7 +59,7 @@ </select> <select id="selectSysCustomerCaseById" parameterType="Long" resultMap="SysCustomerCaseResult"> - select scc.id, scc.name, scc.keyword, scc.remark, scc.customer_id, scc.create_time,sc.name as customer_name from sys_customer_case scc + select scc.id, scc.name, scc.keyword, scc.remark, scc.customer_id, scc.wx_show, scc.create_time,sc.name as customer_name from sys_customer_case scc left join sys_customer sc on sc.id = scc.customer_id and sc.del_flag = 0 where scc.id = #{id} and scc.del_flag = 0 </select> @@ -62,6 +71,7 @@ <if test="keyword != null">keyword,</if> <if test="remark != null">remark,</if> <if test="customerId != null">customer_id,</if> + <if test="wxShow != null">wx_show,</if> <if test="createTime != null">create_time,</if> <if test="createBy != null">create_by,</if> <if test="updateTime != null">update_time,</if> @@ -73,6 +83,7 @@ <if test="keyword != null">#{keyword},</if> <if test="remark != null">#{remark},</if> <if test="customerId != null">#{customerId},</if> + <if test="wxShow != null">#{wxShow},</if> <if test="createTime != null">#{createTime},</if> <if test="createBy != null">#{createBy},</if> <if test="updateTime != null">#{updateTime},</if> @@ -88,6 +99,7 @@ <if test="keyword != null">keyword = #{keyword},</if> <if test="remark != null">remark = #{remark},</if> <if test="customerId != null">customer_id = #{customerId},</if> + <if test="wxShow != null">wx_show = #{wxShow},</if> <if test="createTime != null">create_time = #{createTime},</if> <if test="createBy != null">create_by = #{createBy},</if> <if test="updateTime != null">update_time = #{updateTime},</if> @@ -108,4 +120,22 @@ </foreach> </update> + <!-- 获取在微信小程序上展示的客户案例 --> + <select id="getWxCustomerCaseList" parameterType="SysCustomerCase" resultMap="SysCustomerCaseResponseResult"> + select scc.id, scc.name, scc.keyword, scc.remark, scc.wx_show from sys_customer_case scc + where scc.del_flag = 0 and scc.wx_show = 1 + <include refid="searchKey"> + <property name="keywordArray" value="#{keywordArray}"/> + </include> + order by id desc + </select> + + <!-- 更新是否在微信小程序上展示 --> + <update id="updateWxShowByIds"> + update sys_customer_case set wx_show = #{wxShow} where del_flag = 0 and id in + <foreach item="id" collection="array" open="(" separator="," close=")"> + #{id} + </foreach> + </update> + </mapper> \ No newline at end of file diff --git a/stdiet-ui/src/api/custom/customerCase.js b/stdiet-ui/src/api/custom/customerCase.js index 0f388c098..7a58862b1 100644 --- a/stdiet-ui/src/api/custom/customerCase.js +++ b/stdiet-ui/src/api/custom/customerCase.js @@ -75,6 +75,15 @@ export function downCaseFile(downUrl) { window.location.href = downUrl; } +// 修改客户案例微信小程序展示状态 +export function updateWxShow(data) { + return request({ + url: '/custom/customerCase/updateWxShow', + method: 'post', + data: data + }) +} + diff --git a/stdiet-ui/src/views/custom/customerCase/index.vue b/stdiet-ui/src/views/custom/customerCase/index.vue index 53800dc9f..73441fb61 100644 --- a/stdiet-ui/src/views/custom/customerCase/index.vue +++ b/stdiet-ui/src/views/custom/customerCase/index.vue @@ -36,6 +36,18 @@ </el-select> </el-form-item> + <el-form-item label="展示状态" prop="wxShow"> + <el-select + v-model="queryParams.wxShow" + placeholder="请选择展示状态" + clearable + size="small" + > + <el-option key="false" label="不展示" value="false"/> + <el-option key="true" label="展示" value="true"/> + </el-select> + </el-form-item> + <el-form-item label="客户姓名" prop="customerName"> <el-input v-model.trim="queryParams.customerName" @@ -139,6 +151,7 @@ </template> </el-table-column> <el-table-column label="所属客户" align="center" prop="customerName" /> + <el-table-column label="文件" align="center"> <template slot-scope="scope"> <el-button @@ -161,6 +174,17 @@ }}</span> </template> </el-table-column> + <el-table-column label="小程序展示状态" align="center" prop="wxShow" > + <template slot-scope="scope"> + <el-switch + v-model="scope.row.wxShow" + active-text="展示" + inactive-text="不展示" + @change="handleWxShow($event, scope.row)" + > + </el-switch> + </template> + </el-table-column> <el-table-column label="操作" align="center" @@ -241,7 +265,7 @@ placeholder="请输入案例备注" v-model.trim="form.remark" maxlength="200" - rows="4" + rows="3" show-word-limit ></el-input> </el-form-item> @@ -259,6 +283,16 @@ ></span > </el-form-item> + + + <el-form-item label="展示状态" prop="wxShow"> + <el-switch + v-model="form.wxShow" + active-text="小程序展示" + inactive-text="小程序不展示"> + </el-switch> + <div>提示:小程序展示的案例需要隐藏客户隐私</div> + </el-form-item> <el-form-item label="案例文件" prop="file"> <DragUpload v-if="form.id == null || form.id <= 0" @@ -301,6 +335,7 @@ import { updateCustomerCase, exportCustomerCase, getFileListByCaseId, + updateWxShow } from "@/api/custom/customerCase"; import DragUpload from "@/components/FileUpload/DragUpload"; import DragUploadEdit from "@/components/FileUpload/DragUploadEdit"; @@ -337,6 +372,7 @@ export default { pageSize: 10, name: null, keyword: null, + wxShow: null, customerName: null, }, // 表单参数 @@ -398,6 +434,7 @@ export default { remark: null, customerId: null, customerName: null, + wxShow: false, caseFileList: [], caseFileUrl: [], caseFileName: [], @@ -437,6 +474,7 @@ export default { keywordArray: response.data.keyword.split(","), remark: response.data.remark, customerId: response.data.customerId, + wxShow: response.data.wxShow == 1 ? true : false, customerName: response.data.customerName, caseFileList: response.data.caseFileList, caseFileUrl: [], @@ -560,6 +598,13 @@ export default { }) .catch(function () {}); }, + handleWxShow(newWxshow, row){ + let param = { + ids:[row.id], + wxShow: newWxshow + }; + updateWxShow(param); + } }, }; </script>