Search in sources :

Example 1 with AdminAccount

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);
}
Also used : Project(com.ibeiliao.deployment.admin.vo.project.Project) ProjectEnv(com.ibeiliao.deployment.admin.vo.global.ProjectEnv) ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule) AdminAccount(com.ibeiliao.deployment.admin.vo.account.AdminAccount)

Example 2 with AdminAccount

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;
}
Also used : AdminAccount(com.ibeiliao.deployment.admin.vo.account.AdminAccount)

Example 3 with AdminAccount

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;
}
Also used : AdminAccount(com.ibeiliao.deployment.admin.vo.account.AdminAccount) AdminLog(com.ibeiliao.deployment.admin.annotation.log.AdminLog) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with AdminAccount

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;
}
Also used : Role(com.ibeiliao.deployment.admin.vo.account.Role) AccountRoleRelation(com.ibeiliao.deployment.admin.vo.account.AccountRoleRelation) AdminAccount(com.ibeiliao.deployment.admin.vo.account.AdminAccount) List(java.util.List) PageResult(com.ibeiliao.deployment.admin.common.PageResult) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with AdminAccount

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;
}
Also used : AccountRoleRelation(com.ibeiliao.deployment.admin.vo.account.AccountRoleRelation) AdminAccount(com.ibeiliao.deployment.admin.vo.account.AdminAccount) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

AdminAccount (com.ibeiliao.deployment.admin.vo.account.AdminAccount)11 MenuResource (com.ibeiliao.deployment.admin.utils.resource.MenuResource)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)5 RestResult (com.ibeiliao.deployment.admin.common.RestResult)2 AccountRoleRelation (com.ibeiliao.deployment.admin.vo.account.AccountRoleRelation)2 Project (com.ibeiliao.deployment.admin.vo.project.Project)2 ProjectModule (com.ibeiliao.deployment.admin.vo.project.ProjectModule)2 AllowAnonymous (com.ibeiliao.deployment.admin.annotation.authority.AllowAnonymous)1 AdminLog (com.ibeiliao.deployment.admin.annotation.log.AdminLog)1 PageResult (com.ibeiliao.deployment.admin.common.PageResult)1 AdminLoginUser (com.ibeiliao.deployment.admin.context.AdminLoginUser)1 DeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO)1 ServerDeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO)1 Role (com.ibeiliao.deployment.admin.vo.account.Role)1 DeployHistory (com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)1 DeploymentOrder (com.ibeiliao.deployment.admin.vo.deploy.DeploymentOrder)1 ServerDeployHistory (com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory)1 GlobalSetting (com.ibeiliao.deployment.admin.vo.global.GlobalSetting)1 ProjectEnv (com.ibeiliao.deployment.admin.vo.global.ProjectEnv)1