From f6d898060ce3ab0bbca1924fad724858d4adc296 Mon Sep 17 00:00:00 2001
From: jyy <935090232@qq.com>
Date: Fri, 22 Jan 2021 13:07:46 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/api' into api

---
 zq-erp/src/main/java/com/matrix/system/common/interceptor/ApiUserLoginInterceptor.java |    2 
 zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml                        |    3 
 zq-erp/src/main/resources/mybatis/mapper/hive/SysVipLabelDao.xml                       |   77 ++++++++++--
 zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java     |   19 +-
 zq-erp/src/main/java/com/matrix/system/hive/bean/SysVipLabel.java                      |   43 +++++--
 zq-erp/src/main/resources/mybatis/mapper/hive/ArticleTypeDao.xml                       |    6 +
 zq-erp/src/main/java/com/matrix/system/app/dto/VipInfoListDto.java                     |   24 +++
 zq-erp/src/main/java/com/matrix/system/app/action/ApiKnowledgeAction.java              |    4 
 zq-erp/src/main/java/com/matrix/system/hive/dao/SysVipLabelDao.java                    |    7 +
 zq-erp/src/main/java/com/matrix/system/app/action/ApiVipLabelAction.java               |   63 ++++++++-
 zq-erp/src/main/java/com/matrix/system/hive/bean/ArticleType.java                      |   11 +
 zq-erp/src/main/java/com/matrix/system/app/dto/LabelDto.java                           |   34 +++++
 zq-erp/src/main/java/com/matrix/system/hive/action/ArticleTypeController.java          |    4 
 zq-erp/src/main/java/com/matrix/system/app/action/ApiVipInfoAction.java                |    6 +
 zq-erp/src/main/java/com/matrix/system/hive/bean/SysVipLabelRelate.java                |   41 ++++++
 15 files changed, 291 insertions(+), 53 deletions(-)

diff --git a/zq-erp/src/main/java/com/matrix/system/app/action/ApiKnowledgeAction.java b/zq-erp/src/main/java/com/matrix/system/app/action/ApiKnowledgeAction.java
index db24fd7..412a3a4 100644
--- a/zq-erp/src/main/java/com/matrix/system/app/action/ApiKnowledgeAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/app/action/ApiKnowledgeAction.java
@@ -6,6 +6,8 @@
 import com.matrix.system.hive.action.BaseController;
 import com.matrix.system.hive.bean.Article;
 import com.matrix.system.hive.bean.ArticleType;
+import com.matrix.system.hive.bean.SysShopInfo;
+import com.matrix.system.hive.dao.SysShopInfoDao;
 import com.matrix.system.hive.service.ArticleService;
 import com.matrix.system.hive.service.ArticleTypeService;
 import io.swagger.annotations.Api;
@@ -32,7 +34,7 @@
     @GetMapping(value = "/findKnowledgeType")
     public AjaxResult findKnowledgeType() {
         ArticleType type = new ArticleType();
-        type.setShopId(getMe().getCompanyId());
+        type.setCompanyId(getMe().getCompanyId());
         type.setParentId(0L);
         return AjaxResult.buildSuccessInstance(articleTypeService.findByModel(type));
     }
diff --git a/zq-erp/src/main/java/com/matrix/system/app/action/ApiVipInfoAction.java b/zq-erp/src/main/java/com/matrix/system/app/action/ApiVipInfoAction.java
index da71651..7906568 100644
--- a/zq-erp/src/main/java/com/matrix/system/app/action/ApiVipInfoAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/app/action/ApiVipInfoAction.java
@@ -2,6 +2,7 @@
 
 import com.matrix.core.constance.MatrixConstance;
 import com.matrix.core.pojo.AjaxResult;
+import com.matrix.core.pojo.PaginationVO;
 import com.matrix.core.tools.EncrypUtil;
 import com.matrix.core.tools.StringUtils;
 import com.matrix.core.tools.WebUtil;
@@ -78,6 +79,11 @@
         if (StringUtils.isBlank(vipInfoListDto.getOrder())) {
             vipInfoListDto.setOrder("asc");
         }
