zq-erp/src/main/java/com/matrix/system/hive/bean/SysVipLabelRelate.java | ●●●●● patch | view | raw | blame | history | |
zq-erp/src/main/java/com/matrix/system/hive/dao/SysVipLabelDao.java | ●●●●● patch | view | raw | blame | history | |
zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java | ●●●●● patch | view | raw | blame | history | |
zq-erp/src/main/resources/mybatis/mapper/hive/SysVipLabelDao.xml | ●●●●● patch | view | raw | blame | history |
zq-erp/src/main/java/com/matrix/system/hive/bean/SysVipLabelRelate.java
New file @@ -0,0 +1,41 @@ package com.matrix.system.hive.bean; import java.io.Serializable; /** * @author wzy * @date 2021-01-22 **/ public class SysVipLabelRelate implements Serializable { private static final long serialVersionUID = 1860770077746416680L; private Long id; private Long labelId; private Long vipId; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Long getLabelId() { return labelId; } public void setLabelId(Long labelId) { this.labelId = labelId; } public Long getVipId() { return vipId; } public void setVipId(Long vipId) { this.vipId = vipId; } } zq-erp/src/main/java/com/matrix/system/hive/dao/SysVipLabelDao.java
@@ -1,6 +1,7 @@ package com.matrix.system.hive.dao; import com.matrix.system.hive.bean.SysVipLabel; import com.matrix.system.hive.bean.SysVipLabelRelate; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -8,6 +9,8 @@ public interface SysVipLabelDao { int insert(SysVipLabel sysVipLabel); int insertRelate(SysVipLabelRelate sysVipLabelRelate); int update(SysVipLabel sysVipLabel); @@ -17,5 +20,5 @@ List<SysVipLabel> selectByModel(@Param("record") SysVipLabel sysVipLabel); int deleteByVipId(@Param("vipId") Long vipId); int deleteRelateByVipId(@Param("vipId") Long vipId); } zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java
@@ -485,7 +485,7 @@ int i=sysVipInfoDao.insert(vipInfo); if (CollectionUtils.isNotEmpty(addVipDto.getLabels())) { // batchInsertLabel(addVipDto.getLabels(), user.getSuName(), vipInfo.getId()); batchInsertLabel(addVipDto.getLabels(), vipInfo.getId()); } //创建用户默认储值卡 @@ -536,21 +536,20 @@ int i = sysVipInfoDao.update(vipInfo); if (CollectionUtils.isNotEmpty(modifyVipDto.getLabels())) { // sysVipLabelDao.deleteByVipId(modifyVipDto.getVipId()); // batchInsertLabel(modifyVipDto.getLabels(), user.getSuName(), vipInfo.getId()); sysVipLabelDao.deleteRelateByVipId(modifyVipDto.getVipId()); batchInsertLabel(modifyVipDto.getLabels(), vipInfo.getId()); } return i; } private void batchInsertLabel(List<String> labelList, String suName, Long id) { private void batchInsertLabel(List<String> labelList, Long id) { Set<String> labels = new HashSet<>(labelList); Iterator<String> iterator = labels.iterator(); if (iterator.hasNext()) { SysVipLabel sysVipLabel = new SysVipLabel(); sysVipLabel.setCreateTime(new Date()); sysVipLabel.setCreateBy(suName); sysVipLabel.setLabel(iterator.next()); sysVipLabelDao.insert(sysVipLabel); SysVipLabelRelate relate = new SysVipLabelRelate(); relate.setLabelId(Long.parseLong(iterator.next())); relate.setVipId(id); sysVipLabelDao.insertRelate(relate); } } zq-erp/src/main/resources/mybatis/mapper/hive/SysVipLabelDao.xml
@@ -28,6 +28,19 @@ ) </insert> <insert id="insertRelate" parameterType="com.matrix.system.hive.bean.SysVipLabel" useGeneratedKeys="true" keyProperty="id"> insert sys_vip_label_relate ( id, label_id, vip_id ) values ( #{id}, #{labelId}, #{vipId} ) </insert> <update id="update"> update sys_vip_label <set> @@ -83,8 +96,8 @@ </if> </select> <delete id="deleteByVipId"> delete from sys_vip_label <delete id="deleteRelateByVipId"> delete from sys_vip_label_relate where vip_id=#{vipId} </delete> </mapper>