use of com.moxi.mogublog.commons.entity.Role in project mogu_blog_v2 by moxi624.
the class RoleServiceImpl method deleteRole.
@Override
public String deleteRole(RoleVO roleVO) {
// 判断该角色下是否绑定了管理员
QueryWrapper<Admin> blogQueryWrapper = new QueryWrapper<>();
blogQueryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
blogQueryWrapper.in(SQLConf.ROLEUID, roleVO.getUid());
Integer adminCount = adminService.count(blogQueryWrapper);
if (adminCount > 0) {
return ResultUtil.errorWithMessage(MessageConf.ADMIN_UNDER_THIS_ROLE);
}
Role role = roleService.getById(roleVO.getUid());
role.setStatus(EStatus.DISABLED);
role.setUpdateTime(new Date());
role.updateById();
deleteAdminVisitUrl();
return ResultUtil.successWithMessage(MessageConf.DELETE_SUCCESS);
}
use of com.moxi.mogublog.commons.entity.Role in project mogu_blog_v2 by moxi624.
the class AdminServiceImpl method getList.
@Override
public String getList(AdminVO adminVO) {
QueryWrapper<Admin> queryWrapper = new QueryWrapper<>();
String pictureResult = null;
if (StringUtils.isNotEmpty(adminVO.getKeyword())) {
queryWrapper.like(SQLConf.USER_NAME, adminVO.getKeyword()).or().like(SQLConf.NICK_NAME, adminVO.getKeyword().trim());
}
Page<Admin> page = new Page<>();
page.setCurrent(adminVO.getCurrentPage());
page.setSize(adminVO.getPageSize());
// 去除密码
queryWrapper.select(Admin.class, i -> !i.getProperty().equals(SQLConf.PASS_WORD));
queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
IPage<Admin> pageList = adminService.page(page, queryWrapper);
List<Admin> list = pageList.getRecords();
final StringBuffer fileUids = new StringBuffer();
List<String> adminUidList = new ArrayList<>();
list.forEach(item -> {
if (StringUtils.isNotEmpty(item.getAvatar())) {
fileUids.append(item.getAvatar() + SysConf.FILE_SEGMENTATION);
}
adminUidList.add(item.getUid());
});
Map<String, String> pictureMap = new HashMap<>(Constants.NUM_TEN);
if (fileUids != null) {
pictureResult = this.pictureFeignClient.getPicture(fileUids.toString(), SysConf.FILE_SEGMENTATION);
}
List<Map<String, Object>> picList = webUtil.getPictureMap(pictureResult);
picList.forEach(item -> {
pictureMap.put(item.get(SQLConf.UID).toString(), item.get(SQLConf.URL).toString());
});
// 获取用户的网盘存储空间
String storageListJson = pictureFeignClient.getStorageByAdminUid(adminUidList);
List<Storage> storageList = webUtil.getList(storageListJson, Storage.class);
Map<String, Storage> storageMap = new HashMap<>();
storageList.forEach(item -> {
storageMap.put(item.getAdminUid(), item);
});
for (Admin item : list) {
Role role = roleService.getById(item.getRoleUid());
item.setRole(role);
// 获取图片
if (StringUtils.isNotEmpty(item.getAvatar())) {
List<String> pictureUidsTemp = StringUtils.changeStringToString(item.getAvatar(), SysConf.FILE_SEGMENTATION);
List<String> pictureListTemp = new ArrayList<>();
pictureUidsTemp.forEach(picture -> {
if (pictureMap.get(picture) != null && pictureMap.get(picture) != "") {
pictureListTemp.add(pictureMap.get(picture));
}
});
item.setPhotoList(pictureListTemp);
}
// 设置已用容量大小和最大容量
Storage storage = storageMap.get(item.getUid());
if (storage != null) {
item.setStorageSize(storage.getStorageSize());
item.setMaxStorageSize(storage.getMaxStorageSize());
} else {
// 如果没有,默认为0
item.setStorageSize(0L);
item.setMaxStorageSize(0L);
}
}
return ResultUtil.successWithData(pageList);
}
use of com.moxi.mogublog.commons.entity.Role in project mogu_blog_v2 by moxi624.
the class RoleServiceImpl method addRole.
@Override
public String addRole(RoleVO roleVO) {
String roleName = roleVO.getRoleName();
QueryWrapper<Role> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(SQLConf.ROLENAEM, roleName);
Role getRole = roleService.getOne(queryWrapper);
if (getRole == null) {
Role role = new Role();
role.setRoleName(roleVO.getRoleName());
role.setCategoryMenuUids(roleVO.getCategoryMenuUids());
role.setSummary(roleVO.getSummary());
role.insert();
return ResultUtil.result(SysConf.SUCCESS, MessageConf.INSERT_SUCCESS);
}
return ResultUtil.errorWithMessage(MessageConf.ENTITY_EXIST);
}
use of com.moxi.mogublog.commons.entity.Role in project mogu_blog_v2 by moxi624.
the class RoleServiceImpl method editRole.
@Override
public String editRole(RoleVO roleVO) {
String uid = roleVO.getUid();
Role getRole = roleService.getById(uid);
if (getRole == null) {
return ResultUtil.errorWithMessage(MessageConf.PARAM_INCORRECT);
}
getRole.setRoleName(roleVO.getRoleName());
getRole.setCategoryMenuUids(roleVO.getCategoryMenuUids());
getRole.setSummary(roleVO.getSummary());
getRole.setUpdateTime(new Date());
getRole.updateById();
// 修改成功后,需要删除redis中所有的admin访问路径
deleteAdminVisitUrl();
return ResultUtil.successWithMessage(MessageConf.UPDATE_SUCCESS);
}
Aggregations