diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsDeptCategoryController.java b/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsDeptCategoryController.java index abd433f7..b7c1f2df 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsDeptCategoryController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsDeptCategoryController.java @@ -1,5 +1,6 @@ package com.ghy.web.controller.goods; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; import com.ghy.common.annotation.Log; import com.ghy.common.core.controller.BaseController; @@ -11,14 +12,8 @@ import com.ghy.common.enums.ImgType; import com.ghy.common.utils.ExceptionUtil; import com.ghy.common.utils.ShiroUtils; import com.ghy.common.utils.StringUtils; -import com.ghy.goods.domain.CategoryInsuranceRelation; -import com.ghy.goods.domain.DeptGoodsCategory; -import com.ghy.goods.domain.GoodsImgs; -import com.ghy.goods.domain.InsuranceManager; -import com.ghy.goods.service.DeptGoodsCategoryService; -import com.ghy.goods.service.GoodsImgsService; -import com.ghy.goods.service.ICategoryInsuranceRelationService; -import com.ghy.goods.service.IInsuranceManagerService; +import com.ghy.goods.domain.*; +import com.ghy.goods.service.*; import com.ghy.web.pojo.vo.AppCategoryRequest; import com.ghy.web.pojo.vo.HotCategoryResponse; import org.apache.shiro.authz.annotation.RequiresPermissions; @@ -46,6 +41,9 @@ public class GoodsDeptCategoryController extends BaseController { @Resource ICategoryInsuranceRelationService categoryInsuranceRelationService; + @Resource + IDeptCategoryInsuranceRelationService deptCategoryInsuranceRelationService; + @Resource IInsuranceManagerService insuranceManagerService; @@ -159,14 +157,40 @@ public class GoodsDeptCategoryController extends BaseController { CategoryInsuranceRelation relation = new CategoryInsuranceRelation(); relation.setGoodsCategoryId(deptGoodsCategory.getGoodsCategoryId()); List relations = categoryInsuranceRelationService.selectCategoryInsuranceRelationList(relation); - List list = null; + // pc保险设置 + List pcInsuranceList = new ArrayList<>(); + // 商城保险设置 + List shopInsuranceList = new ArrayList<>(); if(CollectionUtil.isNotEmpty(relations)){ - list = insuranceManagerService.selectByIds(relations.stream().map(CategoryInsuranceRelation::getInsuranceId).collect(Collectors.toList())); + List list = insuranceManagerService.selectByIds(relations.stream().map(CategoryInsuranceRelation::getInsuranceId).collect(Collectors.toList())); list.forEach(model->{ model.setInsuranceName(model.getCompanyName() + "||" + model.getInsuranceName() + "||" + model.getInsuranceAmount() + "元"); + // 查看pc勾选状态 + DeptCategoryInsuranceRelation pcParam = new DeptCategoryInsuranceRelation(); + pcParam.setType("02"); + pcParam.setInsuranceId(model.getId()); + pcParam.setDeptCategoryId(deptGoodsCategory.getDeptGoodsCategoryId()); + InsuranceManager pcModel = new InsuranceManager(); + BeanUtil.copyProperties(model, pcModel); + if(CollectionUtil.isNotEmpty(deptCategoryInsuranceRelationService.selectDeptCategoryInsuranceRelationList(pcParam))){ + pcModel.setFlag(true); + } + pcInsuranceList.add(pcModel); + + DeptCategoryInsuranceRelation shopParam = new DeptCategoryInsuranceRelation(); + shopParam.setType("01"); + shopParam.setInsuranceId(model.getId()); + shopParam.setDeptCategoryId(deptGoodsCategory.getDeptGoodsCategoryId()); + InsuranceManager shopModel = new InsuranceManager(); + BeanUtil.copyProperties(model, shopModel); + if(CollectionUtil.isNotEmpty(deptCategoryInsuranceRelationService.selectDeptCategoryInsuranceRelationList(shopParam))){ + shopModel.setFlag(true); + } + shopInsuranceList.add(shopModel); }); } - mmap.put("insurances", list); + mmap.put("pcInsurances", pcInsuranceList); + mmap.put("shopInsurances", shopInsuranceList); mmap.put("deptGoodsCategory", deptGoodsCategory); return PREFIX + "/edit"; } @@ -175,6 +199,8 @@ public class GoodsDeptCategoryController extends BaseController { @PostMapping("/edit") @ResponseBody public AjaxResult edit(DeptGoodsCategory category) { + // 更新保险设置 + deptCategoryInsuranceRelationService.updateDeptCategoryInsuranceRelation(category.getPcInsuranceIds(), category.getShopInsuranceIds(), category.getDeptGoodsCategoryId()); category.setUpdateBy(getLoginName()); deptGoodsCategoryService.edit(category); return AjaxResult.success(); diff --git a/ghy-admin/src/main/resources/templates/goods/deptcategory/edit.html b/ghy-admin/src/main/resources/templates/goods/deptcategory/edit.html index de9e8cbc..4118b2c0 100644 --- a/ghy-admin/src/main/resources/templates/goods/deptcategory/edit.html +++ b/ghy-admin/src/main/resources/templates/goods/deptcategory/edit.html @@ -245,7 +245,7 @@
-
@@ -259,7 +259,7 @@
-
@@ -310,6 +310,10 @@ function submitHandler() { if ($.validate.form()) { var data = $("#form-deptGoodsCategory-edit").serializeArray(); + var pcInsuranceIds = $.form.selectCheckeds("pcInsurance"); + var shopInsuranceIds = $.form.selectCheckeds("shopInsurance"); + data.push({"name": "pcInsuranceIds", "value": pcInsuranceIds}); + data.push({"name": "shopInsuranceIds", "value": shopInsuranceIds}); $.operate.saveTab(prefix + "/edit", data); $.modal.close(); } diff --git a/ghy-goods/src/main/java/com/ghy/goods/domain/DeptCategoryInsuranceRelation.java b/ghy-goods/src/main/java/com/ghy/goods/domain/DeptCategoryInsuranceRelation.java new file mode 100644 index 00000000..418e4b84 --- /dev/null +++ b/ghy-goods/src/main/java/com/ghy/goods/domain/DeptCategoryInsuranceRelation.java @@ -0,0 +1,36 @@ +package com.ghy.goods.domain; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import com.ghy.common.annotation.Excel; +import com.ghy.common.core.domain.BaseEntity; + +/** + * 平台类目保险关联关系对象 dept_category_insurance_relation + * + * @author clunt + * @date 2024-09-27 + */ + +@Data +@EqualsAndHashCode(callSuper = true) +public class DeptCategoryInsuranceRelation extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** 平台类目id */ + @Excel(name = "平台类目id") + private Long deptCategoryId; + + /** 类型 01.商城 02.PC */ + @Excel(name = "类型 01.商城 02.PC") + private String type; + + /** 保险id */ + @Excel(name = "保险id") + private Long insuranceId; + +} \ No newline at end of file diff --git a/ghy-goods/src/main/java/com/ghy/goods/domain/DeptGoodsCategory.java b/ghy-goods/src/main/java/com/ghy/goods/domain/DeptGoodsCategory.java index cd8b4e6f..03c722a2 100644 --- a/ghy-goods/src/main/java/com/ghy/goods/domain/DeptGoodsCategory.java +++ b/ghy-goods/src/main/java/com/ghy/goods/domain/DeptGoodsCategory.java @@ -101,4 +101,8 @@ public class DeptGoodsCategory extends GoodsCategory { // 是否需要证书 1.需要 private Integer isCert; + private String pcInsuranceIds; + + private String shopInsuranceIds; + } diff --git a/ghy-goods/src/main/java/com/ghy/goods/mapper/DeptCategoryInsuranceRelationMapper.java b/ghy-goods/src/main/java/com/ghy/goods/mapper/DeptCategoryInsuranceRelationMapper.java new file mode 100644 index 00000000..b83d12ce --- /dev/null +++ b/ghy-goods/src/main/java/com/ghy/goods/mapper/DeptCategoryInsuranceRelationMapper.java @@ -0,0 +1,61 @@ +package com.ghy.goods.mapper; + +import java.util.List; +import com.ghy.goods.domain.DeptCategoryInsuranceRelation; + +/** + * 平台类目保险关联关系Mapper接口 + * + * @author clunt + * @date 2024-09-27 + */ +public interface DeptCategoryInsuranceRelationMapper +{ + /** + * 查询平台类目保险关联关系 + * + * @param id 平台类目保险关联关系主键 + * @return 平台类目保险关联关系 + */ + public DeptCategoryInsuranceRelation selectDeptCategoryInsuranceRelationById(Long id); + + /** + * 查询平台类目保险关联关系列表 + * + * @param deptCategoryInsuranceRelation 平台类目保险关联关系 + * @return 平台类目保险关联关系集合 + */ + public List selectDeptCategoryInsuranceRelationList(DeptCategoryInsuranceRelation deptCategoryInsuranceRelation); + + /** + * 新增平台类目保险关联关系 + * + * @param deptCategoryInsuranceRelation 平台类目保险关联关系 + * @return 结果 + */ + public int insertDeptCategoryInsuranceRelation(DeptCategoryInsuranceRelation deptCategoryInsuranceRelation); + + /** + * 修改平台类目保险关联关系 + * + * @param deptCategoryInsuranceRelation 平台类目保险关联关系 + * @return 结果 + */ + public int updateDeptCategoryInsuranceRelation(DeptCategoryInsuranceRelation deptCategoryInsuranceRelation); + + /** + * 删除平台类目保险关联关系 + * + * @param id 平台类目保险关联关系主键 + * @return 结果 + */ + public int deleteDeptCategoryInsuranceRelationById(Long id); + + /** + * 批量删除平台类目保险关联关系 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteDeptCategoryInsuranceRelationByIds(String[] ids); +} \ No newline at end of file diff --git a/ghy-goods/src/main/java/com/ghy/goods/service/IDeptCategoryInsuranceRelationService.java b/ghy-goods/src/main/java/com/ghy/goods/service/IDeptCategoryInsuranceRelationService.java new file mode 100644 index 00000000..a9b11932 --- /dev/null +++ b/ghy-goods/src/main/java/com/ghy/goods/service/IDeptCategoryInsuranceRelationService.java @@ -0,0 +1,64 @@ +package com.ghy.goods.service; + +import java.util.List; +import com.ghy.goods.domain.DeptCategoryInsuranceRelation; + +/** + * 平台类目保险关联关系Service接口 + * + * @author clunt + * @date 2024-09-27 + */ +public interface IDeptCategoryInsuranceRelationService +{ + /** + * 查询平台类目保险关联关系 + * + * @param id 平台类目保险关联关系主键 + * @return 平台类目保险关联关系 + */ + public DeptCategoryInsuranceRelation selectDeptCategoryInsuranceRelationById(Long id); + + /** + * 查询平台类目保险关联关系列表 + * + * @param deptCategoryInsuranceRelation 平台类目保险关联关系 + * @return 平台类目保险关联关系集合 + */ + public List selectDeptCategoryInsuranceRelationList(DeptCategoryInsuranceRelation deptCategoryInsuranceRelation); + + /** + * 新增平台类目保险关联关系 + * + * @param deptCategoryInsuranceRelation 平台类目保险关联关系 + * @return 结果 + */ + public int insertDeptCategoryInsuranceRelation(DeptCategoryInsuranceRelation deptCategoryInsuranceRelation); + + /** + * 修改平台类目保险关联关系 + * + * @param deptCategoryInsuranceRelation 平台类目保险关联关系 + * @return 结果 + */ + public int updateDeptCategoryInsuranceRelation(DeptCategoryInsuranceRelation deptCategoryInsuranceRelation); + + /** + * 批量删除平台类目保险关联关系 + * + * @param ids 需要删除的平台类目保险关联关系主键集合 + * @return 结果 + */ + public int deleteDeptCategoryInsuranceRelationByIds(String ids); + + /** + * 删除平台类目保险关联关系信息 + * + * @param id 平台类目保险关联关系主键 + * @return 结果 + */ + public int deleteDeptCategoryInsuranceRelationById(Long id); + + void updateDeptCategoryInsuranceRelation(String pcInsuranceIds, String shopInsuranceIds, Long deptGoodsCategoryId); + +} diff --git a/ghy-goods/src/main/java/com/ghy/goods/service/impl/DeptCategoryInsuranceRelationServiceImpl.java b/ghy-goods/src/main/java/com/ghy/goods/service/impl/DeptCategoryInsuranceRelationServiceImpl.java new file mode 100644 index 00000000..71748874 --- /dev/null +++ b/ghy-goods/src/main/java/com/ghy/goods/service/impl/DeptCategoryInsuranceRelationServiceImpl.java @@ -0,0 +1,102 @@ +package com.ghy.goods.service.impl; + +import java.util.List; +import com.ghy.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ghy.goods.mapper.DeptCategoryInsuranceRelationMapper; +import com.ghy.goods.domain.DeptCategoryInsuranceRelation; +import com.ghy.goods.service.IDeptCategoryInsuranceRelationService; +import com.ghy.common.core.text.Convert; + +/** + * 平台类目保险关联关系Service业务层处理 + * + * @author clunt + * @date 2024-09-27 + */ +@Service +public class DeptCategoryInsuranceRelationServiceImpl implements IDeptCategoryInsuranceRelationService +{ + @Autowired + private DeptCategoryInsuranceRelationMapper deptCategoryInsuranceRelationMapper; + + /** + * 查询平台类目保险关联关系 + * + * @param id 平台类目保险关联关系主键 + * @return 平台类目保险关联关系 + */ + @Override + public DeptCategoryInsuranceRelation selectDeptCategoryInsuranceRelationById(Long id) + { + return deptCategoryInsuranceRelationMapper.selectDeptCategoryInsuranceRelationById(id); + } + + /** + * 查询平台类目保险关联关系列表 + * + * @param deptCategoryInsuranceRelation 平台类目保险关联关系 + * @return 平台类目保险关联关系 + */ + @Override + public List selectDeptCategoryInsuranceRelationList(DeptCategoryInsuranceRelation deptCategoryInsuranceRelation) + { + return deptCategoryInsuranceRelationMapper.selectDeptCategoryInsuranceRelationList(deptCategoryInsuranceRelation); + } + + /** + * 新增平台类目保险关联关系 + * + * @param deptCategoryInsuranceRelation 平台类目保险关联关系 + * @return 结果 + */ + @Override + public int insertDeptCategoryInsuranceRelation(DeptCategoryInsuranceRelation deptCategoryInsuranceRelation) + { + deptCategoryInsuranceRelation.setCreateTime(DateUtils.getNowDate()); + return deptCategoryInsuranceRelationMapper.insertDeptCategoryInsuranceRelation(deptCategoryInsuranceRelation); + } + + /** + * 修改平台类目保险关联关系 + * + * @param deptCategoryInsuranceRelation 平台类目保险关联关系 + * @return 结果 + */ + @Override + public int updateDeptCategoryInsuranceRelation(DeptCategoryInsuranceRelation deptCategoryInsuranceRelation) + { + deptCategoryInsuranceRelation.setUpdateTime(DateUtils.getNowDate()); + return deptCategoryInsuranceRelationMapper.updateDeptCategoryInsuranceRelation(deptCategoryInsuranceRelation); + } + + /** + * 批量删除平台类目保险关联关系 + * + * @param ids 需要删除的平台类目保险关联关系主键 + * @return 结果 + */ + @Override + public int deleteDeptCategoryInsuranceRelationByIds(String ids) + { + return deptCategoryInsuranceRelationMapper.deleteDeptCategoryInsuranceRelationByIds(Convert.toStrArray(ids)); + } + + /** + * 删除平台类目保险关联关系信息 + * + * @param id 平台类目保险关联关系主键 + * @return 结果 + */ + @Override + public int deleteDeptCategoryInsuranceRelationById(Long id) + { + return deptCategoryInsuranceRelationMapper.deleteDeptCategoryInsuranceRelationById(id); + } + + @Override + public void updateDeptCategoryInsuranceRelation(String pcInsuranceIds, String shopInsuranceIds, Long deptGoodsCategoryId) { + + } +} diff --git a/ghy-goods/src/main/resources/mapper/goods/DeptCategoryInsuranceRelationMapper.xml b/ghy-goods/src/main/resources/mapper/goods/DeptCategoryInsuranceRelationMapper.xml new file mode 100644 index 00000000..afb5656b --- /dev/null +++ b/ghy-goods/src/main/resources/mapper/goods/DeptCategoryInsuranceRelationMapper.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + select id, dept_category_id, type, insurance_id, create_by, create_time, update_by, update_time, remark from dept_category_insurance_relation + + + + + + + + insert into dept_category_insurance_relation + + dept_category_id, + type, + insurance_id, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{deptCategoryId}, + #{type}, + #{insuranceId}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update dept_category_insurance_relation + + dept_category_id = #{deptCategoryId}, + type = #{type}, + insurance_id = #{insuranceId}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from dept_category_insurance_relation where id = #{id} + + + + delete from dept_category_insurance_relation where id in + + #{id} + + + + \ No newline at end of file