feat: 系统功能开发,帐号、用户组、角色
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/v1/admin/AdminAccountController.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/v1/admin/AdminAccountController.java
index d23f7c9..0d5f4d6 100644
--- a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/v1/admin/AdminAccountController.java
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/v1/admin/AdminAccountController.java
@@ -1,5 +1,566 @@
 package com.supwisdom.institute.backend.system.api.v1.admin;
 
+import java.util.HashMap;
+
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.http.HttpStatus;
+import org.springframework.util.MimeTypeUtils;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.supwisdom.institute.backend.common.framework.entity.EntityUtils;
+import com.supwisdom.institute.backend.common.framework.vo.response.DefaultApiResponse;
+import com.supwisdom.institute.backend.system.api.vo.request.AccountCreateRequest;
+import com.supwisdom.institute.backend.system.api.vo.request.AccountQueryRequest;
+import com.supwisdom.institute.backend.system.api.vo.request.AccountRelateGroupsRequest;
+import com.supwisdom.institute.backend.system.api.vo.request.AccountRelateRolesRequest;
+import com.supwisdom.institute.backend.system.api.vo.request.AccountRelatedGroupsRequest;
+import com.supwisdom.institute.backend.system.api.vo.request.AccountRelatedRolesRequest;
+import com.supwisdom.institute.backend.system.api.vo.request.AccountUpdateRequest;
+import com.supwisdom.institute.backend.system.api.vo.response.AccountCreateResponseData;
+import com.supwisdom.institute.backend.system.api.vo.response.AccountLoadResponseData;
+import com.supwisdom.institute.backend.system.api.vo.response.AccountQueryResponseData;
+import com.supwisdom.institute.backend.system.api.vo.response.AccountRelateGroupsResponseData;
+import com.supwisdom.institute.backend.system.api.vo.response.AccountRelateRolesResponseData;
+import com.supwisdom.institute.backend.system.api.vo.response.AccountRelatedGroupsResponseData;
+import com.supwisdom.institute.backend.system.api.vo.response.AccountRelatedRolesResponseData;
+import com.supwisdom.institute.backend.system.api.vo.response.AccountRemoveResponseData;
+import com.supwisdom.institute.backend.system.api.vo.response.AccountUpdateResponseData;
+import com.supwisdom.institute.backend.system.domain.entity.Account;
+import com.supwisdom.institute.backend.system.domain.entity.AccountGroup;
+import com.supwisdom.institute.backend.system.domain.entity.AccountRole;
+import com.supwisdom.institute.backend.system.domain.service.AccountService;
+
+@Api(value = "SystemAdminAccount", tags = { "SystemAdminAccount" }, description = "帐号的操作接口")
+@Slf4j
+@RestController
+@RequestMapping("/v1/admin/accounts")
 public class AdminAccountController {
+  
+  @Autowired
+  private AccountService accountService;
+
+  /**
+   * 
+   * curl -i -s -X GET -H 'Accept:application/json' 'http://localhost:8081/api/v1/admin/accounts'
+   * curl -i -s -X GET -H 'Accept:application/json' 'http://localhost:8081/api/v1/admin/accounts?pageIndex=2&pageSize=50'
+   * curl -i -s -X GET -H 'Accept:application/json' 'http://localhost:8081/api/v1/admin/accounts?pageIndex=0&pageSize=20&mapBean[username]=username&mapBean[name]=name&mapBean[status]=1'
+   * curl -i -s -X GET -H 'Accept:application/json' 'http://localhost:8081/api/v1/admin/accounts?pageIndex=0&pageSize=20&mapBean[username]=username&mapBean[name]=name&mapBean[status]=0'
+   * 
+   * response success:
+   * 
+   * <pre>
+   * {
+   *   "pageIndex":0,
+   *   "pageSize":20,
+   *   "mapBean":null,
+   *   "pageCount":1,
+   *   "recordCount":1,
+   *   "items":[
+   *     {
+   *       "id":"ff80808164feb8990164feba0de50000",
+   *       "companyId":"1",
+   *       "deleted":false,
+   *       "addAccount":"account","addTime":"2018-08-03T07:39:23.000+0000",
+   *       "editAccount":null,"editTime":null,
+   *       "deleteAccount":null,"deleteTime":null,
+   *       "accountname":"test001",
+   *       "password":"test001",
+   *       "enabled":true,
+   *       "accountNonExpired":true,
+   *       "accountNonLocked":true,
+   *       "credentialsNonExpired":true,
+   *       "name":"测试001",
+   *       "status":"1",
+   *       "mobile":null,
+   *       "email":null
+   *     }
+   *   ]
+   * }
+   * </pre>
+   * 
+   * response error 401:
+   * 
+   * <pre>
+   * {
+   *   "timestamp":"2018-08-03T08:48:25.777+0000",
+   *   "status":401,
+   *   "error":"Http Status 401",
+   *   "message":"Unauthorized",
+   *   "path":"/api/v1/admin/accounts"
+   * }
+   * </pre>
+   * 
+   * @param pagerRequestModel
+   * @return
+   */
+  @GetMapping(produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
+  @ResponseStatus(value = HttpStatus.OK)
+  @ResponseBody
+  public DefaultApiResponse<AccountQueryResponseData> query(AccountQueryRequest queryRequest) {
+
+    Page<Account> page = accountService.selectPageList(
+        queryRequest.isLoadAll(), 
+        queryRequest.getPageIndex(), 
+        queryRequest.getPageSize(),
+        queryRequest.getMapBean(),
+        queryRequest.getOrderBy());
+
+    AccountQueryResponseData data = AccountQueryResponseData.of(queryRequest).build(page);
+
+    return new DefaultApiResponse<AccountQueryResponseData>(data);
+  }
+
+  /**
+   * 
+   * curl -i -s -X GET -H 'Accept:application/json' 'http://localhost:8081/api/v1/admin/accounts/1'
+   * 
+   * response success:
+   * 
+   * <pre>
+   * {
+   *   "id":"ff80808164feb8990164feba0de50000",
+   *   "companyId":"1",
+   *   "deleted":false,
+   *   "addAccount":"account","addTime":"2018-08-03T07:39:23.000+0000",
+   *   "editAccount":null,"editTime":null,
+   *   "deleteAccount":null,"deleteTime":null,
+   *   "username":"test001",
+   *   "password":"test001",
+   *   "enabled":true,
+   *   "accountNonExpired":true,
+   *   "accountNonLocked":true,
+   *   "credentialsNonExpired":true,
+   *   "name":"测试001",
+   *   "status":"1",
+   *   "mobile":null,
+   *   "email":null
+   * }
+   * </pre>
+   * 
+   * response error 401:
+   * 
+   * <pre>
+   * {
+   *   "timestamp":"2018-08-03T08:43:26.080+0000",
+   *   "status":401,
+   *   "error":"Http Status 401",
+   *   "message":"Unauthorized",
+   *   "path":"/api/v1/admin/accounts/ff80808164fecf640164fed269480000"
+   * }
+   * </pre>
+   * 
+   * response error 500:
+   * 
+   * <pre>
+   * {
+   *   "timestamp":"2018-08-03T07:44:07.963+0000",
+   *   "status":500,
+   *   "error":"Internal Server Error",
+   *   "exception":"java.lang.RuntimeException",
+   *   "message":"exception.get.domain.not.exist",
+   *   "path":"/api/v1/admin/accounts/1"
+   * }
+   * </pre>
+   * 
+   * @param id
+   * @return
+   */
+  @GetMapping(path = "/{id}", produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
+  @ResponseStatus(value = HttpStatus.OK)
+  @ResponseBody
+  public DefaultApiResponse<AccountLoadResponseData> load(@PathVariable("id") String id) {
+
+    if (id == null || id.length() == 0) {
+      throw new RuntimeException("exception.get.id.must.not.empty"); // FIXME: RestException
+    }
+
+    Account account = accountService.selectById(id);
+
+    if (account == null) {
+      throw new RuntimeException("exception.get.domain.not.exist"); // FIXME: RestException
+    }
+    
+    AccountLoadResponseData data = AccountLoadResponseData.of(account);
+
+    return new DefaultApiResponse<AccountLoadResponseData>(data);
+  }
+
+  /**
+   * 
+   * curl -i -s -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' 'http://localhost:8081/api/v1/admin/accounts' \
+   * -d '{"accountname":"test001","password":"test001","enabled":true,"accountNonExpired":true,"accountNonLocked":true,"credentialsNonExpired":true,"name":"测试001","status":"1"}'
+   * 
+   * response success:
+   * 
+   * <pre>
+   * {
+   *   "success":"info.create.success"
+   * }
+   * </pre>
+   * 
+   * response error 401:
+   * 
+   * <pre>
+   * {
+   *   "timestamp":"2018-08-03T08:48:25.777+0000",
+   *   "status":401,
+   *   "error":"Http Status 401",
+   *   "message":"Unauthorized",
+   *   "path":"/api/v1/admin/accounts"
+   * }
+   * </pre>
+   * 
+   * response error: // FIXME: save error
+   * 
+   * <pre>
+   * {
+   *   "timestamp":"2018-08-03T07:45:43.436+0000",
+   *   "status":500,
+   *   "error":"Internal Server Error",
+   *   "exception":"org.springframework.dao.DataIntegrityViolationException",
+   *   "message":"could not execute statement; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement",
+   *   "path":"/api/v1/admin/accounts"
+   * }
+   * </pre>
+   * 
+   * @param account
+   * @return
+   */
+  @PostMapping(consumes = MimeTypeUtils.APPLICATION_JSON_VALUE, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
+  @ResponseStatus(value = HttpStatus.OK)
+  @ResponseBody
+  public DefaultApiResponse<AccountCreateResponseData> create(
+      @RequestBody AccountCreateRequest createRequest) {
+    
+    // FIXME: 验证数据有效性
+    
+    Account account = createRequest.getEntity();
+    
+    if (account.getPassword() !=null && account.getPassword().length() > 0 && !account.getPassword().startsWith("{")) {
+      //account.setPassword(passwordEncoder.encode(account.getPassword()));
+    }
+
+    Account ret = accountService.insert(account);
+    
+    AccountCreateResponseData data = AccountCreateResponseData.build(ret);
+
+    return new DefaultApiResponse<AccountCreateResponseData>(data);
+  }
+
+  /**
+   * 
+   * curl -i -s -X PUT -H 'Content-Type:application/json' -H 'Accept:application/json' 'http://localhost:8081/api/v1/admin/accounts' \
+   * -d '{"id":"1","status":"0"}'
+   * 
+   * response success:
+   * 
+   * <pre>
+   * {
+   *   "success":"info.update.success"
+   * }
+   * </pre>
+   * 
+   * response error 401:
+   * 
+   * <pre>
+   * {
+   *   "timestamp":"2018-08-03T08:48:25.777+0000",
+   *   "status":401,
+   *   "error":"Http Status 401",
+   *   "message":"Unauthorized",
+   *   "path":"/api/v1/admin/accounts"
+   * }
+   * </pre>
+   * 
+   * curl -i -s -X PUT -H 'Content-Type:application/json' -H 'Accept:application/json' 'http://localhost:8081/api/v1/admin/accounts' \
+   * -d '{"status":"0"}'
+   * 
+   * response error:
+   * 
+   * <pre>
+   * {
+   *   "timestamp":"2018-08-03T07:50:52.327+0000",
+   *   "status":500,
+   *   "error":"Internal Server Error",
+   *   "exception":"java.lang.RuntimeException",
+   *   "message":"exception.update.id.must.not.empty",
+   *   "path":"/api/v1/admin/accounts"
+   * }
+   * </pre>
+   * 
+   * curl -i -s -X PUT -H 'Content-Type:application/json' -H 'Accept:application/json' 'http://localhost:8081/api/v1/admin/accounts' \
+   * -d '{"id":"1","status":"0"}'
+   * 
+   * response error:
+   * 
+   * <pre>
+   * {
+   *   "timestamp":"2018-08-03T07:48:24.774+0000",
+   *   "status":500,
+   *   "error":"Internal Server Error",
+   *   "exception":"java.lang.RuntimeException",
+   *   "message":"exception.update.domain.not.exist",
+   *   "path":"/api/v1/admin/accounts"
+   * }
+   * </pre>
+   * 
+   * @param account
+   * @return
+   */
+  @PutMapping(path = "/{id}", consumes = MimeTypeUtils.APPLICATION_JSON_VALUE, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
+  @ResponseStatus(value = HttpStatus.OK)
+  @ResponseBody
+  public DefaultApiResponse<AccountUpdateResponseData> update(
+      @PathVariable("id") String id, 
+      @RequestBody AccountUpdateRequest updateRequest) {
+
+    if (id == null || id.length() == 0) {
+      throw new RuntimeException("exception.update.id.must.not.empty");
+    }
+
+    Account tmp = accountService.selectById(id);
+    if (tmp == null) {
+      throw new RuntimeException("exception.update.domain.not.exist");
+    }
+
+    Account account = updateRequest.getEntity();
+    account.setId(id);
+
+    if (account.getPassword() !=null && account.getPassword().length() > 0 && !account.getPassword().startsWith("{")) {
+      //account.setPassword(passwordEncoder.encode(account.getPassword()));
+    }
+
+    account = EntityUtils.merge(tmp, account);
+
+    Account ret = accountService.update(account);
+
+    AccountUpdateResponseData data = AccountUpdateResponseData.build(ret);
+    
+    return new DefaultApiResponse<AccountUpdateResponseData>(data);
+  }
+  
+
+  /**
+   * 
+   * curl -i -s -X DELETE -H 'Accept:application/json' 'http://localhost:8081/api/v1/admin/accounts/1'
+   * 
+   * response success:
+   * 
+   * <pre>
+   * {
+   *   "success":"info.delete.success"
+   * }
+   * </pre>
+   * 
+   * response error 401:
+   * 
+   * <pre>
+   * {
+   *   "timestamp":"2018-08-03T08:48:25.777+0000",
+   *   "status":401,
+   *   "error":"Http Status 401",
+   *   "message":"Unauthorized",
+   *   "path":"/api/v1/admin/accounts/1"
+   * }
+   * </pre>
+   * 
+   * response error 500:
+   * 
+   * <pre>
+   * {
+   *   "timestamp":"2018-08-03T08:03:16.364+0000",
+   *   "status":500,
+   *   "error":"Internal Server Error",
+   *   "exception":"java.lang.RuntimeException",
+   *   "message":"exception.delete.domain.not.exist",
+   *   "path":"/api/v1/admin/accounts/1"
+   * }
+   * </pre>
+   * 
+   * @param id
+   * @return
+   */
+  @DeleteMapping(path = "/{id}", produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
+  @ResponseStatus(value = HttpStatus.OK)
+  @ResponseBody
+  public DefaultApiResponse<AccountRemoveResponseData> delete(
+      @PathVariable("id") String id) {
+
+    if (id == null || id.length() == 0) {
+      throw new RuntimeException("exception.delete.id.must.not.empty"); // FIXME: RestException
+    }
+
+    Account tmp = accountService.selectById(id);
+    if (tmp == null) {
+      throw new RuntimeException("exception.delete.domain.not.exist"); // FIXME: RestException
+    }
+
+    accountService.deleteById(id);
+
+    AccountRemoveResponseData data = AccountRemoveResponseData.build(tmp);
+    return new DefaultApiResponse<AccountRemoveResponseData>(data);
+  }
+
+  /**
+   * 
+   * curl -i -s -X GET -H 'Accept:application/json' 'http://localhost:8081/api/v1/admin/accounts/1/groups'
+   * curl -i -s -X GET -H 'Accept:application/json' 'http://localhost:8081/api/v1/admin/accounts/1/groups?pageIndex=2&pageSize=50'
+   * curl -i -s -X GET -H 'Accept:application/json' 'http://localhost:8081/api/v1/admin/accounts/1/groups?pageIndex=0&pageSize=20&mapBean[groupCode]=groupCode&mapBean[groupName]=groupName'
+   * 
+   * 
+   * 
+   * @param id
+   * @param pagerRequestModel
+   * @return
+   */
+  @RequestMapping(method = RequestMethod.GET, path = "/{id}/groups", produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
+  @ResponseBody
+  public DefaultApiResponse<AccountRelatedGroupsResponseData> accountGroups(
+      @PathVariable("id") String id, 
+      AccountRelatedGroupsRequest request) {
+
+    if (id == null || id.length() == 0) {
+      throw new RuntimeException("exception.get.id.must.not.empty"); // FIXME: RestException
+    }
+
+    Account account = accountService.selectById(id);
+
+    if (account == null) {
+      throw new RuntimeException("exception.get.domain.not.exist"); // FIXME: RestException
+    }
+
+    if (request.getMapBean() == null) {
+      request.setMapBean(new HashMap<String, Object>());
+    }
+    request.getMapBean().put("accountId", account.getId());
+
+    Page<AccountGroup> page = accountService.selectAccountGroups(request.getPageIndex(),
+        request.getPageSize(), request.getMapBean());
+
+    AccountRelatedGroupsResponseData data = AccountRelatedGroupsResponseData.of(request).build(page);
+
+    return new DefaultApiResponse<AccountRelatedGroupsResponseData>(data);
+  }
+
+  /**
+   * 
+   * curl -i -s -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' 'http://localhost:8081/api/v1/admin/accounts/1/groups' \
+   * -d '{"groupAccounts":[{"groupId":"1"},{"groupId":"2"}]}'
+   * 
+   * 
+   * @param id
+   * @param groupAccounts
+   * @return
+   */
+  @RequestMapping(method = RequestMethod.POST, path = "/{id}/groups", consumes = MimeTypeUtils.APPLICATION_JSON_VALUE, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
+  @ResponseBody
+  public DefaultApiResponse<AccountRelateGroupsResponseData> relateGroups(
+      @PathVariable("id") String id, 
+      @RequestBody AccountRelateGroupsRequest accountGroups) {
+
+    if (id == null || id.length() == 0) {
+      throw new RuntimeException("exception.get.id.must.not.empty"); // FIXME: RestException
+    }
+
+    Account tmp = accountService.selectById(id);
+
+    if (tmp == null) {
+      throw new RuntimeException("exception.get.domain.not.exist"); // FIXME: RestException
+    }
+
+    accountService.relateAccountGroups(tmp, accountGroups.getAccountGroups());
+
+    AccountRelateGroupsResponseData data = AccountRelateGroupsResponseData.of("info.relate.success");
+
+    return new DefaultApiResponse<AccountRelateGroupsResponseData>(data);
+  }
+
+  /**
+   * 
+   * curl -i -s -X GET -H 'Accept:application/json' 'http://localhost:8081/api/v1/admin/accounts/1/roles'
+   * curl -i -s -X GET -H 'Accept:application/json' 'http://localhost:8081/api/v1/admin/accounts/1/roles?pageIndex=2&pageSize=50'
+   * curl -i -s -X GET -H 'Accept:application/json' 'http://localhost:8081/api/v1/admin/accounts/1/roles?pageIndex=0&pageSize=20&mapBean[roleCode]=roleCode&mapBean[roleName]=roleName'
+   * 
+   * 
+   * 
+   * @param id
+   * @param pagerRequestModel
+   * @return
+   */
+  @RequestMapping(method = RequestMethod.GET, path = "/{id}/roles", produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
+  @ResponseBody
+  public DefaultApiResponse<AccountRelatedRolesResponseData> accountRoles(
+      @PathVariable("id") String id, 
+      AccountRelatedRolesRequest request) {
+
+    if (id == null || id.length() == 0) {
+      throw new RuntimeException("exception.get.id.must.not.empty"); // FIXME: RestException
+    }
+
+    Account account = accountService.selectById(id);
+
+    if (account == null) {
+      throw new RuntimeException("exception.get.domain.not.exist"); // FIXME: RestException
+    }
+
+    if (request.getMapBean() == null) {
+      request.setMapBean(new HashMap<String, Object>());
+    }
+    request.getMapBean().put("accountId", account.getId());
+
+    Page<AccountRole> page = accountService.selectAccountRoles(request.getPageIndex(),
+        request.getPageSize(), request.getMapBean());
+
+    AccountRelatedRolesResponseData data = AccountRelatedRolesResponseData.of(request).build(page);
+
+    return new DefaultApiResponse<AccountRelatedRolesResponseData>(data);
+  }
+
+  /**
+   * 
+   * curl -i -s -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' 'http://localhost:8081/api/v1/admin/accounts/1/roles' \
+   * -d '{"accountRoles":[{"roleId":"1"},{"roleId":"2"}]}'
+   * 
+   * 
+   * @param id
+   * @param accountRoles
+   * @return
+   */
+  @RequestMapping(method = RequestMethod.POST, path = "/{id}/roles", consumes = MimeTypeUtils.APPLICATION_JSON_VALUE, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
+  @ResponseBody
+  public DefaultApiResponse<AccountRelateRolesResponseData> relateRoles(
+      @PathVariable("id") String id, 
+      @RequestBody AccountRelateRolesRequest accountRoles) {
+
+    if (id == null || id.length() == 0) {
+      throw new RuntimeException("exception.get.id.must.not.empty"); // FIXME: RestException
+    }
+
+    Account account = accountService.selectById(id);
+
+    if (account == null) {
+      throw new RuntimeException("exception.get.domain.not.exist"); // FIXME: RestException
+    }
+
+    accountService.relateAccountRoles(account, accountRoles.getAccountRoles());
+
+    AccountRelateRolesResponseData data = AccountRelateRolesResponseData.of("info.relate.success");
+
+    return new DefaultApiResponse<AccountRelateRolesResponseData>(data);
+  }
 
 }
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/v1/admin/AdminConfigController.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/v1/admin/AdminConfigController.java
index b67493a..10a5c64 100644
--- a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/v1/admin/AdminConfigController.java
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/v1/admin/AdminConfigController.java
@@ -131,13 +131,11 @@
       @PathVariable("id") String id,
       @RequestBody ConfigUpdateRequest configUpdateRequest) {
 
-    Config entity = configUpdateRequest.getEntity();
-
-    if (entity.getId() == null || entity.getId().length() == 0) {
+    if (id == null || id.length() == 0) {
       throw new ConfigException().newInstance("exception.update.id.must.not.empty");
     }
 
-    Config tmp = configService.selectById(entity.getId());
+    Config tmp = configService.selectById(id);
     if (tmp == null) {
       throw new ConfigException().newInstance("exception.update.domain.not.exist");
     }
@@ -146,6 +144,9 @@
       throw new ConfigException().newInstance("exception.editable.can.not.update");
     }
 
+    Config entity = configUpdateRequest.getEntity();
+    entity.setId(id);
+
     entity = EntityUtils.merge(tmp, entity);
     
 //    if (tmp.getEditable().booleanValue() != entity.getEditable().booleanValue()) {
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/v1/admin/AdminRoleController.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/v1/admin/AdminRoleController.java
index 4a7a517..34fb317 100644
--- a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/v1/admin/AdminRoleController.java
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/v1/admin/AdminRoleController.java
@@ -1,5 +1,270 @@
 package com.supwisdom.institute.backend.system.api.v1.admin;
 
+import java.util.HashMap;
+
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.http.HttpStatus;
+import org.springframework.util.MimeTypeUtils;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.supwisdom.institute.backend.common.framework.entity.EntityUtils;
+import com.supwisdom.institute.backend.common.framework.vo.response.DefaultApiResponse;
+import com.supwisdom.institute.backend.system.api.vo.request.RoleCreateRequest;
+import com.supwisdom.institute.backend.system.api.vo.request.RoleRelateAccountsRequest;
+import com.supwisdom.institute.backend.system.api.vo.request.RoleRelateGroupsRequest;
+import com.supwisdom.institute.backend.system.api.vo.request.RoleRelatedAccountsRequest;
+import com.supwisdom.institute.backend.system.api.vo.request.RoleRelatedGroupsRequest;
+import com.supwisdom.institute.backend.system.api.vo.request.RoleUpdateRequest;
+import com.supwisdom.institute.backend.system.api.vo.request.RoleQueryRequest;
+import com.supwisdom.institute.backend.system.api.vo.response.RoleCreateResponseData;
+import com.supwisdom.institute.backend.system.api.vo.response.RoleLoadResponseData;
+import com.supwisdom.institute.backend.system.api.vo.response.RoleRelateAccountsResponseData;
+import com.supwisdom.institute.backend.system.api.vo.response.RoleRelateGroupsResponseData;
+import com.supwisdom.institute.backend.system.api.vo.response.RoleRelatedAccountsResponseData;
+import com.supwisdom.institute.backend.system.api.vo.response.RoleRelatedGroupsResponseData;
+import com.supwisdom.institute.backend.system.api.vo.response.RoleRemoveResponseData;
+import com.supwisdom.institute.backend.system.api.vo.response.RoleUpdateResponseData;
+import com.supwisdom.institute.backend.system.api.vo.response.RoleQueryResponseData;
+import com.supwisdom.institute.backend.system.domain.entity.AccountRole;
+import com.supwisdom.institute.backend.system.domain.entity.GroupRole;
+import com.supwisdom.institute.backend.system.domain.entity.Role;
+import com.supwisdom.institute.backend.system.domain.service.RoleService;
+
+@Api(value = "SystemAdminRole", tags = { "SystemAdminRole" }, description = "角色的操作接口")
+@Slf4j
+@RestController
+@RequestMapping("/v1/admin/roles")
 public class AdminRoleController {
 
+  @Autowired
+  private RoleService roleService;
+
+  @GetMapping(produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
+  @ResponseStatus(value = HttpStatus.OK)
+  @ResponseBody
+  public DefaultApiResponse<RoleQueryResponseData> query(RoleQueryRequest queryRequest) {
+
+    Page<Role> page = roleService.selectPageList(
+        queryRequest.isLoadAll(), 
+        queryRequest.getPageIndex(), 
+        queryRequest.getPageSize(),
+        queryRequest.getMapBean(),
+        queryRequest.getOrderBy());
+
+    RoleQueryResponseData data = RoleQueryResponseData.of(queryRequest).build(page);
+
+    return new DefaultApiResponse<RoleQueryResponseData>(data);
+  }
+  
+  @GetMapping(path = "/{id}", produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
+  @ResponseStatus(value = HttpStatus.OK)
+  @ResponseBody
+  public DefaultApiResponse<RoleLoadResponseData> load(@PathVariable("id") String id) {
+
+    if (id == null || id.length() == 0) {
+      throw new RuntimeException("exception.get.id.must.not.empty"); // FIXME: RestException
+    }
+
+    Role role = roleService.selectById(id);
+
+    if (role == null) {
+      throw new RuntimeException("exception.get.domain.not.exist"); // FIXME: RestException
+    }
+    
+    RoleLoadResponseData data = RoleLoadResponseData.of(role);
+
+    return new DefaultApiResponse<RoleLoadResponseData>(data);
+  }
+
+  @PostMapping(consumes = MimeTypeUtils.APPLICATION_JSON_VALUE, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
+  @ResponseStatus(value = HttpStatus.OK)
+  @ResponseBody
+  public DefaultApiResponse<RoleCreateResponseData> create(
+      @RequestBody RoleCreateRequest createRequest) {
+    
+    // FIXME: 验证数据有效性
+    
+    Role role = createRequest.getEntity();
+    
+    Role ret = roleService.insert(role);
+    
+    RoleCreateResponseData data = RoleCreateResponseData.build(ret);
+
+    return new DefaultApiResponse<RoleCreateResponseData>(data);
+  }
+  
+  @PutMapping(path = "/{id}", consumes = MimeTypeUtils.APPLICATION_JSON_VALUE, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
+  @ResponseStatus(value = HttpStatus.OK)
+  @ResponseBody
+  public DefaultApiResponse<RoleUpdateResponseData> update(
+      @PathVariable("id") String id, 
+      @RequestBody RoleUpdateRequest updateRequest) {
+
+    if (id == null || id.length() == 0) {
+      throw new RuntimeException("exception.update.id.must.not.empty");
+    }
+
+    Role tmp = roleService.selectById(id);
+    if (tmp == null) {
+      throw new RuntimeException("exception.update.domain.not.exist");
+    }
+
+    Role role = updateRequest.getEntity();
+    role.setId(id);
+
+    role = EntityUtils.merge(tmp, role);
+
+    Role ret = roleService.update(role);
+
+    RoleUpdateResponseData data = RoleUpdateResponseData.build(ret);
+    
+    return new DefaultApiResponse<RoleUpdateResponseData>(data);
+  }
+
+  @DeleteMapping(path = "/{id}", produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
+  @ResponseStatus(value = HttpStatus.OK)
+  @ResponseBody
+  public DefaultApiResponse<RoleRemoveResponseData> delete(
+      @PathVariable("id") String id) {
+
+    if (id == null || id.length() == 0) {
+      throw new RuntimeException("exception.delete.id.must.not.empty"); // FIXME: RestException
+    }
+
+    Role tmp = roleService.selectById(id);
+    if (tmp == null) {
+      throw new RuntimeException("exception.delete.domain.not.exist"); // FIXME: RestException
+    }
+
+    roleService.deleteById(id);
+
+    RoleRemoveResponseData data = RoleRemoveResponseData.build(tmp);
+    return new DefaultApiResponse<RoleRemoveResponseData>(data);
+  }
+
+
+  @RequestMapping(method = RequestMethod.GET, path = "/{id}/accounts", produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
+  @ResponseBody
+  public DefaultApiResponse<RoleRelatedAccountsResponseData> roleAccounts(
+      @PathVariable("id") String id, 
+      RoleRelatedAccountsRequest request) {
+
+    if (id == null || id.length() == 0) {
+      throw new RuntimeException("exception.get.id.must.not.empty"); // FIXME: RestException
+    }
+
+    Role role = roleService.selectById(id);
+
+    if (role == null) {
+      throw new RuntimeException("exception.get.domain.not.exist"); // FIXME: RestException
+    }
+
+    if (request.getMapBean() == null) {
+      request.setMapBean(new HashMap<String, Object>());
+    }
+    request.getMapBean().put("roleId", role.getId());
+
+    Page<AccountRole> page = roleService.selectRoleAccounts(
+        request.getPageIndex(),
+        request.getPageSize(), 
+        request.getMapBean());
+
+    RoleRelatedAccountsResponseData data = RoleRelatedAccountsResponseData.of(request).build(page);
+
+    return new DefaultApiResponse<RoleRelatedAccountsResponseData>(data);
+  }
+
+  @RequestMapping(method = RequestMethod.POST, path = "/{id}/accounts", consumes = MimeTypeUtils.APPLICATION_JSON_VALUE, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
+  @ResponseBody
+  public DefaultApiResponse<RoleRelateAccountsResponseData> relateAccounts(
+      @PathVariable("id") String id, 
+      @RequestBody RoleRelateAccountsRequest roleAccounts) {
+
+    if (id == null || id.length() == 0) {
+      throw new RuntimeException("exception.get.id.must.not.empty"); // FIXME: RestException
+    }
+
+    Role role = roleService.selectById(id);
+
+    if (role == null) {
+      throw new RuntimeException("exception.get.domain.not.exist"); // FIXME: RestException
+    }
+
+    roleService.relateRoleAccounts(role, roleAccounts.getRoleAccounts());
+
+    RoleRelateAccountsResponseData data = RoleRelateAccountsResponseData.of("info.relate.success");
+
+    return new DefaultApiResponse<RoleRelateAccountsResponseData>(data);
+  }
+
+
+  @RequestMapping(method = RequestMethod.GET, path = "/{id}/groups", produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
+  @ResponseBody
+  public DefaultApiResponse<RoleRelatedGroupsResponseData> roleGroups(
+      @PathVariable("id") String id, 
+      RoleRelatedGroupsRequest request) {
+
+    if (id == null || id.length() == 0) {
+      throw new RuntimeException("exception.get.id.must.not.empty"); // FIXME: RestException
+    }
+
+    Role role = roleService.selectById(id);
+
+    if (role == null) {
+      throw new RuntimeException("exception.get.domain.not.exist"); // FIXME: RestException
+    }
+
+    if (request.getMapBean() == null) {
+      request.setMapBean(new HashMap<String, Object>());
+    }
+    request.getMapBean().put("roleId", role.getId());
+
+    Page<GroupRole> page = roleService.selectRoleGroups(
+        request.getPageIndex(),
+        request.getPageSize(), 
+        request.getMapBean());
+
+    RoleRelatedGroupsResponseData data = RoleRelatedGroupsResponseData.of(request).build(page);
+
+    return new DefaultApiResponse<RoleRelatedGroupsResponseData>(data);
+  }
+
+  @RequestMapping(method = RequestMethod.POST, path = "/{id}/groups", consumes = MimeTypeUtils.APPLICATION_JSON_VALUE, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
+  @ResponseBody
+  public DefaultApiResponse<RoleRelateGroupsResponseData> relateGroups(
+      @PathVariable("id") String id, 
+      @RequestBody RoleRelateGroupsRequest accountGroups) {
+
+    if (id == null || id.length() == 0) {
+      throw new RuntimeException("exception.get.id.must.not.empty"); // FIXME: RestException
+    }
+
+    Role role = roleService.selectById(id);
+
+    if (role == null) {
+      throw new RuntimeException("exception.get.domain.not.exist"); // FIXME: RestException
+    }
+
+    roleService.relateRoleGroups(role, accountGroups.getRoleGroups());
+
+    RoleRelateGroupsResponseData data = RoleRelateGroupsResponseData.of("info.relate.success");
+
+    return new DefaultApiResponse<RoleRelateGroupsResponseData>(data);
+  }
+
+  
 }
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/AccountCreateRequest.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/AccountCreateRequest.java
new file mode 100644
index 0000000..abdd2c1
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/AccountCreateRequest.java
@@ -0,0 +1,21 @@
+package com.supwisdom.institute.backend.system.api.vo.request;
+
+import com.supwisdom.institute.backend.common.framework.entity.EntityUtils;
+import com.supwisdom.institute.backend.common.framework.vo.request.IApiCreateRequest;
+import com.supwisdom.institute.backend.system.domain.entity.Account;
+
+/**
+ * @author loie
+ */
+public class AccountCreateRequest extends Account implements IApiCreateRequest {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 3708476811446308442L;
+
+  public Account getEntity() {
+    return EntityUtils.copy(this, new Account());
+  }
+  
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/AccountQueryRequest.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/AccountQueryRequest.java
new file mode 100644
index 0000000..21e0d5f
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/AccountQueryRequest.java
@@ -0,0 +1,40 @@
+package com.supwisdom.institute.backend.system.api.vo.request;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Map;
+
+import com.supwisdom.institute.backend.common.framework.vo.request.IApiQueryRequest;
+
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @author loie
+ */
+public class AccountQueryRequest implements IApiQueryRequest {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -8594346811904818135L;
+
+  @Getter
+  @Setter
+  private boolean loadAll = false;
+  @Getter
+  @Setter
+  private int pageIndex = 0;
+  @Getter
+  @Setter
+  private int pageSize = 20;
+  @Getter
+  @Setter
+  @ApiModelProperty(hidden = true)
+  private Map<String, Object> mapBean;
+  @Getter
+  @Setter
+  @ApiModelProperty(hidden = true)
+  private Map<String, String> orderBy;
+
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/AccountRelateGroupsRequest.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/AccountRelateGroupsRequest.java
new file mode 100644
index 0000000..bc0e913
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/AccountRelateGroupsRequest.java
@@ -0,0 +1,22 @@
+package com.supwisdom.institute.backend.system.api.vo.request;
+
+import java.util.List;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import com.supwisdom.institute.backend.common.framework.vo.request.IApiRequest;
+import com.supwisdom.institute.backend.system.domain.entity.AccountGroup;
+
+public class AccountRelateGroupsRequest implements IApiRequest {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 5685421340396797488L;
+
+  @Getter
+  @Setter
+  private List<AccountGroup> accountGroups;
+
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/AccountRelateRolesRequest.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/AccountRelateRolesRequest.java
new file mode 100644
index 0000000..7054a7f
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/AccountRelateRolesRequest.java
@@ -0,0 +1,22 @@
+package com.supwisdom.institute.backend.system.api.vo.request;
+
+import java.util.List;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import com.supwisdom.institute.backend.common.framework.vo.request.IApiRequest;
+import com.supwisdom.institute.backend.system.domain.entity.AccountRole;
+
+public class AccountRelateRolesRequest implements IApiRequest {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 6612833201128786481L;
+  
+  @Getter
+  @Setter
+  private List<AccountRole> accountRoles;
+
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/AccountRelatedGroupsRequest.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/AccountRelatedGroupsRequest.java
new file mode 100644
index 0000000..a6e17a8
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/AccountRelatedGroupsRequest.java
@@ -0,0 +1,40 @@
+package com.supwisdom.institute.backend.system.api.vo.request;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Map;
+
+import com.supwisdom.institute.backend.common.framework.vo.request.IApiQueryRequest;
+
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @author loie
+ */
+public class AccountRelatedGroupsRequest implements IApiQueryRequest {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -1998794079137356318L;
+  
+  @Getter
+  @Setter
+  private boolean loadAll = false;
+  @Getter
+  @Setter
+  private int pageIndex = 0;
+  @Getter
+  @Setter
+  private int pageSize = 20;
+  @Getter
+  @Setter
+  @ApiModelProperty(hidden = true)
+  private Map<String, Object> mapBean;
+  @Getter
+  @Setter
+  @ApiModelProperty(hidden = true)
+  private Map<String, String> orderBy;
+
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/AccountRelatedRolesRequest.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/AccountRelatedRolesRequest.java
new file mode 100644
index 0000000..608c5ca
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/AccountRelatedRolesRequest.java
@@ -0,0 +1,40 @@
+package com.supwisdom.institute.backend.system.api.vo.request;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Map;
+
+import com.supwisdom.institute.backend.common.framework.vo.request.IApiQueryRequest;
+
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @author loie
+ */
+public class AccountRelatedRolesRequest implements IApiQueryRequest {
+  
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -2118300523470868823L;
+
+  @Getter
+  @Setter
+  private boolean loadAll = false;
+  @Getter
+  @Setter
+  private int pageIndex = 0;
+  @Getter
+  @Setter
+  private int pageSize = 20;
+  @Getter
+  @Setter
+  @ApiModelProperty(hidden = true)
+  private Map<String, Object> mapBean;
+  @Getter
+  @Setter
+  @ApiModelProperty(hidden = true)
+  private Map<String, String> orderBy;
+
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/AccountUpdateRequest.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/AccountUpdateRequest.java
new file mode 100644
index 0000000..64d4e1b
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/AccountUpdateRequest.java
@@ -0,0 +1,28 @@
+package com.supwisdom.institute.backend.system.api.vo.request;
+
+import com.supwisdom.institute.backend.common.framework.entity.EntityUtils;
+import com.supwisdom.institute.backend.common.framework.vo.request.IApiUpdateRequest;
+import com.supwisdom.institute.backend.system.domain.entity.Account;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author loie
+ */
+public class AccountUpdateRequest extends Account implements IApiUpdateRequest {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -7297542338912221083L;
+
+  @Getter
+  @Setter
+  private String id;
+
+  public Account getEntity() {
+    return EntityUtils.copy(this, new Account());
+  }
+
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/RoleCreateRequest.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/RoleCreateRequest.java
new file mode 100644
index 0000000..f8dfc33
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/RoleCreateRequest.java
@@ -0,0 +1,21 @@
+package com.supwisdom.institute.backend.system.api.vo.request;
+
+import com.supwisdom.institute.backend.common.framework.entity.EntityUtils;
+import com.supwisdom.institute.backend.common.framework.vo.request.IApiCreateRequest;
+import com.supwisdom.institute.backend.system.domain.entity.Role;
+
+/**
+ * @author loie
+ */
+public class RoleCreateRequest extends Role implements IApiCreateRequest {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -5891171833738647843L;
+
+  public Role getEntity() {
+    return EntityUtils.copy(this, new Role());
+  }
+  
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/RoleQueryRequest.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/RoleQueryRequest.java
new file mode 100644
index 0000000..76a3f9e
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/RoleQueryRequest.java
@@ -0,0 +1,40 @@
+package com.supwisdom.institute.backend.system.api.vo.request;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Map;
+
+import com.supwisdom.institute.backend.common.framework.vo.request.IApiQueryRequest;
+
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @author loie
+ */
+public class RoleQueryRequest implements IApiQueryRequest {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -8717113985995182773L;
+  
+  @Getter
+  @Setter
+  private boolean loadAll = false;
+  @Getter
+  @Setter
+  private int pageIndex = 0;
+  @Getter
+  @Setter
+  private int pageSize = 20;
+  @Getter
+  @Setter
+  @ApiModelProperty(hidden = true)
+  private Map<String, Object> mapBean;
+  @Getter
+  @Setter
+  @ApiModelProperty(hidden = true)
+  private Map<String, String> orderBy;
+
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/RoleRelateAccountsRequest.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/RoleRelateAccountsRequest.java
new file mode 100644
index 0000000..69a0b4d
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/RoleRelateAccountsRequest.java
@@ -0,0 +1,22 @@
+package com.supwisdom.institute.backend.system.api.vo.request;
+
+import java.util.List;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import com.supwisdom.institute.backend.common.framework.vo.request.IApiRequest;
+import com.supwisdom.institute.backend.system.domain.entity.AccountRole;
+
+public class RoleRelateAccountsRequest implements IApiRequest {
+  
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -7935779803020137819L;
+
+  @Getter
+  @Setter
+  private List<AccountRole> roleAccounts;
+
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/RoleRelateGroupsRequest.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/RoleRelateGroupsRequest.java
new file mode 100644
index 0000000..b31c4d2
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/RoleRelateGroupsRequest.java
@@ -0,0 +1,22 @@
+package com.supwisdom.institute.backend.system.api.vo.request;
+
+import java.util.List;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import com.supwisdom.institute.backend.common.framework.vo.request.IApiRequest;
+import com.supwisdom.institute.backend.system.domain.entity.GroupRole;
+
+public class RoleRelateGroupsRequest implements IApiRequest {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 9206282464451171269L;
+  
+  @Getter
+  @Setter
+  private List<GroupRole> roleGroups;
+
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/RoleRelatedAccountsRequest.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/RoleRelatedAccountsRequest.java
new file mode 100644
index 0000000..0480258
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/RoleRelatedAccountsRequest.java
@@ -0,0 +1,40 @@
+package com.supwisdom.institute.backend.system.api.vo.request;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Map;
+
+import com.supwisdom.institute.backend.common.framework.vo.request.IApiQueryRequest;
+
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @author loie
+ */
+public class RoleRelatedAccountsRequest implements IApiQueryRequest {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -1798385113493396290L;
+
+  @Getter
+  @Setter
+  private boolean loadAll = false;
+  @Getter
+  @Setter
+  private int pageIndex = 0;
+  @Getter
+  @Setter
+  private int pageSize = 20;
+  @Getter
+  @Setter
+  @ApiModelProperty(hidden = true)
+  private Map<String, Object> mapBean;
+  @Getter
+  @Setter
+  @ApiModelProperty(hidden = true)
+  private Map<String, String> orderBy;
+
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/RoleRelatedGroupsRequest.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/RoleRelatedGroupsRequest.java
new file mode 100644
index 0000000..52126ab
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/RoleRelatedGroupsRequest.java
@@ -0,0 +1,40 @@
+package com.supwisdom.institute.backend.system.api.vo.request;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Map;
+
+import com.supwisdom.institute.backend.common.framework.vo.request.IApiQueryRequest;
+
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @author loie
+ */
+public class RoleRelatedGroupsRequest implements IApiQueryRequest {
+  
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 7253046382409370442L;
+
+  @Getter
+  @Setter
+  private boolean loadAll = false;
+  @Getter
+  @Setter
+  private int pageIndex = 0;
+  @Getter
+  @Setter
+  private int pageSize = 20;
+  @Getter
+  @Setter
+  @ApiModelProperty(hidden = true)
+  private Map<String, Object> mapBean;
+  @Getter
+  @Setter
+  @ApiModelProperty(hidden = true)
+  private Map<String, String> orderBy;
+
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/RoleUpdateRequest.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/RoleUpdateRequest.java
new file mode 100644
index 0000000..b5adc41
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/request/RoleUpdateRequest.java
@@ -0,0 +1,28 @@
+package com.supwisdom.institute.backend.system.api.vo.request;
+
+import com.supwisdom.institute.backend.common.framework.entity.EntityUtils;
+import com.supwisdom.institute.backend.common.framework.vo.request.IApiUpdateRequest;
+import com.supwisdom.institute.backend.system.domain.entity.Role;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author loie
+ */
+public class RoleUpdateRequest extends Role implements IApiUpdateRequest {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -7272388577177587142L;
+
+  @Getter
+  @Setter
+  private String id;
+
+  public Role getEntity() {
+    return EntityUtils.copy(this, new Role());
+  }
+
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountCreateResponseData.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountCreateResponseData.java
new file mode 100644
index 0000000..49b5383
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountCreateResponseData.java
@@ -0,0 +1,33 @@
+package com.supwisdom.institute.backend.system.api.vo.response;
+
+import com.supwisdom.institute.backend.common.framework.entity.EntityUtils;
+import com.supwisdom.institute.backend.common.framework.vo.response.data.IApiCreateResponseData;
+import com.supwisdom.institute.backend.system.domain.entity.Account;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author loie
+ */
+public class AccountCreateResponseData extends Account implements IApiCreateResponseData {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -8882701323050726169L;
+
+  @Getter
+  @Setter
+  private String id;
+
+  private AccountCreateResponseData() {
+
+  }
+
+  public static AccountCreateResponseData build(Account entity) {
+    AccountCreateResponseData data = new AccountCreateResponseData();
+
+    return EntityUtils.copy(entity, data);
+  }
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountLoadResponseData.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountLoadResponseData.java
new file mode 100644
index 0000000..d8f2c43
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountLoadResponseData.java
@@ -0,0 +1,33 @@
+package com.supwisdom.institute.backend.system.api.vo.response;
+
+import com.supwisdom.institute.backend.common.framework.entity.EntityUtils;
+import com.supwisdom.institute.backend.common.framework.vo.response.data.IApiLoadResponseData;
+import com.supwisdom.institute.backend.system.domain.entity.Account;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author loie
+ */
+public class AccountLoadResponseData extends Account implements IApiLoadResponseData {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -8236721435440256832L;
+
+  @Getter
+  @Setter
+  private String id;
+
+  private AccountLoadResponseData() {
+
+  }
+
+  public static AccountLoadResponseData of(Account entity) {
+    AccountLoadResponseData data = new AccountLoadResponseData();
+    return EntityUtils.copy(entity, data);
+  }
+
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountQueryResponseData.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountQueryResponseData.java
new file mode 100644
index 0000000..723dc26
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountQueryResponseData.java
@@ -0,0 +1,80 @@
+package com.supwisdom.institute.backend.system.api.vo.response;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.data.domain.Page;
+
+import com.supwisdom.institute.backend.common.framework.vo.request.IApiQueryRequest;
+import com.supwisdom.institute.backend.common.framework.vo.response.data.IApiQueryResponseData;
+import com.supwisdom.institute.backend.system.domain.entity.Account;
+
+/**
+ * @author loie
+ */
+public class AccountQueryResponseData implements IApiQueryResponseData<Account> {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 3949426339318397970L;
+
+  private AccountQueryResponseData(boolean loadAll, int pageIndex, int pageSize, Map<String, Object> mapBean, Map<String, String> orderBy) {
+    this.loadAll = loadAll;
+    this.pageIndex = pageIndex;
+    this.pageSize = pageSize;
+    this.mapBean = mapBean;
+    this.orderBy = orderBy;
+  }
+
+  public static AccountQueryResponseData of(IApiQueryRequest queryRequest) {
+    AccountQueryResponseData configQueryResponse = new AccountQueryResponseData(
+        queryRequest.isLoadAll(), 
+        queryRequest.getPageIndex(), 
+        queryRequest.getPageSize(), 
+        queryRequest.getMapBean(), 
+        queryRequest.getOrderBy()
+    );
+    
+    return configQueryResponse;
+  }
+  
+  public AccountQueryResponseData build(Page<Account> page) {
+    this.currentItemCount = page.getNumberOfElements();
+    this.pageCount = page.getTotalPages();
+    this.recordCount = page.getTotalElements();
+    this.items = page.getContent();
+
+    return this;
+  }
+
+  @Getter
+  private boolean loadAll;
+  @Getter
+  private int pageIndex;
+  @Getter
+  private int pageSize;
+  @Getter
+  private Map<String, Object> mapBean;
+  @Getter
+  private Map<String, String> orderBy;
+  
+  @Getter
+  @Setter
+  private int pageCount;
+  @Getter
+  @Setter
+  private long recordCount;
+  
+  @Getter
+  @Setter
+  private int currentItemCount;
+  
+  @Getter
+  @Setter
+  private List<Account> items;
+  
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountRelateGroupsResponseData.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountRelateGroupsResponseData.java
new file mode 100644
index 0000000..b1d8b43
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountRelateGroupsResponseData.java
@@ -0,0 +1,29 @@
+package com.supwisdom.institute.backend.system.api.vo.response;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import com.supwisdom.institute.backend.common.framework.vo.response.data.IApiResponseData;
+
+public class AccountRelateGroupsResponseData implements IApiResponseData {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -720047649055920794L;
+  
+  @Getter
+  @Setter
+  private String message;
+
+  public AccountRelateGroupsResponseData(String message) {
+    this.message = message;
+  }
+
+  public static AccountRelateGroupsResponseData of(String message) {
+    AccountRelateGroupsResponseData data = new AccountRelateGroupsResponseData(message);
+    
+    return data;
+  }
+
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountRelateRolesResponseData.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountRelateRolesResponseData.java
new file mode 100644
index 0000000..1d9c932
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountRelateRolesResponseData.java
@@ -0,0 +1,29 @@
+package com.supwisdom.institute.backend.system.api.vo.response;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import com.supwisdom.institute.backend.common.framework.vo.response.data.IApiResponseData;
+
+public class AccountRelateRolesResponseData implements IApiResponseData {
+  
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -5011147266134585651L;
+  
+  @Getter
+  @Setter
+  private String message;
+
+  public AccountRelateRolesResponseData(String message) {
+    this.message = message;
+  }
+
+  public static AccountRelateRolesResponseData of(String message) {
+    AccountRelateRolesResponseData data = new AccountRelateRolesResponseData(message);
+    
+    return data;
+  }
+
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountRelatedGroupsResponseData.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountRelatedGroupsResponseData.java
new file mode 100644
index 0000000..01c9884
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountRelatedGroupsResponseData.java
@@ -0,0 +1,80 @@
+package com.supwisdom.institute.backend.system.api.vo.response;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.data.domain.Page;
+
+import com.supwisdom.institute.backend.common.framework.vo.request.IApiQueryRequest;
+import com.supwisdom.institute.backend.common.framework.vo.response.data.IApiQueryResponseData;
+import com.supwisdom.institute.backend.system.domain.entity.AccountGroup;
+
+/**
+ * @author loie
+ */
+public class AccountRelatedGroupsResponseData implements IApiQueryResponseData<AccountGroup> {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 3949426339318397970L;
+
+  private AccountRelatedGroupsResponseData(boolean loadAll, int pageIndex, int pageSize, Map<String, Object> mapBean, Map<String, String> orderBy) {
+    this.loadAll = loadAll;
+    this.pageIndex = pageIndex;
+    this.pageSize = pageSize;
+    this.mapBean = mapBean;
+    this.orderBy = orderBy;
+  }
+
+  public static AccountRelatedGroupsResponseData of(IApiQueryRequest queryRequest) {
+    AccountRelatedGroupsResponseData configQueryResponse = new AccountRelatedGroupsResponseData(
+        queryRequest.isLoadAll(), 
+        queryRequest.getPageIndex(), 
+        queryRequest.getPageSize(), 
+        queryRequest.getMapBean(), 
+        queryRequest.getOrderBy()
+    );
+    
+    return configQueryResponse;
+  }
+  
+  public AccountRelatedGroupsResponseData build(Page<AccountGroup> page) {
+    this.currentItemCount = page.getNumberOfElements();
+    this.pageCount = page.getTotalPages();
+    this.recordCount = page.getTotalElements();
+    this.items = page.getContent();
+
+    return this;
+  }
+
+  @Getter
+  private boolean loadAll;
+  @Getter
+  private int pageIndex;
+  @Getter
+  private int pageSize;
+  @Getter
+  private Map<String, Object> mapBean;
+  @Getter
+  private Map<String, String> orderBy;
+  
+  @Getter
+  @Setter
+  private int pageCount;
+  @Getter
+  @Setter
+  private long recordCount;
+  
+  @Getter
+  @Setter
+  private int currentItemCount;
+  
+  @Getter
+  @Setter
+  private List<AccountGroup> items;
+  
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountRelatedRolesResponseData.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountRelatedRolesResponseData.java
new file mode 100644
index 0000000..fc6c1c0
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountRelatedRolesResponseData.java
@@ -0,0 +1,80 @@
+package com.supwisdom.institute.backend.system.api.vo.response;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.data.domain.Page;
+
+import com.supwisdom.institute.backend.common.framework.vo.request.IApiQueryRequest;
+import com.supwisdom.institute.backend.common.framework.vo.response.data.IApiQueryResponseData;
+import com.supwisdom.institute.backend.system.domain.entity.AccountRole;
+
+/**
+ * @author loie
+ */
+public class AccountRelatedRolesResponseData implements IApiQueryResponseData<AccountRole> {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 4933467585328478547L;
+
+  private AccountRelatedRolesResponseData(boolean loadAll, int pageIndex, int pageSize, Map<String, Object> mapBean, Map<String, String> orderBy) {
+    this.loadAll = loadAll;
+    this.pageIndex = pageIndex;
+    this.pageSize = pageSize;
+    this.mapBean = mapBean;
+    this.orderBy = orderBy;
+  }
+
+  public static AccountRelatedRolesResponseData of(IApiQueryRequest queryRequest) {
+    AccountRelatedRolesResponseData configQueryResponse = new AccountRelatedRolesResponseData(
+        queryRequest.isLoadAll(), 
+        queryRequest.getPageIndex(), 
+        queryRequest.getPageSize(), 
+        queryRequest.getMapBean(), 
+        queryRequest.getOrderBy()
+    );
+    
+    return configQueryResponse;
+  }
+  
+  public AccountRelatedRolesResponseData build(Page<AccountRole> page) {
+    this.currentItemCount = page.getNumberOfElements();
+    this.pageCount = page.getTotalPages();
+    this.recordCount = page.getTotalElements();
+    this.items = page.getContent();
+
+    return this;
+  }
+
+  @Getter
+  private boolean loadAll;
+  @Getter
+  private int pageIndex;
+  @Getter
+  private int pageSize;
+  @Getter
+  private Map<String, Object> mapBean;
+  @Getter
+  private Map<String, String> orderBy;
+  
+  @Getter
+  @Setter
+  private int pageCount;
+  @Getter
+  @Setter
+  private long recordCount;
+  
+  @Getter
+  @Setter
+  private int currentItemCount;
+  
+  @Getter
+  @Setter
+  private List<AccountRole> items;
+  
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountRemoveResponseData.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountRemoveResponseData.java
new file mode 100644
index 0000000..4d89768
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountRemoveResponseData.java
@@ -0,0 +1,34 @@
+package com.supwisdom.institute.backend.system.api.vo.response;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import com.supwisdom.institute.backend.common.framework.entity.EntityUtils;
+import com.supwisdom.institute.backend.common.framework.vo.response.data.IApiRemoveResponseData;
+import com.supwisdom.institute.backend.system.domain.entity.Account;
+
+/**
+ * @author loie
+ */
+public class AccountRemoveResponseData implements IApiRemoveResponseData {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 8510464738198696332L;
+
+  @Getter
+  @Setter
+  private String id;
+
+  private AccountRemoveResponseData() {
+    
+  }
+  
+  public static AccountRemoveResponseData build(Account entity) {
+    AccountRemoveResponseData data = new AccountRemoveResponseData();
+    
+    return EntityUtils.copy(entity, data);
+  }
+  
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountUpdateResponseData.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountUpdateResponseData.java
new file mode 100644
index 0000000..4b637dc
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/AccountUpdateResponseData.java
@@ -0,0 +1,34 @@
+package com.supwisdom.institute.backend.system.api.vo.response;
+
+import com.supwisdom.institute.backend.common.framework.entity.EntityUtils;
+import com.supwisdom.institute.backend.common.framework.vo.response.data.IApiUpdateResponseData;
+import com.supwisdom.institute.backend.system.domain.entity.Account;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author loie
+ */
+public class AccountUpdateResponseData extends Account implements IApiUpdateResponseData {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -7885193620877829529L;
+
+  @Getter
+  @Setter
+  private String id;
+
+  private AccountUpdateResponseData() {
+
+  }
+
+  public static AccountUpdateResponseData build(Account entity) {
+    AccountUpdateResponseData data = new AccountUpdateResponseData();
+
+    return EntityUtils.copy(entity, data);
+  }
+
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/ConfigRemoveResponseData.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/ConfigRemoveResponseData.java
index d593ed4..26f9a35 100644
--- a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/ConfigRemoveResponseData.java
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/ConfigRemoveResponseData.java
@@ -3,8 +3,6 @@
 import lombok.Getter;
 import lombok.Setter;
 
-import javax.persistence.Id;
-
 import com.supwisdom.institute.backend.common.framework.entity.EntityUtils;
 import com.supwisdom.institute.backend.common.framework.vo.response.data.IApiRemoveResponseData;
 import com.supwisdom.institute.backend.system.domain.entity.Config;
@@ -21,7 +19,6 @@
 
   @Getter
   @Setter
-  @Id
   private String id;
 
   private ConfigRemoveResponseData() {
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleCreateResponseData.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleCreateResponseData.java
new file mode 100644
index 0000000..7d4ee1c
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleCreateResponseData.java
@@ -0,0 +1,33 @@
+package com.supwisdom.institute.backend.system.api.vo.response;
+
+import com.supwisdom.institute.backend.common.framework.entity.EntityUtils;
+import com.supwisdom.institute.backend.common.framework.vo.response.data.IApiCreateResponseData;
+import com.supwisdom.institute.backend.system.domain.entity.Role;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author loie
+ */
+public class RoleCreateResponseData extends Role implements IApiCreateResponseData {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -6548339240060091209L;
+
+  @Getter
+  @Setter
+  private String id;
+
+  private RoleCreateResponseData() {
+
+  }
+
+  public static RoleCreateResponseData build(Role entity) {
+    RoleCreateResponseData data = new RoleCreateResponseData();
+
+    return EntityUtils.copy(entity, data);
+  }
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleLoadResponseData.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleLoadResponseData.java
new file mode 100644
index 0000000..628920a
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleLoadResponseData.java
@@ -0,0 +1,33 @@
+package com.supwisdom.institute.backend.system.api.vo.response;
+
+import com.supwisdom.institute.backend.common.framework.entity.EntityUtils;
+import com.supwisdom.institute.backend.common.framework.vo.response.data.IApiLoadResponseData;
+import com.supwisdom.institute.backend.system.domain.entity.Role;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author loie
+ */
+public class RoleLoadResponseData extends Role implements IApiLoadResponseData {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 57708002489387653L;
+
+  @Getter
+  @Setter
+  private String id;
+
+  private RoleLoadResponseData() {
+
+  }
+
+  public static RoleLoadResponseData of(Role entity) {
+    RoleLoadResponseData data = new RoleLoadResponseData();
+    return EntityUtils.copy(entity, data);
+  }
+
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleQueryResponseData.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleQueryResponseData.java
new file mode 100644
index 0000000..83bab25
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleQueryResponseData.java
@@ -0,0 +1,80 @@
+package com.supwisdom.institute.backend.system.api.vo.response;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.data.domain.Page;
+
+import com.supwisdom.institute.backend.common.framework.vo.request.IApiQueryRequest;
+import com.supwisdom.institute.backend.common.framework.vo.response.data.IApiQueryResponseData;
+import com.supwisdom.institute.backend.system.domain.entity.Role;
+
+/**
+ * @author loie
+ */
+public class RoleQueryResponseData implements IApiQueryResponseData<Role> {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 2542992897241822185L;
+
+  private RoleQueryResponseData(boolean loadAll, int pageIndex, int pageSize, Map<String, Object> mapBean, Map<String, String> orderBy) {
+    this.loadAll = loadAll;
+    this.pageIndex = pageIndex;
+    this.pageSize = pageSize;
+    this.mapBean = mapBean;
+    this.orderBy = orderBy;
+  }
+
+  public static RoleQueryResponseData of(IApiQueryRequest queryRequest) {
+    RoleQueryResponseData configQueryResponse = new RoleQueryResponseData(
+        queryRequest.isLoadAll(), 
+        queryRequest.getPageIndex(), 
+        queryRequest.getPageSize(), 
+        queryRequest.getMapBean(), 
+        queryRequest.getOrderBy()
+    );
+    
+    return configQueryResponse;
+  }
+  
+  public RoleQueryResponseData build(Page<Role> page) {
+    this.currentItemCount = page.getNumberOfElements();
+    this.pageCount = page.getTotalPages();
+    this.recordCount = page.getTotalElements();
+    this.items = page.getContent();
+
+    return this;
+  }
+
+  @Getter
+  private boolean loadAll;
+  @Getter
+  private int pageIndex;
+  @Getter
+  private int pageSize;
+  @Getter
+  private Map<String, Object> mapBean;
+  @Getter
+  private Map<String, String> orderBy;
+  
+  @Getter
+  @Setter
+  private int pageCount;
+  @Getter
+  @Setter
+  private long recordCount;
+  
+  @Getter
+  @Setter
+  private int currentItemCount;
+  
+  @Getter
+  @Setter
+  private List<Role> items;
+  
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleRelateAccountsResponseData.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleRelateAccountsResponseData.java
new file mode 100644
index 0000000..5bb6838
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleRelateAccountsResponseData.java
@@ -0,0 +1,29 @@
+package com.supwisdom.institute.backend.system.api.vo.response;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import com.supwisdom.institute.backend.common.framework.vo.response.data.IApiResponseData;
+
+public class RoleRelateAccountsResponseData implements IApiResponseData {
+  
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -1732402839300368775L;
+
+  @Getter
+  @Setter
+  private String message;
+
+  public RoleRelateAccountsResponseData(String message) {
+    this.message = message;
+  }
+
+  public static RoleRelateAccountsResponseData of(String message) {
+    RoleRelateAccountsResponseData data = new RoleRelateAccountsResponseData(message);
+    
+    return data;
+  }
+
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleRelateGroupsResponseData.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleRelateGroupsResponseData.java
new file mode 100644
index 0000000..3548655
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleRelateGroupsResponseData.java
@@ -0,0 +1,29 @@
+package com.supwisdom.institute.backend.system.api.vo.response;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import com.supwisdom.institute.backend.common.framework.vo.response.data.IApiResponseData;
+
+public class RoleRelateGroupsResponseData implements IApiResponseData {
+  
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -248658847598115689L;
+
+  @Getter
+  @Setter
+  private String message;
+
+  public RoleRelateGroupsResponseData(String message) {
+    this.message = message;
+  }
+
+  public static RoleRelateGroupsResponseData of(String message) {
+    RoleRelateGroupsResponseData data = new RoleRelateGroupsResponseData(message);
+    
+    return data;
+  }
+
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleRelatedAccountsResponseData.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleRelatedAccountsResponseData.java
new file mode 100644
index 0000000..eeb44d2
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleRelatedAccountsResponseData.java
@@ -0,0 +1,80 @@
+package com.supwisdom.institute.backend.system.api.vo.response;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.data.domain.Page;
+
+import com.supwisdom.institute.backend.common.framework.vo.request.IApiQueryRequest;
+import com.supwisdom.institute.backend.common.framework.vo.response.data.IApiQueryResponseData;
+import com.supwisdom.institute.backend.system.domain.entity.AccountRole;
+
+/**
+ * @author loie
+ */
+public class RoleRelatedAccountsResponseData implements IApiQueryResponseData<AccountRole> {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 5272966183728979505L;
+
+  private RoleRelatedAccountsResponseData(boolean loadAll, int pageIndex, int pageSize, Map<String, Object> mapBean, Map<String, String> orderBy) {
+    this.loadAll = loadAll;
+    this.pageIndex = pageIndex;
+    this.pageSize = pageSize;
+    this.mapBean = mapBean;
+    this.orderBy = orderBy;
+  }
+
+  public static RoleRelatedAccountsResponseData of(IApiQueryRequest queryRequest) {
+    RoleRelatedAccountsResponseData configQueryResponse = new RoleRelatedAccountsResponseData(
+        queryRequest.isLoadAll(), 
+        queryRequest.getPageIndex(), 
+        queryRequest.getPageSize(), 
+        queryRequest.getMapBean(), 
+        queryRequest.getOrderBy()
+    );
+    
+    return configQueryResponse;
+  }
+  
+  public RoleRelatedAccountsResponseData build(Page<AccountRole> page) {
+    this.currentItemCount = page.getNumberOfElements();
+    this.pageCount = page.getTotalPages();
+    this.recordCount = page.getTotalElements();
+    this.items = page.getContent();
+
+    return this;
+  }
+
+  @Getter
+  private boolean loadAll;
+  @Getter
+  private int pageIndex;
+  @Getter
+  private int pageSize;
+  @Getter
+  private Map<String, Object> mapBean;
+  @Getter
+  private Map<String, String> orderBy;
+  
+  @Getter
+  @Setter
+  private int pageCount;
+  @Getter
+  @Setter
+  private long recordCount;
+  
+  @Getter
+  @Setter
+  private int currentItemCount;
+  
+  @Getter
+  @Setter
+  private List<AccountRole> items;
+  
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleRelatedGroupsResponseData.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleRelatedGroupsResponseData.java
new file mode 100644
index 0000000..7f4865e
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleRelatedGroupsResponseData.java
@@ -0,0 +1,80 @@
+package com.supwisdom.institute.backend.system.api.vo.response;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.data.domain.Page;
+
+import com.supwisdom.institute.backend.common.framework.vo.request.IApiQueryRequest;
+import com.supwisdom.institute.backend.common.framework.vo.response.data.IApiQueryResponseData;
+import com.supwisdom.institute.backend.system.domain.entity.GroupRole;
+
+/**
+ * @author loie
+ */
+public class RoleRelatedGroupsResponseData implements IApiQueryResponseData<GroupRole> {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -1327331843770679868L;
+
+  private RoleRelatedGroupsResponseData(boolean loadAll, int pageIndex, int pageSize, Map<String, Object> mapBean, Map<String, String> orderBy) {
+    this.loadAll = loadAll;
+    this.pageIndex = pageIndex;
+    this.pageSize = pageSize;
+    this.mapBean = mapBean;
+    this.orderBy = orderBy;
+  }
+
+  public static RoleRelatedGroupsResponseData of(IApiQueryRequest queryRequest) {
+    RoleRelatedGroupsResponseData configQueryResponse = new RoleRelatedGroupsResponseData(
+        queryRequest.isLoadAll(), 
+        queryRequest.getPageIndex(), 
+        queryRequest.getPageSize(), 
+        queryRequest.getMapBean(), 
+        queryRequest.getOrderBy()
+    );
+    
+    return configQueryResponse;
+  }
+  
+  public RoleRelatedGroupsResponseData build(Page<GroupRole> page) {
+    this.currentItemCount = page.getNumberOfElements();
+    this.pageCount = page.getTotalPages();
+    this.recordCount = page.getTotalElements();
+    this.items = page.getContent();
+
+    return this;
+  }
+
+  @Getter
+  private boolean loadAll;
+  @Getter
+  private int pageIndex;
+  @Getter
+  private int pageSize;
+  @Getter
+  private Map<String, Object> mapBean;
+  @Getter
+  private Map<String, String> orderBy;
+  
+  @Getter
+  @Setter
+  private int pageCount;
+  @Getter
+  @Setter
+  private long recordCount;
+  
+  @Getter
+  @Setter
+  private int currentItemCount;
+  
+  @Getter
+  @Setter
+  private List<GroupRole> items;
+  
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleRemoveResponseData.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleRemoveResponseData.java
new file mode 100644
index 0000000..cf7f3ba
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleRemoveResponseData.java
@@ -0,0 +1,34 @@
+package com.supwisdom.institute.backend.system.api.vo.response;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import com.supwisdom.institute.backend.common.framework.entity.EntityUtils;
+import com.supwisdom.institute.backend.common.framework.vo.response.data.IApiRemoveResponseData;
+import com.supwisdom.institute.backend.system.domain.entity.Role;
+
+/**
+ * @author loie
+ */
+public class RoleRemoveResponseData implements IApiRemoveResponseData {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -2556956704425975795L;
+
+  @Getter
+  @Setter
+  private String id;
+
+  private RoleRemoveResponseData() {
+    
+  }
+  
+  public static RoleRemoveResponseData build(Role entity) {
+    RoleRemoveResponseData data = new RoleRemoveResponseData();
+    
+    return EntityUtils.copy(entity, data);
+  }
+  
+}
diff --git a/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleUpdateResponseData.java b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleUpdateResponseData.java
new file mode 100644
index 0000000..ea2cd26
--- /dev/null
+++ b/system/api/src/main/java/com/supwisdom/institute/backend/system/api/vo/response/RoleUpdateResponseData.java
@@ -0,0 +1,34 @@
+package com.supwisdom.institute.backend.system.api.vo.response;
+
+import com.supwisdom.institute.backend.common.framework.entity.EntityUtils;
+import com.supwisdom.institute.backend.common.framework.vo.response.data.IApiUpdateResponseData;
+import com.supwisdom.institute.backend.system.domain.entity.Role;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author loie
+ */
+public class RoleUpdateResponseData extends Role implements IApiUpdateResponseData {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -7822437040348157286L;
+
+  @Getter
+  @Setter
+  private String id;
+
+  private RoleUpdateResponseData() {
+
+  }
+
+  public static RoleUpdateResponseData build(Role entity) {
+    RoleUpdateResponseData data = new RoleUpdateResponseData();
+
+    return EntityUtils.copy(entity, data);
+  }
+
+}
diff --git a/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/entity/Account.java b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/entity/Account.java
new file mode 100644
index 0000000..71e863f
--- /dev/null
+++ b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/entity/Account.java
@@ -0,0 +1,154 @@
+package com.supwisdom.institute.backend.system.domain.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+import com.supwisdom.institute.backend.common.framework.entity.ABaseEntity;
+
+@Entity
+@Table(name = "TB_U_ACCOUNT")
+public class Account extends ABaseEntity {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 7955624268022038897L;
+
+  /**
+   * 用户名
+   */
+  @Column(name = "USERNAME", unique = true)
+  private String username;
+  
+  /**
+   * 密码
+   */
+  @Column(name = "PASSWORD")
+  private String password;
+
+  /**
+   * 是否可用,1 可用,0 不可用,默认:1
+   */
+  @Column(name = "ENABLED")
+  private Boolean enabled;
+  /**
+   * 账号未过期,1 未过期,0 过期,默认:1
+   */
+  @Column(name = "ACCOUNT_NON_EXPIRED")
+  private Boolean accountNonExpired;
+  /**
+   * 账号未锁定,1 未锁定,0 锁定,默认:1
+   */
+  @Column(name = "ACCOUNT_NON_LOCKED")
+  private Boolean accountNonLocked;
+  /**
+   * 密码未过期,1 未过期,0 过期,默认:1
+   */
+  @Column(name = "CREDENTIALS_NON_EXPIRED")
+  private Boolean credentialsNonExpired;
+
+  /**
+   * 姓名
+   */
+  @Column(name = "NAME")
+  private String name;
+  
+  /**
+   * 状态(1 启用,0 停用)
+   */
+  @Column(name = "STATUS")
+  private String status;
+
+  /**
+   * 登录手机
+   */
+  @Column(name = "MOBILE", nullable = true)
+  private String mobile;
+  /**
+   * 登录邮箱
+   */
+  @Column(name = "EMAIL", nullable = true)
+  private String email;
+
+  public String getUsername() {
+    return username;
+  }
+
+  public void setUsername(String username) {
+    this.username = username;
+  }
+
+  public String getPassword() {
+    return password;
+  }
+
+  public void setPassword(String password) {
+    this.password = password;
+  }
+
+  public Boolean getEnabled() {
+    return enabled;
+  }
+
+  public void setEnabled(Boolean enabled) {
+    this.enabled = enabled;
+  }
+
+  public Boolean getAccountNonExpired() {
+    return accountNonExpired;
+  }
+
+  public void setAccountNonExpired(Boolean accountNonExpired) {
+    this.accountNonExpired = accountNonExpired;
+  }
+
+  public Boolean getAccountNonLocked() {
+    return accountNonLocked;
+  }
+
+  public void setAccountNonLocked(Boolean accountNonLocked) {
+    this.accountNonLocked = accountNonLocked;
+  }
+
+  public Boolean getCredentialsNonExpired() {
+    return credentialsNonExpired;
+  }
+
+  public void setCredentialsNonExpired(Boolean credentialsNonExpired) {
+    this.credentialsNonExpired = credentialsNonExpired;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getStatus() {
+    return status;
+  }
+
+  public void setStatus(String status) {
+    this.status = status;
+  }
+
+  public String getMobile() {
+    return mobile;
+  }
+
+  public void setMobile(String mobile) {
+    this.mobile = mobile;
+  }
+
+  public String getEmail() {
+    return email;
+  }
+
+  public void setEmail(String email) {
+    this.email = email;
+  }
+
+}
diff --git a/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/entity/AccountGroup.java b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/entity/AccountGroup.java
new file mode 100644
index 0000000..f7ae973
--- /dev/null
+++ b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/entity/AccountGroup.java
@@ -0,0 +1,46 @@
+package com.supwisdom.institute.backend.system.domain.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+import com.supwisdom.institute.backend.common.framework.entity.ABaseEntity;
+
+@Entity
+@Table(name = "TB_U_ACCOUNT_GROUP")
+public class AccountGroup extends ABaseEntity {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -4239845385965871983L;
+
+  /**
+   * 帐号ID
+   */
+  @Column(name = "ACCOUNT_ID")
+  private String accountId;
+
+  /**
+   * 用户组ID
+   */
+  @Column(name = "GROUP_ID")
+  private String groupId;
+
+  public String getAccountId() {
+    return accountId;
+  }
+
+  public void setAccountId(String accountId) {
+    this.accountId = accountId;
+  }
+
+  public String getGroupId() {
+    return groupId;
+  }
+
+  public void setGroupId(String groupId) {
+    this.groupId = groupId;
+  }
+
+}
diff --git a/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/entity/AccountRole.java b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/entity/AccountRole.java
new file mode 100644
index 0000000..a91b367
--- /dev/null
+++ b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/entity/AccountRole.java
@@ -0,0 +1,46 @@
+package com.supwisdom.institute.backend.system.domain.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+import com.supwisdom.institute.backend.common.framework.entity.ABaseEntity;
+
+@Entity
+@Table(name = "TB_U_ACCOUNT_ROLE")
+public class AccountRole extends ABaseEntity {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -6158470486381850942L;
+
+  /**
+   * 帐号ID
+   */
+  @Column(name = "ACCOUNT_ID")
+  private String accountId;
+
+  /**
+   * 角色ID
+   */
+  @Column(name = "ROLE_ID")
+  private String roleId;
+
+  public String getAccountId() {
+    return accountId;
+  }
+
+  public void setAccountId(String accountId) {
+    this.accountId = accountId;
+  }
+
+  public String getRoleId() {
+    return roleId;
+  }
+
+  public void setRoleId(String roleId) {
+    this.roleId = roleId;
+  }
+
+}
diff --git a/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/entity/Group.java b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/entity/Group.java
new file mode 100644
index 0000000..d1de8a2
--- /dev/null
+++ b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/entity/Group.java
@@ -0,0 +1,74 @@
+package com.supwisdom.institute.backend.system.domain.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+import com.supwisdom.institute.backend.common.framework.entity.ABaseEntity;
+
+@Entity(name = "Group_")
+@Table(name = "TB_U_GROUP")
+public class Group extends ABaseEntity {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 4260326816456622523L;
+
+  /**
+   * 代码
+   */
+  @Column(name = "CODE")
+  private String code;
+
+  /**
+   * 名称
+   */
+  @Column(name = "NAME")
+  private String name;
+
+  /**
+   * 备注
+   */
+  @Column(name = "MEMO")
+  private String memo;
+
+  /**
+   * 状态(1 启用,0 停用)
+   */
+  @Column(name = "STATUS")
+  private String status;
+
+  public String getCode() {
+    return code;
+  }
+
+  public void setCode(String code) {
+    this.code = code;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getMemo() {
+    return memo;
+  }
+
+  public void setMemo(String memo) {
+    this.memo = memo;
+  }
+
+  public String getStatus() {
+    return status;
+  }
+
+  public void setStatus(String status) {
+    this.status = status;
+  }
+
+}
diff --git a/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/entity/GroupRole.java b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/entity/GroupRole.java
new file mode 100644
index 0000000..1addd93
--- /dev/null
+++ b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/entity/GroupRole.java
@@ -0,0 +1,46 @@
+package com.supwisdom.institute.backend.system.domain.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+import com.supwisdom.institute.backend.common.framework.entity.ABaseEntity;
+
+@Entity
+@Table(name = "TB_U_GROUP_ROLE")
+public class GroupRole extends ABaseEntity {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = -3141266845902556712L;
+
+  /**
+   * 用户组ID
+   */
+  @Column(name = "GROUP_ID")
+  private String groupId;
+
+  /**
+   * 角色ID
+   */
+  @Column(name = "ROLE_ID")
+  private String roleId;
+
+  public String getGroupId() {
+    return groupId;
+  }
+
+  public void setGroupId(String groupId) {
+    this.groupId = groupId;
+  }
+
+  public String getRoleId() {
+    return roleId;
+  }
+
+  public void setRoleId(String roleId) {
+    this.roleId = roleId;
+  }
+
+}
diff --git a/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/entity/Role.java b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/entity/Role.java
new file mode 100644
index 0000000..d2f57e7
--- /dev/null
+++ b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/entity/Role.java
@@ -0,0 +1,74 @@
+package com.supwisdom.institute.backend.system.domain.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+import com.supwisdom.institute.backend.common.framework.entity.ABaseEntity;
+
+@Entity
+@Table(name = "TB_U_ROLE")
+public class Role extends ABaseEntity {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 5470129732727732514L;
+
+  /**
+   * 代码
+   */
+  @Column(name = "CODE")
+  private String code;
+
+  /**
+   * 名称
+   */
+  @Column(name = "NAME")
+  private String name;
+
+  /**
+   * 备注
+   */
+  @Column(name = "MEMO")
+  private String memo;
+
+  /**
+   * 状态(1 启用,0 停用)
+   */
+  @Column(name = "STATUS")
+  private String status;
+
+  public String getCode() {
+    return code;
+  }
+
+  public void setCode(String code) {
+    this.code = code;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getMemo() {
+    return memo;
+  }
+
+  public void setMemo(String memo) {
+    this.memo = memo;
+  }
+
+  public String getStatus() {
+    return status;
+  }
+
+  public void setStatus(String status) {
+    this.status = status;
+  }
+
+}
diff --git a/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/repo/AccountGroupRepository.java b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/repo/AccountGroupRepository.java
new file mode 100644
index 0000000..e4239ff
--- /dev/null
+++ b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/repo/AccountGroupRepository.java
@@ -0,0 +1,191 @@
+package com.supwisdom.institute.backend.system.domain.repo;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.ExampleMatcher;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.stereotype.Repository;
+
+import com.supwisdom.institute.backend.common.framework.repo.BaseJpaRepository;
+import com.supwisdom.institute.backend.common.util.MapBeanUtils;
+import com.supwisdom.institute.backend.system.domain.entity.Group;
+import com.supwisdom.institute.backend.system.domain.entity.Account;
+import com.supwisdom.institute.backend.system.domain.entity.AccountGroup;
+
+@Repository
+public interface AccountGroupRepository extends BaseJpaRepository<AccountGroup> {
+
+  public default Page<AccountGroup> selectPageList(int pageIndex, int pageSize, Map<String, Object> mapBean) {
+    AccountGroup probe = new AccountGroup();
+    if (mapBean != null) {
+      probe.setGroupId(MapBeanUtils.getString(mapBean, "groupId"));
+      probe.setAccountId(MapBeanUtils.getString(mapBean, "accountId"));
+    }
+
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("groupId", ExampleMatcher.GenericPropertyMatchers.exact())
+        .withMatcher("accountId", ExampleMatcher.GenericPropertyMatchers.exact());
+
+    Example<AccountGroup> example = Example.of(probe, matcher);
+
+    PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
+
+    Page<AccountGroup> page = this.findAll(example, pageRequest);
+
+    return page;
+  }
+
+  public default Page<AccountGroup> selectAccountGroups(int pageIndex, int pageSize, Map<String, Object> mapBean) {
+
+    AccountGroup probe = new AccountGroup();
+    if (mapBean != null) {
+      probe.setGroupId(MapBeanUtils.getString(mapBean, "groupId"));
+      probe.setAccountId(MapBeanUtils.getString(mapBean, "accountId"));
+    }
+
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("groupId", ExampleMatcher.GenericPropertyMatchers.exact())
+        .withMatcher("accountId", ExampleMatcher.GenericPropertyMatchers.exact());
+
+    Example<AccountGroup> example = Example.of(probe, matcher);
+
+    PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
+
+    Page<AccountGroup> page = this.findAll(example, pageRequest); // FIXME: 多表关联查询
+
+    return page;
+  }
+
+  public default void relateAccountGroups(Account account, List<AccountGroup> accountGroups) {
+
+    List<AccountGroup> existAccountGroups = this.selectListByAccountId(account.getId());
+
+    Map<String, AccountGroup> existMapAccountGroups = new LinkedHashMap<String, AccountGroup>();
+    for (AccountGroup accountGroup : existAccountGroups) {
+      String k = String.format("%s", accountGroup.getGroupId());
+      existMapAccountGroups.put(k, accountGroup);
+    }
+
+    for (AccountGroup accountGroup : accountGroups) {
+      String k = String.format("%s", accountGroup.getGroupId());
+
+      if (existMapAccountGroups.containsKey(k)) {
+        existMapAccountGroups.remove(k);
+      } else {
+        accountGroup.setCompanyId(account.getCompanyId());
+        accountGroup.setAccountId(account.getId());
+
+        this.insert(accountGroup);
+      }
+    }
+
+    for (AccountGroup accountGroup : existMapAccountGroups.values()) {
+      this.deleteById(accountGroup.getId());
+    }
+  }
+
+  public default List<AccountGroup> selectListByAccountId(String accountId) {
+
+    AccountGroup probe = new AccountGroup();
+    probe.setAccountId(accountId);
+
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("accountId", ExampleMatcher.GenericPropertyMatchers.exact());
+
+    Example<AccountGroup> example = Example.of(probe, matcher);
+
+    List<AccountGroup> accountGroups = this.findAll(example);
+
+    return accountGroups;
+  }
+
+  public default void relateGroupAccounts(Group group, List<AccountGroup> accountGroups) {
+
+    List<AccountGroup> existGroupAccounts = this.selectListByGroupId(group.getId());
+
+    Map<String, AccountGroup> existMapGroupAccounts = new LinkedHashMap<String, AccountGroup>();
+    for (AccountGroup accountGroup : existGroupAccounts) {
+      String k = String.format("%s", accountGroup.getAccountId());
+      existMapGroupAccounts.put(k, accountGroup);
+    }
+
+    for (AccountGroup accountGroup : accountGroups) {
+      String k = String.format("%s", accountGroup.getAccountId());
+
+      if (existMapGroupAccounts.containsKey(k)) {
+        existMapGroupAccounts.remove(k);
+      } else {
+        accountGroup.setCompanyId(group.getCompanyId());
+        accountGroup.setGroupId(group.getId());
+
+        this.insert(accountGroup);
+      }
+    }
+
+    for (AccountGroup accountGroup : existMapGroupAccounts.values()) {
+      this.deleteById(accountGroup.getId());
+    }
+  }
+
+  public default List<AccountGroup> selectListByGroupId(String groupId) {
+
+    AccountGroup probe = new AccountGroup();
+    probe.setGroupId(groupId);
+
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("groupId", ExampleMatcher.GenericPropertyMatchers.exact());
+
+    Example<AccountGroup> example = Example.of(probe, matcher);
+
+    List<AccountGroup> accountGroups = this.findAll(example);
+
+    return accountGroups;
+  }
+  
+  public default AccountGroup selectOneByAccountGroup(String accountId, String groupId) {
+
+    AccountGroup probe = new AccountGroup();
+    probe.setAccountId(accountId);
+    probe.setGroupId(groupId);
+
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("accountId", ExampleMatcher.GenericPropertyMatchers.exact())
+        .withMatcher("groupId", ExampleMatcher.GenericPropertyMatchers.exact())
+        ;
+
+    Example<AccountGroup> example = Example.of(probe, matcher);
+    
+    Optional<AccountGroup> o = this.findOne(example);
+    
+    return o.isPresent() ? o.get() : null;
+  }
+
+  public default void addAccountGroup(String accountId, String groupId) {
+    
+    AccountGroup accountGroup = this.selectOneByAccountGroup(accountId, groupId);
+    
+    if (accountGroup == null) {
+      accountGroup = new AccountGroup();
+      //accountGroup.setCompanyId(companyId);
+      accountGroup.setAccountId(accountId);
+      accountGroup.setGroupId(groupId);
+      
+      this.insert(accountGroup);
+    }
+  }
+
+  public default void removeAccountGroup(String accountId, String groupId) {
+    
+    AccountGroup accountGroup = this.selectOneByAccountGroup(accountId, groupId);
+    
+    if (accountGroup != null) {
+      this.deleteById(accountGroup.getId());
+    }
+  }
+
+}
diff --git a/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/repo/AccountRepository.java b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/repo/AccountRepository.java
new file mode 100644
index 0000000..526350f
--- /dev/null
+++ b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/repo/AccountRepository.java
@@ -0,0 +1,115 @@
+package com.supwisdom.institute.backend.system.domain.repo;
+
+import java.util.Map;
+import java.util.Optional;
+
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.ExampleMatcher;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.stereotype.Repository;
+
+import com.supwisdom.institute.backend.common.framework.repo.BaseJpaRepository;
+import com.supwisdom.institute.backend.common.util.MapBeanUtils;
+import com.supwisdom.institute.backend.system.domain.entity.Account;
+
+@Repository
+public interface AccountRepository extends BaseJpaRepository<Account> {
+  
+  public default Page<Account> selectPageList(int pageIndex, int pageSize, Account probe) {
+    
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("username", ExampleMatcher.GenericPropertyMatchers.contains())
+        .withMatcher("name", ExampleMatcher.GenericPropertyMatchers.contains())
+        .withMatcher("status", ExampleMatcher.GenericPropertyMatchers.exact());
+    
+    PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
+    Example<Account> example = Example.of(probe, matcher);
+    
+    Page<Account> page = this.findAll(example, pageRequest);
+    
+    return page;
+  }
+  
+  public default Page<Account> selectPageList(int pageIndex, int pageSize, Map<String, Object> mapBean) {
+    Account probe = new Account();
+    if (mapBean != null) {
+      probe.setUsername(MapBeanUtils.getString(mapBean, "username"));
+      probe.setName(MapBeanUtils.getString(mapBean, "name"));
+      probe.setStatus(MapBeanUtils.getString(mapBean, "status"));
+    }
+    
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("username", ExampleMatcher.GenericPropertyMatchers.contains())
+        .withMatcher("name", ExampleMatcher.GenericPropertyMatchers.contains())
+        .withMatcher("status", ExampleMatcher.GenericPropertyMatchers.exact());
+    
+    PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
+    Example<Account> example = Example.of(probe, matcher);
+    
+    Page<Account> page = this.findAll(example, pageRequest);
+    
+    return page;
+  }
+  
+  /*
+  public default User selectById(String id) {
+    
+    try {
+      Optional<User> entity = this.findById(id);
+      
+      return entity.get();
+    } catch(RuntimeException e) {
+      System.out.println("RuntimeException:"+e.getMessage());
+    } catch(Exception e) {
+      System.out.println("Exception:"+e.getMessage());
+    }
+    
+    return null;
+  }
+  
+  public default User insert(User entity) {
+    
+    if (entity.getCompanyId() == null || entity.getCompanyId().isEmpty()) {
+      entity.setCompanyId("1");
+    }
+    
+    entity.setDeleted(false);
+    //entity.setAddAccount(AuthUtil.getRemoteUser());
+    entity.setAddTime(Calendar.getInstance().getTime());
+    
+    User e = this.save(entity);
+    
+    return e;
+  }
+  
+  public default User update(User entity) {
+    
+    //entity.setEditAccount(AuthUtil.getRemoteUser());
+    entity.setEditTime(Calendar.getInstance().getTime());
+    
+    User e = this.save(entity);
+    
+    return e;
+  }
+  */
+  
+  public default Account selectByUsername(String username) {
+    Account probe = new Account();
+    probe.setUsername(username);
+    
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("username", ExampleMatcher.GenericPropertyMatchers.exact());
+    
+    Example<Account> example = Example.of(probe, matcher);
+    
+    Optional<Account> u = this.findOne(example);
+    
+    if (u.isPresent()) {
+      return u.get();
+    }
+    
+    return null;
+  }
+
+}
diff --git a/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/repo/AccountRoleRepository.java b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/repo/AccountRoleRepository.java
new file mode 100644
index 0000000..822bd9f
--- /dev/null
+++ b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/repo/AccountRoleRepository.java
@@ -0,0 +1,191 @@
+package com.supwisdom.institute.backend.system.domain.repo;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.ExampleMatcher;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.stereotype.Repository;
+
+import com.supwisdom.institute.backend.common.framework.repo.BaseJpaRepository;
+import com.supwisdom.institute.backend.common.util.MapBeanUtils;
+import com.supwisdom.institute.backend.system.domain.entity.Role;
+import com.supwisdom.institute.backend.system.domain.entity.Account;
+import com.supwisdom.institute.backend.system.domain.entity.AccountRole;
+
+@Repository
+public interface AccountRoleRepository extends BaseJpaRepository<AccountRole> {
+
+  public default Page<AccountRole> selectPageList(int pageIndex, int pageSize, Map<String, Object> mapBean) {
+
+    AccountRole probe = new AccountRole();
+    if (mapBean != null) {
+      probe.setAccountId(MapBeanUtils.getString(mapBean, "accountId"));
+      probe.setRoleId(MapBeanUtils.getString(mapBean, "roleId"));
+    }
+
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("accountId", ExampleMatcher.GenericPropertyMatchers.exact())
+        .withMatcher("roleId", ExampleMatcher.GenericPropertyMatchers.exact());
+
+    PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
+    Example<AccountRole> example = Example.of(probe, matcher);
+
+    Page<AccountRole> page = this.findAll(example, pageRequest);
+
+    return page;
+  }
+
+  public default Page<AccountRole> selectAccountRoles(int pageIndex, int pageSize, Map<String, Object> mapBean) {
+
+    AccountRole probe = new AccountRole();
+    if (mapBean != null) {
+      probe.setAccountId(MapBeanUtils.getString(mapBean, "accountId"));
+      probe.setRoleId(MapBeanUtils.getString(mapBean, "roleId"));
+    }
+
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("accountId", ExampleMatcher.GenericPropertyMatchers.exact())
+        .withMatcher("roleId", ExampleMatcher.GenericPropertyMatchers.exact());
+
+    Example<AccountRole> example = Example.of(probe, matcher);
+
+    PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
+
+    Page<AccountRole> page = this.findAll(example, pageRequest); // FIXME: 多表关联查询
+
+    return page;
+  }
+
+  public default void relateAccountRoles(Account account, List<AccountRole> accountRoles) {
+
+    List<AccountRole> existAccountRoles = this.selectListByAccountId(account.getId());
+
+    Map<String, AccountRole> existMapAccountRoles = new LinkedHashMap<String, AccountRole>();
+    for (AccountRole accountRole : existAccountRoles) {
+      String k = String.format("%s", accountRole.getRoleId());
+      existMapAccountRoles.put(k, accountRole);
+    }
+
+    for (AccountRole accountRole : accountRoles) {
+      String k = String.format("%s", accountRole.getRoleId());
+
+      if (existMapAccountRoles.containsKey(k)) {
+        existMapAccountRoles.remove(k);
+      } else {
+        accountRole.setCompanyId(account.getCompanyId());
+        accountRole.setAccountId(account.getId());
+
+        this.insert(accountRole);
+      }
+    }
+
+    for (AccountRole accountRole : existMapAccountRoles.values()) {
+      this.deleteById(accountRole.getId());
+    }
+  }
+
+  public default List<AccountRole> selectListByAccountId(String accountId) {
+
+    AccountRole probe = new AccountRole();
+    probe.setAccountId(accountId);
+
+    ExampleMatcher matcher = ExampleMatcher.matching().withMatcher("accountId",
+        ExampleMatcher.GenericPropertyMatchers.exact());
+
+    Example<AccountRole> example = Example.of(probe, matcher);
+
+    List<AccountRole> accountRoles = this.findAll(example);
+
+    return accountRoles;
+  }
+
+  public default void relateRoleAccounts(Role role, List<AccountRole> accountRoles) {
+
+    List<AccountRole> existRoleAccounts = this.selectListByRoleId(role.getId());
+
+    Map<String, AccountRole> existMapRoleAccounts = new LinkedHashMap<String, AccountRole>();
+    for (AccountRole accountRole : existRoleAccounts) {
+      String k = String.format("%s", accountRole.getAccountId());
+      existMapRoleAccounts.put(k, accountRole);
+    }
+
+    for (AccountRole accountRole : accountRoles) {
+      String k = String.format("%s", accountRole.getAccountId());
+
+      if (existMapRoleAccounts.containsKey(k)) {
+        existMapRoleAccounts.remove(k);
+      } else {
+        accountRole.setCompanyId(role.getCompanyId());
+        accountRole.setRoleId(role.getId());
+
+        this.insert(accountRole);
+      }
+    }
+
+    for (AccountRole accountRole : existMapRoleAccounts.values()) {
+      this.deleteById(accountRole.getId());
+    }
+  }
+
+  public default List<AccountRole> selectListByRoleId(String roleId) {
+
+    AccountRole probe = new AccountRole();
+    probe.setRoleId(roleId);
+
+    ExampleMatcher matcher = ExampleMatcher.matching().withMatcher("roleId",
+        ExampleMatcher.GenericPropertyMatchers.exact());
+
+    Example<AccountRole> example = Example.of(probe, matcher);
+
+    List<AccountRole> accountRoles = this.findAll(example);
+
+    return accountRoles;
+  }
+  
+  public default AccountRole selectOneByAccountRole(String accountId, String roleId) {
+
+    AccountRole probe = new AccountRole();
+    probe.setAccountId(accountId);
+    probe.setRoleId(roleId);
+
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("accountId", ExampleMatcher.GenericPropertyMatchers.exact())
+        .withMatcher("roleId", ExampleMatcher.GenericPropertyMatchers.exact())
+        ;
+
+    Example<AccountRole> example = Example.of(probe, matcher);
+    
+    Optional<AccountRole> o = this.findOne(example);
+    
+    return o.isPresent() ? o.get() : null;
+  }
+
+  public default void addAccountRole(String accountId, String roleId) {
+
+    AccountRole accountRole = this.selectOneByAccountRole(accountId, roleId);
+    
+    if (accountRole == null) {
+      accountRole = new AccountRole();
+      //accountRole.setCompanyId(companyId);
+      accountRole.setAccountId(accountId);
+      accountRole.setRoleId(roleId);
+      
+      this.insert(accountRole);
+    }
+  }
+
+  public default void removeAccountRole(String accountId, String roleId) {
+
+    AccountRole accountRole = this.selectOneByAccountRole(accountId, roleId);
+    
+    if (accountRole != null) {
+      this.deleteById(accountRole.getId());
+    }
+  }
+
+}
diff --git a/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/repo/GroupRepository.java b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/repo/GroupRepository.java
new file mode 100644
index 0000000..ba8607a
--- /dev/null
+++ b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/repo/GroupRepository.java
@@ -0,0 +1,41 @@
+package com.supwisdom.institute.backend.system.domain.repo;
+
+import java.util.Map;
+
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.ExampleMatcher;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.stereotype.Repository;
+
+import com.supwisdom.institute.backend.common.framework.repo.BaseJpaRepository;
+import com.supwisdom.institute.backend.common.util.MapBeanUtils;
+import com.supwisdom.institute.backend.system.domain.entity.Group;
+
+@Repository
+public interface GroupRepository extends BaseJpaRepository<Group> {
+
+  public default Page<Group> selectPageList(int pageIndex, int pageSize, Map<String, Object> mapBean) {
+    Group probe = new Group();
+    if (mapBean != null) {
+      probe.setCode(MapBeanUtils.getString(mapBean, "code"));
+      probe.setName(MapBeanUtils.getString(mapBean, "name"));
+      probe.setMemo(MapBeanUtils.getString(mapBean, "memo"));
+      probe.setStatus(MapBeanUtils.getString(mapBean, "status"));
+    }
+    
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("code", ExampleMatcher.GenericPropertyMatchers.contains())
+        .withMatcher("name", ExampleMatcher.GenericPropertyMatchers.contains())
+        .withMatcher("memo", ExampleMatcher.GenericPropertyMatchers.contains())
+        .withMatcher("status", ExampleMatcher.GenericPropertyMatchers.exact());
+    
+    PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
+    Example<Group> example = Example.of(probe, matcher);
+    
+    Page<Group> page = this.findAll(example, pageRequest);
+    
+    return page;
+  }
+  
+}
diff --git a/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/repo/GroupRoleRepository.java b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/repo/GroupRoleRepository.java
new file mode 100644
index 0000000..8f0386e
--- /dev/null
+++ b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/repo/GroupRoleRepository.java
@@ -0,0 +1,191 @@
+package com.supwisdom.institute.backend.system.domain.repo;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.ExampleMatcher;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.stereotype.Repository;
+
+import com.supwisdom.institute.backend.common.framework.repo.BaseJpaRepository;
+import com.supwisdom.institute.backend.common.util.MapBeanUtils;
+import com.supwisdom.institute.backend.system.domain.entity.Group;
+import com.supwisdom.institute.backend.system.domain.entity.GroupRole;
+import com.supwisdom.institute.backend.system.domain.entity.Role;
+
+@Repository
+public interface GroupRoleRepository extends BaseJpaRepository<GroupRole> {
+
+  public default Page<GroupRole> selectPageList(int pageIndex, int pageSize, Map<String, Object> mapBean) {
+    GroupRole probe = new GroupRole();
+    if (mapBean != null) {
+      probe.setGroupId(MapBeanUtils.getString(mapBean, "groupId"));
+      probe.setRoleId(MapBeanUtils.getString(mapBean, "roleId"));
+    }
+
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("groupId", ExampleMatcher.GenericPropertyMatchers.exact())
+        .withMatcher("roleId", ExampleMatcher.GenericPropertyMatchers.exact());
+
+    PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
+    Example<GroupRole> example = Example.of(probe, matcher);
+
+    Page<GroupRole> page = this.findAll(example, pageRequest);
+
+    return page;
+  }
+
+  public default Page<GroupRole> selectGroupRoles(int pageIndex, int pageSize, Map<String, Object> mapBean) {
+
+    GroupRole probe = new GroupRole();
+    if (mapBean != null) {
+      probe.setGroupId(MapBeanUtils.getString(mapBean, "groupId"));
+      probe.setRoleId(MapBeanUtils.getString(mapBean, "roleId"));
+    }
+
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("groupId", ExampleMatcher.GenericPropertyMatchers.exact())
+        .withMatcher("roleId", ExampleMatcher.GenericPropertyMatchers.exact());
+
+    Example<GroupRole> example = Example.of(probe, matcher);
+
+    PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
+
+    Page<GroupRole> page = this.findAll(example, pageRequest);  // FIXME: 多表关联查询
+
+    return page;
+  }
+
+  public default void relateGroupRoles(Group group, List<GroupRole> groupRoles) {
+
+    List<GroupRole> existGroupRoles = this.selectListByGroupId(group.getId());
+
+    Map<String, GroupRole> existMapGroupRoles = new LinkedHashMap<String, GroupRole>();
+    for (GroupRole groupRole : existGroupRoles) {
+      String k = String.format("%s", groupRole.getRoleId());
+      existMapGroupRoles.put(k, groupRole);
+    }
+
+    for (GroupRole groupRole : groupRoles) {
+      String k = String.format("%s", groupRole.getRoleId());
+
+      if (existMapGroupRoles.containsKey(k)) {
+        existMapGroupRoles.remove(k);
+      } else {
+        groupRole.setCompanyId(group.getCompanyId());
+        groupRole.setGroupId(group.getId());
+
+        this.insert(groupRole);
+      }
+    }
+
+    for (GroupRole groupRole : existMapGroupRoles.values()) {
+      this.deleteById(groupRole.getId());
+    }
+  }
+
+  public default List<GroupRole> selectListByGroupId(String groupId) {
+
+    GroupRole probe = new GroupRole();
+    probe.setGroupId(groupId);
+
+    ExampleMatcher matcher = ExampleMatcher.matching().withMatcher("groupId",
+        ExampleMatcher.GenericPropertyMatchers.exact());
+
+    Example<GroupRole> example = Example.of(probe, matcher);
+
+    List<GroupRole> groupRoles = this.findAll(example);
+
+    return groupRoles;
+  }
+
+
+  public default void relateRoleGroups(Role role, List<GroupRole> groupRoles) {
+
+    List<GroupRole> existRoleGroups = this.selectListByRoleId(role.getCode());
+
+    Map<String, GroupRole> existMapRoleGroups = new LinkedHashMap<String, GroupRole>();
+    for (GroupRole groupRole : existRoleGroups) {
+      String k = String.format("%s", groupRole.getGroupId());
+      existMapRoleGroups.put(k, groupRole);
+    }
+
+    for (GroupRole groupRole : groupRoles) {
+      String k = String.format("%s", groupRole.getGroupId());
+
+      if (existMapRoleGroups.containsKey(k)) {
+        existMapRoleGroups.remove(k);
+      } else {
+        groupRole.setCompanyId(role.getCompanyId());
+        groupRole.setRoleId(role.getId());
+
+        this.insert(groupRole);
+      }
+    }
+
+    for (GroupRole groupRole : existMapRoleGroups.values()) {
+      this.deleteById(groupRole.getId());
+    }
+  }
+
+  public default List<GroupRole> selectListByRoleId(String roleId) {
+
+    GroupRole probe = new GroupRole();
+    probe.setRoleId(roleId);
+
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("roleId", ExampleMatcher.GenericPropertyMatchers.exact());
+
+    Example<GroupRole> example = Example.of(probe, matcher);
+
+    List<GroupRole> groupRoles = this.findAll(example);
+
+    return groupRoles;
+  }
+
+  public default GroupRole selectOneByGroupRole(String groupId, String roleId) {
+
+    GroupRole probe = new GroupRole();
+    probe.setGroupId(groupId);
+    probe.setRoleId(roleId);
+
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("groupId", ExampleMatcher.GenericPropertyMatchers.exact())
+        .withMatcher("roleId", ExampleMatcher.GenericPropertyMatchers.exact())
+        ;
+
+    Example<GroupRole> example = Example.of(probe, matcher);
+    
+    Optional<GroupRole> o = this.findOne(example);
+    
+    return o.isPresent() ? o.get() : null;
+  }
+
+  public default void addGroupRole(String groupId, String roleId) {
+
+    GroupRole groupRole = this.selectOneByGroupRole(groupId, roleId);
+    
+    if (groupRole == null) {
+      groupRole = new GroupRole();
+      //groupRole.setCompanyId(companyId);
+      groupRole.setGroupId(groupId);
+      groupRole.setRoleId(roleId);
+      
+      this.insert(groupRole);
+    }
+  }
+
+  public default void removeGroupRole(String groupId, String roleId) {
+
+    GroupRole groupRole = this.selectOneByGroupRole(groupId, roleId);
+    
+    if (groupRole != null) {
+      this.deleteById(groupRole.getId());
+    }
+  }
+
+}
diff --git a/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/repo/RoleRepository.java b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/repo/RoleRepository.java
new file mode 100644
index 0000000..44787bb
--- /dev/null
+++ b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/repo/RoleRepository.java
@@ -0,0 +1,93 @@
+package com.supwisdom.institute.backend.system.domain.repo;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.ExampleMatcher;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+import org.springframework.stereotype.Repository;
+
+import com.supwisdom.institute.backend.common.framework.repo.BaseJpaRepository;
+import com.supwisdom.institute.backend.common.util.MapBeanUtils;
+import com.supwisdom.institute.backend.system.domain.entity.Role;
+
+@Repository
+public interface RoleRepository extends BaseJpaRepository<Role> {
+
+  public default Page<Role> selectPageList(int pageIndex, int pageSize, Map<String, Object> mapBean) {
+    Role probe = new Role();
+    if (mapBean != null) {
+      probe.setCode(MapBeanUtils.getString(mapBean, "code"));
+      probe.setName(MapBeanUtils.getString(mapBean, "name"));
+      probe.setMemo(MapBeanUtils.getString(mapBean, "memo"));
+      probe.setStatus(MapBeanUtils.getString(mapBean, "status"));
+    }
+    
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("code", ExampleMatcher.GenericPropertyMatchers.contains())
+        .withMatcher("name", ExampleMatcher.GenericPropertyMatchers.contains())
+        .withMatcher("memo", ExampleMatcher.GenericPropertyMatchers.contains())
+        .withMatcher("status", ExampleMatcher.GenericPropertyMatchers.exact());
+    
+    PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
+    Example<Role> example = Example.of(probe, matcher);
+    
+    Page<Role> page = this.findAll(example, pageRequest);
+    
+    return page;
+  }
+  
+  
+  public default Role selectByCode(String code) {
+    Role probe = new Role();
+    probe.setCode(code);
+    
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("code", ExampleMatcher.GenericPropertyMatchers.exact());
+    
+    Example<Role> example = Example.of(probe, matcher);
+    
+    Optional<Role> o = this.findOne(example);
+    
+    if (o.isPresent()) {
+      return o.get();
+    }
+    
+    return null;
+  }
+  
+  @Query(value = "select r from Role r "
+      + "inner join AccountRole ar on r.id=ar.roleId "
+      + "inner join Account a on ar.accountId=a.id "
+      + "where a.username=:username "
+      + "and r.status='1' and a.status='1' and a.enabled=1 ")
+  public List<Role> selectAccountRoleByUsername(@Param("username") String username);
+  
+  @Query(value = "select r from Role r "
+      + "inner join GroupRole gr on r.id=gr.roleId "
+      + "inner join Group_ g on gr.groupId=g.id "
+      + "inner join AccountGroup ag on g.id=ag.groupId "
+      + "inner join Account a on ag.accountId=a.id "
+      + "where a.username=:username "
+      + "and r.status='1' and g.status='1' and a.status='1' and a.enabled=1 ")
+  public List<Role> selectAccountGroupRoleByUsername(@Param("username") String username);
+
+  public default List<Role> selectByUsername(String username) {
+    List<Role> roles = new ArrayList<Role>();
+    
+    List<Role> userRoles = selectAccountRoleByUsername(username);
+    roles.addAll(userRoles);
+    
+    List<Role> userGroupRoles = selectAccountGroupRoleByUsername(username);
+    roles.addAll(userGroupRoles);
+    
+    return roles;
+  }
+  
+}
diff --git a/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/service/AccountService.java b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/service/AccountService.java
new file mode 100644
index 0000000..e59b9fd
--- /dev/null
+++ b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/service/AccountService.java
@@ -0,0 +1,172 @@
+package com.supwisdom.institute.backend.system.domain.service;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.ExampleMatcher;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.stereotype.Service;
+
+import com.supwisdom.institute.backend.common.framework.service.ABaseService;
+import com.supwisdom.institute.backend.common.util.MapBeanUtils;
+import com.supwisdom.institute.backend.system.domain.entity.Account;
+import com.supwisdom.institute.backend.system.domain.entity.AccountGroup;
+import com.supwisdom.institute.backend.system.domain.entity.AccountRole;
+import com.supwisdom.institute.backend.system.domain.repo.AccountGroupRepository;
+import com.supwisdom.institute.backend.system.domain.repo.AccountRepository;
+import com.supwisdom.institute.backend.system.domain.repo.AccountRoleRepository;
+
+@Service
+public class AccountService extends ABaseService<Account, AccountRepository> {
+  
+  @Override
+  public AccountRepository getRepo() {
+    return accountRepository;
+  }
+
+  @Autowired
+  private AccountRepository accountRepository;
+
+  @Autowired
+  private AccountGroupRepository accountGroupRepository;
+
+  @Autowired
+  private AccountRoleRepository accountRoleRepository;
+
+  
+
+  public Page<AccountGroup> selectAccountGroups(int pageIndex, int pageSize, Map<String, Object> mapBean) {
+
+    AccountGroup probe = new AccountGroup();
+    if (mapBean != null) {
+      probe.setGroupId(MapBeanUtils.getString(mapBean, "groupId"));
+      probe.setAccountId(MapBeanUtils.getString(mapBean, "accountId"));
+    }
+
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("groupId", ExampleMatcher.GenericPropertyMatchers.exact())
+        .withMatcher("accountId", ExampleMatcher.GenericPropertyMatchers.exact());
+
+    Example<AccountGroup> example = Example.of(probe, matcher);
+
+    PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
+
+    Page<AccountGroup> page = accountGroupRepository.findAll(example, pageRequest); // FIXME: 多表关联查询
+
+    return page;
+  }
+
+  public void relateAccountGroups(Account account, List<AccountGroup> accountGroups) {
+
+    List<AccountGroup> existAccountGroups = this.selectAccountGroupsByAccountId(account.getId());
+
+    Map<String, AccountGroup> existMapAccountGroups = new LinkedHashMap<String, AccountGroup>();
+    for (AccountGroup accountGroup : existAccountGroups) {
+      String k = String.format("%s", accountGroup.getGroupId());
+      existMapAccountGroups.put(k, accountGroup);
+    }
+
+    for (AccountGroup accountGroup : accountGroups) {
+      String k = String.format("%s", accountGroup.getGroupId());
+
+      if (existMapAccountGroups.containsKey(k)) {
+        existMapAccountGroups.remove(k);
+      } else {
+        accountGroup.setCompanyId(account.getCompanyId());
+        accountGroup.setAccountId(account.getId());
+
+        accountGroupRepository.insert(accountGroup);
+      }
+    }
+
+    for (AccountGroup accountGroup : existMapAccountGroups.values()) {
+      this.deleteById(accountGroup.getId());
+    }
+  }
+
+  public List<AccountGroup> selectAccountGroupsByAccountId(String accountId) {
+
+    AccountGroup probe = new AccountGroup();
+    probe.setAccountId(accountId);
+
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("accountId", ExampleMatcher.GenericPropertyMatchers.exact());
+
+    Example<AccountGroup> example = Example.of(probe, matcher);
+
+    List<AccountGroup> accountGroups = accountGroupRepository.findAll(example);
+
+    return accountGroups;
+  }
+
+  
+
+  public Page<AccountRole> selectAccountRoles(int pageIndex, int pageSize, Map<String, Object> mapBean) {
+
+    AccountRole probe = new AccountRole();
+    if (mapBean != null) {
+      probe.setAccountId(MapBeanUtils.getString(mapBean, "accountId"));
+      probe.setRoleId(MapBeanUtils.getString(mapBean, "roleId"));
+    }
+
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("accountId", ExampleMatcher.GenericPropertyMatchers.exact())
+        .withMatcher("roleId", ExampleMatcher.GenericPropertyMatchers.exact());
+
+    Example<AccountRole> example = Example.of(probe, matcher);
+
+    PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
+
+    Page<AccountRole> page = accountRoleRepository.findAll(example, pageRequest); // FIXME: 多表关联查询
+
+    return page;
+  }
+
+  public void relateAccountRoles(Account account, List<AccountRole> accountRoles) {
+
+    List<AccountRole> existAccountRoles = this.selectAccountRolesByAccountId(account.getId());
+
+    Map<String, AccountRole> existMapAccountRoles = new LinkedHashMap<String, AccountRole>();
+    for (AccountRole accountRole : existAccountRoles) {
+      String k = String.format("%s", accountRole.getRoleId());
+      existMapAccountRoles.put(k, accountRole);
+    }
+
+    for (AccountRole accountRole : accountRoles) {
+      String k = String.format("%s", accountRole.getRoleId());
+
+      if (existMapAccountRoles.containsKey(k)) {
+        existMapAccountRoles.remove(k);
+      } else {
+        accountRole.setCompanyId(account.getCompanyId());
+        accountRole.setAccountId(account.getId());
+
+        accountRoleRepository.insert(accountRole);
+      }
+    }
+
+    for (AccountRole accountRole : existMapAccountRoles.values()) {
+      this.deleteById(accountRole.getId());
+    }
+  }
+
+  public List<AccountRole> selectAccountRolesByAccountId(String accountId) {
+
+    AccountRole probe = new AccountRole();
+    probe.setAccountId(accountId);
+
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("accountId", ExampleMatcher.GenericPropertyMatchers.exact());
+
+    Example<AccountRole> example = Example.of(probe, matcher);
+
+    List<AccountRole> accountRoles = accountRoleRepository.findAll(example);
+
+    return accountRoles;
+  }
+
+}
diff --git a/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/service/ConfigService.java b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/service/ConfigService.java
index 858da54..55ba8ed 100644
--- a/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/service/ConfigService.java
+++ b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/service/ConfigService.java
@@ -10,14 +10,14 @@
 @Service
 public class ConfigService extends ABaseService<Config, ConfigRepository> {
   
-  @Autowired
-  private ConfigRepository configRepository;
-
   @Override
   public ConfigRepository getRepo() {
     return configRepository;
   }
 
+  @Autowired
+  private ConfigRepository configRepository;
+
   public Config selectByCategoryKey(String categoryCode, String configKey) {
     
     return configRepository.selectByCategoryKey(categoryCode, configKey);
diff --git a/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/service/GroupService.java b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/service/GroupService.java
new file mode 100644
index 0000000..4290954
--- /dev/null
+++ b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/service/GroupService.java
@@ -0,0 +1,19 @@
+package com.supwisdom.institute.backend.system.domain.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.supwisdom.institute.backend.common.framework.service.ABaseService;
+import com.supwisdom.institute.backend.system.domain.entity.Group;
+import com.supwisdom.institute.backend.system.domain.repo.GroupRepository;
+
+public class GroupService extends ABaseService<Group, GroupRepository> {
+  
+  @Override
+  public GroupRepository getRepo() {
+    return groupRepository;
+  }
+
+  @Autowired
+  private GroupRepository groupRepository;
+
+}
diff --git a/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/service/RoleService.java b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/service/RoleService.java
new file mode 100644
index 0000000..41952ed
--- /dev/null
+++ b/system/domain/src/main/java/com/supwisdom/institute/backend/system/domain/service/RoleService.java
@@ -0,0 +1,171 @@
+package com.supwisdom.institute.backend.system.domain.service;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.ExampleMatcher;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+
+import com.supwisdom.institute.backend.common.framework.service.ABaseService;
+import com.supwisdom.institute.backend.common.util.MapBeanUtils;
+import com.supwisdom.institute.backend.system.domain.entity.AccountRole;
+import com.supwisdom.institute.backend.system.domain.entity.GroupRole;
+import com.supwisdom.institute.backend.system.domain.entity.Role;
+import com.supwisdom.institute.backend.system.domain.repo.AccountRoleRepository;
+import com.supwisdom.institute.backend.system.domain.repo.GroupRoleRepository;
+import com.supwisdom.institute.backend.system.domain.repo.RoleRepository;
+
+public class RoleService extends ABaseService<Role, RoleRepository> {
+  
+  @Override
+  public RoleRepository getRepo() {
+    return roleRepository;
+  }
+
+  @Autowired
+  private RoleRepository roleRepository;
+
+  @Autowired
+  private AccountRoleRepository accountRoleRepository;
+
+  @Autowired
+  private GroupRoleRepository groupRoleRepository;
+
+  
+
+  public Page<AccountRole> selectRoleAccounts(int pageIndex, int pageSize, Map<String, Object> mapBean) {
+
+    AccountRole probe = new AccountRole();
+    if (mapBean != null) {
+      probe.setAccountId(MapBeanUtils.getString(mapBean, "accountId"));
+      probe.setRoleId(MapBeanUtils.getString(mapBean, "roleId"));
+    }
+
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("accountId", ExampleMatcher.GenericPropertyMatchers.exact())
+        .withMatcher("roleId", ExampleMatcher.GenericPropertyMatchers.exact());
+
+    Example<AccountRole> example = Example.of(probe, matcher);
+
+    PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
+
+    Page<AccountRole> page = accountRoleRepository.findAll(example, pageRequest); // FIXME: 多表关联查询
+
+    return page;
+  }
+
+  public void relateRoleAccounts(Role role, List<AccountRole> roleAccounts) {
+
+    List<AccountRole> existRoleAccounts = this.selectRoleAccountsByRoleId(role.getId());
+
+    Map<String, AccountRole> existMapRoleAccounts = new LinkedHashMap<String, AccountRole>();
+    for (AccountRole accountRole : existRoleAccounts) {
+      String k = String.format("%s", accountRole.getAccountId());
+      existMapRoleAccounts.put(k, accountRole);
+    }
+
+    for (AccountRole accountRole : roleAccounts) {
+      String k = String.format("%s", accountRole.getAccountId());
+
+      if (existMapRoleAccounts.containsKey(k)) {
+        existMapRoleAccounts.remove(k);
+      } else {
+        accountRole.setCompanyId(role.getCompanyId());
+        accountRole.setRoleId(role.getId());
+
+        accountRoleRepository.insert(accountRole);
+      }
+    }
+
+    for (AccountRole accountRole : existMapRoleAccounts.values()) {
+      this.deleteById(accountRole.getId());
+    }
+  }
+
+  public List<AccountRole> selectRoleAccountsByRoleId(String roleId) {
+
+    AccountRole probe = new AccountRole();
+    probe.setRoleId(roleId);
+
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("roleId", ExampleMatcher.GenericPropertyMatchers.exact());
+
+    Example<AccountRole> example = Example.of(probe, matcher);
+
+    List<AccountRole> accountRoles = accountRoleRepository.findAll(example);
+
+    return accountRoles;
+  }
+  
+  
+
+  public Page<GroupRole> selectRoleGroups(int pageIndex, int pageSize, Map<String, Object> mapBean) {
+
+    GroupRole probe = new GroupRole();
+    if (mapBean != null) {
+      probe.setGroupId(MapBeanUtils.getString(mapBean, "groupId"));
+      probe.setRoleId(MapBeanUtils.getString(mapBean, "roleId"));
+    }
+
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("groupId", ExampleMatcher.GenericPropertyMatchers.exact())
+        .withMatcher("roleId", ExampleMatcher.GenericPropertyMatchers.exact());
+
+    Example<GroupRole> example = Example.of(probe, matcher);
+
+    PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
+
+    Page<GroupRole> page = groupRoleRepository.findAll(example, pageRequest);  // FIXME: 多表关联查询
+
+    return page;
+  }
+
+  public void relateRoleGroups(Role role, List<GroupRole> groupRoles) {
+
+    List<GroupRole> existRoleGroups = this.selectRoleGroupsByRoleId(role.getCode());
+
+    Map<String, GroupRole> existMapRoleGroups = new LinkedHashMap<String, GroupRole>();
+    for (GroupRole groupRole : existRoleGroups) {
+      String k = String.format("%s", groupRole.getGroupId());
+      existMapRoleGroups.put(k, groupRole);
+    }
+
+    for (GroupRole groupRole : groupRoles) {
+      String k = String.format("%s", groupRole.getGroupId());
+
+      if (existMapRoleGroups.containsKey(k)) {
+        existMapRoleGroups.remove(k);
+      } else {
+        groupRole.setCompanyId(role.getCompanyId());
+        groupRole.setRoleId(role.getId());
+
+        groupRoleRepository.insert(groupRole);
+      }
+    }
+
+    for (GroupRole groupRole : existMapRoleGroups.values()) {
+      this.deleteById(groupRole.getId());
+    }
+  }
+
+  public List<GroupRole> selectRoleGroupsByRoleId(String roleId) {
+
+    GroupRole probe = new GroupRole();
+    probe.setRoleId(roleId);
+
+    ExampleMatcher matcher = ExampleMatcher.matching()
+        .withMatcher("roleId", ExampleMatcher.GenericPropertyMatchers.exact());
+
+    Example<GroupRole> example = Example.of(probe, matcher);
+
+    List<GroupRole> groupRoles = groupRoleRepository.findAll(example);
+
+    return groupRoles;
+  }
+
+  
+}