Commit c49cc743 by wancheng

Merge remote-tracking branch 'origin/dev' into dev

parents fac973a1 461e726c
...@@ -20,9 +20,9 @@ public class ServiceHPXS002 extends ServiceEPBase { ...@@ -20,9 +20,9 @@ public class ServiceHPXS002 extends ServiceEPBase {
@Override @Override
public EiInfo initLoad(EiInfo inInfo) { public EiInfo initLoad(EiInfo inInfo) {
EiInfo outInfo = super.initLoad(inInfo, new HPXS002()); EiInfo outInfo = super.query(inInfo,HPXS002.QUERY,new HPXS002());
CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.PROJ_RECORD_BLOCK_ID), null, false); CommonMethod.initBlock(outInfo, Arrays.asList(DdynamicEnum.PROJ_RECORD_BLOCK_ID), null, false);
outInfo.getBlock(EiConstant.resultBlock).getRows().clear(); //outInfo.getBlock(EiConstant.resultBlock).getRows().clear();
return outInfo; return outInfo;
} }
......
package com.baosight.iplat4j.core.security.service;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.security.base.SecurityFactory;
import com.baosight.iplat4j.core.security.base.UserNotExistException;
import com.baosight.iplat4j.core.security.user.IUserManager;
import com.baosight.iplat4j.core.security.user.User;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.util.StringUtils;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
/**
* 重写
*
* @author:songx
* @date:2024/4/10,16:08
*/
public class PlatformUserDetailsService implements UserDetailsService {
private String role = "ROLE_VERIFIED";
public PlatformUserDetailsService() {
}
public void setRole(String role) {
this.role = role;
}
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
try {
IUserManager userManager = SecurityFactory.getUserManager();
User user = userManager.getUser(username);
if (user == null) {
throw new UsernameNotFoundException("找不到这个用户");
} else {
SimpleGrantedAuthority authority = new SimpleGrantedAuthority(this.role);
Collection<GrantedAuthority> authorities = new ArrayList();
authorities.add(authority);
boolean valid = user.getValid() == 1;
boolean userNotExpired = true;
String expireDate = user.getExpireDate();
if (expireDate != null && StringUtils.hasText(expireDate)) {
Calendar currentDate = Calendar.getInstance();
Date nowTime = currentDate.getTime();
SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date expireDateTime = time.parse(expireDate);
userNotExpired = expireDateTime.after(nowTime);
}
boolean passwordNotExpired = true;
// 支持登录名或手机号两种方式登录 modify by songx at 2024-04-10
return new org.springframework.security.core.userdetails.User(user.getLoginName(), user.getLoginName(),
valid, userNotExpired, passwordNotExpired, !user.getIsLocked(), authorities);
}
} catch (UserNotExistException var13) {
throw new UsernameNotFoundException(var13.getMessage(), var13);
} catch (Exception var14) {
throw new PlatException(var14);
}
}
}
...@@ -16,6 +16,7 @@ import com.baosight.xservices.xs.constants.LoginConstants; ...@@ -16,6 +16,7 @@ import com.baosight.xservices.xs.constants.LoginConstants;
import com.baosight.xservices.xs.domain.XS01; import com.baosight.xservices.xs.domain.XS01;
import com.baosight.xservices.xs.domain.XS02; import com.baosight.xservices.xs.domain.XS02;
import com.baosight.xservices.xs.util.UserSession; import com.baosight.xservices.xs.util.UserSession;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
...@@ -84,6 +85,17 @@ public class ServiceXS0102 extends ServiceEPBase implements LoginConstants { ...@@ -84,6 +85,17 @@ public class ServiceXS0102 extends ServiceEPBase implements LoginConstants {
return inInfo; return inInfo;
} }
// 校验手机号是否存在 added by songx at 2024-04-10
if (StringUtils.isNotBlank(mobile)) {
Map paramMap = new HashMap();
paramMap.put("mobile", mobile);
List existMobile = this.dao.query("XSUser.query", paramMap);
if (CollectionUtils.isNotEmpty(existMobile)) {
inInfo.setStatus(EiConstant.STATUS_FAILURE);
inInfo.setMsg("注册失败!手机号已被其他用户使用");
return inInfo;
}
}
String userGroupEname = (String) inInfoRowMap.get("groupName"); String userGroupEname = (String) inInfoRowMap.get("groupName");
inInfoRowMap.put("userGroupEname", userGroupEname); inInfoRowMap.put("userGroupEname", userGroupEname);
inInfoRowMap.put("password", password); inInfoRowMap.put("password", password);
......
package com.baosight.xservices.xs.service;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.log.xeye.entity.XEyeEntity;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.core.util.DateUtils;
import com.baosight.xservices.xs.util.UserSession;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 重写
*
* @author:songx
* @date:2024/4/10,17:15
*/
public class ServiceXS0103 extends ServiceEPBase {
private static Logger logger = LogManager.getLogger(ServiceXS0103.class);
public ServiceXS0103() {
}
public EiInfo initLoad(EiInfo inInfo) {
return this.query(inInfo);
}
public EiInfo query(EiInfo inInfo) {
String loginName = UserSession.getUser().getUsername();
Map map = new HashMap();
map.put("loginName", loginName);
List resultList = this.dao.query("XS0103.query", map);
if (null != resultList && resultList.size() > 0) {
Map result = (Map) resultList.get(0);
inInfo.set("userId", result.get("userId"));
inInfo.set("userName", result.get("userName"));
inInfo.set("mobile", result.get("mobile"));
inInfo.set("email", result.get("email"));
}
return inInfo;
}
public EiInfo update(EiInfo inInfo) {
StringBuilder buffer = new StringBuilder();
StringBuilder detail = new StringBuilder();
String mobile = (String) inInfo.get("mobile");
Map map = new HashMap();
map.put("userId", inInfo.get("userId"));
map.put("userName", inInfo.get("userName"));
map.put("mobile", mobile);
map.put("email", inInfo.get("email"));
map.put("recRevisor", inInfo.get("userName"));
map.put("recReviseTime", DateUtils.curDateTimeStr14());
try {
Map paramMap = new HashMap();
paramMap.put("userId", inInfo.get("userId"));
List existsUsers = this.dao.query("XSUser.query", paramMap);
if (existsUsers.size() < 1) {
inInfo.setStatus(-1);
inInfo.setMsg("编辑用户信息失败,不存在: " + inInfo.get("userName") + "的用户!");
return inInfo;
}
Map existsUserMap = (Map)existsUsers.get(0);
String dbMobile = (String) existsUserMap.get("mobile");
// 手机号变更需要校验唯一性 added by songx at 2024-04-10
if (StringUtils.isNotBlank(mobile) && !dbMobile.equals(mobile)) {
paramMap = new HashMap();
paramMap.put("mobile", mobile);
List existMobile = this.dao.query("XSUser.query", paramMap);
if (CollectionUtils.isNotEmpty(existMobile)) {
inInfo.setStatus(EiConstant.STATUS_FAILURE);
inInfo.setMsg("手机号已被其他用户使用");
return inInfo;
}
}
this.dao.update("XS0103.update", map);
buffer.append("更新记录成功");
Map param = new HashMap();
param.put("userId", inInfo.get("userId"));
List userList = this.dao.query("XS01.query", param);
if (userList != null && userList.size() > 0) {
Map userMap = (Map) userList.get(0);
XEyeEntity xEyeEntity = new XEyeEntity();
xEyeEntity.setLogId("1002");
xEyeEntity.setLogName("修改用户信息");
xEyeEntity.setInvokeInfo(
UserSession.getUser().getUsername() + "在" + DateUtils.curDateStr("yyyy-MM-dd HH:mm:ss")
+ "修改了登录名为 " + userMap.get("loginName") + " 的用户信息");
xEyeEntity.setStatus(inInfo.getStatus() + "");
xEyeEntity.set("x_xs_id", userMap.get("userId"));
xEyeEntity.set("x_xs_on", UserSession.getUser().getUsername());
xEyeEntity.set("x_xs_ln", userMap.get("loginName"));
this.log(xEyeEntity);
}
} catch (Exception var9) {
buffer.append("更新记录失败");
inInfo.setStatus(-1);
detail.append(var9.getCause().toString());
logger.error(var9.getCause().getMessage());
}
EiInfo outInfo = this.query(inInfo);
outInfo.setMsg(buffer.toString());
outInfo.setDetailMsg(detail.toString());
return outInfo;
}
}
...@@ -52,7 +52,10 @@ ...@@ -52,7 +52,10 @@
USER_NAME like ('%$userName$%') USER_NAME like ('%$userName$%')
</isNotEmpty> </isNotEmpty>
<isNotEmpty prepend=" AND " property="loginName"> <isNotEmpty prepend=" AND " property="loginName">
LOGIN_NAME = #loginName# (LOGIN_NAME = #loginName# OR MOBILE = #loginName#)
</isNotEmpty>
<isNotEmpty prepend=" AND " property="mobile">
MOBILE = #mobile#
</isNotEmpty> </isNotEmpty>
<isNotEmpty prepend=" AND " property="userType"> <isNotEmpty prepend=" AND " property="userType">
USER_TYPE = #userType# USER_TYPE = #userType#
......
...@@ -162,7 +162,7 @@ $(function () { ...@@ -162,7 +162,7 @@ $(function () {
return return
} }
$("#authWindow").data("kendoWindow").open() $("#authWindow").data("kendoWindow").open()
result4Grid.dataSource.page(1); // result4Grid.dataSource.page(1);
result5Grid.dataSource.page(1); result5Grid.dataSource.page(1);
}) })
}, },
......
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