+
+        int offset = (vipInfoListDto.getPageNum() - 1) * vipInfoListDto.getPageSize();
+        int limit = vipInfoListDto.getPageSize();
+        vipInfoListDto.setOffset(offset);
+        vipInfoListDto.setLimit(limit);
         return AjaxResult.buildSuccessInstance(sysVipInfoService.findVipAddressBook(vipInfoListDto));
     }
 
diff --git a/zq-erp/src/main/java/com/matrix/system/app/action/ApiVipLabelAction.java b/zq-erp/src/main/java/com/matrix/system/app/action/ApiVipLabelAction.java
index 1d518c6..7db86dd 100644
--- a/zq-erp/src/main/java/com/matrix/system/app/action/ApiVipLabelAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/app/action/ApiVipLabelAction.java
@@ -1,37 +1,80 @@
 package com.matrix.system.app.action;
 
 import com.matrix.core.pojo.AjaxResult;
+import com.matrix.system.app.dto.LabelDto;
+import com.matrix.system.hive.action.BaseController;
+import com.matrix.system.hive.bean.SysVipLabel;
+import com.matrix.system.hive.dao.SysVipLabelDao;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
 
 /**
  * @author wzy
  * @date 2020-12-22
  **/
-//@Api(value = "ApiVipLabelAction", tags = "客户标签接口类")
+@Api(value = "ApiVipLabelAction", tags = "客户标签接口类")
 @RestController
 @RequestMapping(value = "/api/label")
-public class ApiVipLabelAction {
+public class ApiVipLabelAction extends BaseController {
 
+    @Autowired
+    private SysVipLabelDao sysVipLabelDao;
 
-    @ApiOperation(value = "获取客户标签列表", notes = "获取客户标签列表")
-    @GetMapping(value = "/findLabelByVipId/{vipId}")
-    public AjaxResult findLabelByVipId(@PathVariable("vipId") Long vipId) {
-        return null;
+    @ApiOperation(value = "获取标签列表", notes = "获取标签列表")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "ok", response = SysVipLabel.class)
+    })
+    @PostMapping(value = "/findLabelList")
+    public AjaxResult findLabelByVipId(@RequestBody LabelDto labelDto) {
+        SysVipLabel sysVipLabel = new SysVipLabel();
+        sysVipLabel.setCompanyId(getMe().getCompanyId());
+        sysVipLabel.setIsAll(1);
+        sysVipLabel.setLabel(labelDto.getLabel());
+        List<SysVipLabel> zbLabel = sysVipLabelDao.selectByModel(sysVipLabel);
+
+        sysVipLabel = new SysVipLabel();
+        sysVipLabel.setUserId(getMe().getSuId());
+        sysVipLabel.setLabel(labelDto.getLabel());
+        List<SysVipLabel> userLabel = sysVipLabelDao.selectByModel(sysVipLabel);
+        AjaxResult ajaxResult = AjaxResult.buildSuccessInstance("获取成功");
+        ajaxResult.putInMap("allLabel", zbLabel);
+        ajaxResult.putInMap("myLabel", userLabel);
+        return ajaxResult;
     }
 
 
-    @ApiOperation(value = "添加客户标签", notes = "添加客户标签")
+    @ApiOperation(value = "添加标签", notes = "添加标签")
     @PostMapping(value = "/addLabel")
