Commit 3ab4c4d7 authored by 赵啸非's avatar 赵啸非

添加目录字段

parent 03610017
package com.mortals.xhx.base.system.user.model;
import com.mortals.framework.annotation.desensitization.MobileDesensitize;
import com.mortals.framework.ap.SysConstains;
import com.mortals.framework.service.IUser;
import com.mortals.xhx.base.system.user.model.vo.UserVo;
......@@ -35,7 +34,6 @@ public class UserEntity extends UserVo implements IUser {
/**
* 用户手机号
*/
@MobileDesensitize
private String mobile;
/**
* 用户联系电话
......@@ -49,20 +47,14 @@ public class UserEntity extends UserVo implements IUser {
* QQ号码
*/
private String qq;
/**
* 用户类型(0.系统用户,1.普通用户,2.工作人员,3.巡查人员,4.窗口负责人)
*/
private Integer userType;
/**
* 用户所属部门id
*/
private Long deptId;
private String deptName;
/**
* 所属部门名称
* 用户类型(0.系统用户,1.普通用户,2.工作人员)
*/
private String deptName;
private Integer userType;
/**
* 所属站点id,多个逗号分隔
*/
......@@ -88,16 +80,20 @@ public class UserEntity extends UserVo implements IUser {
*/
private String lastLoginAddress;
/**
* 员工id
*/
private Long customerId;
/**
* 钉钉userId
*/
private String dingUserId;
public UserEntity(){}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
public String getDingUserId() {
return dingUserId;
}
......@@ -106,7 +102,6 @@ public class UserEntity extends UserVo implements IUser {
this.dingUserId = dingUserId;
}
public UserEntity(){}
/**
* 获取 登录名
* @return String
......@@ -128,15 +123,6 @@ public class UserEntity extends UserVo implements IUser {
public String getLoginPwd(){
return loginPwd;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
/**
* 设置 登录密码,使用md5双次加密
* @param loginPwd
......@@ -169,7 +155,6 @@ public class UserEntity extends UserVo implements IUser {
@Override
public boolean isAdmin() {
return super.getId() == null ? false : super.getId().longValue() == SysConstains.ADMIN_ID;
// return true;
}
@Override
......@@ -246,7 +231,7 @@ public class UserEntity extends UserVo implements IUser {
this.qq = qq;
}
/**
* 获取 用户类型(0.系统用户,1.普通用户,2.工作人员,3.普通员工)
* 获取 用户类型(0.系统用户,1.普通用户,2.工作人员)
* @return Integer
*/
public Integer getUserType(){
......@@ -262,17 +247,17 @@ public class UserEntity extends UserVo implements IUser {
@Override
public Long getDeptId() {
return this.deptId;
return deptId;
}
@Override
public String getDeptName() {
return this.deptName;
return deptName;
}
@Override
public Long getCustomerId() {
return this.customerId;
return null;
}
@Override
......@@ -377,9 +362,7 @@ public class UserEntity extends UserVo implements IUser {
}
public void setCustomerId(Long customerId) {
this.customerId = customerId;
}
@Override
public int hashCode() {
......
package com.mortals.xhx.base.system.user.model;
import com.mortals.framework.model.BaseEntityLong;
import lombok.Data;
/**
* Description:User
* date: 2021-9-26 16:11:48
*/
@Data
public class UserEntityExt extends BaseEntityLong {
/**
* 站点名称
*/
private String siteName;
private String roleIds;
/**
* 唯一标识
*/
private String token;
/**
* 菜单栏
*/
private String menuUrl;
/**
* 登录时间
*/
private Long loginTime;
/**
* 过期时间
*/
private Long expireTime;
private Long deptId;
private String deptName;
}
\ No newline at end of file
......@@ -4,8 +4,6 @@ package com.mortals.xhx.base.system.user.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import lombok.Data;
import java.util.List;
/**
* 用户信息业务视图对象
*
......@@ -19,7 +17,7 @@ public class UserVo extends BaseEntityLong {
*/
private String siteName;
private List<Long> roleIds;
private String roleIds;
/**
* 唯一标识
*/
......@@ -38,6 +36,4 @@ public class UserVo extends BaseEntityLong {
* 过期时间
*/
private Long expireTime;
String roleIdStrs;
}
\ No newline at end of file
......@@ -8,6 +8,7 @@
package com.mortals.xhx.base.system.user.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Result;
import com.mortals.framework.service.ICRUDCacheService;
......@@ -38,7 +39,7 @@ public interface UserService extends ICRUDCacheService<UserEntity,Long> {
* @return
* @throws AppException
*/
public UserEntity doLogin(String loginName, String password, String loginIp) throws AppException;
UserEntity doLogin(String loginName, String password, String loginIp) throws AppException;
/**
* 校验用户名与密码是否正确
......@@ -48,7 +49,7 @@ public interface UserService extends ICRUDCacheService<UserEntity,Long> {
* @return
* @throws AppException
*/
public UserEntity doCheckUser(String loginName, String password) throws AppException;
UserEntity doCheckUser(String loginName, String password) throws AppException;
/**
* 检查用户是否存在
......@@ -57,7 +58,7 @@ public interface UserService extends ICRUDCacheService<UserEntity,Long> {
* @param userId 密码
* @return
*/
public boolean existUser(String loginName, Long userId) throws AppException;
boolean existUser(String loginName, Long userId) throws AppException;
/**
* 通过登录用户获取菜单功能权限
......@@ -65,7 +66,7 @@ public interface UserService extends ICRUDCacheService<UserEntity,Long> {
* @param user
* @return
*/
public List<MenuEntity> findOutlookBarList(IUser user);
List<MenuEntity> findOutlookBarList(IUser user);
/**
* 查询用户所有有权限的菜单ID
......@@ -73,7 +74,7 @@ public interface UserService extends ICRUDCacheService<UserEntity,Long> {
* @param userEntity
* @return
*/
public Set<Long> findAllAuthIds(UserEntity userEntity) throws AppException;
Set<Long> findAllAuthIds(UserEntity userEntity) throws AppException;
/**
* 查询用户记录
......@@ -85,7 +86,7 @@ public interface UserService extends ICRUDCacheService<UserEntity,Long> {
* @return
* @throws AppException
*/
public Result<UserEntity> find(Long platformId, UserEntity params, int currPage, int prePageResult) throws AppException;
Result<UserEntity> find(Long platformId, UserEntity params, int currPage, int prePageResult) throws AppException;
/**
* 为客户创建用户
......@@ -100,7 +101,7 @@ public interface UserService extends ICRUDCacheService<UserEntity,Long> {
* @return
* @throws AppException
*/
public UserEntity createUser(IUser currUser, Long customerId, String customerName, String loginName, String password,
UserEntity createUser(IUser currUser, Long customerId, String customerName, String loginName, String password,
String userName, String mobile) throws AppException;
/**
......@@ -112,32 +113,11 @@ public interface UserService extends ICRUDCacheService<UserEntity,Long> {
* @return
* @throws AppException
*/
public boolean updateUserPwd(String loginName, String oldPwd, String newPwd) throws AppException;
boolean updateUserPwd(String loginName, String oldPwd, String newPwd) throws AppException;
/**
*
* @param entity
*/
void doHandlerUser(UserEntity entity);
Rest<Void> refreshUser();
UserDao getUserDao();
/**
* 发送手机验证码
* @param mobileNumber
* @throws AppException
*/
void sendSmsVerifyCode(String mobileNumber) throws AppException;
/**
* 手机验证码登录
* @param mobileNumber
* @param verifyCode
* @param loginIp
* @return
* @throws AppException
*/
UserEntity doSmsLogin(String mobileNumber, String verifyCode, String loginIp) throws AppException;
}
\ No newline at end of file
......@@ -2,6 +2,10 @@ package com.mortals.xhx.base.system.user.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.common.Rest;
import com.mortals.framework.common.code.UserType;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
......@@ -14,8 +18,6 @@ import com.mortals.xhx.base.system.role.service.RoleUserService;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.code.UserStatus;
import com.mortals.xhx.module.dept.model.DeptQuery;
import com.mortals.xhx.module.dept.service.DeptService;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -23,7 +25,6 @@ import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.util.Base64;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -41,9 +42,6 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
private RoleService roleService;
@Autowired
private RoleUserService roleUserService;
@Autowired
private DeptService deptService;
public UserController() {
super.setModuleDesc("用户信息");
......@@ -51,9 +49,9 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
@Override
protected void init(Map<String, Object> model, Context context) {
this.addDict(model, "userType", IBaseEnum.getEnumMap(UserType.class));
this.addDict(model, "status", UserStatus.getEnumMap());
this.addDict(model, "roleIds", roleService.find(new RoleQuery()).stream().collect(Collectors.toMap(x -> x.getId().toString(), y -> y.getName())));
this.addDict(model, "deptId", deptService.find(new DeptQuery()).stream().collect(Collectors.toMap(x -> x.getId().toString(), y -> y.getDeptName(), (o, n) -> n)));
}
......@@ -72,20 +70,26 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
protected int editAfter(Long id, Map<String, Object> model, UserEntity entity, Context context) throws AppException {
RoleUserQuery roleUserQuery = new RoleUserQuery();
roleUserQuery.setUserId(entity.getId());
List<Long> roleIds = roleUserService.find(roleUserQuery).stream().map(RoleUserEntity::getRoleId).collect(Collectors.toList());
String roleIds = roleUserService.find(roleUserQuery).stream().map(RoleUserEntity::getRoleId).map(String::valueOf).collect(Collectors.joining(","));
entity.setRoleIds(roleIds);
return super.editAfter(id, model, entity, context);
}
@Override
protected int saveAfter(UserEntity entity, Map<String, Object> model, Context context) throws AppException {
if (entity.getId() == getCurUser().getId()) {
// TODO: 2022/8/15 更新redis session信息
//saveCurrUserForSession(request, response, userService.get(form.getEntity().getId(), false));
}
return super.saveAfter(entity, model, context);
}
// @Override
// protected void saveBefore(UserEntity entity, Map<String, Object> model, Context context) throws AppException {
// if (!ObjectUtils.isEmpty(entity.getLoginName()) && service.existUser(entity.getLoginName(), entity.getId())) {
// throw new AppException("登录名已存在!");
// }
// super.saveBefore(entity, model, context);
// }
@RequestMapping(value = "change/password", method = RequestMethod.POST)
@Operlog(msg = "密码修改成功!")
public String changePassword(@RequestParam String oldPwd, @RequestParam String newPwd) {
......@@ -102,28 +106,12 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
}
@RequestMapping(value = "repassword", method = RequestMethod.POST)
public String rePassword(@RequestBody UserEntity userEntity) {
JSONObject ret = new JSONObject();
try {
//查询用户是否存在
boolean existUser = service.existUser(userEntity.getLoginName(), userEntity.getId());
if(!existUser) throw new AppException("用户不存在!");
//修改密码
//service.doHandlerUser(userEntity);
service.update(userEntity,getContext());
//更新密码
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
ret.put(KEY_RESULT_MSG, "密码修改成功!");
} catch (Exception e) {
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
}
return ret.toJSONString();
@PostMapping({"refreshUser"})
@UnAuth
public Rest<Object> refreshUser() {
log.info("刷新用户");
this.service.refreshUser();
return Rest.ok("用户同步刷新操作成功");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment