更新用户表的登录用户名的字段

This commit is contained in:
季圣华
2020-03-31 21:08:09 +08:00
parent e45e3b119e
commit f954061dba
16 changed files with 176 additions and 169 deletions

View File

@@ -55,7 +55,7 @@ public class TenantConfig {
Object userInfo = request.getSession().getAttribute("user");
if(userInfo != null) {
User user = (User) userInfo;
loginName = user.getLoginame();
loginName = user.getLoginName();
}
if(("admin").equals(loginName)) {
return true;

View File

@@ -149,7 +149,7 @@ public class FunctionsController {
Object userInfo = request.getSession().getAttribute("user");
if(userInfo != null) {
User user = (User) userInfo;
loginName = user.getLoginame();
loginName = user.getLoginName();
}
if(("admin").equals(loginName)) {
dataList.add(fun);

View File

@@ -67,7 +67,7 @@ public class UserController {
User user=null;
BaseResponseInfo res = new BaseResponseInfo();
try {
String username = loginName.trim();
loginName = loginName.trim();
password = password.trim();
//判断用户是否已经登录过,登录过不再处理
Object userInfo = request.getSession().getAttribute("user");
@@ -75,18 +75,18 @@ public class UserController {
if (userInfo != null) {
sessionUser = (User) userInfo;
}
if (sessionUser != null && username.equalsIgnoreCase(sessionUser.getLoginame())) {
logger.info("====用户 " + username + "已经登录过, login 方法调用结束====");
if (sessionUser != null && loginName.equalsIgnoreCase(sessionUser.getLoginName())) {
logger.info("====用户 " + loginName + "已经登录过, login 方法调用结束====");
msgTip = "user already login";
}
//获取用户状态
int userStatus = -1;
try {
request.getSession().removeAttribute("tenantId");
userStatus = userService.validateUser(username, password);
userStatus = userService.validateUser(loginName, password);
} catch (Exception e) {
e.printStackTrace();
logger.error(">>>>>>>>>>>>>用户 " + username + " 登录 login 方法 访问服务层异常====", e);
logger.error(">>>>>>>>>>>>>用户 " + loginName + " 登录 login 方法 访问服务层异常====", e);
msgTip = "access service exception";
}
switch (userStatus) {
@@ -106,7 +106,7 @@ public class UserController {
try {
msgTip = "user can login";
//验证通过 可以登录放入session记录登录日志
user = userService.getUserByUserName(username);
user = userService.getUserByLoginName(loginName);
request.getSession().setAttribute("user",user);
if(user.getTenantId()!=null) {
Tenant tenant = tenantService.getTenantByTenantId(user.getTenantId());
@@ -126,7 +126,7 @@ public class UserController {
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
} catch (Exception e) {
e.printStackTrace();
logger.error(">>>>>>>>>>>>>>>查询用户名为:" + username + " ,用户信息异常", e);
logger.error(">>>>>>>>>>>>>>>查询用户名为:" + loginName + " ,用户信息异常", e);
}
break;
}
@@ -213,7 +213,7 @@ public class UserController {
String oldPassword = Tools.md5Encryp(oldpwd);
String md5Pwd = Tools.md5Encryp(password);
//必须和原始密码一致才可以更新密码
if(user.getLoginame().equals("jsh")){
if(user.getLoginName().equals("jsh")){
flag = 3; //管理员jsh不能修改密码
} else if (oldPassword.equalsIgnoreCase(user.getPassword())) {
user.setPassword(md5Pwd);
@@ -330,19 +330,19 @@ public class UserController {
/**
* 注册用户
* @param loginame
* @param loginName
* @param password
* @return
* @throws Exception
*/
@PostMapping(value = "/registerUser")
public Object registerUser(@RequestParam(value = "loginame", required = false) String loginame,
public Object registerUser(@RequestParam(value = "loginName", required = false) String loginName,
@RequestParam(value = "password", required = false) String password,
HttpServletRequest request)throws Exception{
JSONObject result = ExceptionConstants.standardSuccess();
UserEx ue= new UserEx();
ue.setUsername(loginame);
ue.setLoginame(loginame);
ue.setUsername(loginName);
ue.setLoginName(loginName);
ue.setPassword(password);
userService.checkUserNameAndLoginName(ue); //检查用户名和登录名
ue = userService.registerUser(ue,manageRoleId,request);

View File

@@ -5,7 +5,7 @@ public class User {
private String username;
private String loginame;
private String loginName;
private String password;
@@ -45,12 +45,12 @@ public class User {
this.username = username == null ? null : username.trim();
}
public String getLoginame() {
return loginame;
public String getLoginName() {
return loginName;
}
public void setLoginame(String loginame) {
this.loginame = loginame == null ? null : loginame.trim();
public void setLoginName(String loginName) {
this.loginName = loginName == null ? null : loginName.trim();
}
public String getPassword() {

View File

@@ -234,73 +234,73 @@ public class UserExample {
return (Criteria) this;
}
public Criteria andLoginameIsNull() {
addCriterion("loginame is null");
public Criteria andLoginNameIsNull() {
addCriterion("login_name is null");
return (Criteria) this;
}
public Criteria andLoginameIsNotNull() {
addCriterion("loginame is not null");
public Criteria andLoginNameIsNotNull() {
addCriterion("login_name is not null");
return (Criteria) this;
}
public Criteria andLoginameEqualTo(String value) {
addCriterion("loginame =", value, "loginame");
public Criteria andLoginNameEqualTo(String value) {
addCriterion("login_name =", value, "loginName");
return (Criteria) this;
}
public Criteria andLoginameNotEqualTo(String value) {
addCriterion("loginame <>", value, "loginame");
public Criteria andLoginNameNotEqualTo(String value) {
addCriterion("login_name <>", value, "loginName");
return (Criteria) this;
}
public Criteria andLoginameGreaterThan(String value) {
addCriterion("loginame >", value, "loginame");
public Criteria andLoginNameGreaterThan(String value) {
addCriterion("login_name >", value, "loginName");
return (Criteria) this;
}
public Criteria andLoginameGreaterThanOrEqualTo(String value) {
addCriterion("loginame >=", value, "loginame");
public Criteria andLoginNameGreaterThanOrEqualTo(String value) {
addCriterion("login_name >=", value, "loginName");
return (Criteria) this;
}
public Criteria andLoginameLessThan(String value) {
addCriterion("loginame <", value, "loginame");
public Criteria andLoginNameLessThan(String value) {
addCriterion("login_name <", value, "loginName");
return (Criteria) this;
}
public Criteria andLoginameLessThanOrEqualTo(String value) {
addCriterion("loginame <=", value, "loginame");
public Criteria andLoginNameLessThanOrEqualTo(String value) {
addCriterion("login_name <=", value, "loginName");
return (Criteria) this;
}
public Criteria andLoginameLike(String value) {
addCriterion("loginame like", value, "loginame");
public Criteria andLoginNameLike(String value) {
addCriterion("login_name like", value, "loginName");
return (Criteria) this;
}
public Criteria andLoginameNotLike(String value) {
addCriterion("loginame not like", value, "loginame");
public Criteria andLoginNameNotLike(String value) {
addCriterion("login_name not like", value, "loginName");
return (Criteria) this;
}
public Criteria andLoginameIn(List<String> values) {
addCriterion("loginame in", values, "loginame");
public Criteria andLoginNameIn(List<String> values) {
addCriterion("login_name in", values, "loginName");
return (Criteria) this;
}
public Criteria andLoginameNotIn(List<String> values) {
addCriterion("loginame not in", values, "loginame");
public Criteria andLoginNameNotIn(List<String> values) {
addCriterion("login_name not in", values, "loginName");
return (Criteria) this;
}
public Criteria andLoginameBetween(String value1, String value2) {
addCriterion("loginame between", value1, value2, "loginame");
public Criteria andLoginNameBetween(String value1, String value2) {
addCriterion("login_name between", value1, value2, "loginName");
return (Criteria) this;
}
public Criteria andLoginameNotBetween(String value1, String value2) {
addCriterion("loginame not between", value1, value2, "loginame");
public Criteria andLoginNameNotBetween(String value1, String value2) {
addCriterion("login_name not between", value1, value2, "loginName");
return (Criteria) this;
}

View File

@@ -26,7 +26,7 @@ public interface UserMapperEx {
List<UserEx> getUserList(Map<String, Object> parameterMap);
List<User> getUserListByUserNameOrLoginName(@Param("userName") String userName,
@Param("loginame") String loginame);
@Param("loginName") String loginName);
int batDeleteOrUpdateUser(@Param("ids") String ids[], @Param("status") byte status);

View File

@@ -155,8 +155,8 @@ public class MaterialExtendService {
materialExtend.setDeleteFlag(BusinessConstants.DELETE_FLAG_EXISTS);
materialExtend.setCreateTime(new Date());
materialExtend.setUpdateTime(new Date().getTime());
materialExtend.setCreateSerial(user.getLoginame());
materialExtend.setUpdateSerial(user.getLoginame());
materialExtend.setCreateSerial(user.getLoginName());
materialExtend.setUpdateSerial(user.getLoginName());
int result =0;
try{
result= materialExtendMapper.insertSelective(materialExtend);
@@ -170,7 +170,7 @@ public class MaterialExtendService {
public int updateMaterialExtend(MaterialExtend MaterialExtend, HttpServletRequest request) throws Exception{
User user = userService.getCurrentUser();
MaterialExtend.setUpdateTime(new Date().getTime());
MaterialExtend.setUpdateSerial(user.getLoginame());
MaterialExtend.setUpdateSerial(user.getLoginName());
int res =0;
try{
res= materialExtendMapper.updateByPrimaryKeySelective(MaterialExtend);
@@ -205,7 +205,7 @@ public class MaterialExtendService {
Object userInfo = request.getSession().getAttribute("user");
User user = (User)userInfo;
materialExtend.setUpdateTime(new Date().getTime());
materialExtend.setUpdateSerial(user.getLoginame());
materialExtend.setUpdateSerial(user.getLoginName());
try{
result= materialExtendMapper.updateByPrimaryKeySelective(materialExtend);
}catch(Exception e){

View File

@@ -224,12 +224,12 @@ public class UserService {
return result;
}
public int validateUser(String username, String password) throws Exception {
public int validateUser(String loginName, String password) throws Exception {
/**默认是可以登录的*/
List<User> list = null;
try {
UserExample example = new UserExample();
example.createCriteria().andLoginameEqualTo(username).andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL);
example.createCriteria().andLoginNameEqualTo(loginName).andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL);
list = userMapper.selectByExample(example);
} catch (Exception e) {
logger.error(">>>>>>>>访问验证用户姓名是否存在后台信息异常", e);
@@ -242,7 +242,7 @@ public class UserService {
try {
UserExample example = new UserExample();
example.createCriteria().andLoginameEqualTo(username).andPasswordEqualTo(password)
example.createCriteria().andLoginNameEqualTo(loginName).andPasswordEqualTo(password)
.andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL);
list = userMapper.selectByExample(example);
} catch (Exception e) {
@@ -256,9 +256,9 @@ public class UserService {
return ExceptionCodeConstants.UserExceptionCode.USER_CONDITION_FIT;
}
public User getUserByUserName(String username)throws Exception {
public User getUserByLoginName(String loginName)throws Exception {
UserExample example = new UserExample();
example.createCriteria().andLoginameEqualTo(username).andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL);
example.createCriteria().andLoginNameEqualTo(loginName).andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL);
List<User> list=null;
try{
list= userMapper.selectByExample(example);
@@ -277,7 +277,7 @@ public class UserService {
List <Byte> userStatus=new ArrayList<Byte>();
userStatus.add(BusinessConstants.USER_STATUS_DELETE);
userStatus.add(BusinessConstants.USER_STATUS_BANNED);
example.createCriteria().andIdNotEqualTo(id).andLoginameEqualTo(name).andStatusNotIn(userStatus);
example.createCriteria().andIdNotEqualTo(id).andLoginNameEqualTo(name).andStatusNotIn(userStatus);
List<User> list=null;
try{
list= userMapper.selectByExample(example);
@@ -317,7 +317,7 @@ public class UserService {
public Long getIdByLoginName(String loginName) {
Long userId = 0L;
UserExample example = new UserExample();
example.createCriteria().andLoginameEqualTo(loginName).andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL);
example.createCriteria().andLoginNameEqualTo(loginName).andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL);
List<User> list = userMapper.selectByExample(example);
if(list!=null) {
userId = list.get(0).getId();
@@ -327,7 +327,7 @@ public class UserService {
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void addUserAndOrgUserRel(UserEx ue) throws Exception{
if(BusinessConstants.DEFAULT_MANAGER.equals(ue.getLoginame())) {
if(BusinessConstants.DEFAULT_MANAGER.equals(ue.getLoginName())) {
throw new BusinessRunTimeException(ExceptionConstants.USER_NAME_LIMIT_USE_CODE,
ExceptionConstants.USER_NAME_LIMIT_USE_MSG);
} else {
@@ -353,7 +353,7 @@ public class UserService {
//机构id
oul.setOrgaId(ue.getOrgaId());
//用户id根据用户名查询id
Long userId = getIdByLoginName(ue.getLoginame());
Long userId = getIdByLoginName(ue.getLoginName());
oul.setUserId(userId);
//用户在机构中的排序
oul.setUserBlngOrgaDsplSeq(ue.getUserBlngOrgaDsplSeq());
@@ -403,7 +403,7 @@ public class UserService {
* description:
* 多次创建事务,事物之间无法协同,应该在入口处创建一个事务以做协调
*/
if(BusinessConstants.DEFAULT_MANAGER.equals(ue.getLoginame())) {
if(BusinessConstants.DEFAULT_MANAGER.equals(ue.getLoginName())) {
throw new BusinessRunTimeException(ExceptionConstants.USER_NAME_LIMIT_USE_CODE,
ExceptionConstants.USER_NAME_LIMIT_USE_MSG);
} else {
@@ -416,7 +416,7 @@ public class UserService {
int result=0;
try{
result= userMapper.insertSelective(ue);
Long userId = getIdByLoginName(ue.getLoginame());
Long userId = getIdByLoginName(ue.getLoginName());
ue.setId(userId);
}catch(Exception e){
JshException.writeFail(logger, e);
@@ -437,7 +437,7 @@ public class UserService {
//创建租户信息
JSONObject tenantObj = new JSONObject();
tenantObj.put("tenantId", ue.getId());
tenantObj.put("loginName",ue.getLoginame());
tenantObj.put("loginName",ue.getLoginName());
String param = tenantObj.toJSONString();
tenantService.insertTenant(param, request);
logger.info("===============创建租户信息完成===============");
@@ -461,7 +461,7 @@ public class UserService {
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void updateUserAndOrgUserRel(UserEx ue) throws Exception{
if(BusinessConstants.DEFAULT_MANAGER.equals(ue.getLoginame())) {
if(BusinessConstants.DEFAULT_MANAGER.equals(ue.getLoginName())) {
throw new BusinessRunTimeException(ExceptionConstants.USER_NAME_LIMIT_USE_CODE,
ExceptionConstants.USER_NAME_LIMIT_USE_MSG);
} else {
@@ -535,8 +535,8 @@ public class UserService {
}
Long userId=userEx.getId();
//检查登录名
if(!StringUtils.isEmpty(userEx.getLoginame())){
String loginName=userEx.getLoginame();
if(!StringUtils.isEmpty(userEx.getLoginName())){
String loginName=userEx.getLoginName();
list=this.getUserListByloginName(loginName);
if(list!=null&&list.size()>0){
if(list.size()>1){

View File

@@ -4,7 +4,7 @@
<resultMap id="BaseResultMap" type="com.jsh.erp.datasource.entities.User">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="username" jdbcType="VARCHAR" property="username" />
<result column="loginame" jdbcType="VARCHAR" property="loginame" />
<result column="login_name" jdbcType="VARCHAR" property="loginName" />
<result column="password" jdbcType="VARCHAR" property="password" />
<result column="position" jdbcType="VARCHAR" property="position" />
<result column="department" jdbcType="VARCHAR" property="department" />
@@ -76,7 +76,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, username, loginame, password, position, department, email, phonenum, ismanager,
id, username, login_name, password, position, department, email, phonenum, ismanager,
isystem, Status, description, remark, tenant_id
</sql>
<select id="selectByExample" parameterType="com.jsh.erp.datasource.entities.UserExample" resultMap="BaseResultMap">
@@ -110,12 +110,12 @@
</if>
</delete>
<insert id="insert" parameterType="com.jsh.erp.datasource.entities.User">
insert into jsh_user (id, username, loginame,
insert into jsh_user (id, username, login_name,
password, position, department,
email, phonenum, ismanager,
isystem, Status, description,
remark, tenant_id)
values (#{id,jdbcType=BIGINT}, #{username,jdbcType=VARCHAR}, #{loginame,jdbcType=VARCHAR},
values (#{id,jdbcType=BIGINT}, #{username,jdbcType=VARCHAR}, #{loginName,jdbcType=VARCHAR},
#{password,jdbcType=VARCHAR}, #{position,jdbcType=VARCHAR}, #{department,jdbcType=VARCHAR},
#{email,jdbcType=VARCHAR}, #{phonenum,jdbcType=VARCHAR}, #{ismanager,jdbcType=TINYINT},
#{isystem,jdbcType=TINYINT}, #{status,jdbcType=TINYINT}, #{description,jdbcType=VARCHAR},
@@ -130,8 +130,8 @@
<if test="username != null">
username,
</if>
<if test="loginame != null">
loginame,
<if test="loginName != null">
login_name,
</if>
<if test="password != null">
password,
@@ -174,8 +174,8 @@
<if test="username != null">
#{username,jdbcType=VARCHAR},
</if>
<if test="loginame != null">
#{loginame,jdbcType=VARCHAR},
<if test="loginName != null">
#{loginName,jdbcType=VARCHAR},
</if>
<if test="password != null">
#{password,jdbcType=VARCHAR},
@@ -227,8 +227,8 @@
<if test="record.username != null">
username = #{record.username,jdbcType=VARCHAR},
</if>
<if test="record.loginame != null">
loginame = #{record.loginame,jdbcType=VARCHAR},
<if test="record.loginName != null">
login_name = #{record.loginName,jdbcType=VARCHAR},
</if>
<if test="record.password != null">
password = #{record.password,jdbcType=VARCHAR},
@@ -272,7 +272,7 @@
update jsh_user
set id = #{record.id,jdbcType=BIGINT},
username = #{record.username,jdbcType=VARCHAR},
loginame = #{record.loginame,jdbcType=VARCHAR},
login_name = #{record.loginName,jdbcType=VARCHAR},
password = #{record.password,jdbcType=VARCHAR},
position = #{record.position,jdbcType=VARCHAR},
department = #{record.department,jdbcType=VARCHAR},
@@ -294,8 +294,8 @@
<if test="username != null">
username = #{username,jdbcType=VARCHAR},
</if>
<if test="loginame != null">
loginame = #{loginame,jdbcType=VARCHAR},
<if test="loginName != null">
login_name = #{loginName,jdbcType=VARCHAR},
</if>
<if test="password != null">
password = #{password,jdbcType=VARCHAR},
@@ -336,7 +336,7 @@
<update id="updateByPrimaryKey" parameterType="com.jsh.erp.datasource.entities.User">
update jsh_user
set username = #{username,jdbcType=VARCHAR},
loginame = #{loginame,jdbcType=VARCHAR},
login_name = #{loginName,jdbcType=VARCHAR},
password = #{password,jdbcType=VARCHAR},
position = #{position,jdbcType=VARCHAR},
department = #{department,jdbcType=VARCHAR},

View File

@@ -16,7 +16,7 @@
and username like '%${userName}%'
</if>
<if test="loginName != null">
and loginame like '%${loginName}%'
and login_name like '%${loginName}%'
</if>
<if test="offset != null and rows != null">
limit #{offset},#{rows}
@@ -32,11 +32,11 @@
and username like '%${userName}%'
</if>
<if test="loginName != null">
and loginame like '%${loginName}%'
and login_name like '%${loginName}%'
</if>
</select>
<select id="getUserList" parameterType="java.util.Map" resultMap="ResultMapEx">
select user.id, user.username, user.loginame, user.position, user.email, user.phonenum,
select user.id, user.username, user.login_name, user.position, user.email, user.phonenum,
user.description, user.remark,user.isystem,org.id as orgaId,user.tenant_id,org.org_abr,rel.user_blng_orga_dspl_seq,
rel.id as orgaUserRelId
FROM jsh_user user
@@ -50,12 +50,12 @@
</if>
<if test="loginName != null and loginName != ''">
<bind name="loginName" value="'%' + _parameter.loginName + '%'" />
and user.loginame like #{loginName}
and user.login_name like #{loginName}
</if>
order by user.id desc
</select>
<select id="getUserListByUserNameOrLoginName" resultMap="com.jsh.erp.datasource.mappers.UserMapper.BaseResultMap">
select user.id, user.username, user.loginame, user.position, user.email, user.phonenum,
select user.id, user.username, user.login_name, user.position, user.email, user.phonenum,
user.description, user.remark,user.isystem
FROM jsh_user user
where 1=1
@@ -63,8 +63,8 @@
<if test="userName != null and userName != ''">
and user.userName = #{userName}
</if>
<if test="loginame != null and loginame != ''">
and user.loginame = #{loginame}
<if test="loginName != null and loginName != ''">
and user.login_name = #{loginName}
</if>
order by user.id desc
</select>