-    public AjaxResult addLabel() {
-        return null;
+    public AjaxResult addLabel(@RequestBody LabelDto labelDto) {
+        SysVipLabel sysVipLabel = new SysVipLabel();
+        sysVipLabel.setLabel(labelDto.getLabel());
+        sysVipLabel.setColor(labelDto.getColor());
+        sysVipLabel.setShopId(getMe().getShopId());
+        sysVipLabel.setCompanyId(getMe().getCompanyId());
+        sysVipLabel.setUserId(getMe().getSuId());
+        sysVipLabel.setIsAll(2);
+        int i = sysVipLabelDao.insert(sysVipLabel);
+        if (i > 0) {
+            return AjaxResult.buildSuccessInstance("添加成功");
+        } else {
+            return AjaxResult.buildFailInstance("添加失败");
+        }
     }
 
     @ApiOperation(value = "删除标签", notes = "删除标签")
     @GetMapping(value = "/delById/{id}")
     public AjaxResult delById(@PathVariable("id") Long id) {
-        return null;
+        int i = sysVipLabelDao.deleteById(id);
+        if (i > 0) {
+            return AjaxResult.buildSuccessInstance("删除成功");
+        }
+        return AjaxResult.buildFailInstance("删除失败");
     }
 
 
diff --git a/zq-erp/src/main/java/com/matrix/system/app/dto/LabelDto.java b/zq-erp/src/main/java/com/matrix/system/app/dto/LabelDto.java
new file mode 100644
index 0000000..635a1ea
--- /dev/null
+++ b/zq-erp/src/main/java/com/matrix/system/app/dto/LabelDto.java
@@ -0,0 +1,34 @@
+package com.matrix.system.app.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @author wzy
+ * @date 2021-01-22
+ **/
+@ApiModel(value = "LabelDto", description = "添加标签接收参数接收类")
+public class LabelDto {
+
+    @ApiModelProperty(value = "标签内容", example = "123")
+    private String label;
+
+    @ApiModelProperty(value = "颜色", example = "#FFFFFF")
+    private String color;
+
+    public String getLabel() {
+        return label;
+    }
+
+    public void setLabel(String label) {
+        this.label = label;
+    }
+
+    public String getColor() {
+        return color;
+    }
+
+    public void setColor(String color) {
+        this.color = color;
+    }
+}
diff --git a/zq-erp/src/main/java/com/matrix/system/app/dto/VipInfoListDto.java b/zq-erp/src/main/java/com/matrix/system/app/dto/VipInfoListDto.java
index 03feb35..1154bf5 100644
--- a/zq-erp/src/main/java/com/matrix/system/app/dto/VipInfoListDto.java
+++ b/zq-erp/src/main/java/com/matrix/system/app/dto/VipInfoListDto.java
@@ -8,7 +8,7 @@
  * @date 2020-12-21
  **/
 @ApiModel(value = "VipInfoListDto", description = "获取会员列表参数类")
-public class VipInfoListDto {
+public class VipInfoListDto extends BasePageDto {
 
     @ApiModelProperty(value = "查询参数(客户姓名/手机/会员编号/拼音)", example = "")
     private String queryKey;
@@ -34,6 +34,28 @@
     @ApiModelProperty(hidden = true)
     private Long companyId;
 
+    @ApiModelProperty(hidden = true)
+    private int offset;
+
+    @ApiModelProperty(hidden = true)
+    private int limit;
+
+    public int getOffset() {
+        return offset;
+    }
+
+    public void setOffset(int offset) {
+        this.offset = offset;
+    }
+
+    public int getLimit() {
+        return limit;
+    }
+
+    public void setLimit(int limit) {
+        this.limit = limit;
+    }
+
     public Long getCompanyId() {
         return companyId;
     }
diff --git a/zq-erp/src/main/java/com/matrix/system/common/interceptor/ApiUserLoginInterceptor.java b/zq-erp/src/main/java/com/matrix/system/common/interceptor/ApiUserLoginInterceptor.java
index ade0b0b..4fe5642 100644
--- a/zq-erp/src/main/java/com/matrix/system/common/interceptor/ApiUserLoginInterceptor.java
+++ b/zq-erp/src/main/java/com/matrix/system/common/interceptor/ApiUserLoginInterceptor.java
@@ -47,7 +47,7 @@
     @Override
     public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
         if ("dev".equals(evn)) {
-            SysUsers sysUsers = sysUsersDao.selectById(1074L);
+            SysUsers sysUsers = sysUsersDao.selectById(1012L);
             request.getSession().setAttribute(MatrixConstance.LOGIN_KEY, sysUsers);
             return true;
         }
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/action/ArticleTypeController.java b/zq-erp/src/main/java/com/matrix/system/hive/action/ArticleTypeController.java
index 2857afc..3811381 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/action/ArticleTypeController.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/action/ArticleTypeController.java
@@ -77,7 +77,7 @@
 	public @ResponseBody AjaxResult queryAll(ArticleType articleType) {
 		SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
 		articleType.setType(Dictionary.ARTICEL_TYPE_NAME_MDXY);
-		articleType.setShopId(users.getShopId());
+		articleType.setCompanyId(users.getCompanyId());
 		return new AjaxResult(AjaxResult.STATUS_SUCCESS,	currentService.findByModel(articleType), 0);
 	}
 	
@@ -115,7 +115,7 @@
    		articleType.setType(Dictionary.ARTICEL_TYPE_NAME_MDXY);
 		SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
 		articleType.setShopId(users.getShopId());
-
+		articleType.setCompanyId(users.getCompanyId());
 		Long parentId = articleType.getParentId();
 		List<Long> ids = new ArrayList<>();
 		while (parentId != 0) {
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/bean/ArticleType.java b/zq-erp/src/main/java/com/matrix/system/hive/bean/ArticleType.java
index 3c9420e..fc2cee1 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/bean/ArticleType.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/bean/ArticleType.java
@@ -58,6 +58,8 @@
 	private Long shopId;
 
 	private String parentIds;
+
+	private Long companyId;
 			
 	/**
 	 * 扩展属性
@@ -83,6 +85,15 @@
 	public void setArticle(Article article) {
 		this.article = article;
 	}*/
+
+	public Long getCompanyId() {
+		return companyId;
+	}
+
+	public void setCompanyId(Long companyId) {
+		this.companyId = companyId;
+	}
+
 	public Long getId() {
 		return id;
 	}
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/bean/SysVipLabel.java b/zq-erp/src/main/java/com/matrix/system/hive/bean/SysVipLabel.java
index 1319298..c71e8e9 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/bean/SysVipLabel.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/bean/SysVipLabel.java
@@ -24,11 +24,6 @@
     private Long id;
 
     /**
-     * 会员ID
-     */
-    private Long vipId;
-
-    /**
      * 标签内容
      */
     private String label;
@@ -36,6 +31,36 @@
     private Long shopId;
 
     private Long companyId;
+
+    private Long userId;
+
+    private Integer isAll;
+
+    private String color;
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public Integer getIsAll() {
+        return isAll;
+    }
+
+    public void setIsAll(Integer isAll) {
+        this.isAll = isAll;
+    }
+
+    public String getColor() {
+        return color;
+    }
+
+    public void setColor(String color) {
+        this.color = color;
+    }
 
     public Long getShopId() {
         return shopId;
@@ -75,14 +100,6 @@
 
     public void setId(Long id) {
         this.id = id;
-    }
-
-    public Long getVipId() {
-        return vipId;
-    }
-
-    public void setVipId(Long vipId) {
-        this.vipId = vipId;
     }
 
     public String getLabel() {
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/bean/SysVipLabelRelate.java b/zq-erp/src/main/java/com/matrix/system/hive/bean/SysVipLabelRelate.java
new file mode 100644
index 0000000..d3fdd37
--- /dev/null
+++ b/zq-erp/src/main/java/com/matrix/system/hive/bean/SysVipLabelRelate.java
@@ -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;
+    }
+}
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/dao/SysVipLabelDao.java b/zq-erp/src/main/java/com/matrix/system/hive/dao/SysVipLabelDao.java
index 7333440..6c5cf07 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/dao/SysVipLabelDao.java
+++ b/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;
@@ -9,11 +10,15 @@
 
     int insert(SysVipLabel sysVipLabel);
 
+    int insertRelate(SysVipLabelRelate sysVipLabelRelate);
+
+    int update(SysVipLabel sysVipLabel);
+
     int deleteById(@Param("id") Long id);
 
     List<SysVipLabel> selectByVipId(@Param("vipId") Long vipId);
 
     List<SysVipLabel> selectByModel(@Param("record") SysVipLabel sysVipLabel);
 
-    int deleteByVipId(@Param("vipId") Long vipId);
+    int deleteRelateByVipId(@Param("vipId") Long vipId);
 }
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java
index 8a6f81e..025715b 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java
+++ b/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,23 +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());
-			sysVipLabel.setVipId(id);
-			sysVipLabelDao.insert(sysVipLabel);
+			SysVipLabelRelate relate = new SysVipLabelRelate();
+			relate.setLabelId(Long.parseLong(iterator.next()));
+			relate.setVipId(id);
+			sysVipLabelDao.insertRelate(relate);
 		}
 	}
 
diff --git a/zq-erp/src/main/resources/mybatis/mapper/hive/ArticleTypeDao.xml b/zq-erp/src/main/resources/mybatis/mapper/hive/ArticleTypeDao.xml
index 65db100..1cdc488 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/hive/ArticleTypeDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/hive/ArticleTypeDao.xml
@@ -15,6 +15,7 @@
 		<result property="type" column="type" />
 		<result property="parentIds" column="parent_ids" />
 		<result property="shopId" column="shop_id"/>
+		<result property="companyId" column="company_id" />
 			<!--扩展属性  -->
 			<!-- <association property="article" javaType="Article"
 			column="{type_id=id}" select="com.matrix.system.hive.dao.ArticleDao.selectById" /> -->
@@ -32,6 +33,7 @@
 			icon,
 			type,
 			shop_id,
+			company_id,
 			parent_ids
 		)
 	VALUES (
@@ -44,6 +46,7 @@
 			#{icon},
 			#{type},
 			#{shopId},
+			#{companyId},
 			#{parentIds}
 	)
 	</insert>
@@ -250,6 +253,9 @@
 			<if test="record.shopId != null and record.shopId !='' ">
 				and shop_id = #{record.shopId}
 			</if>
+			<if test="record.companyId != null and record.companyId !='' ">
+				and company_id = #{record.companyId}
+			</if>
 		</if>
 	</select>
 </mapper>
