用户管理前后端代码提交
This commit is contained in:
parent
93b45e0a14
commit
c84e1524ad
|
|
@ -1,11 +1,13 @@
|
|||
package com.bonus.imgTool.model;
|
||||
|
||||
import com.bonus.imgTool.base.entity.PageEntity;
|
||||
import com.bonus.imgTool.system.vo.SelectVo;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SysUser extends PageEntity {
|
||||
|
|
@ -149,6 +151,16 @@ public class SysUser extends PageEntity {
|
|||
* 签字路径
|
||||
*/
|
||||
private String signImg;
|
||||
private List<SelectVo> projects;
|
||||
/**
|
||||
* 绑定工程
|
||||
*/
|
||||
private String project;
|
||||
/**
|
||||
* 角色级别
|
||||
*/
|
||||
private String levelName;
|
||||
private String keyWord;
|
||||
|
||||
/**
|
||||
* 角色级别
|
||||
|
|
|
|||
|
|
@ -73,6 +73,18 @@ public class SelectController {
|
|||
}
|
||||
return ServerResponse.createErroe("操作失败");
|
||||
}
|
||||
@GetMapping(value = "getProjectSelect")
|
||||
@DecryptAndVerify(decryptedClass = SelectDto.class)//加解密统一管理
|
||||
@LogAnnotation(operModul = "工程查询", operation = "下拉框", operDesc = "系统级事件",operType="查询")
|
||||
public ServerResponse getProjectSelect(EncryptedReq<SelectDto> data) {
|
||||
try {
|
||||
List<SelectVo> list = service.getProjectSelect(data.getData());
|
||||
return ServerResponse.createSuccess(list);
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return ServerResponse.createErroe("操作失败");
|
||||
}
|
||||
|
||||
|
||||
private void setDictsList(Long pId, List<Dict> dictsAll, List<Dict> list) {
|
||||
|
|
|
|||
|
|
@ -10,10 +10,7 @@ import java.util.Objects;
|
|||
import com.bonus.imgTool.annotation.DecryptAndVerify;
|
||||
import com.bonus.imgTool.model.Role;
|
||||
import com.bonus.imgTool.system.dao.UserDao;
|
||||
import com.bonus.imgTool.system.vo.EncryptedReq;
|
||||
import com.bonus.imgTool.system.vo.Org;
|
||||
import com.bonus.imgTool.system.vo.SysMenuVo;
|
||||
import com.bonus.imgTool.system.vo.UserDto;
|
||||
import com.bonus.imgTool.system.vo.*;
|
||||
import com.bonus.imgTool.model.PasswordConfig;
|
||||
import com.bonus.imgTool.model.SysUser;
|
||||
import com.bonus.imgTool.system.service.UserService;
|
||||
|
|
@ -140,13 +137,14 @@ public class UserController {
|
|||
if (u != null && !Objects.equals(data.getData().getId(), u.getId())) {
|
||||
return ServerResponse.createErroe(data.getData().getLoginName() + "已存在");
|
||||
}
|
||||
if(StringHelper.isNotEmpty(data.getData().getPhone())){
|
||||
/* if(StringHelper.isNotEmpty(data.getData().getPhone())){
|
||||
SysUser u2 = userService.getPhone(data.getData().getPhone());
|
||||
if (u2 != null && !Objects.equals(data.getData().getId(), u2.getId())) {
|
||||
return ServerResponse.createErroe("手机号"+data.getData().getPhone() + "已存在");
|
||||
}
|
||||
}
|
||||
}*/
|
||||
userService.updateUser(data.getData());
|
||||
// 先删除对应的工程再新增
|
||||
return ServerResponse.createBySuccessMsg("操作成功");
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
|
|
@ -168,6 +166,18 @@ public class UserController {
|
|||
}
|
||||
return ServerResponse.createErroe("操作失败");
|
||||
}
|
||||
@PostMapping(value = "checkPassword")
|
||||
@DecryptAndVerify(decryptedClass = SysUser.class)
|
||||
@LogAnnotation(operModul = "系统管理-用户管理", operation = "校验用户名密码", operDesc = "系统级事件",operType="查询")
|
||||
public ServerResponse checkPassword(EncryptedReq<SysUser> data) {
|
||||
try {
|
||||
ServerResponse response = userService.checkPassword(data.getData());
|
||||
return response;
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return ServerResponse.createErroe("操作失败");
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "password")
|
||||
|
|
@ -214,7 +224,9 @@ public class UserController {
|
|||
public ServerResponse user(EncryptedReq<UserDto> data) {
|
||||
try {
|
||||
UserDto userDto = userService.getById(data.getData().getId());
|
||||
String loginType = userDto.getLoginType();
|
||||
List<SelectVo> projects = userService.getProjects(userDto);
|
||||
userDto.setProjects(projects);
|
||||
/*String loginType = userDto.getLoginType();
|
||||
if (loginType != null && !loginType.isEmpty()){
|
||||
String[] loginTypeArr = loginType.split(",");
|
||||
List<Long> loginTypes = new ArrayList<>();
|
||||
|
|
@ -222,7 +234,7 @@ public class UserController {
|
|||
loginTypes.add(Long.parseLong(type.trim()));
|
||||
}
|
||||
userDto.setLoginTypes(loginTypes);
|
||||
}
|
||||
}*/
|
||||
return ServerResponse.createSuccess(userDto);
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
|
|
|
|||
|
|
@ -14,4 +14,6 @@ public interface SelectDao {
|
|||
List<SelectVo> getProfessionSelect(SelectDto data);
|
||||
|
||||
List<SelectVo> getProcessSelect(SelectDto data);
|
||||
|
||||
List<SelectVo> getProjectSelect(SelectDto data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,7 @@ import java.util.Map;
|
|||
|
||||
import com.bonus.imgTool.base.entity.DtreeVo;
|
||||
import com.bonus.imgTool.model.Role;
|
||||
import com.bonus.imgTool.system.vo.LoginUser;
|
||||
import com.bonus.imgTool.system.vo.Org;
|
||||
import com.bonus.imgTool.system.vo.SysMenuVo;
|
||||
import com.bonus.imgTool.system.vo.UserDto;
|
||||
import com.bonus.imgTool.system.vo.*;
|
||||
import com.bonus.imgTool.model.PasswordConfig;
|
||||
import com.bonus.imgTool.model.SysUser;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
|
|
@ -197,4 +194,10 @@ public interface UserDao {
|
|||
* @return
|
||||
*/
|
||||
List<SysUser> getPersonList(SysUser data);
|
||||
|
||||
Integer deleteUserProject(Long id);
|
||||
|
||||
Integer saveUserProject(@Param("userId") Long id, @Param("proId")String proId);
|
||||
|
||||
List<SelectVo> getProjects(UserDto userDto);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,4 +15,6 @@ public interface SelectService {
|
|||
List<SelectVo> getProfessionSelect(SelectDto data);
|
||||
|
||||
List<SelectVo> getProcessSelect(SelectDto data);
|
||||
|
||||
List<SelectVo> getProjectSelect(SelectDto data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.bonus.imgTool.system.service;
|
|||
|
||||
import com.bonus.imgTool.model.Role;
|
||||
import com.bonus.imgTool.system.vo.Org;
|
||||
import com.bonus.imgTool.system.vo.SelectVo;
|
||||
import com.bonus.imgTool.system.vo.SysMenuVo;
|
||||
import com.bonus.imgTool.system.vo.UserDto;
|
||||
import com.bonus.imgTool.model.PasswordConfig;
|
||||
|
|
@ -51,9 +52,8 @@ public interface UserService {
|
|||
* @param user
|
||||
* @return
|
||||
*/
|
||||
default ServerResponse changePassword(SysUser user) {
|
||||
return null;
|
||||
}
|
||||
ServerResponse changePassword(SysUser user);
|
||||
ServerResponse checkPassword(SysUser user);
|
||||
|
||||
/**
|
||||
* 管理员修改密码
|
||||
|
|
@ -168,4 +168,6 @@ public interface UserService {
|
|||
* @return
|
||||
*/
|
||||
List<SysUser> getPersonList(SysUser data);
|
||||
|
||||
List<SelectVo> getProjects(UserDto userDto);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,4 +40,9 @@ public class SelectServiceImpl implements SelectService {
|
|||
public List<SelectVo> getProcessSelect(SelectDto data) {
|
||||
return dao.getProcessSelect(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SelectVo> getProjectSelect(SelectDto data) {
|
||||
return dao.getProjectSelect(data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,13 @@ import com.bonus.imgTool.base.entity.DtreeVo;
|
|||
import com.bonus.imgTool.model.Role;
|
||||
import com.bonus.imgTool.system.vo.Org;
|
||||
import com.bonus.imgTool.model.PasswordConfig;
|
||||
import com.bonus.imgTool.system.vo.SelectVo;
|
||||
import com.bonus.imgTool.system.vo.SysMenuVo;
|
||||
import com.bonus.imgTool.utils.ServerResponse;
|
||||
import com.bonus.imgTool.utils.StringHelper;
|
||||
import com.bonus.imgTool.utils.UserUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -33,258 +35,295 @@ import javax.annotation.Resource;
|
|||
public class UserServiceImpl implements UserService {
|
||||
|
||||
|
||||
@Resource
|
||||
private UserDao userDao;
|
||||
@Autowired
|
||||
private BCryptPasswordEncoder passwordEncoder;
|
||||
@Resource
|
||||
private UserDao userDao;
|
||||
@Autowired
|
||||
private BCryptPasswordEncoder passwordEncoder;
|
||||
|
||||
/**
|
||||
* 新增用户
|
||||
*/
|
||||
@Override
|
||||
public ServerResponse saveUser(UserDto userDto) {
|
||||
try{
|
||||
SysUser user = userDto;
|
||||
user.setPassword(passwordEncoder.encode(user.getPassword()));
|
||||
int num=userDao.saveUser(user);
|
||||
if(num>0){
|
||||
return ServerResponse.createSuccess("新增成功",num);
|
||||
}else{
|
||||
return ServerResponse.createErroe("新增失败");
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return ServerResponse.createErroe("新增失败,数据异常");
|
||||
}
|
||||
private void saveUserRoles(Long userId, List<Long> roleIds) {
|
||||
if (roleIds != null) {
|
||||
userDao.deleteUserRole(userId);
|
||||
if (!CollectionUtils.isEmpty(roleIds)) {
|
||||
userDao.saveUserRoles(userId, roleIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 新增用户
|
||||
*/
|
||||
@Override
|
||||
public ServerResponse saveUser(UserDto userDto) {
|
||||
try {
|
||||
String project = userDto.getProject();
|
||||
SysUser user = userDto;
|
||||
user.setPassword(passwordEncoder.encode(user.getPassword()));
|
||||
int num = userDao.saveUser(user);
|
||||
if (StringUtils.isNotBlank(project)){
|
||||
for (String proId : project.split(",")) {
|
||||
// 新增工程
|
||||
userDao.saveUserProject(userDto.getId(), proId);
|
||||
}
|
||||
}
|
||||
if (num > 0) {
|
||||
return ServerResponse.createSuccess("新增成功", num);
|
||||
} else {
|
||||
return ServerResponse.createErroe("新增失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return ServerResponse.createErroe("新增失败,数据异常");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUser getUser(String loginName) {
|
||||
try{
|
||||
return userDao.getUser(loginName);
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private void saveUserRoles(Long userId, List<Long> roleIds) {
|
||||
if (roleIds != null) {
|
||||
userDao.deleteUserRole(userId);
|
||||
if (!CollectionUtils.isEmpty(roleIds)) {
|
||||
userDao.saveUserRoles(userId, roleIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUser getUserCode(String userCode) {
|
||||
try{
|
||||
return userDao.getUserCode(userCode);
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public SysUser getUser(String loginName) {
|
||||
try {
|
||||
return userDao.getUser(loginName);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerResponse changePassword(SysUser user) {
|
||||
Long userId = UserUtil.getLoginUser().getId();
|
||||
UserDto bean = userDao.getById(userId);
|
||||
SysUser u = userDao.getUser(bean.getLoginName());
|
||||
if (u == null) {
|
||||
return ServerResponse.createErroe("用户不存在");
|
||||
}
|
||||
if (!passwordEncoder.matches(user.getOldP(), u.getPassword())) {
|
||||
return ServerResponse.createErroe("旧密码错误");
|
||||
}
|
||||
userDao.changePassword(u.getId(), passwordEncoder.encode(user.getNewP1()));
|
||||
return ServerResponse.createBySuccessMsg("修改成功");
|
||||
}
|
||||
@Override
|
||||
public SysUser getUserCode(String userCode) {
|
||||
try {
|
||||
return userDao.getUserCode(userCode);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void password(SysUser user) {
|
||||
user.setPassword(passwordEncoder.encode(user.getPassword()));
|
||||
userDao.password(user);
|
||||
}
|
||||
@Override
|
||||
public ServerResponse changePassword(SysUser user) {
|
||||
Long userId = UserUtil.getLoginUser().getId();
|
||||
UserDto bean = userDao.getById(userId);
|
||||
SysUser u = userDao.getUser(bean.getLoginName());
|
||||
if (u == null) {
|
||||
return ServerResponse.createErroe("用户不存在");
|
||||
}
|
||||
if (!passwordEncoder.matches(user.getOldP(), u.getPassword())) {
|
||||
return ServerResponse.createErroe("旧密码错误");
|
||||
}
|
||||
userDao.changePassword(u.getId(), passwordEncoder.encode(user.getNewP1()));
|
||||
return ServerResponse.createBySuccessMsg("修改成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Map<String, Object> params) {
|
||||
return userDao.count(params);
|
||||
}
|
||||
@Override
|
||||
public ServerResponse checkPassword(SysUser user) {
|
||||
Long userId = UserUtil.getLoginUser().getId();
|
||||
UserDto bean = userDao.getById(userId);
|
||||
SysUser u = userDao.getUser(bean.getLoginName());
|
||||
if (u == null) {
|
||||
return ServerResponse.createByErrorMsg(500,"用户不存在");
|
||||
}
|
||||
if (!passwordEncoder.matches(user.getOldP(), u.getPassword())) {
|
||||
return ServerResponse.createByErrorMsg(500,"旧密码错误");
|
||||
}
|
||||
return ServerResponse.createSuccess("校验成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysUser> list(SysUser user) {
|
||||
List<SysUser> list = userDao.list(user);
|
||||
if (list.size()>0){
|
||||
for (SysUser users : list){
|
||||
//如果班组为不空,则拼接;否则只展示组织
|
||||
if (StringHelper.isNotEmpty(users.getTeamName())){
|
||||
users.setOrgName(users.getOrgName()+"/"+users.getTeamName());
|
||||
}
|
||||
if (StringHelper.isNotEmpty(users.getSignImg())){
|
||||
users.setSignStatus("已签");
|
||||
} else {
|
||||
users.setSignStatus("未签");
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@Override
|
||||
public void password(SysUser user) {
|
||||
user.setPassword(passwordEncoder.encode(user.getPassword()));
|
||||
userDao.password(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户详情
|
||||
*/
|
||||
@Override
|
||||
public UserDto getById(Long id) {
|
||||
return userDao.getById(id);
|
||||
}
|
||||
@Override
|
||||
public int count(Map<String, Object> params) {
|
||||
return userDao.count(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delUser(Long id) {
|
||||
return userDao.delUser(id);
|
||||
}
|
||||
/**
|
||||
* 查询用户列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysUser> list(SysUser user) {
|
||||
List<SysUser> list = userDao.list(user);
|
||||
if (list.size() > 0) {
|
||||
for (SysUser users : list) {
|
||||
//如果班组为不空,则拼接;否则只展示组织
|
||||
if (StringHelper.isNotEmpty(users.getTeamName())) {
|
||||
users.setOrgName(users.getOrgName() + "/" + users.getTeamName());
|
||||
}
|
||||
if (StringHelper.isNotEmpty(users.getSignImg())) {
|
||||
users.setSignStatus("已签");
|
||||
} else {
|
||||
users.setSignStatus("未签");
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PasswordConfig getPasswordConfigById() {
|
||||
return userDao.getPasswordConfigById();
|
||||
}
|
||||
/**
|
||||
* 查询用户详情
|
||||
*/
|
||||
@Override
|
||||
public UserDto getById(Long id) {
|
||||
return userDao.getById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Org> getOrg() {
|
||||
return userDao.getOrg();
|
||||
}
|
||||
@Override
|
||||
public int delUser(Long id) {
|
||||
return userDao.delUser(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUser getPhone(String phone) {
|
||||
return userDao.getPhone(phone);
|
||||
}
|
||||
@Override
|
||||
public PasswordConfig getPasswordConfigById() {
|
||||
return userDao.getPasswordConfigById();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询锁定的用户
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<SysUser> getLockUser(String state,String type) {
|
||||
try{
|
||||
return userDao.getLockUser(state, type);
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public List<Org> getOrg() {
|
||||
return userDao.getOrg();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUserState(String loginName, String state,String delFlag,Long id) {
|
||||
try{
|
||||
userDao.updateUserState(loginName, state,delFlag, id);
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public SysUser getPhone(String phone) {
|
||||
return userDao.getPhone(phone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerResponse getOrgTree() {
|
||||
List<DtreeVo> list = null;
|
||||
try {
|
||||
list = userDao.getOrgTree();
|
||||
} catch (Exception e) {
|
||||
log.error("单位部门树", e);
|
||||
}
|
||||
return ServerResponse.createSuccess("查询成功", list);
|
||||
}
|
||||
/**
|
||||
* 查询锁定的用户
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<SysUser> getLockUser(String state, String type) {
|
||||
try {
|
||||
return userDao.getLockUser(state, type);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改启用状态
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ServerResponse updateEnableState(UserDto data) {
|
||||
try {
|
||||
if (data.getId() == 0 || data.getState() == null) {
|
||||
return ServerResponse.createErroe("参数不能为空");
|
||||
} else {
|
||||
int num = userDao.updateEnableState(data);
|
||||
if (num == 1) {
|
||||
if (data.getState()==1) {
|
||||
return ServerResponse.createSuccess("开启成功");
|
||||
}
|
||||
return ServerResponse.createSuccess("关闭成功");
|
||||
} else {
|
||||
return ServerResponse.createErroe("设置失败,请联系管理员");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return ServerResponse.createErroe("参数异常,请联系管理员");
|
||||
}
|
||||
@Override
|
||||
public void updateUserState(String loginName, String state, String delFlag, Long id) {
|
||||
try {
|
||||
userDao.updateUserState(loginName, state, delFlag, id);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Role> getRoleAll() {
|
||||
return userDao.getRoleAll();
|
||||
}
|
||||
@Override
|
||||
public ServerResponse getOrgTree() {
|
||||
List<DtreeVo> list = null;
|
||||
try {
|
||||
list = userDao.getOrgTree();
|
||||
} catch (Exception e) {
|
||||
log.error("单位部门树", e);
|
||||
}
|
||||
return ServerResponse.createSuccess("查询成功", list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色下App权限菜单
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenuVo> getRoleAppAuth() {
|
||||
//获取当前登录用户角色编码
|
||||
String roleCode = UserUtil.getLoginUser() != null ? UserUtil.getLoginUser().getRoleCode() : "";
|
||||
return userDao.getRoleAppAuth(roleCode);
|
||||
}
|
||||
/**
|
||||
* 修改启用状态
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ServerResponse updateEnableState(UserDto data) {
|
||||
try {
|
||||
if (data.getId() == 0 || data.getState() == null) {
|
||||
return ServerResponse.createErroe("参数不能为空");
|
||||
} else {
|
||||
int num = userDao.updateEnableState(data);
|
||||
if (num == 1) {
|
||||
if (data.getState() == 1) {
|
||||
return ServerResponse.createSuccess("开启成功");
|
||||
}
|
||||
return ServerResponse.createSuccess("关闭成功");
|
||||
} else {
|
||||
return ServerResponse.createErroe("设置失败,请联系管理员");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return ServerResponse.createErroe("参数异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存签名
|
||||
*/
|
||||
@Override
|
||||
public int updateSign(UserDto userDto) {
|
||||
return userDao.updateSign(userDto);
|
||||
}
|
||||
@Override
|
||||
public List<Role> getRoleAll() {
|
||||
return userDao.getRoleAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delSignById(Long id) {
|
||||
return userDao.delSignById(id);
|
||||
}
|
||||
/**
|
||||
* 获取角色下App权限菜单
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenuVo> getRoleAppAuth() {
|
||||
//获取当前登录用户角色编码
|
||||
String roleCode = UserUtil.getLoginUser() != null ? UserUtil.getLoginUser().getRoleCode() : "";
|
||||
return userDao.getRoleAppAuth(roleCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUser> getPersonList(SysUser data) {
|
||||
//获取登录人id
|
||||
Long userId = UserUtil.getLoginUser().getId();
|
||||
data.setId(userId);
|
||||
List<SysUser> list = userDao.getPersonList(data);
|
||||
if (list.size() > 0) {
|
||||
for (SysUser users : list) {
|
||||
if (StringHelper.isNotEmpty(users.getSignImg())) {
|
||||
users.setSignStatus("已签");
|
||||
} else {
|
||||
users.setSignStatus("未签");
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
* 保存签名
|
||||
*/
|
||||
@Override
|
||||
public int updateSign(UserDto userDto) {
|
||||
return userDao.updateSign(userDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public SysUser updateUser(UserDto userDto) {
|
||||
if (userDto.getRoleId().isEmpty()){
|
||||
userDto.setRoleId(null);
|
||||
}
|
||||
if (StringHelper.isEmpty(userDto.getTeamId())){
|
||||
userDto.setTeamId(null);
|
||||
}
|
||||
userDao.update(userDto);
|
||||
//saveUserRoles(userDto.getId(), userDto.getRoleIds());
|
||||
@Override
|
||||
public int delSignById(Long id) {
|
||||
return userDao.delSignById(id);
|
||||
}
|
||||
|
||||
return userDto;
|
||||
}
|
||||
@Override
|
||||
public List<SysUser> getPersonList(SysUser data) {
|
||||
//获取登录人id
|
||||
Long userId = UserUtil.getLoginUser().getId();
|
||||
data.setId(userId);
|
||||
List<SysUser> list = userDao.getPersonList(data);
|
||||
if (list.size() > 0) {
|
||||
for (SysUser users : list) {
|
||||
if (StringHelper.isNotEmpty(users.getSignImg())) {
|
||||
users.setSignStatus("已签");
|
||||
} else {
|
||||
users.setSignStatus("未签");
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SelectVo> getProjects(UserDto userDto) {
|
||||
return userDao.getProjects(userDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public SysUser updateUser(UserDto userDto) {
|
||||
String project = userDto.getProject();
|
||||
if (userDto.getRoleId().isEmpty()) {
|
||||
userDto.setRoleId(null);
|
||||
}
|
||||
if (StringHelper.isEmpty(userDto.getTeamId())) {
|
||||
userDto.setTeamId(null);
|
||||
}
|
||||
userDao.update(userDto);
|
||||
// saveUserRoles(userDto.getId(), userDto.getRoleIds());
|
||||
// 先删除之前绑定的工程
|
||||
userDao.deleteUserProject(userDto.getId());
|
||||
if (StringUtils.isNotBlank(project)){
|
||||
for (String proId : project.split(",")) {
|
||||
// 在新增修改后的工程
|
||||
userDao.saveUserProject(userDto.getId(), proId);
|
||||
}
|
||||
}
|
||||
return userDto;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,12 @@
|
|||
major_id = #{pid}
|
||||
</where>
|
||||
</select>
|
||||
<select id="getProjectSelect" resultType="com.bonus.imgTool.system.vo.SelectVo">
|
||||
select
|
||||
t.id,
|
||||
t.name
|
||||
from tb_project t where is_active = 1
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@
|
|||
set sign_img=null
|
||||
where id = #{id}
|
||||
</delete>
|
||||
<delete id="deleteUserProject">
|
||||
delete from tb_pro_user
|
||||
where user_id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="getLockUser" resultType="com.bonus.imgTool.model.SysUser">
|
||||
select user_name userName,login_name loginName,ls_time lsTime ,
|
||||
|
|
@ -134,6 +138,10 @@
|
|||
t.org_id as orgId,
|
||||
so.org_name as orgName,
|
||||
sr.role_name roleName,
|
||||
case when sr.level = 0 then '项目部级'
|
||||
when sr.level = 1 then '公司级'
|
||||
else ''
|
||||
end as levelName,
|
||||
t.team_id as teamId,
|
||||
CASE
|
||||
t.user_type
|
||||
|
|
@ -151,19 +159,13 @@
|
|||
LEFT JOIN sys_role sr ON sr.role_id = t.role_id
|
||||
LEFT JOIN sys_org so ON so.org_id = t.org_id
|
||||
where t.del_flag = 0
|
||||
<if test="username != null and username != ''">
|
||||
and t.user_name like concat('%', #{username}, '%')
|
||||
<if test="keyWord!=null and keyWord!=''">
|
||||
AND (
|
||||
INSTR(t.user_name,#{keyWord}) > 0 OR
|
||||
INSTR(t.login_name,#{keyWord}) > 0
|
||||
)
|
||||
</if>
|
||||
<if test="phone != null and phone != ''">
|
||||
and t.phone like concat('%', #{phone}, '%')
|
||||
</if>
|
||||
<if test="orgId != null and orgId != ''">
|
||||
and t.org_id = #{orgId}
|
||||
</if>
|
||||
<if test="userType != null and userType != ''">
|
||||
and t.user_type = #{userType}
|
||||
</if>
|
||||
order by t.del_flag ASC , t.state,t.create_time DESC
|
||||
order by t.del_flag ASC , t.state,t.create_time DESC
|
||||
</select>
|
||||
<select id="getPasswordConfigById" resultType="com.bonus.imgTool.model.PasswordConfig">
|
||||
select pwd_strength as pwdStrength,
|
||||
|
|
@ -175,6 +177,7 @@
|
|||
<select id="getById" resultType="com.bonus.imgTool.system.vo.UserDto">
|
||||
select id,
|
||||
user_name as username,
|
||||
password,
|
||||
login_name as loginName,
|
||||
sex,
|
||||
user_code as userCode,
|
||||
|
|
@ -279,13 +282,23 @@
|
|||
and t.id=#{id}
|
||||
order by t.del_flag ASC , t.state,t.create_time DESC
|
||||
</select>
|
||||
<select id="getProjects" resultType="com.bonus.imgTool.system.vo.SelectVo">
|
||||
select p.id,
|
||||
p.name
|
||||
from tb_pro_user t
|
||||
left join tb_project p on t.pro_id = p.id
|
||||
where t.user_id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="saveUserRoles">
|
||||
<insert id="saveUserRoles">
|
||||
insert into sys_role_user(roleId, userId) values
|
||||
<foreach collection="roleIds" item="roleId" separator=",">
|
||||
(#{roleId}, #{userId})
|
||||
</foreach>
|
||||
</insert>
|
||||
<insert id="saveUserProject">
|
||||
insert into tb_pro_user(user_id, pro_id) values (#{userId}, #{proId})
|
||||
</insert>
|
||||
|
||||
<update id="update">
|
||||
update sys_user t
|
||||
|
|
@ -295,11 +308,9 @@
|
|||
t.sex = #{sex},
|
||||
t.org_id = #{orgId},
|
||||
t.role_id = #{roleId},
|
||||
t.phone = #{phone},
|
||||
t.user_type = #{userType},
|
||||
t.login_type = #{loginType},
|
||||
t.team_id = #{teamId},
|
||||
t.state = #{state},
|
||||
t.update_time = now()
|
||||
where t.id = #{id}
|
||||
</update>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
let form, layer, dtree, util, idParam, phoneParam;
|
||||
let form, layer, dtree, util, idParam, phoneParam, formSelects;
|
||||
let arr = ['background', 'web', 'mobile', 'wx'];
|
||||
let background, web, mobile, wx;
|
||||
let data = [], appResList = [];
|
||||
|
|
@ -12,13 +12,15 @@ function setParams(params) {
|
|||
console.log(params)
|
||||
idParam = JSON.parse(params).id;
|
||||
layui.config({
|
||||
base: "../../../js/layui-v2.6.8/dtree/", //此处路径请自行处理, 可以使用绝对路径
|
||||
base: "../../../js/layui-v2.6.8/"
|
||||
}).extend({
|
||||
dtree: 'dtree'
|
||||
}).use(['form', 'layer', 'dtree', 'util'], function () {
|
||||
dtree: 'dtree/dtree',
|
||||
formSelects: 'formSelects-v4',
|
||||
}).use(['form', 'layer', 'dtree', 'util', 'formSelects'], function () {
|
||||
layer = layui.layer;
|
||||
form = layui.form;
|
||||
util = layui.util;
|
||||
formSelects = layui.formSelects;
|
||||
dtree = layui.dtree;
|
||||
var $ = layui.jquery;
|
||||
roleList = getRoleSelected();
|
||||
|
|
@ -123,11 +125,11 @@ function getRoleSelected() {
|
|||
* 获取工程数据
|
||||
*/
|
||||
function getProSelected() {
|
||||
let url = dataUrl + '/users/getRoleAll';
|
||||
ajaxRequest(url, "POST", null, true, function () {
|
||||
let url = dataUrl + '/sys/select/getProjectSelect';
|
||||
ajaxRequest(url, "GET", null, true, function () {
|
||||
}, function (result) {
|
||||
if (result.code === 200) {
|
||||
setSelectValue(result.data, 'project');
|
||||
setProjectValue(result.data);
|
||||
} else {
|
||||
layer.alert(result.msg, {icon: 2})
|
||||
}
|
||||
|
|
@ -163,6 +165,21 @@ function setSelectValue(list, selectName) {
|
|||
layui.form.render();
|
||||
}
|
||||
|
||||
function setProjectValue(data) {
|
||||
let keys = [];
|
||||
$.each(data, function (index, item) {
|
||||
let temp = {
|
||||
"name": item.name,
|
||||
"value": item.id
|
||||
};
|
||||
keys.push(temp);
|
||||
})
|
||||
formSelects.data('project', 'local', {
|
||||
arr: keys
|
||||
});
|
||||
layui.form.render('select'); // 重新渲染 select 组件
|
||||
}
|
||||
|
||||
|
||||
// function setOrgTree(data){
|
||||
// orgTree = dtree.renderSelect({
|
||||
|
|
@ -249,17 +266,25 @@ function setFormData(data) {
|
|||
document.getElementById('userType_0').checked = true;
|
||||
}*/
|
||||
|
||||
if (data.state === 1) {
|
||||
document.getElementById('state_1').checked = true;
|
||||
} else if (data.state === 0) {
|
||||
document.getElementById('state_0').checked = true;
|
||||
}
|
||||
/* if (data.state === 1) {
|
||||
document.getElementById('state_1').checked = true;
|
||||
} else if (data.state === 0) {
|
||||
document.getElementById('state_0').checked = true;
|
||||
}*/
|
||||
$('#type_' + data.type).attr('checked', true)
|
||||
$('#orgId').val(data.orgId)
|
||||
$('#roleId').val(data.roleId)
|
||||
$('#roleId option[value=' + data.roleId + ']').attr('selected', true)
|
||||
$('#project').val(data.roleId)
|
||||
$('#project option[value=' + data.project + ']').attr('selected', true)
|
||||
if ($('#roleId option:selected').text().includes('项目部级')) {
|
||||
$('#projectDiv').removeClass('layui-hide');
|
||||
} else {
|
||||
$('#projectDiv').addClass('layui-hide');
|
||||
}
|
||||
$('#project').val(data.project)
|
||||
var selectedValues = data.projects.map(function (item) {
|
||||
return item.id;
|
||||
});
|
||||
formSelects.value('project', selectedValues);
|
||||
/*$('#teamId').val(data.teamId)
|
||||
$('#teamId option[value=' + data.teamId + ']').attr('selected', true)*/
|
||||
// var arrCB = data.loginTypes;
|
||||
|
|
@ -284,17 +309,17 @@ function saveData(data) {
|
|||
let loadingMsg = layer.msg('数据上传中,请稍候...', {icon: 16, scrollbar: false, time: 0});
|
||||
let url = dataUrl + "/users/addTemp";
|
||||
let params = data.field;
|
||||
var arr_box = [];//固定复选框
|
||||
$('#cbGuDing input[type=checkbox]:checked').each(function () {
|
||||
arr_box.push($(this).val());
|
||||
});
|
||||
var arr_pro = [];//固定复选框
|
||||
$('#project input[type=checkbox]:checked').each(function () {
|
||||
arr_pro.push($(this).val());
|
||||
});
|
||||
// var arr_box = [];//固定复选框
|
||||
// $('#cbGuDing input[type=checkbox]:checked').each(function () {
|
||||
// arr_box.push($(this).val());
|
||||
// });
|
||||
// var arr_pro = [];//固定复选框
|
||||
// $('#project input[type=checkbox]:checked').each(function () {
|
||||
// arr_pro.push($(this).val());
|
||||
// });
|
||||
|
||||
// params.loginType = arr_box.join()
|
||||
params.project = arr_pro.join()
|
||||
// params.project = arr_pro.join()
|
||||
// params.orgId = params.orgId_select_nodeId;
|
||||
if (params.id != "") {
|
||||
url = dataUrl + "/users/update";
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ function initTable(dataList, limit, page) {
|
|||
// {field: "orgName", title: "单位部门", unresize: true, align: "center"},
|
||||
{field: "roleName", title: "角色", unresize: true, align: "center"},
|
||||
// {field: "phone", title: "联系电话", unresize: true, align: "center"},
|
||||
{field: "userType", title: "用户级别", unresize: true, align: "center"},
|
||||
{field: "levelName", title: "用户级别", unresize: true, align: "center"},
|
||||
{field: "state", title: "启用状态", align: "center", templet: '#is-state'},
|
||||
{field: "createTime", title: "创建时间", unresize: true, align: "center"},
|
||||
{
|
||||
|
|
@ -148,19 +148,13 @@ function getReqParams(page, limit, type) {
|
|||
obj = {
|
||||
page: page + "",
|
||||
limit: limit + "",
|
||||
userName: $('#userName').val(),
|
||||
phone: $('#phone').val(),
|
||||
orgId: selectOrgId,
|
||||
userType: $('#userType').val(),
|
||||
keyWord: $('#keyWord').val(),
|
||||
};
|
||||
} else {
|
||||
obj = {
|
||||
page: '1',
|
||||
limit: '10',
|
||||
userName: '',
|
||||
phone: '',
|
||||
orgId: '',
|
||||
userType: '',
|
||||
keyWord: '',
|
||||
};
|
||||
}
|
||||
console.log(obj)
|
||||
|
|
@ -172,7 +166,7 @@ function getReqParams(page, limit, type) {
|
|||
|
||||
// 查询/重置
|
||||
function query(type) {
|
||||
let pattern = new RegExp("[%_<>]");
|
||||
/* let pattern = new RegExp("[%_<>]");
|
||||
if (pattern.test($("#loginName").val())) {
|
||||
$("#loginName").val('');
|
||||
return layer.msg('用户名查询包含特殊字符,请重新输入', {
|
||||
|
|
@ -186,7 +180,7 @@ function query(type) {
|
|||
icon: 2,
|
||||
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
||||
});
|
||||
}
|
||||
}*/
|
||||
pageNum = 1;
|
||||
pages(1, limitSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="../../../js/layui-v2.6.8/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="../../../js/layui-v2.6.8/dtree/dtree.css">
|
||||
<link href="../../../js/layui-v2.6.8/formSelects-v4.css" rel="stylesheet" type="text/css"/>
|
||||
<link rel="stylesheet" href="../../../js/layui-v2.6.8/dtree/font/dtreefont.css">
|
||||
<link rel="stylesheet" href="../../../css/dataForm.css">
|
||||
<script src="../../../js/libs/jquery-3.7.0.min.js" charset="UTF-8" type="text/javascript"></script>
|
||||
|
|
@ -64,7 +65,9 @@
|
|||
<div class="layui-form-item layui-hide" id="projectDiv">
|
||||
<label class="layui-form-label"><i style="padding: 0 10px;">*</i>管理的工程</label>
|
||||
<div class="layui-input-inline">
|
||||
<select id="project" lay-verify="required" name="project" class="form-control input-sm">
|
||||
<!-- <select id="project" lay-verify="required" name="project" class="form-control input-sm">-->
|
||||
<!-- </select>-->
|
||||
<select class="layui-select" name="project" id="project" xm-select="project" xm-select-show-count='3'>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -13,16 +13,16 @@
|
|||
<fieldset>
|
||||
<input type="hidden" id="id" name="id">
|
||||
<div class="layui-form-item" style="margin-top: 2%;">
|
||||
<label class="layui-form-label"><i style="padding: 0 10px;">*</i>用户名</label>
|
||||
<label class="layui-form-label"><i style="padding: 0 10px;">*</i>登录账号</label>
|
||||
<div class="layui-input-inline">
|
||||
<input class="form-control layui-input" placeholder="用户名" type="text" name="username" disabled id="username" maxlength="30"
|
||||
<input class="form-control layui-input" placeholder="登录账号" type="text" name="loginName" disabled id="loginName" maxlength="30"
|
||||
lay-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" style="margin-top: 2%;">
|
||||
<label class="layui-form-label"><i style="padding: 0 10px;">*</i>登录名</label>
|
||||
<label class="layui-form-label"><i style="padding: 0 10px;">*</i>姓名</label>
|
||||
<div class="layui-input-inline">
|
||||
<input class="form-control layui-input" placeholder="登录名" type="text" name="loginName" disabled id="loginName" maxlength="30"
|
||||
<input class="form-control layui-input" placeholder="姓名" type="text" name="username" disabled id="username" maxlength="30"
|
||||
lay-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue