Pārlūkot izejas kodu

个微用户改动

lmx 1 dienu atpakaļ
vecāks
revīzija
11ad6768c0

+ 5 - 0
fs-service/src/main/java/com/fs/company/domain/CompanyWxAccount.java

@@ -101,4 +101,9 @@ public class CompanyWxAccount extends BaseEntity
 
     @TableField(exist = false)
     private String companyUserName;
+
+    /**
+     * 微信备注(唯一)
+     */
+    private String wxRemark;
 }

+ 2 - 0
fs-service/src/main/java/com/fs/company/mapper/CompanyWxAccountMapper.java

@@ -67,4 +67,6 @@ public interface CompanyWxAccountMapper extends BaseMapper<CompanyWxAccount> {
     List<CompanyUser> companyListAllCompany(CompanyUser companyUser);
 
     CompanyWxAccount selectByCompanyUserAndWxNo(@Param("userId") Long userId, @Param("wxNo") String wxNo);
+
+    CompanyWxAccount selectCompanyWxAccountByWxRemark(@Param("wxRemark") String wxRemark);
 }

+ 5 - 0
fs-service/src/main/java/com/fs/company/service/impl/CompanyWxServiceImpl.java

@@ -153,6 +153,11 @@ public class CompanyWxServiceImpl extends ServiceImpl<CompanyWxAccountMapper, Co
     @Override
     public int insertCompanyWxAccount(CompanyWxAccount companyWxAccount)
     {
+        //校验添加微信前缀唯一性
+        CompanyWxAccount wxAccount = companyWxAccountMapper.selectCompanyWxAccountByWxRemark(companyWxAccount.getWxRemark());
+        if(null != wxAccount){
+            throw new RuntimeException("微信前缀已存在,请更换后重试");
+        }
         companyWxAccount.setCreateTime(DateUtils.getNowDate());
         return companyWxAccountMapper.insertCompanyWxAccount(companyWxAccount);
     }

+ 7 - 0
fs-service/src/main/resources/mapper/company/CompanyWxAccountMapper.xml

@@ -59,6 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyId != null">company_id,</if>
             <if test="createTime != null">create_time,</if>
             <if test="createUser != null">create_user,</if>
+            <if test="wxRemark != null">wx_remark,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="wxNickName != null">#{wxNickName},</if>
@@ -68,6 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyId != null">#{companyId},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="createUser != null">#{createUser},</if>
+            <if test="wxRemark != null">#{wxRemark},</if>
          </trim>
     </insert>
 
@@ -106,4 +108,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectByCompanyUserAndWxNo" resultType="com.fs.company.domain.CompanyWxAccount">
         select * from company_wx_account where company_user_id = #{userId} and wx_no = #{wxNo}
     </select>
+
+    <select id="selectCompanyWxAccountByWxRemark" resultType="com.fs.company.domain.CompanyWxAccount">
+        select * from company_wx_account where wx_remark like concat( #{wxRemark}, '%') limit 1
+    </select>
+
 </mapper>