\ No newline at end of file
diff --git a/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml b/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml
index d29ea9e..b2b7892 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml
@@ -1345,6 +1345,9 @@
         <if test="record.sort != 'monthArrived' and record.sort != 'yearArrived'">
             order by ${record.sort} ${record.order}
         </if>
+        <if test="record.offset >=0  and record.limit >0">
+            limit #{record.offset},#{record.limit}
+        </if>
     </select>
 
     <select id="selectVipInfoById" resultType="com.matrix.system.app.vo.VipInfoVo">
diff --git a/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipLabelDao.xml b/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipLabelDao.xml
index 26606d4..da750be 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipLabelDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipLabelDao.xml
@@ -9,16 +9,50 @@
             create_time,
             create_by,
             id,
-            vip_id,
-            label
+            label,
+            shop_id,
+            company_id,
+            is_all,
+            user_id,
+            color
         ) values (
             #{createTime},
             #{createBy},
             #{id},
-            #{vipId},
-            #{label}
+            #{label},
+            #{shopId},
+            #{companyId},
+            #{isAll},
+            #{userId},
+            #{color}
         )
     </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>
+            <if test="label != null and label !='' ">
+                label = #{label},
+            </if>
+            <if test="color != null and color !='' ">
+                color = #{color},
+            </if>
+        </set>
+        WHERE ID=#{id}
+    </update>
 
     <delete id="deleteById">
         delete from sys_vip_label
@@ -27,26 +61,43 @@
 
 
     <select id="selectByVipId" resultType="com.matrix.system.hive.bean.SysVipLabel">
-        select *
-        from sys_vip_label
-        where vip_id=#{vipId}
+        select b.*
+        from sys_vip_label_relate a
+        inner join sys_vip_label b on a.label_id=b.id
+        where a.vip_id=#{vipId}
     </select>
 
     <select id="selectByModel" resultType="com.matrix.system.hive.bean.SysVipLabel">
-        select * from sys_vip_label
+        select
+            create_time createTime,
+            create_by createBy,
+            id,
+            label,
+            shop_id shopId,
+            company_id companyId,
+            is_all isAll,
+            user_id userId,
+            color
+        from sys_vip_label
         where 1=1
         <if test="record!=null">
             <if test="record.label!=null  and record.label!=''">
-                and label=#{record.label}
+                and label like CONCAT('%', CONCAT(#{record.label},'%'))
             </if>
-            <if test="record.vipId!=null">
-                and vip_id=#{record.vipId}
+            <if test="record.isAll!=null  and record.isAll!=0">
+                and is_all=#{record.isAll}
+            </if>
+            <if test="record.userId!=null  and record.userId!=''">
+                and user_id=#{record.userId}
+            </if>
+            <if test="record.companyId!=null  and record.companyId!=''">
+                and company_id=#{record.companyId}
             </if>
         </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>
\ No newline at end of file

--
Gitblit v1.9.1