use of com.ibeiliao.deployment.admin.vo.account.AdminAccount in project Corgi by kevinYin.
the class InitTestDataService method init.
/**
* 创建初始化数据
*/
public InitData init() {
// 1. 创建 account
// 2. 创建 project
// 3. 创建 module
// 4. 初始化 env
// 5. 创建 server group & server
List<ProjectEnv> envs = createProjectEnv();
AdminAccount account = createAdminAccount();
Project project = createProject(account);
ProjectModule module = createModule(account.getUid(), project, envs);
return new InitData(account, project, module, envs);
}
use of com.ibeiliao.deployment.admin.vo.account.AdminAccount in project Corgi by kevinYin.
the class InitTestDataService method createAdminAccount.
private AdminAccount createAdminAccount() {
AdminAccount account = new AdminAccount();
long accountId = Integer.MAX_VALUE / 10;
account.setAccount(accountId + "@abc.com");
account.setDefaultData(Constants.TRUE);
// account.setLastModify(new Date());
// account.setCreateTime(new Date());
account.setMobileNo("13000001111");
account.setRealname("张" + accountId);
account.setAccountStatus(AdminAccount.NOMAL);
account.setUid(accountId);
Set<Integer> roleIds = new HashSet<>();
roleIds.add(1);
adminAccountService.addOrUpdate(account, roleIds);
Assert.notNull(adminAccountService.getById(accountId));
return account;
}
use of com.ibeiliao.deployment.admin.vo.account.AdminAccount in project Corgi by kevinYin.
the class ListAccountController method lockOrUnlockAccount.
/**
* 冻结解冻管理员帐号,调用一次接口,做一次反操作。
* 比如当前是正常状态,操作一次后变成冻结,再操作一次变成解冻
* @param uid 管理员ID
* @return result.success=true为成功, result.object=新的状态
*/
@RequestMapping(value = "lockOrUnlockAccount.do", method = RequestMethod.POST)
@MenuResource("冻结/解冻管理员")
@ResponseBody
@AdminLog
public RestResult<Integer> lockOrUnlockAccount(long uid) {
AdminAccount account = adminAccountService.getById(uid);
RestResult<Integer> result = null;
if (account == null) {
result = new RestResult<>(ApiCode.FAILURE, "帐号不存在,uid=" + uid);
} else {
String message = null;
int newStatus = 0;
if (account.getAccountStatus() == AdminAccount.LOCKED) {
adminAccountService.unlockAccount(uid);
message = "解冻帐号成功.";
newStatus = AdminAccount.NOMAL;
logger.info("admin#account#lockOrUnlockAccount | 解冻帐号成功 | uid: " + uid);
} else {
adminAccountService.lockAccount(uid);
newStatus = AdminAccount.LOCKED;
message = "冻结帐号成功.";
}
result = new RestResult<>(ApiCode.SUCCESS, message, newStatus);
logger.info("admin#account#lockOrUnlockAccount | 冻结帐号成功 | uid: " + uid);
}
return result;
}
use of com.ibeiliao.deployment.admin.vo.account.AdminAccount in project Corgi by kevinYin.
the class ListAccountController method listAccount.
/**
* 读取管理员列表
* @param keyword 搜索的关键字
* @param page 第几页
* @param pageSize 每页多少
* @return result.object=数据列表,数据列表不为null
*/
@RequestMapping("queryAccount")
@MenuResource("读取管理员列表")
@ResponseBody
public PageResult<List<AdminAccount>> listAccount(String keyword, int page, int pageSize, HttpServletRequest request) {
List<AdminAccount> list = adminAccountService.listAccounts(keyword, page, pageSize);
int total = adminAccountService.statAccount(keyword);
for (AdminAccount account : list) {
StringBuilder buf = new StringBuilder();
List<AccountRoleRelation> tmpList = adminAccountService.listAccountRoles(account.getUid());
for (AccountRoleRelation arr : tmpList) {
Role role = roleService.getById(arr.getRoleId());
if (role != null) {
if (buf.length() > 0)
buf.append(",");
buf.append(role.getRoleName());
}
}
account.setRoleName(buf.toString());
}
PageResult<List<AdminAccount>> result = new PageResult<>(list);
result.setCurrentPage(page);
result.setPageSize(pageSize);
result.setCount(total);
return result;
}
use of com.ibeiliao.deployment.admin.vo.account.AdminAccount in project Corgi by kevinYin.
the class EditAccountController method getAdmin.
/**
* 读取管理员信息
* @param uid 管理员ID
* @return 返回管理员信息
*/
@RequestMapping("getAdmin")
@MenuResource("读取管理员信息")
@ResponseBody
public RestResult<AdminAccount> getAdmin(long uid) {
AdminAccount account = adminAccountService.getById(uid);
RestResult<AdminAccount> result;
if (account == null) {
result = new RestResult<>(ApiCode.FAILURE, "管理员不存在:uid=" + uid);
} else {
List<AccountRoleRelation> list = adminAccountService.listAccountRoles(uid);
if (list.size() == 1) {
account.setRoleId(list.get(0).getRoleId());
}
account.setPassword(aesPropertiesEncoder.decode(account.getPassword()));
result = new RestResult<>(account);
}
return result;
}
Aggregations