Browse Source

Merge remote-tracking branch 'origin/dev' into dev

yingp 7 years ago
parent
commit
11c8b45ff0

+ 4 - 4
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/controller/AccountController.java

@@ -420,9 +420,9 @@ public class AccountController {
      */
     @PostMapping("/disable")
     public Result disableAccount(@RequestParam long accountId) {
-        accountService.disable(accountId);
+        //accountService.disable(accountId);
         //移除账户绑定的企业关系
-        accountService.unbindCompany(accountId, BaseContextHolder.getCompanyId());
+        accountService.updateBindCompanyStatus(accountId, BaseContextHolder.getCompanyId(), "0");
         //同步到优软云
         Long userUU = accountService.findByPrimaryKey(accountId).getUu();
         Long companyUU = companyService.findByPrimaryKey(BaseContextHolder.getCompanyId()).getUu();
@@ -439,9 +439,9 @@ public class AccountController {
      */
     @PostMapping("/enable")
     public Result enableAccount(@RequestParam long accountId) {
-        accountService.enable(accountId);
+        //accountService.enable(accountId);
         //添加账户绑定的企业关系
-        accountService.bindCompany(accountId, BaseContextHolder.getCompanyId());
+        accountService.updateBindCompanyStatus(accountId, BaseContextHolder.getCompanyId(), "1");
         //同步到优软云
         Long userUU = accountService.findByPrimaryKey(accountId).getUu();
         Long companyUU = companyService.findByPrimaryKey(BaseContextHolder.getCompanyId()).getUu();

+ 8 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/AccountMapper.java

@@ -122,4 +122,12 @@ public interface AccountMapper {
      * @return
      */
     int findByUsernameOrMobileOrEmail(@Param("username") String username, @Param("mobile") String mobile, @Param("email") String email);
+
+    /**
+     * 更新账户公司绑定状态
+     * @param accountId
+     * @param companyId
+     * @param status
+     */
+    void updateBindCompanyStatus(@Param("accountId") Long accountId, @Param("companyId") Long companyId, @Param("status") String status);
 }

+ 8 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/AccountService.java

@@ -194,4 +194,12 @@ public interface AccountService {
      * @return
      */
     boolean findByUsernameOrMobileOrEmail(String username, String mobile, String email);
+
+    /**
+     * 更新账户公司的绑定状态
+     * @param accountId
+     * @param companyId
+     * @param status
+     */
+    void updateBindCompanyStatus(Long accountId, Long companyId, String status);
 }

+ 5 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/impl/AccountServiceImpl.java

@@ -209,4 +209,9 @@ public class AccountServiceImpl implements AccountService {
         return accountMapper.findByUsernameOrMobileOrEmail(username, mobile, email) > 0;
     }
 
+    @Override
+    public void updateBindCompanyStatus(Long accountId, Long companyId, String status) {
+        accountMapper.updateBindCompanyStatus(accountId, companyId, status);
+    }
+
 }

+ 2 - 2
base-servers/account/account-server/src/main/resources/mapper/AccountCompanyMapper.xml

@@ -2,7 +2,7 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="com.usoftchina.saas.account.mapper.AccountCompanyMapper">
     <insert id="insert">
-        insert into ac_account_company(account_id,company_id) values (#{accountId}, #{companyId})
+        insert into ac_account_company(account_id,company_id,status) values (#{accountId}, #{companyId}, 1)
     </insert>
     <delete id="delete">
         delete from ac_account_company where account_id=#{accountId} and company_id=#{companyId}
@@ -18,7 +18,7 @@
         left join ac_account_company accmp on accmp.company_id=cmp.id
         left join ac_account ac on ac.id = accmp.account_id
         left join ac_account aci on aci.id = cmp.creator_id
-        where ac.mobile = #{mobile}
+        where ac.mobile = #{mobile} and accmp.status = 1
         order by is_default desc
     </select>
     <update id="unBindDefault" >

+ 3 - 0
base-servers/account/account-server/src/main/resources/mapper/AccountMapper.xml

@@ -210,4 +210,7 @@
         SELECT COUNT(*) FROM AC_ACCOUNT
         WHERE USERNAME = #{username} OR MOBILE = #{mobile} OR EMAIL = #{email};
     </select>
+    <update id="updateBindCompanyStatus">
+        UPDATE AC_ACCOUNT_COMPANY SET STATUS = #{status} WHERE ACCOUNT_ID = #{accountId} AND COMPANYID = #{companyId}
+    </update>
 </mapper>

+ 2 - 2
base-servers/account/account-server/src/main/resources/mapper/AccountRoleMapper.xml

@@ -17,7 +17,7 @@
         delete from ac_account_role where company_id=#{companyId}
     </delete>
     <select id="selectAccountRole" resultType="com.usoftchina.saas.account.dto.AccountRoleDTO">
-        SELECT a.id id,a.username,a.realname,a.email,a.mobile,GROUP_CONCAT(c.name) roleNames,GROUP_CONCAT(c.id) roleIds,a.enabled
+        SELECT a.id id,a.username,a.realname,a.email,a.mobile,GROUP_CONCAT(c.name) roleNames,GROUP_CONCAT(c.id) roleIds,d.status enabled
         FROM ac_account a
         left join ac_account_company d on a.id = d.account_id
         left join ac_account_role b on a.id=b.account_id and d.company_id = b.company_id
@@ -30,7 +30,7 @@
                 AND d.COMPANY_ID = #{companyId}
             </if>
         </where>
-        group by a.id,a.username,a.realname,a.email,a.mobile,a.enabled
+        group by a.id,a.username,a.realname,a.email,a.mobile,d.status
     </select>
     <delete id="unBindRolesById" >
         DELETE FROM AC_ACCOUNT_ROLE WHERE ACCOUNT_ID = #{id} and company_id = #{companyId}

+ 1 - 1
base-servers/account/account-server/src/main/resources/mapper/RoleMapper.xml

@@ -104,7 +104,7 @@
         select <include refid="baseColumns"/> from ac_role,ac_account_role
         where ac_role.id=ac_account_role.role_id and ac_account_role.account_id=#{accountId,jdbcType=BIGINT}
     </select>
-    <select id="findManagerByCompanyId" parameterType="int" resultType="com.usoftchina.saas.account.po.Role">
+    <select id="findManagerByCompanyId" resultType="com.usoftchina.saas.account.po.Role">
         SELECT * FROM AC_ROLE WHERE COMPANY_ID = #{companyId} AND TYPE = 0 limit 1
     </select>
 </mapper>