From aac5ba8b2048715af102a3f6db998e0a5f6e0afb Mon Sep 17 00:00:00 2001 From: "kuang.yife" Date: Wed, 25 Sep 2024 18:16:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E9=99=A9=E7=AE=A1=E7=90=86=E3=80=81?= =?UTF-8?q?=E6=80=BB=E5=B9=B3=E5=8F=B0=E4=BF=9D=E9=99=A9=E3=80=81=E4=BF=9D?= =?UTF-8?q?=E9=99=A9=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods/GoodsCategoryController.java | 43 +++++- .../goods/InsuranceManagerController.java | 135 ++++++++++++++++++ .../templates/goods/category/add.html | 12 ++ .../templates/goods/category/edit.html | 35 +++-- .../templates/goods/manager/add.html | 55 +++++++ .../templates/goods/manager/edit.html | 56 ++++++++ .../templates/goods/manager/manager.html | 110 ++++++++++++++ .../domain/CategoryInsuranceRelation.java | 31 ++++ .../com/ghy/goods/domain/GoodsCategory.java | 12 ++ .../ghy/goods/domain/InsuranceManager.java | 45 ++++++ .../CategoryInsuranceRelationMapper.java | 61 ++++++++ .../goods/mapper/InsuranceManagerMapper.java | 60 ++++++++ .../ICategoryInsuranceRelationService.java | 64 +++++++++ .../service/IInsuranceManagerService.java | 61 ++++++++ .../CategoryInsuranceRelationServiceImpl.java | 127 ++++++++++++++++ .../impl/InsuranceManagerServiceImpl.java | 97 +++++++++++++ .../goods/CategoryInsuranceRelationMapper.xml | 82 +++++++++++ .../mapper/goods/GoodsCategoryMapper.xml | 15 +- .../mapper/goods/InsuranceManagerMapper.xml | 92 ++++++++++++ 19 files changed, 1175 insertions(+), 18 deletions(-) create mode 100644 ghy-admin/src/main/java/com/ghy/web/controller/goods/InsuranceManagerController.java create mode 100644 ghy-admin/src/main/resources/templates/goods/manager/add.html create mode 100644 ghy-admin/src/main/resources/templates/goods/manager/edit.html create mode 100644 ghy-admin/src/main/resources/templates/goods/manager/manager.html create mode 100644 ghy-goods/src/main/java/com/ghy/goods/domain/CategoryInsuranceRelation.java create mode 100644 ghy-goods/src/main/java/com/ghy/goods/domain/InsuranceManager.java create mode 100644 ghy-goods/src/main/java/com/ghy/goods/mapper/CategoryInsuranceRelationMapper.java create mode 100644 ghy-goods/src/main/java/com/ghy/goods/mapper/InsuranceManagerMapper.java create mode 100644 ghy-goods/src/main/java/com/ghy/goods/service/ICategoryInsuranceRelationService.java create mode 100644 ghy-goods/src/main/java/com/ghy/goods/service/IInsuranceManagerService.java create mode 100644 ghy-goods/src/main/java/com/ghy/goods/service/impl/CategoryInsuranceRelationServiceImpl.java create mode 100644 ghy-goods/src/main/java/com/ghy/goods/service/impl/InsuranceManagerServiceImpl.java create mode 100644 ghy-goods/src/main/resources/mapper/goods/CategoryInsuranceRelationMapper.xml create mode 100644 ghy-goods/src/main/resources/mapper/goods/InsuranceManagerMapper.xml diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsCategoryController.java b/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsCategoryController.java index 3ff4d21b..c94dbd59 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsCategoryController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/goods/GoodsCategoryController.java @@ -1,5 +1,6 @@ package com.ghy.web.controller.goods; +import cn.hutool.core.collection.CollectionUtil; import com.ghy.common.annotation.Log; import com.ghy.common.constant.UserConstants; import com.ghy.common.core.controller.BaseController; @@ -7,16 +8,24 @@ import com.ghy.common.core.domain.AjaxResult; import com.ghy.common.core.domain.Ztree; import com.ghy.common.enums.BusinessType; import com.ghy.common.utils.ShiroUtils; +import com.ghy.common.utils.StringUtils; +import com.ghy.goods.domain.CategoryInsuranceRelation; import com.ghy.goods.domain.GoodsCategory; +import com.ghy.goods.domain.InsuranceManager; import com.ghy.goods.service.GoodsCategoryService; +import com.ghy.goods.service.ICategoryInsuranceRelationService; +import com.ghy.goods.service.IInsuranceManagerService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.stereotype.Controller; +import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.ModelMap; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; /** * @author HH 2022/3/19 @@ -30,6 +39,12 @@ public class GoodsCategoryController extends BaseController { @Resource private GoodsCategoryService goodsCategoryService; + @Resource + private IInsuranceManagerService insuranceManagerService; + + @Resource + private ICategoryInsuranceRelationService categoryInsuranceRelationService; + @RequiresPermissions("goods:category:view") @GetMapping() public String goodsCategory() { @@ -43,6 +58,7 @@ public class GoodsCategoryController extends BaseController { @GetMapping("/add/{parentCategoryId}") public String add(@PathVariable("parentCategoryId") Long parentCategoryId, ModelMap mmap) { mmap.put("goodsCategory", goodsCategoryService.selectById(parentCategoryId)); + mmap.put("insurances", insuranceManagerService.selectInsuranceManagerList(new InsuranceManager())); return PREFIX + "/add"; } @@ -50,7 +66,8 @@ public class GoodsCategoryController extends BaseController { * 新增商品类别页面 */ @GetMapping("/add") - public String add() { + public String add(ModelMap mmap) { + mmap.put("insurances", insuranceManagerService.selectInsuranceManagerList(new InsuranceManager())); return PREFIX + "/add"; } @@ -60,7 +77,21 @@ public class GoodsCategoryController extends BaseController { @RequiresPermissions("goods:category:edit") @GetMapping("/edit/{goodsId}") public String edit(@PathVariable("goodsId") Long goodsId, ModelMap mmap) { - mmap.put("goodsCategory", goodsCategoryService.selectById(goodsId)); + GoodsCategory goodsCategory = goodsCategoryService.selectById(goodsId); + mmap.put("goodsCategory", goodsCategory); + List list = insuranceManagerService.selectInsuranceManagerList(new InsuranceManager()); + CategoryInsuranceRelation param = new CategoryInsuranceRelation(); + param.setGoodsCategoryId(goodsCategory.getGoodsCategoryId()); + List relations = categoryInsuranceRelationService.selectCategoryInsuranceRelationList(param); + if(CollectionUtil.isNotEmpty(relations)){ + Map> map = relations.stream().collect(Collectors.groupingBy(CategoryInsuranceRelation::getInsuranceId)); + list.forEach(model->{ + if(map.containsKey(model.getId())){ + model.setFlag(true); + } + }); + } + mmap.put("insurances", list); return PREFIX + "/edit"; } @@ -103,12 +134,10 @@ public class GoodsCategoryController extends BaseController { @Log(title = "商品类别管理", businessType = BusinessType.UPDATE) @PostMapping("/edit") @ResponseBody + @Transactional public AjaxResult editSave(@Validated GoodsCategory category) { -// if (goodsCategoryService.checkGoodsCategoryNameUnique(category)) { -// return error("新增商品类别'" + category.getGoodsCategoryName() + "'失败,商品类别名称已存在"); -// } else if (goodsCategoryService.checkGoodsCategoryCodeUnique(category)) { -// return error("新增商品类别'" + category.getGoodsCategoryCode() + "'失败,商品类别编码已存在"); -// } + // 更新保险设置 + categoryInsuranceRelationService.updateCategoryInsuranceRelation(category.getInsuranceIds(), category.getGoodsCategoryId()); category.setUpdateBy(getLoginName()); return toAjax(goodsCategoryService.updateGoodsCategory(category)); } diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/goods/InsuranceManagerController.java b/ghy-admin/src/main/java/com/ghy/web/controller/goods/InsuranceManagerController.java new file mode 100644 index 00000000..ad516aed --- /dev/null +++ b/ghy-admin/src/main/java/com/ghy/web/controller/goods/InsuranceManagerController.java @@ -0,0 +1,135 @@ +package com.ghy.web.controller.goods; +import java.util.List; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.*; +import com.ghy.common.annotation.Log; +import com.ghy.common.enums.BusinessType; +import com.ghy.goods.domain.InsuranceManager; +import com.ghy.goods.service.IInsuranceManagerService; +import com.ghy.common.core.controller.BaseController; +import com.ghy.common.core.domain.AjaxResult; +import com.ghy.common.utils.poi.ExcelUtil; +import com.ghy.common.core.page.TableDataInfo; + +/** + * 保险管理Controller + * + * @author clunt + * @date 2024-09-25 + */ +@Controller +@RequestMapping("/goods/manager") +public class InsuranceManagerController extends BaseController +{ + private String prefix = "goods/manager"; + + @Autowired + private IInsuranceManagerService insuranceManagerService; + + @RequiresPermissions("goods:manager:view") + @GetMapping() + public String manager() + { + return prefix + "/manager"; + } + + /** + * 查询保险管理列表 + */ + @RequiresPermissions("goods:manager:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(InsuranceManager insuranceManager) + { + startPage(); + List list = insuranceManagerService.selectInsuranceManagerList(insuranceManager); + return getDataTable(list); + } + + /** + * App查询保险管理列表 + */ + @PostMapping("/app/list") + @ResponseBody + public TableDataInfo appList(@RequestBody InsuranceManager insuranceManager) + { + startPage(); + List list = insuranceManagerService.selectInsuranceManagerList(insuranceManager); + return getDataTable(list); + } + + + /** + * 导出保险管理列表 + */ + @RequiresPermissions("goods:manager:export") + @Log(title = "保险管理", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(InsuranceManager insuranceManager) + { + List list = insuranceManagerService.selectInsuranceManagerList(insuranceManager); + ExcelUtil util = new ExcelUtil(InsuranceManager.class); + return util.exportExcel(list, "保险管理数据"); + } + + /** + * 新增保险管理 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存保险管理 + */ + @RequiresPermissions("goods:manager:add") + @Log(title = "保险管理", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(InsuranceManager insuranceManager) + { + return toAjax(insuranceManagerService.insertInsuranceManager(insuranceManager)); + } + + /** + * 修改保险管理 + */ + @RequiresPermissions("goods:manager:edit") + @GetMapping("/edit/{id}") + public String edit(@PathVariable("id") Long id, ModelMap mmap) + { + InsuranceManager insuranceManager = insuranceManagerService.selectInsuranceManagerById(id); + mmap.put("insuranceManager", insuranceManager); + return prefix + "/edit"; + } + + /** + * 修改保存保险管理 + */ + @RequiresPermissions("goods:manager:edit") + @Log(title = "保险管理", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(InsuranceManager insuranceManager) + { + return toAjax(insuranceManagerService.updateInsuranceManager(insuranceManager)); + } + + /** + * 删除保险管理 + */ + @RequiresPermissions("goods:manager:remove") + @Log(title = "保险管理", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(insuranceManagerService.deleteInsuranceManagerByIds(ids)); + } +} diff --git a/ghy-admin/src/main/resources/templates/goods/category/add.html b/ghy-admin/src/main/resources/templates/goods/category/add.html index 8d174895..8d755459 100644 --- a/ghy-admin/src/main/resources/templates/goods/category/add.html +++ b/ghy-admin/src/main/resources/templates/goods/category/add.html @@ -46,6 +46,18 @@ +
+
+
+ +
+ +
+
+
+
diff --git a/ghy-admin/src/main/resources/templates/goods/category/edit.html b/ghy-admin/src/main/resources/templates/goods/category/edit.html index e1222007..1e67f44d 100644 --- a/ghy-admin/src/main/resources/templates/goods/category/edit.html +++ b/ghy-admin/src/main/resources/templates/goods/category/edit.html @@ -17,15 +17,15 @@ -
- -
-
- - -
-
-
+ + + + + + + + +
@@ -62,6 +62,18 @@
+
+
+
+ +
+ +
+
+
+
@@ -103,7 +115,10 @@ function submitHandler() { if ($.validate.form()) { - $.operate.save(prefix + "/edit", $('#form-dept-edit').serialize()); + var data = $("#form-dept-edit").serializeArray(); + var insuranceIds = $.form.selectCheckeds("insurance"); + data.push({"name": "insuranceIds", "value": insuranceIds}); + $.operate.save(prefix + "/edit", data); } } diff --git a/ghy-admin/src/main/resources/templates/goods/manager/add.html b/ghy-admin/src/main/resources/templates/goods/manager/add.html new file mode 100644 index 00000000..48cc10c1 --- /dev/null +++ b/ghy-admin/src/main/resources/templates/goods/manager/add.html @@ -0,0 +1,55 @@ + + + + + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/ghy-admin/src/main/resources/templates/goods/manager/edit.html b/ghy-admin/src/main/resources/templates/goods/manager/edit.html new file mode 100644 index 00000000..1982391b --- /dev/null +++ b/ghy-admin/src/main/resources/templates/goods/manager/edit.html @@ -0,0 +1,56 @@ + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/ghy-admin/src/main/resources/templates/goods/manager/manager.html b/ghy-admin/src/main/resources/templates/goods/manager/manager.html new file mode 100644 index 00000000..3a3b8a1c --- /dev/null +++ b/ghy-admin/src/main/resources/templates/goods/manager/manager.html @@ -0,0 +1,110 @@ + + + + + + +
+
+
+
+
+
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • +  搜索 +  重置 +
  • +
+
+
+
+ + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/ghy-goods/src/main/java/com/ghy/goods/domain/CategoryInsuranceRelation.java b/ghy-goods/src/main/java/com/ghy/goods/domain/CategoryInsuranceRelation.java new file mode 100644 index 00000000..e24f6589 --- /dev/null +++ b/ghy-goods/src/main/java/com/ghy/goods/domain/CategoryInsuranceRelation.java @@ -0,0 +1,31 @@ +package com.ghy.goods.domain; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import com.ghy.common.annotation.Excel; +import com.ghy.common.core.domain.BaseEntity; + +/** + * 总类目保险关联关系对象 category_insurance_relation + * + * @author clunt + * @date 2024-09-25 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class CategoryInsuranceRelation extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** 保险id */ + @Excel(name = "保险id") + private Long insuranceId; + + /** 总平台类目id */ + @Excel(name = "总平台类目id") + private Long goodsCategoryId; + +} diff --git a/ghy-goods/src/main/java/com/ghy/goods/domain/GoodsCategory.java b/ghy-goods/src/main/java/com/ghy/goods/domain/GoodsCategory.java index 4314b4b2..8e72f245 100644 --- a/ghy-goods/src/main/java/com/ghy/goods/domain/GoodsCategory.java +++ b/ghy-goods/src/main/java/com/ghy/goods/domain/GoodsCategory.java @@ -5,6 +5,8 @@ import com.ghy.common.annotation.Excel; import com.ghy.common.core.domain.BaseEntity; import lombok.Data; +import java.math.BigDecimal; + /** * 商品类别表 * @@ -39,5 +41,15 @@ public class GoodsCategory extends BaseEntity { @Excel(name = "状态") private Integer status; + /** + * 保险状态 01.启用 02.禁用 + * */ + private String insuranceStatus; + + private String insuranceUrl; + + private BigDecimal insuranceAmount = BigDecimal.ZERO; + + private String insuranceIds; } diff --git a/ghy-goods/src/main/java/com/ghy/goods/domain/InsuranceManager.java b/ghy-goods/src/main/java/com/ghy/goods/domain/InsuranceManager.java new file mode 100644 index 00000000..eff0acc5 --- /dev/null +++ b/ghy-goods/src/main/java/com/ghy/goods/domain/InsuranceManager.java @@ -0,0 +1,45 @@ +package com.ghy.goods.domain; + +import java.math.BigDecimal; + +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ghy.common.annotation.Excel; +import com.ghy.common.core.domain.BaseEntity; + +/** + * 保险管理对象 insurance_manager + * + * @author clunt + * @date 2024-09-25 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class InsuranceManager extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** 保险公司名称 */ + @Excel(name = "保险公司名称") + private String companyName; + + /** 保险项目名称 */ + @Excel(name = "保险项目名称") + private String insuranceName; + + /** 保险费用 */ + @Excel(name = "保险费用") + private BigDecimal insuranceAmount; + + /** 保险条例url */ + @Excel(name = "保险条例url") + private String insuranceUrl; + + private Boolean flag = false; +} diff --git a/ghy-goods/src/main/java/com/ghy/goods/mapper/CategoryInsuranceRelationMapper.java b/ghy-goods/src/main/java/com/ghy/goods/mapper/CategoryInsuranceRelationMapper.java new file mode 100644 index 00000000..a005c531 --- /dev/null +++ b/ghy-goods/src/main/java/com/ghy/goods/mapper/CategoryInsuranceRelationMapper.java @@ -0,0 +1,61 @@ +package com.ghy.goods.mapper; + +import java.util.List; +import com.ghy.goods.domain.CategoryInsuranceRelation; + +/** + * 总类目保险关联关系Mapper接口 + * + * @author clunt + * @date 2024-09-25 + */ +public interface CategoryInsuranceRelationMapper +{ + /** + * 查询总类目保险关联关系 + * + * @param id 总类目保险关联关系主键 + * @return 总类目保险关联关系 + */ + public CategoryInsuranceRelation selectCategoryInsuranceRelationById(Long id); + + /** + * 查询总类目保险关联关系列表 + * + * @param categoryInsuranceRelation 总类目保险关联关系 + * @return 总类目保险关联关系集合 + */ + public List selectCategoryInsuranceRelationList(CategoryInsuranceRelation categoryInsuranceRelation); + + /** + * 新增总类目保险关联关系 + * + * @param categoryInsuranceRelation 总类目保险关联关系 + * @return 结果 + */ + public int insertCategoryInsuranceRelation(CategoryInsuranceRelation categoryInsuranceRelation); + + /** + * 修改总类目保险关联关系 + * + * @param categoryInsuranceRelation 总类目保险关联关系 + * @return 结果 + */ + public int updateCategoryInsuranceRelation(CategoryInsuranceRelation categoryInsuranceRelation); + + /** + * 删除总类目保险关联关系 + * + * @param id 总类目保险关联关系主键 + * @return 结果 + */ + public int deleteCategoryInsuranceRelationById(Long id); + + /** + * 批量删除总类目保险关联关系 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteCategoryInsuranceRelationByIds(String[] ids); +} diff --git a/ghy-goods/src/main/java/com/ghy/goods/mapper/InsuranceManagerMapper.java b/ghy-goods/src/main/java/com/ghy/goods/mapper/InsuranceManagerMapper.java new file mode 100644 index 00000000..bdd3cc8c --- /dev/null +++ b/ghy-goods/src/main/java/com/ghy/goods/mapper/InsuranceManagerMapper.java @@ -0,0 +1,60 @@ +package com.ghy.goods.mapper; +import java.util.List; +import com.ghy.goods.domain.InsuranceManager; + +/** + * 保险管理Mapper接口 + * + * @author clunt + * @date 2024-09-25 + */ +public interface InsuranceManagerMapper +{ + /** + * 查询保险管理 + * + * @param id 保险管理主键 + * @return 保险管理 + */ + public InsuranceManager selectInsuranceManagerById(Long id); + + /** + * 查询保险管理列表 + * + * @param insuranceManager 保险管理 + * @return 保险管理集合 + */ + public List selectInsuranceManagerList(InsuranceManager insuranceManager); + + /** + * 新增保险管理 + * + * @param insuranceManager 保险管理 + * @return 结果 + */ + public int insertInsuranceManager(InsuranceManager insuranceManager); + + /** + * 修改保险管理 + * + * @param insuranceManager 保险管理 + * @return 结果 + */ + public int updateInsuranceManager(InsuranceManager insuranceManager); + + /** + * 删除保险管理 + * + * @param id 保险管理主键 + * @return 结果 + */ + public int deleteInsuranceManagerById(Long id); + + /** + * 批量删除保险管理 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteInsuranceManagerByIds(String[] ids); +} diff --git a/ghy-goods/src/main/java/com/ghy/goods/service/ICategoryInsuranceRelationService.java b/ghy-goods/src/main/java/com/ghy/goods/service/ICategoryInsuranceRelationService.java new file mode 100644 index 00000000..e1bb7cdb --- /dev/null +++ b/ghy-goods/src/main/java/com/ghy/goods/service/ICategoryInsuranceRelationService.java @@ -0,0 +1,64 @@ +package com.ghy.goods.service; + +import java.util.List; +import com.ghy.goods.domain.CategoryInsuranceRelation; + +/** + * 总类目保险关联关系Service接口 + * + * @author clunt + * @date 2024-09-25 + */ +public interface ICategoryInsuranceRelationService +{ + /** + * 查询总类目保险关联关系 + * + * @param id 总类目保险关联关系主键 + * @return 总类目保险关联关系 + */ + public CategoryInsuranceRelation selectCategoryInsuranceRelationById(Long id); + + /** + * 查询总类目保险关联关系列表 + * + * @param categoryInsuranceRelation 总类目保险关联关系 + * @return 总类目保险关联关系集合 + */ + public List selectCategoryInsuranceRelationList(CategoryInsuranceRelation categoryInsuranceRelation); + + /** + * 新增总类目保险关联关系 + * + * @param categoryInsuranceRelation 总类目保险关联关系 + * @return 结果 + */ + public int insertCategoryInsuranceRelation(CategoryInsuranceRelation categoryInsuranceRelation); + + /** + * 修改总类目保险关联关系 + * + * @param categoryInsuranceRelation 总类目保险关联关系 + * @return 结果 + */ + public int updateCategoryInsuranceRelation(CategoryInsuranceRelation categoryInsuranceRelation); + + /** + * 批量删除总类目保险关联关系 + * + * @param ids 需要删除的总类目保险关联关系主键集合 + * @return 结果 + */ + public int deleteCategoryInsuranceRelationByIds(String ids); + + /** + * 删除总类目保险关联关系信息 + * + * @param id 总类目保险关联关系主键 + * @return 结果 + */ + public int deleteCategoryInsuranceRelationById(Long id); + + void updateCategoryInsuranceRelation(String insuranceIds, Long categoryId); + +} diff --git a/ghy-goods/src/main/java/com/ghy/goods/service/IInsuranceManagerService.java b/ghy-goods/src/main/java/com/ghy/goods/service/IInsuranceManagerService.java new file mode 100644 index 00000000..dee1d7c5 --- /dev/null +++ b/ghy-goods/src/main/java/com/ghy/goods/service/IInsuranceManagerService.java @@ -0,0 +1,61 @@ +package com.ghy.goods.service; + +import java.util.List; +import com.ghy.goods.domain.InsuranceManager; + +/** + * 保险管理Service接口 + * + * @author clunt + * @date 2024-09-25 + */ +public interface IInsuranceManagerService +{ + /** + * 查询保险管理 + * + * @param id 保险管理主键 + * @return 保险管理 + */ + public InsuranceManager selectInsuranceManagerById(Long id); + + /** + * 查询保险管理列表 + * + * @param insuranceManager 保险管理 + * @return 保险管理集合 + */ + public List selectInsuranceManagerList(InsuranceManager insuranceManager); + + /** + * 新增保险管理 + * + * @param insuranceManager 保险管理 + * @return 结果 + */ + public int insertInsuranceManager(InsuranceManager insuranceManager); + + /** + * 修改保险管理 + * + * @param insuranceManager 保险管理 + * @return 结果 + */ + public int updateInsuranceManager(InsuranceManager insuranceManager); + + /** + * 批量删除保险管理 + * + * @param ids 需要删除的保险管理主键集合 + * @return 结果 + */ + public int deleteInsuranceManagerByIds(String ids); + + /** + * 删除保险管理信息 + * + * @param id 保险管理主键 + * @return 结果 + */ + public int deleteInsuranceManagerById(Long id); +} diff --git a/ghy-goods/src/main/java/com/ghy/goods/service/impl/CategoryInsuranceRelationServiceImpl.java b/ghy-goods/src/main/java/com/ghy/goods/service/impl/CategoryInsuranceRelationServiceImpl.java new file mode 100644 index 00000000..f31903b8 --- /dev/null +++ b/ghy-goods/src/main/java/com/ghy/goods/service/impl/CategoryInsuranceRelationServiceImpl.java @@ -0,0 +1,127 @@ +package com.ghy.goods.service.impl; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import cn.hutool.core.collection.CollectionUtil; +import com.ghy.common.utils.DateUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ghy.goods.mapper.CategoryInsuranceRelationMapper; +import com.ghy.goods.domain.CategoryInsuranceRelation; +import com.ghy.goods.service.ICategoryInsuranceRelationService; +import com.ghy.common.core.text.Convert; + +/** + * 总类目保险关联关系Service业务层处理 + * + * @author clunt + * @date 2024-09-25 + */ +@Service +public class CategoryInsuranceRelationServiceImpl implements ICategoryInsuranceRelationService +{ + @Autowired + private CategoryInsuranceRelationMapper categoryInsuranceRelationMapper; + + /** + * 查询总类目保险关联关系 + * + * @param id 总类目保险关联关系主键 + * @return 总类目保险关联关系 + */ + @Override + public CategoryInsuranceRelation selectCategoryInsuranceRelationById(Long id) + { + return categoryInsuranceRelationMapper.selectCategoryInsuranceRelationById(id); + } + + /** + * 查询总类目保险关联关系列表 + * + * @param categoryInsuranceRelation 总类目保险关联关系 + * @return 总类目保险关联关系 + */ + @Override + public List selectCategoryInsuranceRelationList(CategoryInsuranceRelation categoryInsuranceRelation) + { + return categoryInsuranceRelationMapper.selectCategoryInsuranceRelationList(categoryInsuranceRelation); + } + + /** + * 新增总类目保险关联关系 + * + * @param categoryInsuranceRelation 总类目保险关联关系 + * @return 结果 + */ + @Override + public int insertCategoryInsuranceRelation(CategoryInsuranceRelation categoryInsuranceRelation) + { + categoryInsuranceRelation.setCreateTime(DateUtils.getNowDate()); + return categoryInsuranceRelationMapper.insertCategoryInsuranceRelation(categoryInsuranceRelation); + } + + /** + * 修改总类目保险关联关系 + * + * @param categoryInsuranceRelation 总类目保险关联关系 + * @return 结果 + */ + @Override + public int updateCategoryInsuranceRelation(CategoryInsuranceRelation categoryInsuranceRelation) + { + categoryInsuranceRelation.setUpdateTime(DateUtils.getNowDate()); + return categoryInsuranceRelationMapper.updateCategoryInsuranceRelation(categoryInsuranceRelation); + } + + /** + * 批量删除总类目保险关联关系 + * + * @param ids 需要删除的总类目保险关联关系主键 + * @return 结果 + */ + @Override + public int deleteCategoryInsuranceRelationByIds(String ids) + { + return categoryInsuranceRelationMapper.deleteCategoryInsuranceRelationByIds(Convert.toStrArray(ids)); + } + + /** + * 删除总类目保险关联关系信息 + * + * @param id 总类目保险关联关系主键 + * @return 结果 + */ + @Override + public int deleteCategoryInsuranceRelationById(Long id) + { + return categoryInsuranceRelationMapper.deleteCategoryInsuranceRelationById(id); + } + + @Override + public void updateCategoryInsuranceRelation(String insuranceIds, Long categoryId) { + CategoryInsuranceRelation param = new CategoryInsuranceRelation(); + param.setGoodsCategoryId(categoryId); + List oldRecord = categoryInsuranceRelationMapper.selectCategoryInsuranceRelationList(param); + // 删除历史记录 + if(CollectionUtil.isNotEmpty(oldRecord)){ + String [] arr = new String[oldRecord.size()]; + for (int index = 0; index < oldRecord.size(); index ++){ + arr[index] = oldRecord.get(index).getId().toString(); + } + categoryInsuranceRelationMapper.deleteCategoryInsuranceRelationByIds(arr); + } + // 增加新记录 + if(StringUtils.isNotEmpty(insuranceIds)){ + String [] insuranceStr = insuranceIds.split(","); + for (String str : insuranceStr) { + CategoryInsuranceRelation model = new CategoryInsuranceRelation(); + model.setInsuranceId(Long.valueOf(str)); + model.setGoodsCategoryId(categoryId); + categoryInsuranceRelationMapper.insertCategoryInsuranceRelation(model); + } + } + } +} diff --git a/ghy-goods/src/main/java/com/ghy/goods/service/impl/InsuranceManagerServiceImpl.java b/ghy-goods/src/main/java/com/ghy/goods/service/impl/InsuranceManagerServiceImpl.java new file mode 100644 index 00000000..50a4ad42 --- /dev/null +++ b/ghy-goods/src/main/java/com/ghy/goods/service/impl/InsuranceManagerServiceImpl.java @@ -0,0 +1,97 @@ +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.InsuranceManagerMapper; +import com.ghy.goods.domain.InsuranceManager; +import com.ghy.goods.service.IInsuranceManagerService; +import com.ghy.common.core.text.Convert; + +/** + * 保险管理Service业务层处理 + * + * @author clunt + * @date 2024-09-25 + */ +@Service +public class InsuranceManagerServiceImpl implements IInsuranceManagerService +{ + @Autowired + private InsuranceManagerMapper insuranceManagerMapper; + + /** + * 查询保险管理 + * + * @param id 保险管理主键 + * @return 保险管理 + */ + @Override + public InsuranceManager selectInsuranceManagerById(Long id) + { + return insuranceManagerMapper.selectInsuranceManagerById(id); + } + + /** + * 查询保险管理列表 + * + * @param insuranceManager 保险管理 + * @return 保险管理 + */ + @Override + public List selectInsuranceManagerList(InsuranceManager insuranceManager) + { + return insuranceManagerMapper.selectInsuranceManagerList(insuranceManager); + } + + /** + * 新增保险管理 + * + * @param insuranceManager 保险管理 + * @return 结果 + */ + @Override + public int insertInsuranceManager(InsuranceManager insuranceManager) + { + insuranceManager.setCreateTime(DateUtils.getNowDate()); + return insuranceManagerMapper.insertInsuranceManager(insuranceManager); + } + + /** + * 修改保险管理 + * + * @param insuranceManager 保险管理 + * @return 结果 + */ + @Override + public int updateInsuranceManager(InsuranceManager insuranceManager) + { + insuranceManager.setUpdateTime(DateUtils.getNowDate()); + return insuranceManagerMapper.updateInsuranceManager(insuranceManager); + } + + /** + * 批量删除保险管理 + * + * @param ids 需要删除的保险管理主键 + * @return 结果 + */ + @Override + public int deleteInsuranceManagerByIds(String ids) + { + return insuranceManagerMapper.deleteInsuranceManagerByIds(Convert.toStrArray(ids)); + } + + /** + * 删除保险管理信息 + * + * @param id 保险管理主键 + * @return 结果 + */ + @Override + public int deleteInsuranceManagerById(Long id) + { + return insuranceManagerMapper.deleteInsuranceManagerById(id); + } +} diff --git a/ghy-goods/src/main/resources/mapper/goods/CategoryInsuranceRelationMapper.xml b/ghy-goods/src/main/resources/mapper/goods/CategoryInsuranceRelationMapper.xml new file mode 100644 index 00000000..e600fe3d --- /dev/null +++ b/ghy-goods/src/main/resources/mapper/goods/CategoryInsuranceRelationMapper.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + select id, insurance_id, goods_category_id, create_by, update_by, create_time, update_time, remark from category_insurance_relation + + + + + + + + insert into category_insurance_relation + + insurance_id, + goods_category_id, + create_by, + update_by, + create_time, + update_time, + remark, + + + #{insuranceId}, + #{goodsCategoryId}, + #{createBy}, + #{updateBy}, + #{createTime}, + #{updateTime}, + #{remark}, + + + + + update category_insurance_relation + + insurance_id = #{insuranceId}, + goods_category_id = #{goodsCategoryId}, + create_by = #{createBy}, + update_by = #{updateBy}, + create_time = #{createTime}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from category_insurance_relation where id = #{id} + + + + delete from category_insurance_relation where id in + + #{id} + + + + \ No newline at end of file diff --git a/ghy-goods/src/main/resources/mapper/goods/GoodsCategoryMapper.xml b/ghy-goods/src/main/resources/mapper/goods/GoodsCategoryMapper.xml index 77b5fcfb..75fa8fd7 100644 --- a/ghy-goods/src/main/resources/mapper/goods/GoodsCategoryMapper.xml +++ b/ghy-goods/src/main/resources/mapper/goods/GoodsCategoryMapper.xml @@ -16,11 +16,15 @@ + + + SELECT goods_category_id, goods_category_code, goods_category_name, parent_category_id, - level, type, status, create_by, create_time, remark, category_sort + level, type, status, create_by, create_time, remark, category_sort, insurance_status + , insurance_amount, insurance_url FROM goods_category @@ -61,6 +65,9 @@ level = #{level}, type = #{type}, remark = #{remark}, + insurance_status = #{insuranceStatus}, + insurance_amount = #{insuranceAmount}, + insurance_url = #{insuranceUrl}, update_by = #{updateBy}, update_time = sysdate() @@ -85,6 +92,9 @@ level, type, remark, + insurance_status, + insurance_url, + insurance_amount, create_by, create_time )values( @@ -96,6 +106,9 @@ #{level}, #{type}, #{remark}, + #{insuranceStatus}, + #{insuranceUrl}, + #{insuranceAmount}, #{createBy}, sysdate() ) diff --git a/ghy-goods/src/main/resources/mapper/goods/InsuranceManagerMapper.xml b/ghy-goods/src/main/resources/mapper/goods/InsuranceManagerMapper.xml new file mode 100644 index 00000000..11e0295f --- /dev/null +++ b/ghy-goods/src/main/resources/mapper/goods/InsuranceManagerMapper.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + select id, company_name, insurance_name, insurance_amount, insurance_url, create_by, update_by, create_time, update_time, remark from insurance_manager + + + + + + + + insert into insurance_manager + + company_name, + insurance_name, + insurance_amount, + insurance_url, + create_by, + update_by, + create_time, + update_time, + remark, + + + #{companyName}, + #{insuranceName}, + #{insuranceAmount}, + #{insuranceUrl}, + #{createBy}, + #{updateBy}, + #{createTime}, + #{updateTime}, + #{remark}, + + + + + update insurance_manager + + company_name = #{companyName}, + insurance_name = #{insuranceName}, + insurance_amount = #{insuranceAmount}, + insurance_url = #{insuranceUrl}, + create_by = #{createBy}, + update_by = #{updateBy}, + create_time = #{createTime}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from insurance_manager where id = #{id} + + + + delete from insurance_manager where id in + + #{id} + + + + \ No newline at end of file