Compare commits

..

3 Commits

12 changed files with 453 additions and 12 deletions

View File

@ -1,5 +1,7 @@
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;
import com.ghy.common.core.domain.AjaxResult;
@ -10,10 +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.DeptGoodsCategory;
import com.ghy.goods.domain.GoodsImgs;
import com.ghy.goods.service.DeptGoodsCategoryService;
import com.ghy.goods.service.GoodsImgsService;
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;
@ -38,6 +38,15 @@ public class GoodsDeptCategoryController extends BaseController {
@Resource
DeptGoodsCategoryService deptGoodsCategoryService;
@Resource
ICategoryInsuranceRelationService categoryInsuranceRelationService;
@Resource
IDeptCategoryInsuranceRelationService deptCategoryInsuranceRelationService;
@Resource
IInsuranceManagerService insuranceManagerService;
@Autowired
private GoodsImgsService goodsImgsService;
@ -145,6 +154,43 @@ public class GoodsDeptCategoryController extends BaseController {
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Long id, ModelMap mmap) {
DeptGoodsCategory deptGoodsCategory = deptGoodsCategoryService.get(id);
CategoryInsuranceRelation relation = new CategoryInsuranceRelation();
relation.setGoodsCategoryId(deptGoodsCategory.getGoodsCategoryId());
List<CategoryInsuranceRelation> relations = categoryInsuranceRelationService.selectCategoryInsuranceRelationList(relation);
// pc保险设置
List<InsuranceManager> pcInsuranceList = new ArrayList<>();
// 商城保险设置
List<InsuranceManager> shopInsuranceList = new ArrayList<>();
if(CollectionUtil.isNotEmpty(relations)){
List<InsuranceManager> 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("pcInsurances", pcInsuranceList);
mmap.put("shopInsurances", shopInsuranceList);
mmap.put("deptGoodsCategory", deptGoodsCategory);
return PREFIX + "/edit";
}
@ -153,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();

View File

@ -238,14 +238,31 @@
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-6 control-label">是否需要保险:</label>
<div class="col-sm-6">
<select name="isSure" class="form-control m-b" th:field="*{isSure}" th:with="type=${@dict.getType('sys_user_sex')}">
<option th:text="否" th:value="0"/>
<option th:text="是" th:value="1"/>
</select>
</div>
<div class="row">
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<label class="col-xs-3 control-label">PC保险设定</label>
<div class="col-xs-9">
<label th:each="insurance:${pcInsurances}" class="check-box">
<input name="pcInsurance" type="checkbox" th:value="${insurance.id}" th:text="${insurance.insuranceName}" th:checked="${insurance.flag}">
</label>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<label class="col-xs-3 control-label">商城保险设定:</label>
<div class="col-xs-9">
<label th:each="insurance:${shopInsurances}" class="check-box">
<input name="shopInsurance" type="checkbox" th:value="${insurance.id}" th:text="${insurance.insuranceName}" th:checked="${insurance.flag}">
</label>
</div>
</div>
</div>
</div>
@ -293,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();
}

View File

@ -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;
}

View File

@ -101,4 +101,8 @@ public class DeptGoodsCategory extends GoodsCategory {
// 是否需要证书 1.需要
private Integer isCert;
private String pcInsuranceIds;
private String shopInsuranceIds;
}

View File

@ -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<DeptCategoryInsuranceRelation> 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);
}

View File

@ -1,6 +1,7 @@
package com.ghy.goods.mapper;
import java.util.List;
import com.ghy.goods.domain.InsuranceManager;
import org.apache.ibatis.annotations.Param;
/**
* 保险管理Mapper接口
@ -57,4 +58,7 @@ public interface InsuranceManagerMapper
* @return 结果
*/
public int deleteInsuranceManagerByIds(String[] ids);
List<InsuranceManager> selectByIds(@Param("ids") List<Long> ids);
}

View File

@ -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<DeptCategoryInsuranceRelation> 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);
}

View File

@ -27,6 +27,8 @@ public interface IInsuranceManagerService
*/
public List<InsuranceManager> selectInsuranceManagerList(InsuranceManager insuranceManager);
public List<InsuranceManager> selectByIds(List<Long> ids);
/**
* 新增保险管理
*

View File

@ -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<DeptCategoryInsuranceRelation> 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) {
}
}

View File

@ -45,6 +45,11 @@ public class InsuranceManagerServiceImpl implements IInsuranceManagerService
return insuranceManagerMapper.selectInsuranceManagerList(insuranceManager);
}
@Override
public List<InsuranceManager> selectByIds(List<Long> ids) {
return insuranceManagerMapper.selectByIds(ids);
}
/**
* 新增保险管理
*

View File

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ghy.goods.mapper.DeptCategoryInsuranceRelationMapper">
<resultMap type="DeptCategoryInsuranceRelation" id="DeptCategoryInsuranceRelationResult">
<result property="id" column="id" />
<result property="deptCategoryId" column="dept_category_id" />
<result property="type" column="type" />
<result property="insuranceId" column="insurance_id" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectDeptCategoryInsuranceRelationVo">
select id, dept_category_id, type, insurance_id, create_by, create_time, update_by, update_time, remark from dept_category_insurance_relation
</sql>
<select id="selectDeptCategoryInsuranceRelationList" parameterType="DeptCategoryInsuranceRelation" resultMap="DeptCategoryInsuranceRelationResult">
<include refid="selectDeptCategoryInsuranceRelationVo"/>
<where>
<if test="deptCategoryId != null "> and dept_category_id = #{deptCategoryId}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="insuranceId != null "> and insurance_id = #{insuranceId}</if>
</where>
</select>
<select id="selectDeptCategoryInsuranceRelationById" parameterType="Long" resultMap="DeptCategoryInsuranceRelationResult">
<include refid="selectDeptCategoryInsuranceRelationVo"/>
where id = #{id}
</select>
<insert id="insertDeptCategoryInsuranceRelation" parameterType="DeptCategoryInsuranceRelation" useGeneratedKeys="true" keyProperty="id">
insert into dept_category_insurance_relation
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deptCategoryId != null">dept_category_id,</if>
<if test="type != null">type,</if>
<if test="insuranceId != null">insurance_id,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deptCategoryId != null">#{deptCategoryId},</if>
<if test="type != null">#{type},</if>
<if test="insuranceId != null">#{insuranceId},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateDeptCategoryInsuranceRelation" parameterType="DeptCategoryInsuranceRelation">
update dept_category_insurance_relation
<trim prefix="SET" suffixOverrides=",">
<if test="deptCategoryId != null">dept_category_id = #{deptCategoryId},</if>
<if test="type != null">type = #{type},</if>
<if test="insuranceId != null">insurance_id = #{insuranceId},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDeptCategoryInsuranceRelationById" parameterType="Long">
delete from dept_category_insurance_relation where id = #{id}
</delete>
<delete id="deleteDeptCategoryInsuranceRelationByIds" parameterType="String">
delete from dept_category_insurance_relation where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -89,4 +89,11 @@
</foreach>
</delete>
<select id="selectByIds" resultMap="InsuranceManagerResult">
<include refid="selectInsuranceManagerVo"/>
where id in
<foreach collection="ids" item="name" open="(" separator="," close=")">
#{name}
</foreach>
</select>
</mapper>