Commit caf6d1d9 authored by 廖旭伟's avatar 廖旭伟

Merge remote-tracking branch 'origin/master'

parents 5accba1e 6a9ccbdc
......@@ -55,6 +55,7 @@
<id>product</id>
<properties>
<profiles.active>product</profiles.active>
<profiles.server.debug>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=15506</profiles.server.debug>
<profiles.filepath>/mortals/app/data/one</profiles.filepath>
<profiles.nacos.server-addr>192.168.0.252:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
......
......@@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;
import java.util.Set;
......@@ -74,12 +75,13 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
// }
userEntity = userService.doLogin(loginName, password, ip);
userEntity.setLastLoginAddress(ip);
userEntity.setLoginTime(new Date().getTime());
// saveCurrUser(request, response, userEntity);
recordSysLog(request, userEntity, "用户登录系统成功!");
String tmpToken = userEntity.getId() + ":" + IdUtil.fastSimpleUUID();
userEntity.setToken(tmpToken);
userEntity.setExpireTime(DateUtils.addCurrDate(1).getTime());
userEntity.setExpireTime(DateUtils.addCurrDate(3).getTime());
String token = authTokenService.createToken(userEntity);
data.put("token", token);
// 返回拥有的菜单数据
......@@ -127,7 +129,7 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
return JSONObject.toJSONString(Rest.fail(ERROR_TOKEN_EXPIRED, ERROR_TOKEN_EXPIRED_CONTENT));
}
Set<String> urls = resourceService.findUrlSetByUserId(user.getId());
log.info("userId:{},urls:{}", user.getId(),JSON.toJSONString(urls));
log.info("userId:{},urls:{}", user.getId(), JSON.toJSONString(urls));
List<MenuEntity> outlookBarList = menuService.findTreeMenu(user, urls);
String currUserName = user.getRealName();
if (currUserName == null || currUserName.trim().length() == 0) {
......@@ -151,9 +153,6 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
}
@Override
public void afterPropertiesSet() throws Exception {
log.info("初始化加载登录。。。");
......
......@@ -11,7 +11,6 @@ package com.mortals.xhx.base.system.param.dao.ibatis;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import com.mortals.xhx.base.system.param.dao.ParamDao;
import com.mortals.xhx.base.system.param.model.ParamEntity;
import org.springframework.stereotype.Repository;
/**
......
......@@ -21,7 +21,7 @@ import java.util.Date;
* @author
* @version 1.0.0
*/
public class ParamEntity extends ParamEntityExt implements IParam {
public class ParamEntity extends BaseEntityLong implements IParam {
private static final long serialVersionUID = 1536307966363L;
/** 参数名称 */
......
package com.mortals.xhx.base.system.param.model;
import com.mortals.framework.model.BaseEntityLong;
import lombok.Data;
@Data
public class ParamEntityExt extends BaseEntityLong {
/** 素材分组名称 */
private String pictureGroupName;
}
......@@ -5,7 +5,6 @@ import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.framework.service.IParamService;
import com.mortals.xhx.base.system.param.model.ParamEntity;
import java.util.List;
import java.util.Map;
/**
......@@ -45,35 +44,4 @@ public interface ParamService extends ICRUDCacheService<ParamEntity, Long>, IPar
*/
Map<String, String> getParamBySecondOrganize(String firstOrganize,String secondOrganize, String... excludeParamKeys);
/**
* 获取热词列表
* @return
*/
String getHotWords();
/**
* 设置热词列表
* @return
*/
void setHotWords(String value);
/**
* 空白打印材料展示数量
* @return
*/
int getPrintDisplayQuantity();
/**
* 设置空白打印材料展示数量
* @return
*/
void setPrintDisplayQuantity(int value);
/**
* 通过Key设置参数值 value
* @param key
* @param value
* @return
*/
void setValueByKey(String key,String value);
}
\ No newline at end of file
package com.mortals.xhx.base.system.param.service.impl;
import com.mortals.framework.common.code.YesNo;
import cn.hutool.core.util.StrUtil;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.IParam;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.util.DataUtil;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.base.system.param.dao.ParamDao;
import com.mortals.xhx.base.system.param.model.ParamEntity;
import com.mortals.xhx.base.system.param.model.ParamQuery;
import com.mortals.xhx.base.system.param.service.ParamService;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -30,14 +29,21 @@ import java.util.stream.Collectors;
@Service("paramService")
public class ParamServiceImpl extends AbstractCRUDCacheServiceImpl<ParamDao, ParamEntity, Long>
implements ParamService {
private final String HOT_WORDS = "HotWords";
private final String PRINT_QUANTITY = "PrintDisplayQuantity";
@Override
protected String getCacheName() {
return "ParamEntity.paramKey";
}
@Override
protected void saveBefore(ParamEntity entity, Context context) throws AppException {
//过滤换行符
entity.setParamKey(StrUtil.removeAllLineBreaks(entity.getParamKey()));
entity.setParamValue(StrUtil.removeAllLineBreaks(entity.getParamValue()));
super.saveBefore(entity, context);
}
@Override
public String getValueByKey(String key) {
List<ParamEntity> list = this.getCacheList();
......@@ -65,92 +71,6 @@ public class ParamServiceImpl extends AbstractCRUDCacheServiceImpl<ParamDao, Par
).collect(Collectors.toMap(ParamEntity::getParamKey, ParamEntity::getParamValue, (o, n) -> n));
}
@Override
public String getHotWords() {
return this.getParamValue(HOT_WORDS);
}
@Override
public void setHotWords(String value) {
List<ParamEntity> list = this.getCacheList();
ParamEntity entity = null;
for(ParamEntity paramEntity:list){
if(HOT_WORDS.equals(paramEntity.getParamKey())){
entity = paramEntity;
break;
}
}
if(entity!=null){
entity.setParamValue(value);
this.update(entity);
}else {
entity = new ParamEntity();
entity.setParamValue(value);
entity.setParamKey(HOT_WORDS);
entity.setName("热门搜索词汇");
entity.setCreateTime(new Date());
entity.setCreateUserId(1l);
entity.setCreateUserName("系统管理员");
this.save(entity);
}
}
@Override
public int getPrintDisplayQuantity() {
String printV = this.getParamValue(PRINT_QUANTITY);
return DataUtil.converStr2Int(printV,20);
}
@Override
public void setPrintDisplayQuantity(int value) {
List<ParamEntity> list = this.getCacheList();
ParamEntity entity = null;
for(ParamEntity paramEntity:list){
if(PRINT_QUANTITY.equals(paramEntity.getParamKey())){
entity = paramEntity;
break;
}
}
if(entity!=null){
entity.setParamValue(String.valueOf(value));
this.update(entity);
}else {
entity = new ParamEntity();
entity.setParamValue(String.valueOf(value));
entity.setParamKey(PRINT_QUANTITY);
entity.setName("空白打印材料展示数量");
entity.setCreateTime(new Date());
entity.setCreateUserId(1l);
entity.setCreateUserName("系统管理员");
this.save(entity);
}
}
@Override
public void setValueByKey(String key, String value) {
List<ParamEntity> list = this.getCacheList();
ParamEntity entity = null;
for(ParamEntity paramEntity:list){
if(key.equals(paramEntity.getParamKey())){
entity = paramEntity;
break;
}
}
if(entity!=null){
entity.setParamValue(String.valueOf(value));
this.update(entity);
}else {
entity = new ParamEntity();
entity.setParamValue(String.valueOf(value));
entity.setParamKey(key);
entity.setName("key");
entity.setCreateTime(new Date());
entity.setCreateUserId(1l);
entity.setCreateUserName("系统管理员");
this.save(entity);
}
}
@Override
public boolean needRefresh() {
......
package com.mortals.xhx.base.system.param.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.RepeatSubmit;
import com.mortals.framework.common.code.PageDisplayType;
import com.mortals.framework.model.Context;
import com.mortals.framework.util.FileUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.model.ParamEntity;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.DataSatusEnum;
import com.mortals.xhx.common.code.ModStatusEnum;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
/**
*
* 参数信息
*
* @author: zxfei
* @date: 2021/11/30 10:04
* @date: 2022/5/7 15:38
*/
@RestController
@RequestMapping("param")
public class ParamController extends BaseCRUDJsonMappingController<ParamService, ParamForm, ParamEntity, Long> {
public class ParamController extends BaseCRUDJsonBodyMappingController<ParamService, ParamEntity, Long> {
public ParamController() {
super.setFormClass(ParamForm.class);
......@@ -39,21 +31,17 @@ public class ParamController extends BaseCRUDJsonMappingController<ParamService,
}
@Override
protected void init(HttpServletRequest request, HttpServletResponse response, ParamForm form,
Map<String, Object> model, Context context) {
protected void init(Map<String, Object> model, Context context) {
Map<String, Object> status = new HashMap<String, Object>();
status.put("validStatus", DataSatusEnum.getEnumMap(DataSatusEnum.CLOSE.getValue(),
DataSatusEnum.DELETE.getValue(), DataSatusEnum.OVERDUE.getValue(), DataSatusEnum.USEOUT.getValue()));
status.put("modStatus", ModStatusEnum.getEnumMap());
status.put("displayType", getPageDisplayType());
model.put(KEY_RESULT_DICT, status);
super.init(request, response, form, model, context);
}
private Map<String, Object> getPageDisplayType() {
PageDisplayType[] pageDisplayTypes = PageDisplayType.values();
Map<String, Object> result = new HashMap<>(pageDisplayTypes.length);
for (PageDisplayType pageDisplayType : pageDisplayTypes) {
......@@ -62,7 +50,6 @@ public class ParamController extends BaseCRUDJsonMappingController<ParamService,
return result;
}
public static void main(String[] args) {
FileUtil.delete("E:\\pic\\1.png");
}
......
package com.mortals.xhx.base.system.user.model;
import com.mortals.framework.annotation.desensitization.MobileDesensitize;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.mortals.framework.ap.SysConstains;
import com.mortals.framework.service.IUser;
import com.mortals.xhx.base.system.user.model.vo.UserVo;
......@@ -23,6 +23,9 @@ public class UserEntity extends UserVo implements IUser {
/**
* 登录密码,使用md5双次加密
*/
@JsonProperty(
access = JsonProperty.Access.WRITE_ONLY
)
private String loginPwd;
/**
* 登录限制地址,多个IP地址用逗号分隔,可以使用IP段匹配,如:172.17.*非空:则只能该值内的IP可以登录
......@@ -35,7 +38,6 @@ public class UserEntity extends UserVo implements IUser {
/**
* 用户手机号
*/
@MobileDesensitize
private String mobile;
/**
* 用户联系电话
......@@ -49,20 +51,15 @@ public class UserEntity extends UserVo implements IUser {
* QQ号码
*/
private String qq;
/**
* 用户类型(0.系统用户,1.普通用户,2.工作人员,3.巡查人员,4.窗口负责人)
*/
private Integer userType;
/**
* 用户所属部门id
*/
private Long customerId;
private Long deptId;
private String deptName;
/**
* 所属部门名称
* 用户类型(0.系统用户,1.普通用户,2.工作人员)
*/
private String deptName;
private Integer userType;
/**
* 所属站点id,多个逗号分隔
*/
......@@ -88,16 +85,23 @@ public class UserEntity extends UserVo implements IUser {
*/
private String lastLoginAddress;
/**
* 员工id
*/
private Long customerId;
/**
* 钉钉userId
*/
private String dingUserId;
public UserEntity(){}
public void setCustomerId(Long customerId) {
this.customerId = customerId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
public String getDingUserId() {
return dingUserId;
}
......@@ -106,7 +110,6 @@ public class UserEntity extends UserVo implements IUser {
this.dingUserId = dingUserId;
}
public UserEntity(){}
/**
* 获取 登录名
* @return String
......@@ -128,15 +131,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 +163,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 +239,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 +255,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 customerId;
}
@Override
......@@ -377,9 +370,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
package com.mortals.xhx.base.system.user.model;
import java.util.List;
import java.util.List;
/**
* 用户信息业务查询对象
*
* @author zxfei
* @date 2023-03-09
* @date 2022-07-06
*/
public class UserQuery extends UserEntity {
/** 开始 用户ID,主键,自增长 */
......@@ -21,94 +21,48 @@ public class UserQuery extends UserEntity {
/** 用户ID,主键,自增长列表 */
private List <Long> idList;
/** 用户ID,主键,自增长排除列表 */
private List <Long> idNotList;
/** 登录名 */
private List<String> loginNameList;
/** 登录名排除列表 */
private List <String> loginNameNotList;
/** 登录密码,使用md5双次加密 */
private List<String> loginPwdList;
/** 登录密码,使用md5双次加密排除列表 */
private List <String> loginPwdNotList;
/** 登录限制地址,多个IP地址用逗号分隔,可以使用IP段匹配,如:172.17.*非空:则只能该值内的IP可以登录 */
private List<String> loginLimitAddressList;
/** 登录限制地址,多个IP地址用逗号分隔,可以使用IP段匹配,如:172.17.*非空:则只能该值内的IP可以登录排除列表 */
private List <String> loginLimitAddressNotList;
/** 用户名 */
private List<String> realNameList;
/** 用户名排除列表 */
private List <String> realNameNotList;
/** 用户手机号 */
private List<String> mobileList;
/** 用户手机号排除列表 */
private List <String> mobileNotList;
/** 用户联系电话 */
private List<String> phoneList;
/** 用户联系电话排除列表 */
private List <String> phoneNotList;
/** 用户邮箱 */
private List<String> emailList;
/** 用户邮箱排除列表 */
private List <String> emailNotList;
/** QQ号码 */
private List<String> qqList;
/** QQ号码排除列表 */
private List <String> qqNotList;
/** 开始 用户类型(0.系统用户,1.后台管理,2.工作人员) */
/** 开始 用户类型(0.系统用户,1.普通用户,2.工作人员) */
private Integer userTypeStart;
/** 结束 用户类型(0.系统用户,1.后台管理,2.工作人员) */
/** 结束 用户类型(0.系统用户,1.普通用户,2.工作人员) */
private Integer userTypeEnd;
/** 增加 用户类型(0.系统用户,1.后台管理,2.工作人员) */
/** 增加 用户类型(0.系统用户,1.普通用户,2.工作人员) */
private Integer userTypeIncrement;
/** 用户类型(0.系统用户,1.后台管理,2.工作人员)列表 */
/** 用户类型(0.系统用户,1.普通用户,2.工作人员)列表 */
private List <Integer> userTypeList;
/** 用户类型(0.系统用户,1.后台管理,2.工作人员)排除列表 */
private List <Integer> userTypeNotList;
/** 开始 用户所属部门id */
private Long deptIdStart;
/** 结束 用户所属部门id */
private Long deptIdEnd;
/** 增加 用户所属部门id */
private Long deptIdIncrement;
/** 用户所属部门id列表 */
private List <Long> deptIdList;
/** 用户所属部门id排除列表 */
private List <Long> deptIdNotList;
/** 所属部门名称 */
private List<String> deptNameList;
/** 所属部门名称排除列表 */
private List <String> deptNameNotList;
/** 所属站点id,多个逗号分隔 */
private List<String> siteIdsList;
/** 所属站点id,多个逗号分隔排除列表 */
private List <String> siteIdsNotList;
/** 所属区域code,多个逗号分隔 */
private List<String> areaCodesList;
/** 所属区域code,多个逗号分隔排除列表 */
private List <String> areaCodesNotList;
/** 开始 用户状态(0.停用,1.正常,2.冻结,3.销户,4.离职) */
private Integer statusStart;
......@@ -121,9 +75,6 @@ public class UserQuery extends UserEntity {
/** 用户状态(0.停用,1.正常,2.冻结,3.销户,4.离职)列表 */
private List <Integer> statusList;
/** 用户状态(0.停用,1.正常,2.冻结,3.销户,4.离职)排除列表 */
private List <Integer> statusNotList;
/** 开始 创建时间 */
private String createTimeStart;
......@@ -142,14 +93,9 @@ public class UserQuery extends UserEntity {
/** 创建用户列表 */
private List <Long> createUserIdList;
/** 创建用户排除列表 */
private List <Long> createUserIdNotList;
/** 创建用户名称 */
private List<String> createUserNameList;
/** 创建用户名称排除列表 */
private List <String> createUserNameNotList;
/** 开始 最后一次登录时间 */
private String lastLoginTimeStart;
......@@ -159,16 +105,6 @@ public class UserQuery extends UserEntity {
/** 最后一次登录地址 */
private List<String> lastLoginAddressList;
/** 最后一次登录地址排除列表 */
private List <String> lastLoginAddressNotList;
/** 钉钉userId */
private List<String> dingUserIdList;
/** 钉钉userId排除列表 */
private List <String> dingUserIdNotList;
/** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */
private List<UserQuery> orConditionList;
......@@ -241,23 +177,6 @@ public class UserQuery extends UserEntity {
this.idList = idList;
}
/**
* 获取 用户ID,主键,自增长
* @return idNotList
*/
public List<Long> getIdNotList(){
return this.idNotList;
}
/**
* 设置 用户ID,主键,自增长
* @param idNotList
*/
public void setIdNotList(List<Long> idNotList){
this.idNotList = idNotList;
}
/**
* 获取 登录名
* @return loginNameList
......@@ -273,23 +192,6 @@ public class UserQuery extends UserEntity {
public void setLoginNameList(List<String> loginNameList){
this.loginNameList = loginNameList;
}
/**
* 获取 登录名
* @return loginNameNotList
*/
public List<String> getLoginNameNotList(){
return this.loginNameNotList;
}
/**
* 设置 登录名
* @param loginNameNotList
*/
public void setLoginNameNotList(List<String> loginNameNotList){
this.loginNameNotList = loginNameNotList;
}
/**
* 获取 登录密码,使用md5双次加密
* @return loginPwdList
......@@ -305,23 +207,6 @@ public class UserQuery extends UserEntity {
public void setLoginPwdList(List<String> loginPwdList){
this.loginPwdList = loginPwdList;
}
/**
* 获取 登录密码,使用md5双次加密
* @return loginPwdNotList
*/
public List<String> getLoginPwdNotList(){
return this.loginPwdNotList;
}
/**
* 设置 登录密码,使用md5双次加密
* @param loginPwdNotList
*/
public void setLoginPwdNotList(List<String> loginPwdNotList){
this.loginPwdNotList = loginPwdNotList;
}
/**
* 获取 登录限制地址,多个IP地址用逗号分隔,可以使用IP段匹配,如:172.17.*非空:则只能该值内的IP可以登录
* @return loginLimitAddressList
......@@ -337,23 +222,6 @@ public class UserQuery extends UserEntity {
public void setLoginLimitAddressList(List<String> loginLimitAddressList){
this.loginLimitAddressList = loginLimitAddressList;
}
/**
* 获取 登录限制地址,多个IP地址用逗号分隔,可以使用IP段匹配,如:172.17.*非空:则只能该值内的IP可以登录
* @return loginLimitAddressNotList
*/
public List<String> getLoginLimitAddressNotList(){
return this.loginLimitAddressNotList;
}
/**
* 设置 登录限制地址,多个IP地址用逗号分隔,可以使用IP段匹配,如:172.17.*非空:则只能该值内的IP可以登录
* @param loginLimitAddressNotList
*/
public void setLoginLimitAddressNotList(List<String> loginLimitAddressNotList){
this.loginLimitAddressNotList = loginLimitAddressNotList;
}
/**
* 获取 用户名
* @return realNameList
......@@ -369,23 +237,6 @@ public class UserQuery extends UserEntity {
public void setRealNameList(List<String> realNameList){
this.realNameList = realNameList;
}
/**
* 获取 用户名
* @return realNameNotList
*/
public List<String> getRealNameNotList(){
return this.realNameNotList;
}
/**
* 设置 用户名
* @param realNameNotList
*/
public void setRealNameNotList(List<String> realNameNotList){
this.realNameNotList = realNameNotList;
}
/**
* 获取 用户手机号
* @return mobileList
......@@ -401,23 +252,6 @@ public class UserQuery extends UserEntity {
public void setMobileList(List<String> mobileList){
this.mobileList = mobileList;
}
/**
* 获取 用户手机号
* @return mobileNotList
*/
public List<String> getMobileNotList(){
return this.mobileNotList;
}
/**
* 设置 用户手机号
* @param mobileNotList
*/
public void setMobileNotList(List<String> mobileNotList){
this.mobileNotList = mobileNotList;
}
/**
* 获取 用户联系电话
* @return phoneList
......@@ -433,23 +267,6 @@ public class UserQuery extends UserEntity {
public void setPhoneList(List<String> phoneList){
this.phoneList = phoneList;
}
/**
* 获取 用户联系电话
* @return phoneNotList
*/
public List<String> getPhoneNotList(){
return this.phoneNotList;
}
/**
* 设置 用户联系电话
* @param phoneNotList
*/
public void setPhoneNotList(List<String> phoneNotList){
this.phoneNotList = phoneNotList;
}
/**
* 获取 用户邮箱
* @return emailList
......@@ -465,23 +282,6 @@ public class UserQuery extends UserEntity {
public void setEmailList(List<String> emailList){
this.emailList = emailList;
}
/**
* 获取 用户邮箱
* @return emailNotList
*/
public List<String> getEmailNotList(){
return this.emailNotList;
}
/**
* 设置 用户邮箱
* @param emailNotList
*/
public void setEmailNotList(List<String> emailNotList){
this.emailNotList = emailNotList;
}
/**
* 获取 QQ号码
* @return qqList
......@@ -497,25 +297,8 @@ public class UserQuery extends UserEntity {
public void setQqList(List<String> qqList){
this.qqList = qqList;
}
/**
* 获取 QQ号码
* @return qqNotList
*/
public List<String> getQqNotList(){
return this.qqNotList;
}
/**
* 设置 QQ号码
* @param qqNotList
*/
public void setQqNotList(List<String> qqNotList){
this.qqNotList = qqNotList;
}
/**
* 获取 开始 用户类型(0.系统用户,1.后台管理,2.工作人员)
* 获取 开始 用户类型(0.系统用户,1.普通用户,2.工作人员)
* @return userTypeStart
*/
public Integer getUserTypeStart(){
......@@ -523,7 +306,7 @@ public class UserQuery extends UserEntity {
}
/**
* 设置 开始 用户类型(0.系统用户,1.后台管理,2.工作人员)
* 设置 开始 用户类型(0.系统用户,1.普通用户,2.工作人员)
* @param userTypeStart
*/
public void setUserTypeStart(Integer userTypeStart){
......@@ -531,7 +314,7 @@ public class UserQuery extends UserEntity {
}
/**
* 获取 结束 用户类型(0.系统用户,1.后台管理,2.工作人员)
* 获取 结束 用户类型(0.系统用户,1.普通用户,2.工作人员)
* @return $userTypeEnd
*/
public Integer getUserTypeEnd(){
......@@ -539,7 +322,7 @@ public class UserQuery extends UserEntity {
}
/**
* 设置 结束 用户类型(0.系统用户,1.后台管理,2.工作人员)
* 设置 结束 用户类型(0.系统用户,1.普通用户,2.工作人员)
* @param userTypeEnd
*/
public void setUserTypeEnd(Integer userTypeEnd){
......@@ -547,7 +330,7 @@ public class UserQuery extends UserEntity {
}
/**
* 获取 增加 用户类型(0.系统用户,1.后台管理,2.工作人员)
* 获取 增加 用户类型(0.系统用户,1.普通用户,2.工作人员)
* @return userTypeIncrement
*/
public Integer getUserTypeIncrement(){
......@@ -555,7 +338,7 @@ public class UserQuery extends UserEntity {
}
/**
* 设置 增加 用户类型(0.系统用户,1.后台管理,2.工作人员)
* 设置 增加 用户类型(0.系统用户,1.普通用户,2.工作人员)
* @param userTypeIncrement
*/
public void setUserTypeIncrement(Integer userTypeIncrement){
......@@ -563,7 +346,7 @@ public class UserQuery extends UserEntity {
}
/**
* 获取 用户类型(0.系统用户,1.后台管理,2.工作人员)
* 获取 用户类型(0.系统用户,1.普通用户,2.工作人员)
* @return userTypeList
*/
public List<Integer> getUserTypeList(){
......@@ -571,143 +354,13 @@ public class UserQuery extends UserEntity {
}
/**
* 设置 用户类型(0.系统用户,1.后台管理,2.工作人员)
* 设置 用户类型(0.系统用户,1.普通用户,2.工作人员)
* @param userTypeList
*/
public void setUserTypeList(List<Integer> userTypeList){
this.userTypeList = userTypeList;
}
/**
* 获取 用户类型(0.系统用户,1.后台管理,2.工作人员)
* @return userTypeNotList
*/
public List<Integer> getUserTypeNotList(){
return this.userTypeNotList;
}
/**
* 设置 用户类型(0.系统用户,1.后台管理,2.工作人员)
* @param userTypeNotList
*/
public void setUserTypeNotList(List<Integer> userTypeNotList){
this.userTypeNotList = userTypeNotList;
}
/**
* 获取 开始 用户所属部门id
* @return deptIdStart
*/
public Long getDeptIdStart(){
return this.deptIdStart;
}
/**
* 设置 开始 用户所属部门id
* @param deptIdStart
*/
public void setDeptIdStart(Long deptIdStart){
this.deptIdStart = deptIdStart;
}
/**
* 获取 结束 用户所属部门id
* @return $deptIdEnd
*/
public Long getDeptIdEnd(){
return this.deptIdEnd;
}
/**
* 设置 结束 用户所属部门id
* @param deptIdEnd
*/
public void setDeptIdEnd(Long deptIdEnd){
this.deptIdEnd = deptIdEnd;
}
/**
* 获取 增加 用户所属部门id
* @return deptIdIncrement
*/
public Long getDeptIdIncrement(){
return this.deptIdIncrement;
}
/**
* 设置 增加 用户所属部门id
* @param deptIdIncrement
*/
public void setDeptIdIncrement(Long deptIdIncrement){
this.deptIdIncrement = deptIdIncrement;
}
/**
* 获取 用户所属部门id
* @return deptIdList
*/
public List<Long> getDeptIdList(){
return this.deptIdList;
}
/**
* 设置 用户所属部门id
* @param deptIdList
*/
public void setDeptIdList(List<Long> deptIdList){
this.deptIdList = deptIdList;
}
/**
* 获取 用户所属部门id
* @return deptIdNotList
*/
public List<Long> getDeptIdNotList(){
return this.deptIdNotList;
}
/**
* 设置 用户所属部门id
* @param deptIdNotList
*/
public void setDeptIdNotList(List<Long> deptIdNotList){
this.deptIdNotList = deptIdNotList;
}
/**
* 获取 所属部门名称
* @return deptNameList
*/
public List<String> getDeptNameList(){
return this.deptNameList;
}
/**
* 设置 所属部门名称
* @param deptNameList
*/
public void setDeptNameList(List<String> deptNameList){
this.deptNameList = deptNameList;
}
/**
* 获取 所属部门名称
* @return deptNameNotList
*/
public List<String> getDeptNameNotList(){
return this.deptNameNotList;
}
/**
* 设置 所属部门名称
* @param deptNameNotList
*/
public void setDeptNameNotList(List<String> deptNameNotList){
this.deptNameNotList = deptNameNotList;
}
/**
* 获取 所属站点id,多个逗号分隔
* @return siteIdsList
......@@ -723,23 +376,6 @@ public class UserQuery extends UserEntity {
public void setSiteIdsList(List<String> siteIdsList){
this.siteIdsList = siteIdsList;
}
/**
* 获取 所属站点id,多个逗号分隔
* @return siteIdsNotList
*/
public List<String> getSiteIdsNotList(){
return this.siteIdsNotList;
}
/**
* 设置 所属站点id,多个逗号分隔
* @param siteIdsNotList
*/
public void setSiteIdsNotList(List<String> siteIdsNotList){
this.siteIdsNotList = siteIdsNotList;
}
/**
* 获取 所属区域code,多个逗号分隔
* @return areaCodesList
......@@ -755,23 +391,6 @@ public class UserQuery extends UserEntity {
public void setAreaCodesList(List<String> areaCodesList){
this.areaCodesList = areaCodesList;
}
/**
* 获取 所属区域code,多个逗号分隔
* @return areaCodesNotList
*/
public List<String> getAreaCodesNotList(){
return this.areaCodesNotList;
}
/**
* 设置 所属区域code,多个逗号分隔
* @param areaCodesNotList
*/
public void setAreaCodesNotList(List<String> areaCodesNotList){
this.areaCodesNotList = areaCodesNotList;
}
/**
* 获取 开始 用户状态(0.停用,1.正常,2.冻结,3.销户,4.离职)
* @return statusStart
......@@ -836,23 +455,6 @@ public class UserQuery extends UserEntity {
this.statusList = statusList;
}
/**
* 获取 用户状态(0.停用,1.正常,2.冻结,3.销户,4.离职)
* @return statusNotList
*/
public List<Integer> getStatusNotList(){
return this.statusNotList;
}
/**
* 设置 用户状态(0.停用,1.正常,2.冻结,3.销户,4.离职)
* @param statusNotList
*/
public void setStatusNotList(List<Integer> statusNotList){
this.statusNotList = statusNotList;
}
/**
* 获取 开始 创建时间
* @return createTimeStart
......@@ -949,23 +551,6 @@ public class UserQuery extends UserEntity {
this.createUserIdList = createUserIdList;
}
/**
* 获取 创建用户
* @return createUserIdNotList
*/
public List<Long> getCreateUserIdNotList(){
return this.createUserIdNotList;
}
/**
* 设置 创建用户
* @param createUserIdNotList
*/
public void setCreateUserIdNotList(List<Long> createUserIdNotList){
this.createUserIdNotList = createUserIdNotList;
}
/**
* 获取 创建用户名称
* @return createUserNameList
......@@ -981,23 +566,6 @@ public class UserQuery extends UserEntity {
public void setCreateUserNameList(List<String> createUserNameList){
this.createUserNameList = createUserNameList;
}
/**
* 获取 创建用户名称
* @return createUserNameNotList
*/
public List<String> getCreateUserNameNotList(){
return this.createUserNameNotList;
}
/**
* 设置 创建用户名称
* @param createUserNameNotList
*/
public void setCreateUserNameNotList(List<String> createUserNameNotList){
this.createUserNameNotList = createUserNameNotList;
}
/**
* 获取 开始 最后一次登录时间
* @return lastLoginTimeStart
......@@ -1045,23 +613,6 @@ public class UserQuery extends UserEntity {
public void setLastLoginAddressList(List<String> lastLoginAddressList){
this.lastLoginAddressList = lastLoginAddressList;
}
/**
* 获取 最后一次登录地址
* @return lastLoginAddressNotList
*/
public List<String> getLastLoginAddressNotList(){
return this.lastLoginAddressNotList;
}
/**
* 设置 最后一次登录地址
* @param lastLoginAddressNotList
*/
public void setLastLoginAddressNotList(List<String> lastLoginAddressNotList){
this.lastLoginAddressNotList = lastLoginAddressNotList;
}
/**
* 设置 用户ID,主键,自增长
* @param id
......@@ -1107,15 +658,6 @@ public class UserQuery extends UserEntity {
return this;
}
/**
* 设置 用户ID,主键,自增长
* @param idNotList
*/
public UserQuery idNotList(List<Long> idNotList){
this.idNotList = idNotList;
return this;
}
/**
* 设置 登录名
......@@ -1269,7 +811,7 @@ public class UserQuery extends UserEntity {
}
/**
* 设置 用户类型(0.系统用户,1.后台管理,2.工作人员)
* 设置 用户类型(0.系统用户,1.普通用户,2.工作人员)
* @param userType
*/
public UserQuery userType(Integer userType){
......@@ -1278,7 +820,7 @@ public class UserQuery extends UserEntity {
}
/**
* 设置 开始 用户类型(0.系统用户,1.后台管理,2.工作人员)
* 设置 开始 用户类型(0.系统用户,1.普通用户,2.工作人员)
* @param userTypeStart
*/
public UserQuery userTypeStart(Integer userTypeStart){
......@@ -1287,7 +829,7 @@ public class UserQuery extends UserEntity {
}
/**
* 设置 结束 用户类型(0.系统用户,1.后台管理,2.工作人员)
* 设置 结束 用户类型(0.系统用户,1.普通用户,2.工作人员)
* @param userTypeEnd
*/
public UserQuery userTypeEnd(Integer userTypeEnd){
......@@ -1296,7 +838,7 @@ public class UserQuery extends UserEntity {
}
/**
* 设置 增加 用户类型(0.系统用户,1.后台管理,2.工作人员)
* 设置 增加 用户类型(0.系统用户,1.普通用户,2.工作人员)
* @param userTypeIncrement
*/
public UserQuery userTypeIncrement(Integer userTypeIncrement){
......@@ -1305,7 +847,7 @@ public class UserQuery extends UserEntity {
}
/**
* 设置 用户类型(0.系统用户,1.后台管理,2.工作人员)
* 设置 用户类型(0.系统用户,1.普通用户,2.工作人员)
* @param userTypeList
*/
public UserQuery userTypeList(List<Integer> userTypeList){
......@@ -1313,88 +855,6 @@ public class UserQuery extends UserEntity {
return this;
}
/**
* 设置 用户类型(0.系统用户,1.后台管理,2.工作人员)
* @param userTypeNotList
*/
public UserQuery userTypeNotList(List<Integer> userTypeNotList){
this.userTypeNotList = userTypeNotList;
return this;
}
/**
* 设置 用户所属部门id
* @param deptId
*/
public UserQuery deptId(Long deptId){
setDeptId(deptId);
return this;
}
/**
* 设置 开始 用户所属部门id
* @param deptIdStart
*/
public UserQuery deptIdStart(Long deptIdStart){
this.deptIdStart = deptIdStart;
return this;
}
/**
* 设置 结束 用户所属部门id
* @param deptIdEnd
*/
public UserQuery deptIdEnd(Long deptIdEnd){
this.deptIdEnd = deptIdEnd;
return this;
}
/**
* 设置 增加 用户所属部门id
* @param deptIdIncrement
*/
public UserQuery deptIdIncrement(Long deptIdIncrement){
this.deptIdIncrement = deptIdIncrement;
return this;
}
/**
* 设置 用户所属部门id
* @param deptIdList
*/
public UserQuery deptIdList(List<Long> deptIdList){
this.deptIdList = deptIdList;
return this;
}
/**
* 设置 用户所属部门id
* @param deptIdNotList
*/
public UserQuery deptIdNotList(List<Long> deptIdNotList){
this.deptIdNotList = deptIdNotList;
return this;
}
/**
* 设置 所属部门名称
* @param deptName
*/
public UserQuery deptName(String deptName){
setDeptName(deptName);
return this;
}
/**
* 设置 所属部门名称
* @param deptNameList
*/
public UserQuery deptNameList(List<String> deptNameList){
this.deptNameList = deptNameList;
return this;
}
/**
* 设置 所属站点id,多个逗号分隔
......@@ -1478,15 +938,6 @@ public class UserQuery extends UserEntity {
return this;
}
/**
* 设置 用户状态(0.停用,1.正常,2.冻结,3.销户,4.离职)
* @param statusNotList
*/
public UserQuery statusNotList(List<Integer> statusNotList){
this.statusNotList = statusNotList;
return this;
}
/**
* 设置 创建用户
......@@ -1533,15 +984,6 @@ public class UserQuery extends UserEntity {
return this;
}
/**
* 设置 创建用户
* @param createUserIdNotList
*/
public UserQuery createUserIdNotList(List<Long> createUserIdNotList){
this.createUserIdNotList = createUserIdNotList;
return this;
}
/**
* 设置 创建用户名称
......@@ -1613,23 +1055,4 @@ public class UserQuery extends UserEntity {
this.andConditionList = andConditionList;
}
/**
* 设置 钉钉userId
* @param dingUserId
*/
public UserQuery dingUserId(String dingUserId){
setDingUserId(dingUserId);
return this;
}
/**
* 设置 钉钉userId
* @param dingUserIdList
*/
public UserQuery dingUserIdList(List<String> dingUserIdList){
this.dingUserIdList = dingUserIdList;
return this;
}
}
\ 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;
UserDao getUserDao();
}
\ No newline at end of file
......@@ -8,10 +8,8 @@
package com.mortals.xhx.base.system.user.service.impl;
import cn.hutool.core.util.PhoneUtil;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.ap.SysConstains;
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;
......@@ -19,26 +17,32 @@ import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.service.IUser;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.util.HttpUtil;
import com.mortals.framework.util.SecurityUtil;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.base.system.menu.model.MenuEntity;
import com.mortals.xhx.base.system.menu.service.MenuService;
import com.mortals.xhx.base.system.resource.model.ResourceEntity;
import com.mortals.xhx.base.system.resource.service.ResourceService;
import com.mortals.xhx.base.system.role.dao.RoleUserDao;
import com.mortals.xhx.base.system.role.model.RoleUserEntity;
import com.mortals.xhx.base.system.role.model.RoleUserQuery;
import com.mortals.xhx.base.system.role.service.RoleUserService;
import com.mortals.xhx.base.system.user.dao.UserDao;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.model.UserQuery;
import com.mortals.xhx.base.system.user.service.UserService;
import org.apache.commons.collections4.CollectionUtils;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.user.UserPdu;
import com.mortals.xhx.feign.user.IUserFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>Title: 用户信息</p>
......@@ -50,6 +54,7 @@ import java.util.*;
* @version 1.0.0
*/
@Service("userService")
@Slf4j
public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserEntity, Long> implements UserService {
......@@ -58,27 +63,18 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Autowired
private ResourceService resourceService;
@Autowired
private RoleUserDao roleUserDao;
private RoleUserService roleUserService;
@Value("${sms.smsSendUrl:http://sms.wx3.com.cn/api/index/index}")
private String smsApiUrl;
@Value("${sms.apiId:ADsUXLrS81vZDU95}")
private String appid;
/**
* 短信模板ID
**/
private static String SMS_TPYE = "30";
private static String SMS_VERIFY_CODE_KEY = "login:sms:verify:";
@Lazy
@Autowired
private IUserFeign userFeign;
@Override
protected String getExtKey(UserEntity data) {
return data.getLoginName();
}
public void doHandlerUser(UserEntity entity) throws AppException {
private void doHandlerUser(UserEntity entity) throws AppException {
if (StringUtils.isNotEmpty(entity.getLoginPwd())) {
try {
entity.setLoginPwd(SecurityUtil.md5DoubleEncoding(entity.getLoginPwd()));
......@@ -88,98 +84,63 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
} else {
entity.setLoginPwd(null);
}
// if (entity.isSystemUser()) {
// entity.setUserType(UserType.SYSTEM.getValue());
// } else {
// entity.setUserType(UserType.CUSTOMER.getValue());
// }
}
@Override
protected void saveBefore(UserEntity entity, Context context) throws AppException {
if (!ObjectUtils.isEmpty(entity.getLoginName()) && existUser(entity.getLoginName(), entity.getId())) {
throw new AppException("登录名已存在!");
}
this.doHandlerUser(entity);
}
@Override
protected void saveAfter(UserEntity entity, Context context) throws AppException {
if (CollectionUtils.isNotEmpty(entity.getRoleIds())) {
List<RoleUserEntity> roleUserEntityList = new ArrayList<>();
entity.getRoleIds().stream().forEach(item -> {
RoleUserEntity roleUserEntity = new RoleUserEntity();
roleUserEntity.setUserId(entity.getId());
roleUserEntity.setRoleId(item);
roleUserEntityList.add(roleUserEntity);
});
roleUserDao.insertBatch(roleUserEntityList);
}
}
@Override
protected void updateBefore(UserEntity entity, Context context) throws AppException {
/* if (entity.getId().longValue() == SysConstains.ADMIN_ID && !context.getUser().isAdmin()) {
throw new AppException("你没有权限执行该操作");
}*/
if (entity.getId().longValue() == SysConstains.ADMIN_ID) {
throw new AppException("你没有权限执行该操作");
}
// if (entity.getId().longValue() == SysConstains.ADMIN_ID && !context.getUser().isAdmin()) {
// throw new AppException("你没有权限执行该操作");
// }
//更新不更新密码字段
entity.setLoginPwd(null);
this.doHandlerUser(entity);
}
@Override
protected void updateAfter(UserEntity entity, Context context) throws AppException {
if (CollectionUtils.isNotEmpty(entity.getRoleIds())) {
List<RoleUserEntity> roleUserEntityList = new ArrayList<>();
entity.getRoleIds().stream().forEach(item -> {
RoleUserEntity roleUserEntity = new RoleUserEntity();
roleUserEntity.setUserId(entity.getId());
roleUserEntity.setRoleId(item);
roleUserEntityList.add(roleUserEntity);
});
RoleUserEntity condition = new RoleUserEntity();
condition.setUserId(entity.getId());
roleUserDao.delete(condition);
roleUserDao.insertBatch(roleUserEntityList);
}
protected void saveAfter(UserEntity entity, Context context) throws AppException {
//新增角色
updateUserRole(entity);
super.saveAfter(entity, context);
}
@Override
protected UserEntity findBefore(UserEntity params, Context context) throws AppException {
// if (StringUtils.isNotEmpty(params.getDeptIds())) {
// params.setDeptIds(StringUtils.fillWithMark(params.getDeptIds(), ","));
// }
return super.findBefore(params, context);
protected void updateAfter(UserEntity entity, Context context) throws AppException {
updateUserRole(entity);
super.updateAfter(entity, context);
}
@Override
protected UserEntity findBefore(UserEntity params, PageInfo pageInfo, Context context) throws AppException {
// if (StringUtils.isNotEmpty(params.getDeptIds())) {
// params.setDeptIds(StringUtils.fillWithMark(params.getDeptIds(), ","));
// }
return super.findBefore(params, pageInfo, context);
private void updateUserRole(UserEntity entity) {
if (!ObjectUtils.isEmpty(entity.getId()) && entity.getId().longValue() != SysConstains.ADMIN_ID && !ObjectUtils.isEmpty(entity.getRoleIds())) {
RoleUserQuery roleUserQuery = new RoleUserQuery();
roleUserQuery.setUserId(entity.getId());
List<Long> idList = Arrays.asList(entity.getRoleIds().split(",")).stream().map(Long::parseLong).collect(Collectors.toList());
roleUserQuery.setRoleIdList(idList);
roleUserService.doDistributionRole(roleUserQuery);
}
}
@Override
protected void findAfter(UserEntity params, PageInfo pageInfo, Context context, List<UserEntity> list) throws AppException {
if (CollectionUtils.isNotEmpty(list)) {
list.stream().forEach(item -> {
RoleUserEntity query = new RoleUserEntity();
query.setUserId(item.getId());
List<RoleUserEntity> roleUserEntityList = roleUserDao.getList(query);
List<Long> roleIds = new ArrayList<>();
roleUserEntityList.stream().forEach(role -> {
roleIds.add(role.getRoleId());
});
item.setRoleIds(roleIds);
String roleIdStrs = StringUtils.join(roleIds, ",");
item.setRoleIdStrs(roleIdStrs);
RoleUserQuery roleUserQuery = new RoleUserQuery();
roleUserQuery.setUserId(item.getId());
});
}
list.stream().peek(item -> {
RoleUserQuery roleUserQuery = new RoleUserQuery();
roleUserQuery.setUserId(item.getId());
String roleIds = roleUserService.find(roleUserQuery).stream().map(RoleUserEntity::getRoleId).map(String::valueOf).collect(Collectors.joining(","));
item.setRoleIds(roleIds);
}).count();
super.findAfter(params, pageInfo, context, list);
}
public UserEntity findByLoginName(String loginName) {
UserQuery params = new UserQuery();
params.setLoginName(loginName);
......@@ -203,11 +164,6 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
} catch (Exception e) {
throw new AppException("密码验认出错!", e);
}
UserEntity update = new UserEntity();
update.setId(sysUser.getId());
update.setLastLoginAddress(loginIp);
update.setLastLoginTime(new Date());
this.dao.update(update);
return sysUser;
}
......@@ -251,7 +207,7 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
urls.addAll(StringUtils.converStr2Set(url));
}
}
Set<Long> authIds = new HashSet<Long>();
Set<Long> authIds = new HashSet<>();
Map<Long, MenuEntity> menuMap = new HashMap<Long, MenuEntity>();
List<MenuEntity> userModuleList = this.menuService.findAllEnable();
for (MenuEntity sysModule : userModuleList) {
......@@ -259,6 +215,7 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
continue;
}
menuMap.put(sysModule.getId(), sysModule);
if (!user.isAdmin() && urls.contains(StringUtils.trim(sysModule.getUrl()))) {
authIds.add(sysModule.getId());
}
......@@ -307,7 +264,6 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
entity.initAttrValue();
entity.setLoginName(loginName);
entity.setRealName(userName);
entity.setCustomerId(customerId);
entity.setLoginPwd(password);
entity.setMobile(mobile);
entity.setUserType(UserType.CUSTOMER.getValue());
......@@ -353,7 +309,6 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
}
try {
sysUser.setLoginPwd(SecurityUtil.md5DoubleEncoding(newPwd));
} catch (Exception e) {
throw new AppException("密码转换异常!", e);
}
......@@ -362,78 +317,78 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
}
@Override
public UserDao getUserDao() {
return this.getDao();
}
public Rest<Void> refreshUser() {
UserPdu userPdu = new UserPdu();
userPdu.setPage(1);
userPdu.setSize(-1);
Rest<RespData<List<UserPdu>>> resp = userFeign.list(userPdu);
if (resp.getCode() == YesNoEnum.YES.getValue()) {
List<UserPdu> userPduList = resp.getData().getData();
log.info("用户总数量:{}", userPduList.size());
if (!ObjectUtils.isEmpty(userPduList)) {
List<UserEntity> newUserList = userPduList.stream().map(newUser -> {
UserEntity userEntity = new UserEntity();
userEntity.initAttrValue();
BeanUtils.copyProperties(newUser, userEntity, new String[]{"id", "lastLoginTime", "lastLoginAddress"});
return userEntity;
}).collect(Collectors.toList());
List<UserEntity> saveUpdateUserList = newUserList.parallelStream().map(item -> {
UserEntity extCache = this.getExtCache(item.getLoginName());
if (ObjectUtils.isEmpty(extCache)) {
item.setCreateUserId(1L);
item.setCreateUserName("系统管理员");
item.setCreateTime(new Date());
return item;
} else {
//更新用户列表
item.setId(extCache.getId());
item.setUpdateUserId(1L);
item.setUpdateUserName("系统管理员");
item.setUpdateTime(new Date());
return item;
}
}).collect(Collectors.toList());
Map<Boolean, List<UserEntity>> saveUpdateCollect = saveUpdateUserList.stream().collect(Collectors.partitioningBy(x -> x.getId() == null));
if (!ObjectUtils.isEmpty(saveUpdateCollect.get(true))) {
//需要新增的用户
log.info("需要新增用户数量:{}", saveUpdateCollect.get(true).size());
saveUpdateCollect.get(true).stream().forEach(item -> {
this.getUserDao().insert(item);
this.putCache(item.getId() == null ? "" : item.getId().toString(), item);
//更新默认用户角色
RoleUserQuery roleUserQuery = new RoleUserQuery();
roleUserQuery.setUserId(item.getId());
roleUserQuery.setRoleIdList(Arrays.asList(1L));
roleUserService.doDistributionRole(roleUserQuery);
});
}
@Override
public void sendSmsVerifyCode(String mobileNumber) throws AppException {
if (StringUtils.isEmpty(mobileNumber)) {
throw new AppException("手机号不能为空");
}
if (!PhoneUtil.isPhone(mobileNumber)) {
throw new AppException("手机号码格式不正确");
}
UserEntity user = this.selectOne(new UserQuery().mobile(mobileNumber));
if (user == null) {
throw new AppException("手机号码:" + mobileNumber + "没有注册用户");
}
String verifyCode = cacheService.get(SMS_VERIFY_CODE_KEY + mobileNumber);
if (StringUtils.isNotEmpty(verifyCode)) {
throw new AppException("当前手机号码已发送验证码,请稍后重试");
}
try {
Map<String, String> params = new HashMap<>();
params.put("appid", appid);
params.put("phone", mobileNumber);
params.put("type", SMS_TPYE);
String[] json = new String[2];
String vCode = RandomUtil.randomNumbers(6);
json[0] = vCode;
json[1] = "1";
params.put("json", JSONObject.toJSON(json).toString());
String resp = HttpUtil.doPost(smsApiUrl, params);
JSONObject respJson = JSONObject.parseObject(resp);
if (respJson.getIntValue("code") == 0) {
throw new AppException("短信发送失败:" + respJson.getString("message"));
if (!ObjectUtils.isEmpty(saveUpdateCollect.get(false))) {
//需要新增的用户
log.info("需要更新用户数量:{}", saveUpdateCollect.get(false).size());
saveUpdateCollect.get(false).stream().forEach(item -> {
this.getUserDao().update(item);
this.putCache(item.getId() == null ? "" : item.getId().toString(), item);
});
}
}
//有效期60秒
cacheService.setnx(SMS_VERIFY_CODE_KEY + mobileNumber, vCode, 60);
} catch (Exception e) {
log.error("短信发送异常", e);
throw new AppException("短信发送异常");
//查找新增 与更新
}
return Rest.ok();
}
@Override
public UserEntity doSmsLogin(String mobileNumber, String verifyCode, String loginIp) throws AppException {
if (StringUtils.isEmpty(mobileNumber)) {
throw new AppException("手机号不能为空");
}
if (StringUtils.isEmpty(verifyCode)) {
throw new AppException("验证码不能为空");
}
if (!PhoneUtil.isPhone(mobileNumber)) {
throw new AppException("手机号码格式不正确");
}
UserEntity customer = this.selectOne(new UserQuery().mobile(mobileNumber));
if (customer == null) {
throw new AppException("手机号码:" + mobileNumber + "没有注册用户");
}
String vCode = cacheService.get(SMS_VERIFY_CODE_KEY + mobileNumber);
if (StringUtils.isEmpty(vCode)) {
throw new AppException("验证码已失效");
}
if (!verifyCode.equals(vCode)) {
throw new AppException("验证码不正确");
}
UserEntity update = new UserEntity();
update.setId(customer.getId());
update.setLastLoginAddress(loginIp);
update.setLastLoginTime(new Date());
this.update(update);
return customer;
public UserDao getUserDao() {
return getDao();
}
@Override
protected void removeAfter(Long[] ids, Context context, int result) throws AppException {
super.removeAfter(ids, context, result);
RoleUserQuery roleUserQuery = new RoleUserQuery();
roleUserQuery.setUserIdList(Arrays.asList(ids));
Long[] userIds = roleUserService.find(roleUserQuery).stream().map(RoleUserEntity::getId).toArray(Long[]::new);
roleUserService.remove(userIds, context);
}
}
\ No newline at end of file
......@@ -2,12 +2,13 @@ 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;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.xhx.base.framework.annotation.Operlog;
import com.mortals.xhx.base.system.role.model.RoleQuery;
import com.mortals.xhx.base.system.role.model.RoleUserEntity;
......@@ -17,20 +18,13 @@ 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;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -48,9 +42,6 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
private RoleService roleService;
@Autowired
private RoleUserService roleUserService;
@Autowired
private DeptService deptService;
public UserController() {
super.setModuleDesc("用户信息");
......@@ -58,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)));
}
......@@ -79,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) {
......@@ -109,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("用户同步刷新操作成功");
}
......
{
"local": {
"baseUrl": "http://127.0.0.1:17500/attendance"
},
"test": {
"baseUrl": "http://192.168.0.250:11011/onecert"
},
"test-remote": {
"baseUrl": "http://8.136.255.30:11011/onecert"
},
"yibin": {
"baseUrl": "http://112.19.80.237:11039/attendance",
"baseLogin": "http://192.168.0.98:11078/base"
},
"pengxi": {
"baseUrl": "http://118.122.189.109:11039/attendance",
"baseLogin": "http://192.168.0.98:11078/base"
},
"portal": {
"baseUrl": "http://192.168.0.98:11072/zwfw",
"baseLogin": "http://192.168.0.98:11078/base"
},
"portal-yibin": {
"baseUrl": "http://112.19.80.237:11078/zwfw"
}
}
\ No newline at end of file
###登录
POST {{baseUrl}}/login/login
Content-Type: application/json
{
"loginName": "admin",
"password": "admin",
"securityCode": "admin"
}
> {%
client.global.set("SmsSet_id", JSON.parse(response.body).data.id);
client.global.set("authToken", JSON.parse(response.body).data.token);
%}
###修改用户密码
POST {{baseUrl}}/user/change/password
Authorization: {{authToken}}
Content-Type: application/x-www-form-urlencoded
oldPwd=aA123!@#&newPwd=aA123!@#.
###首页
POST {{baseUrl}}/login/index
Authorization: {{authToken}}
Content-Type: application/json
{}
###获取用户信息
POST {{baseUrl}}/user/interlist
Content-Type: application/json
{}
\ No newline at end of file
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