Browse Source

账户设置接口修改

chenw 7 years ago
parent
commit
16ed3f14a6

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

@@ -12,8 +12,11 @@ import com.usoftchina.saas.account.service.RoleService;
 import com.usoftchina.saas.account.vo.CompanyBaseVO;
 import com.usoftchina.saas.auth.client.annotation.IgnoreAuth;
 import com.usoftchina.saas.base.Result;
+import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.context.BaseContextHolder;
 import com.usoftchina.saas.exception.ExceptionCode;
+import com.usoftchina.saas.page.PageDefault;
+import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.utils.BeanMapper;
 import com.usoftchina.saas.utils.CollectionUtils;
 import com.usoftchina.saas.utils.RegexpUtils;
@@ -264,9 +267,13 @@ public class AccountController {
         return Result.success();
     }
 
+    /**
+     * 账户角色列表
+     * @return
+     */
     @GetMapping("/accountRole/list")
-    public Result getAccountRole(){
-        return Result.success(accountService.selectAccountRole());
+    public Result getAccountRole(@PageDefault(number = 1, size = 10) PageRequest pageRequest, ListReqDTO listReqDTO){
+        return Result.success(accountService.selectAccountRole(pageRequest, listReqDTO));
     }
 
     /**

+ 1 - 1
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/AccountRoleMapper.java

@@ -49,5 +49,5 @@ public interface AccountRoleMapper {
      */
     void deleteByRoleId(@Param("roleId") Long roleId);
 
-    List<AccountRoleDTO> selectAccountRole();
+    List<AccountRoleDTO> selectAccountRole(@Param("condition") String condition, @Param("companyId") Long companyId);
 }

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

@@ -1,8 +1,11 @@
 package com.usoftchina.saas.account.service;
 
+import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.account.dto.AccountRoleDTO;
 import com.usoftchina.saas.account.po.Account;
 import com.usoftchina.saas.account.po.RoleResource;
+import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.page.PageRequest;
 
 import java.util.List;
 
@@ -121,7 +124,7 @@ public interface AccountService {
      * 账号+角色信息列表
      * @return
      */
-    List<AccountRoleDTO> selectAccountRole();
+    PageInfo<AccountRoleDTO> selectAccountRole(PageRequest pageRequest, ListReqDTO listReqDTO);
 
     /**
      * 解除个人账号与角色的绑定

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

@@ -1,5 +1,7 @@
 package com.usoftchina.saas.account.service.impl;
 
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.account.cache.AccountCache;
 import com.usoftchina.saas.account.dto.AccountRoleDTO;
 import com.usoftchina.saas.account.mapper.AccountCompanyMapper;
@@ -11,7 +13,9 @@ import com.usoftchina.saas.account.po.Role;
 import com.usoftchina.saas.account.po.RoleResource;
 import com.usoftchina.saas.account.service.AccountService;
 import com.usoftchina.saas.account.service.RoleService;
+import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.context.BaseContextHolder;
+import com.usoftchina.saas.page.PageRequest;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -123,8 +127,22 @@ public class AccountServiceImpl implements AccountService {
     }
 
     @Override
-    public List<AccountRoleDTO> selectAccountRole(){
-        return accountRoleMapper.selectAccountRole();
+    public PageInfo<AccountRoleDTO> selectAccountRole(PageRequest page, ListReqDTO listReqDTO){
+        PageHelper.startPage(page.getNumber(), page.getSize());
+        List<AccountRoleDTO> accountRoleDTOList = getList(listReqDTO);
+        //取分页信息
+        PageInfo<AccountRoleDTO> pageInfo = new PageInfo<AccountRoleDTO>(accountRoleDTOList);
+        return pageInfo;
+    }
+
+    private List<AccountRoleDTO> getList(ListReqDTO listReqDTO) {
+        Long companyId = BaseContextHolder.getCompanyId();
+        String condition = listReqDTO.getFinalCondition();
+        if(condition == null){
+            condition = "1=1";
+        }
+        List<AccountRoleDTO> AccountRoleDTOList = accountRoleMapper.selectAccountRole(condition, companyId);
+        return AccountRoleDTOList;
     }
 
     @Override

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

@@ -21,6 +21,14 @@
         FROM ac_account a
         left join ac_account_role b on a.id=b.account_id
         left join ac_role c  on b.role_id = c.id
+        <where>
+            <if test="condition!=null">
+                ${condition}
+            </if>
+            <if test="companyId!=null">
+                AND C.COMPANY_ID = #{companyId}
+            </if>
+        </where>
         group by a.id,a.username,a.realname,a.email,a.mobile
     </select>
 </mapper>