use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class PmphGroupServiceImpl method addEditorSelcetionGroup.
@Override
public PmphGroup addEditorSelcetionGroup(String sessionId, List<PmphGroupMember> list, Long textbookId) throws CheckedServiceException {
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (null == pmphUser || null == pmphUser.getId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "用户为空");
}
if (list.size() == 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "成员名单为空,更新失败");
}
Textbook textbook = textbookService.getTextbookById(textbookId);
list.get(0).setTextbookId(textbookId);
list.get(0).setMaterialId(textbook.getMaterialId());
// 未上传小组头像时,获取默认小组头像路径
String groupImage = RouteUtil.DEFAULT_GROUP_IMAGE;
PmphGroup pmphGroup = new PmphGroup();
// 查询小组名称是否已存在 不存在直接用书名
if (ObjectUtil.isNull(pmphGroupDao.getPmphGroupByGroupName(textbook.getTextbookName()))) {
pmphGroup.setGroupName(textbook.getTextbookName());
} else {
// 存在则用书名加当前小组总数进行区分
Long count = pmphGroupDao.getPmphGroupCount();
pmphGroup.setGroupName(textbook.getTextbookName() + count);
}
pmphGroup.setGroupImage(groupImage);
pmphGroup.setBookId(textbookId);
pmphGroup.setFounderId(pmphUser.getId());
pmphGroupDao.addPmphGroup(pmphGroup);
if (null != pmphGroup.getId()) {
// 判断是否新增小组成功,如果成功则调用PmphGroupMemberService添加小组成员的方法将创建者添加到小组中
PmphGroupMember pmphGroupMember = new PmphGroupMember();
pmphGroupMember.setGroupId(pmphGroup.getId());
pmphGroupMember.setIsFounder(true);
pmphGroupMember.setUserId(pmphUser.getId());
pmphGroupMember.setDisplayName(pmphUser.getRealname());
pmphGroupMemberService.addPmphGroupMember(pmphGroupMember);
// 批量把前台传入的作家用户添加到该小组
pmphGroupMemberService.addPmphGroupMemberOnGroup(pmphGroup.getId(), list, sessionId);
} else {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.OBJECT_NOT_FOUND, "添加小组和成员失败");
}
return pmphGroup;
}
use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class PmphGroupServiceImpl method listPmphGroupFile.
@Override
public List<PmphGroupListVO> listPmphGroupFile(PmphGroup pmphGroup, String sessionId) throws CheckedServiceException {
if (null == pmphGroup) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "参数对象为空");
}
// session PmphUser用户验证
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (null == pmphUser || null == pmphUser.getId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "用户为空");
}
List<PmphGroupListVO> list = new ArrayList<>();
list = pmphGroupDao.getList(pmphGroup, pmphUser.getId());
for (PmphGroupListVO pmphGroupListVO : list) {
pmphGroupListVO.setGroupImage(RouteUtil.groupImage(pmphGroupListVO.getGroupImage()));
}
return list;
}
use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class PmphUserServiceImpl method getListByUsernameAndRealname.
@Override
public PageResult<PmphUserManagerVO> getListByUsernameAndRealname(String name, int number, int size) throws CheckedServiceException {
if (null == name || "".equals(name)) {
throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "模糊查询条件为空");
}
List<PmphUser> pmphUsers = pmphUserDao.getListByUsernameAndRealname(name, (number - 1) * size, size);
PageResult<PmphUserManagerVO> page = new PageResult<>();
page.setFirst(true);
page.setLast(true);
page.setPageNumber(number);
page.setPageSize(size);
if (!pmphUsers.isEmpty()) {
List<PmphUserManagerVO> list = new ArrayList<>();
for (PmphUser user : pmphUsers) {
PmphUserManagerVO userVO = new PmphUserManagerVO();
PmphDepartment department = pmphDepartmentDao.getPmphDepartmentById(user.getDepartmentId());
if (null != department) {
userVO.setDepartmentName(department.getDpName());
}
try {
BeanUtils.copyProperties(userVO, user);
} catch (BeansException ex) {
throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.VO_CONVERSION_FAILED, ex.getMessage());
}
list.add(userVO);
}
page.setRows(list);
}
return page;
}
use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class PmphUserServiceImpl method updatePassword.
@Override
public Integer updatePassword(HttpServletRequest request, String oldPassword, String newPassword) {
// 获取当前用户
String sessionId = CookiesUtil.getSessionId(request);
PmphUser sessionPmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (null == sessionPmphUser) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "请求用户不存在");
}
Long id = sessionPmphUser.getId();
if (null == id) {
throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "用户ID为空时禁止查询");
}
if (StringUtil.isEmpty(oldPassword)) {
throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "原密码为空");
}
if (StringUtil.isEmpty(newPassword)) {
throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "新密码为空");
}
oldPassword = oldPassword.trim();
newPassword = newPassword.trim();
if (newPassword.length() > 50) {
throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.ILLEGAL_PARAM, "新密码长度不能超过50");
}
if (oldPassword.equals(newPassword)) {
throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.ILLEGAL_PARAM, "新旧密码不能一致");
}
// 先修改SSO
// ---------------------------------
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", id);
// 加密密码
map.put("oldPassword", new DesRun("", oldPassword).enpsw);
map.put("newPassword", new DesRun("", newPassword).enpsw);
Integer res = pmphUserDao.updatePassword(map);
if (null == res || res == 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "原密码错误");
}
return 1;
}
use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class PmphUserServiceImpl method getInfo.
/**
* 根据主键 id 加载用户对象
*
* @param id
* @return
*/
@Override
public PmphUser getInfo(HttpServletRequest request) throws CheckedServiceException {
// 获取当前用户
String sessionId = CookiesUtil.getSessionId(request);
PmphUser sessionPmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (null == sessionPmphUser) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "请求用户不存在");
}
Long id = sessionPmphUser.getId();
if (ObjectUtil.isNull(id)) {
throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "用户ID为空时禁止查询");
}
PmphUser pmphUser = pmphUserDao.getInfo(id);
if (null == pmphUser) {
pmphUser = new PmphUser();
}
String avatar = pmphUser.getAvatar();
pmphUser.setAvatar(RouteUtil.userAvatar(avatar));
return pmphUser;
}
Aggregations