|
|
|
@ -2,25 +2,43 @@ package com.shxy.xymanager_service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.bean.copier.CopyOptions;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
import com.shxy.xymanager_common.bean.ServiceBody;
|
|
|
|
|
import com.shxy.xymanager_common.bean.SysUser;
|
|
|
|
|
import com.shxy.xymanager_common.config.CustomRsaProperties;
|
|
|
|
|
import com.shxy.xymanager_common.dto.TerminalsAndLineAndChannelDto;
|
|
|
|
|
import com.shxy.xymanager_common.entity.UserSession;
|
|
|
|
|
import com.shxy.xymanager_common.enums.CommonStatus;
|
|
|
|
|
import com.shxy.xymanager_common.exception.Asserts;
|
|
|
|
|
import com.shxy.xymanager_common.model.SysUserModel;
|
|
|
|
|
import com.shxy.xymanager_common.model.TerminalListModel;
|
|
|
|
|
import com.shxy.xymanager_common.page.PageUtils;
|
|
|
|
|
import com.shxy.xymanager_common.util.MyDateUtils;
|
|
|
|
|
import com.shxy.xymanager_common.util.RsaUtils;
|
|
|
|
|
import com.shxy.xymanager_common.util.StringUtils;
|
|
|
|
|
import com.shxy.xymanager_common.vo.PageVo;
|
|
|
|
|
import com.shxy.xymanager_common.vo.SysUserUpdateVo;
|
|
|
|
|
import com.shxy.xymanager_common.vo.SysUserVo;
|
|
|
|
|
import com.shxy.xymanager_dao.dao.SysUserMapperDao;
|
|
|
|
|
import com.shxy.xymanager_service.service.SysUserService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.http.HttpEntity;
|
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.math.BigInteger;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -86,7 +104,8 @@ public class SysUserServiceImpl implements SysUserService {
|
|
|
|
|
// }
|
|
|
|
|
sysUser.setUserName(userName);
|
|
|
|
|
sysUser.setNickName(nickName);
|
|
|
|
|
|
|
|
|
|
sysUser.setCreateTime(new DateTime());
|
|
|
|
|
sysUser.setRole(vo.getRole());
|
|
|
|
|
try {
|
|
|
|
|
sysUser.setPassword(RsaUtils.encryptByPublicKey( CustomRsaProperties.publicKey,vo.getPassword()));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
@ -103,26 +122,38 @@ public class SysUserServiceImpl implements SysUserService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean updateUser(SysUser user) {
|
|
|
|
|
return sysUserMapperDao.updateById(user);
|
|
|
|
|
public ServiceBody<String> updateUser(SysUserUpdateVo vo) {
|
|
|
|
|
SysUser user = new SysUser();
|
|
|
|
|
BeanUtils.copyProperties(vo,user);
|
|
|
|
|
try {
|
|
|
|
|
if(StringUtils.isNotBlank( user.getPassword())) {
|
|
|
|
|
user.setPassword(RsaUtils.encryptByPublicKey(CustomRsaProperties.publicKey, vo.getPassword()));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("修改密码异常:{}",e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
int result = sysUserMapperDao.updateById(user);
|
|
|
|
|
if(result>0){
|
|
|
|
|
return Asserts.success("修改成功");
|
|
|
|
|
}
|
|
|
|
|
return Asserts.error("修改失败");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean updateUserStatus(SysUser user) {
|
|
|
|
|
return sysUserMapperDao.updateById(user);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean updateUserProfile(SysUser user) {
|
|
|
|
|
return sysUserMapperDao.updateById(user);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean resetPwd(SysUser user) {
|
|
|
|
|
return sysUserMapperDao.updateById(user);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -132,18 +163,16 @@ public class SysUserServiceImpl implements SysUserService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int deleteUserById(Long userId) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
public ServiceBody<String> deleteUserById(String userId) {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int deleteUserByIds(Long[] userIds) {
|
|
|
|
|
for (Long userId : userIds) {
|
|
|
|
|
checkUserAllowed(new SysUser(userId));
|
|
|
|
|
int result = sysUserMapperDao.deleteUserById(userId);
|
|
|
|
|
if(result>0){
|
|
|
|
|
return Asserts.success("删除成功");
|
|
|
|
|
}
|
|
|
|
|
return sysUserMapperDao.deleteUserByIds(userIds);
|
|
|
|
|
return Asserts.error("失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public UserSession selectUserById(String sessionId) {
|
|
|
|
|
UserSession session = sysUserMapperDao.selectUserBySessionId(sessionId);
|
|
|
|
@ -156,6 +185,40 @@ public class SysUserServiceImpl implements SysUserService {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ServiceBody<SysUserModel> selectUserList(@RequestBody @Validated PageVo vo) {
|
|
|
|
|
SysUserModel model = new SysUserModel();
|
|
|
|
|
int pageindex = vo.getPageindex();
|
|
|
|
|
int pagesize = vo.getPagesize();
|
|
|
|
|
PageUtils.SetPage(pageindex, pagesize);
|
|
|
|
|
List<SysUser> list = sysUserMapperDao.selectUserInfoList(CommonStatus.EFFECTIVE.value());
|
|
|
|
|
|
|
|
|
|
boolean empty = CollectionUtil.isEmpty(list);
|
|
|
|
|
if (empty) {
|
|
|
|
|
model.setList(new ArrayList<>());
|
|
|
|
|
} else {
|
|
|
|
|
List<SysUserModel.SysUserBean> beans = Lists.newArrayList();
|
|
|
|
|
list.forEach(var->{
|
|
|
|
|
SysUserModel.SysUserBean bean = new SysUserModel.SysUserBean();
|
|
|
|
|
BeanUtils.copyProperties(var,bean);
|
|
|
|
|
bean.setCreateTime(MyDateUtils.TimeMillSecondToSecond(MyDateUtils.beginOfDay(var.getCreateTime())));
|
|
|
|
|
beans.add(bean);
|
|
|
|
|
});
|
|
|
|
|
model.setList(beans);
|
|
|
|
|
}
|
|
|
|
|
PageInfo pageData = PageUtils.getPageData(list);
|
|
|
|
|
int currentpage = pageData.getPageNum();
|
|
|
|
|
model.setCurrentpage(currentpage);
|
|
|
|
|
long total = pageData.getTotal();
|
|
|
|
|
model.setTotal(total);
|
|
|
|
|
|
|
|
|
|
int pageSize = pageData.getPageSize();
|
|
|
|
|
model.setPagesize(pageSize);
|
|
|
|
|
int pages = pageData.getPages();
|
|
|
|
|
model.setTotalpage(pages);
|
|
|
|
|
return Asserts.success(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean addUserRemote(Map<String, Object> map) {
|
|
|
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
|
|
httpHeaders.setContentType(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE));
|
|
|
|
|