use of com.ibeiliao.deployment.admin.po.account.AdminAccountPO in project Corgi by kevinYin.
the class AdminAccountServiceImpl method lockAccount.
@Override
public void lockAccount(long uid) {
// 判断帐号是否存在
AdminAccountPO current = adminAccountDao.getById(uid);
ParameterUtil.assertNotNull(current, "帐号不存在,请重试。");
if (current.getAccountStatus() != AdminAccount.NOMAL) {
throw new ServiceException(ApiCode.FAILURE, "帐号状态错误,只能冻结正常的用户帐号。");
}
int rows = adminAccountDao.updateStatus(uid, AdminAccount.LOCKED, current.getAccountStatus(), new Date());
if (rows > 0) {
logger.info("admin#account#lockAccount | 冻结帐号成功 | uid: {}", uid);
} else {
logger.error("admin#account#lockAccount | 冻结帐号失败 | uid: {}", uid);
throw new ServiceException(ApiCode.FAILURE, "冻结用户帐号失败,未知错误,请重试");
}
}
use of com.ibeiliao.deployment.admin.po.account.AdminAccountPO in project Corgi by kevinYin.
the class AdminAccountServiceImpl method unlockAccount.
@Override
public void unlockAccount(long uid) {
// 判断帐号是否存在
AdminAccountPO current = adminAccountDao.getById(uid);
ParameterUtil.assertNotNull(current, "帐号不存在,请重试。");
if (current.getAccountStatus() != AdminAccount.LOCKED) {
throw new ServiceException(ApiCode.FAILURE, "帐号状态错误,只能解冻被冻结的用户帐号。");
}
int rows = adminAccountDao.updateStatus(uid, AdminAccount.NOMAL, current.getAccountStatus(), new Date());
if (rows > 0) {
logger.info("admin#account#unlockAccount | 解冻帐号成功 | uid: {}", uid);
} else {
logger.error("admin#account#unlockAccount | 解冻帐号失败 | uid: {}", uid);
throw new ServiceException(ApiCode.FAILURE, "冻结用户帐号失败,未知错误,请重试");
}
}
use of com.ibeiliao.deployment.admin.po.account.AdminAccountPO in project Corgi by kevinYin.
the class AdminAccountServiceImpl method update.
/**
* 更新帐号信息,但不会更新帐号的状态(冻结、正常)
* @param account 帐号信息
* @param roleIds 角色ID,至少要有一个角色
*/
private void update(AdminAccount account, Set<Integer> roleIds) {
validateAdminAccount(account, roleIds, false);
// 帐号校验
AdminAccountPO po = adminAccountDao.getById(account.getUid());
ParameterUtil.assertNotNull(po, "帐号不存在.");
// 处理帐号
po = VOUtil.from(account, AdminAccountPO.class);
po.setLastModify(new Date());
logger.info("admin#account#update | 更新帐号 | uid: {}", po.getUid());
int rows = adminAccountDao.update(po);
ParameterUtil.assertGreaterThanZero(rows, "更新帐号失败.");
logger.info("admin#account#update | 删除帐号角色关系 | uid: {}", po.getUid());
accountRoleRelationDao.deleteByAccount(po.getUid());
// 处理帐号角色关系
for (Integer roleId : roleIds) {
AccountRoleRelationPO relation = new AccountRoleRelationPO();
relation.setUid(po.getUid());
relation.setRoleId(roleId);
logger.info("admin#account#update | 添加用户角色关系 | uid: {}, roleId: {}", relation.getUid(), roleId);
accountRoleRelationDao.save(relation);
}
}
use of com.ibeiliao.deployment.admin.po.account.AdminAccountPO in project Corgi by kevinYin.
the class AdminAccountServiceImpl method add.
/**
* 增加新帐号
* @param account 帐号信息
* @param roleIds 角色ID,至少要有一个角色
*/
private void add(AdminAccount account, Set<Integer> roleIds) {
validateAdminAccount(account, roleIds, true);
// 帐号校验
if (adminAccountDao.getById(account.getUid()) != null) {
logger.info("admin#account#add | 帐号已存在 | uid: {}", account.getUid());
throw new ServiceException(ApiCode.FAILURE, "帐号已存在:" + account.getUid() + "");
}
AdminAccountPO po = VOUtil.from(account, AdminAccountPO.class);
// 处理帐号
po.setCreateTime(new Date());
po.setLastModify(po.getCreateTime());
this.adminAccountDao.save(po);
long uid = account.getUid();
logger.info("admin#account#add | 删除用户角色关系 | uid: {}", uid);
accountRoleRelationDao.deleteByAccount(uid);
// 处理帐号角色关系
for (Integer roleId : roleIds) {
AccountRoleRelationPO relation = new AccountRoleRelationPO();
relation.setUid(uid);
relation.setRoleId(roleId);
logger.info("admin#account#add | 添加用户角色关系 | uid: {}, roleId: {}", uid, roleId);
accountRoleRelationDao.save(relation);
}
logger.info("admin#account#add | 添加用户成功 | uid: {}", uid);
}
Aggregations