1去掉openFeign调用,自己写用户管理部分
This commit is contained in:
parent
7b74f6b138
commit
f50e8bc0e6
@ -1,5 +1,6 @@
|
|||||||
package com.xhpc.system.api.domain;
|
package com.xhpc.system.api.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.xhpc.common.core.annotation.Excel;
|
import com.xhpc.common.core.annotation.Excel;
|
||||||
import com.xhpc.common.core.annotation.Excel.ColumnType;
|
import com.xhpc.common.core.annotation.Excel.ColumnType;
|
||||||
@ -8,6 +9,7 @@ import com.xhpc.common.core.annotation.Excels;
|
|||||||
import com.xhpc.common.core.web.domain.BaseEntity;
|
import com.xhpc.common.core.web.domain.BaseEntity;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import javax.validation.constraints.Email;
|
import javax.validation.constraints.Email;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
@ -96,6 +98,8 @@ public class SysUser extends BaseEntity
|
|||||||
|
|
||||||
/** 最后登录时间 */
|
/** 最后登录时间 */
|
||||||
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
|
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date loginDate;
|
private Date loginDate;
|
||||||
|
|
||||||
/** 部门对象 */
|
/** 部门对象 */
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
package com.xhpc.common.core.web.domain;
|
package com.xhpc.common.core.web.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entity基类
|
* Entity基类
|
||||||
@ -23,6 +25,7 @@ public class BaseEntity implements Serializable
|
|||||||
|
|
||||||
/** 创建时间 */
|
/** 创建时间 */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
/** 更新者 */
|
/** 更新者 */
|
||||||
@ -30,6 +33,7 @@ public class BaseEntity implements Serializable
|
|||||||
|
|
||||||
/** 更新时间 */
|
/** 更新时间 */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
/** 备注 */
|
/** 备注 */
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package com.xhpc.order.aspect;
|
package com.xhpc.order.aspect;
|
||||||
|
|
||||||
|
|
||||||
import com.xhpc.common.core.utils.DateUtils;
|
|
||||||
import com.xhpc.common.core.utils.SecurityUtils;
|
import com.xhpc.common.core.utils.SecurityUtils;
|
||||||
import com.xhpc.common.core.utils.StringUtils;
|
import com.xhpc.common.core.utils.StringUtils;
|
||||||
import com.xhpc.system.api.model.LoginUser;
|
import com.xhpc.system.api.model.LoginUser;
|
||||||
@ -16,6 +15,7 @@ import org.springframework.web.context.request.RequestContextHolder;
|
|||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO AO切面,插入创建人,创建时间,修改人,修改时间
|
* TODO AO切面,插入创建人,创建时间,修改人,修改时间
|
||||||
@ -26,9 +26,9 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
@Component
|
@Component
|
||||||
@Configuration
|
@Configuration
|
||||||
public class DaoAspect {
|
public class DaoAspect {
|
||||||
private static final String CREATE_USER = "createUser";
|
private static final String CREATE_USER = "createBy";
|
||||||
private static final String CREATE_TIME = "createTime";
|
private static final String CREATE_TIME = "createTime";
|
||||||
private static final String UPDATE_USER = "updateUser";
|
private static final String UPDATE_USER = "updateBy";
|
||||||
private static final String UPDATE_TIME = "updateTime";
|
private static final String UPDATE_TIME = "updateTime";
|
||||||
|
|
||||||
@Pointcut("execution(* com.xhpc..*.update*(..))")
|
@Pointcut("execution(* com.xhpc..*.update*(..))")
|
||||||
@ -68,7 +68,7 @@ public class DaoAspect {
|
|||||||
BeanUtils.setProperty(arg, UPDATE_USER, userName);
|
BeanUtils.setProperty(arg, UPDATE_USER, userName);
|
||||||
}
|
}
|
||||||
if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
||||||
BeanUtils.setProperty(arg, UPDATE_TIME, DateUtils.getTime());
|
BeanUtils.setProperty(arg, UPDATE_TIME, new Date());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,6 +104,7 @@ public class DaoAspect {
|
|||||||
if (StringUtils.isNull(userName)) {
|
if (StringUtils.isNull(userName)) {
|
||||||
userName = "admin";
|
userName = "admin";
|
||||||
}
|
}
|
||||||
|
Date date = new Date();
|
||||||
if (isProperty(arg, CREATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_USER))) {
|
if (isProperty(arg, CREATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_USER))) {
|
||||||
BeanUtils.setProperty(arg, CREATE_USER, userName);
|
BeanUtils.setProperty(arg, CREATE_USER, userName);
|
||||||
}
|
}
|
||||||
@ -112,10 +113,10 @@ public class DaoAspect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isProperty(arg, CREATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_TIME))) {
|
if (isProperty(arg, CREATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_TIME))) {
|
||||||
BeanUtils.setProperty(arg, CREATE_TIME, DateUtils.getTime());
|
BeanUtils.setProperty(arg, CREATE_TIME, date);
|
||||||
}
|
}
|
||||||
if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
||||||
BeanUtils.setProperty(arg, UPDATE_TIME, DateUtils.getTime());
|
BeanUtils.setProperty(arg, UPDATE_TIME, date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package com.xhpc.payment.aspect;
|
package com.xhpc.payment.aspect;
|
||||||
|
|
||||||
|
|
||||||
import com.xhpc.common.core.utils.DateUtils;
|
|
||||||
import com.xhpc.common.core.utils.SecurityUtils;
|
import com.xhpc.common.core.utils.SecurityUtils;
|
||||||
import com.xhpc.common.core.utils.StringUtils;
|
import com.xhpc.common.core.utils.StringUtils;
|
||||||
import com.xhpc.system.api.model.LoginUser;
|
import com.xhpc.system.api.model.LoginUser;
|
||||||
@ -16,6 +15,7 @@ import org.springframework.web.context.request.RequestContextHolder;
|
|||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO AO切面,插入创建人,创建时间,修改人,修改时间
|
* TODO AO切面,插入创建人,创建时间,修改人,修改时间
|
||||||
@ -26,9 +26,9 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
@Component
|
@Component
|
||||||
@Configuration
|
@Configuration
|
||||||
public class DaoAspect {
|
public class DaoAspect {
|
||||||
private static final String CREATE_USER = "createUser";
|
private static final String CREATE_USER = "createBy";
|
||||||
private static final String CREATE_TIME = "createTime";
|
private static final String CREATE_TIME = "createTime";
|
||||||
private static final String UPDATE_USER = "updateUser";
|
private static final String UPDATE_USER = "updateBy";
|
||||||
private static final String UPDATE_TIME = "updateTime";
|
private static final String UPDATE_TIME = "updateTime";
|
||||||
|
|
||||||
@Pointcut("execution(* com.xhpc..*.update*(..))")
|
@Pointcut("execution(* com.xhpc..*.update*(..))")
|
||||||
@ -68,7 +68,7 @@ public class DaoAspect {
|
|||||||
BeanUtils.setProperty(arg, UPDATE_USER, userName);
|
BeanUtils.setProperty(arg, UPDATE_USER, userName);
|
||||||
}
|
}
|
||||||
if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
||||||
BeanUtils.setProperty(arg, UPDATE_TIME, DateUtils.getTime());
|
BeanUtils.setProperty(arg, UPDATE_TIME, new Date());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,6 +104,7 @@ public class DaoAspect {
|
|||||||
if (StringUtils.isNull(userName)) {
|
if (StringUtils.isNull(userName)) {
|
||||||
userName = "admin";
|
userName = "admin";
|
||||||
}
|
}
|
||||||
|
Date date = new Date();
|
||||||
if (isProperty(arg, CREATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_USER))) {
|
if (isProperty(arg, CREATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_USER))) {
|
||||||
BeanUtils.setProperty(arg, CREATE_USER, userName);
|
BeanUtils.setProperty(arg, CREATE_USER, userName);
|
||||||
}
|
}
|
||||||
@ -112,10 +113,10 @@ public class DaoAspect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isProperty(arg, CREATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_TIME))) {
|
if (isProperty(arg, CREATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_TIME))) {
|
||||||
BeanUtils.setProperty(arg, CREATE_TIME, DateUtils.getTime());
|
BeanUtils.setProperty(arg, CREATE_TIME, date);
|
||||||
}
|
}
|
||||||
if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
||||||
BeanUtils.setProperty(arg, UPDATE_TIME, DateUtils.getTime());
|
BeanUtils.setProperty(arg, UPDATE_TIME, date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package com.xhpc.user.aspect;
|
package com.xhpc.user.aspect;
|
||||||
|
|
||||||
|
|
||||||
import com.xhpc.common.core.utils.DateUtils;
|
|
||||||
import com.xhpc.common.core.utils.SecurityUtils;
|
import com.xhpc.common.core.utils.SecurityUtils;
|
||||||
import com.xhpc.common.core.utils.StringUtils;
|
import com.xhpc.common.core.utils.StringUtils;
|
||||||
import com.xhpc.system.api.model.LoginUser;
|
import com.xhpc.system.api.model.LoginUser;
|
||||||
@ -27,9 +26,9 @@ import java.util.Date;
|
|||||||
@Component
|
@Component
|
||||||
@Configuration
|
@Configuration
|
||||||
public class DaoAspect {
|
public class DaoAspect {
|
||||||
private static final String CREATE_BY = "create_by";
|
private static final String CREATE_BY = "createBy";
|
||||||
private static final String CREATE_TIME = "createTime";
|
private static final String CREATE_TIME = "createTime";
|
||||||
private static final String UPDATE_BY = "update_by";
|
private static final String UPDATE_BY = "updateBy";
|
||||||
private static final String UPDATE_TIME = "updateTime";
|
private static final String UPDATE_TIME = "updateTime";
|
||||||
|
|
||||||
@Pointcut("execution(* com.xhpc..*.update*(..))")
|
@Pointcut("execution(* com.xhpc..*.update*(..))")
|
||||||
@ -69,7 +68,7 @@ public class DaoAspect {
|
|||||||
BeanUtils.setProperty(arg, UPDATE_BY, userName);
|
BeanUtils.setProperty(arg, UPDATE_BY, userName);
|
||||||
}
|
}
|
||||||
if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
||||||
BeanUtils.setProperty(arg, UPDATE_TIME, DateUtils.getTime());
|
BeanUtils.setProperty(arg, UPDATE_TIME, new Date());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,10 +113,10 @@ public class DaoAspect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isProperty(arg, CREATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_TIME))) {
|
if (isProperty(arg, CREATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_TIME))) {
|
||||||
BeanUtils.setProperty(arg, CREATE_TIME, DateUtils.getTime());
|
BeanUtils.setProperty(arg, CREATE_TIME, date);
|
||||||
}
|
}
|
||||||
if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) {
|
||||||
BeanUtils.setProperty(arg, UPDATE_TIME, DateUtils.getTime());
|
BeanUtils.setProperty(arg, UPDATE_TIME, date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import com.xhpc.common.core.web.page.TableDataInfo;
|
|||||||
import com.xhpc.common.security.annotation.PreAuthorize;
|
import com.xhpc.common.security.annotation.PreAuthorize;
|
||||||
import com.xhpc.system.api.domain.SysUser;
|
import com.xhpc.system.api.domain.SysUser;
|
||||||
import com.xhpc.user.domain.XhpcInternetUser;
|
import com.xhpc.user.domain.XhpcInternetUser;
|
||||||
import com.xhpc.user.openfeign.RemoteSystemService;
|
|
||||||
import com.xhpc.user.service.IXhpcInternetUserService;
|
import com.xhpc.user.service.IXhpcInternetUserService;
|
||||||
import com.xhpc.user.service.IXhpcUserService;
|
import com.xhpc.user.service.IXhpcUserService;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
@ -33,9 +32,6 @@ public class XhpcInternetUserController extends BaseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IXhpcInternetUserService iXhpcInternetUserService;
|
private IXhpcInternetUserService iXhpcInternetUserService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RemoteSystemService remoteSystemService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IXhpcUserService iXhpcUserService;
|
private IXhpcUserService iXhpcUserService;
|
||||||
|
|
||||||
@ -55,21 +51,15 @@ public class XhpcInternetUserController extends BaseController {
|
|||||||
sysUser.setUserType(StatusConstants.INTERNET_USER_TYPE);
|
sysUser.setUserType(StatusConstants.INTERNET_USER_TYPE);
|
||||||
sysUser.setDataPowerType(StatusConstants.INTERNET_POWER_TYPE);
|
sysUser.setDataPowerType(StatusConstants.INTERNET_POWER_TYPE);
|
||||||
sysUser.setCreateBy(SecurityUtils.getUsername());
|
sysUser.setCreateBy(SecurityUtils.getUsername());
|
||||||
sysUser.setPassword(SecurityUtils.encryptPassword(xhpcInternetUser.getPhone()));
|
sysUser.setPassword(xhpcInternetUser.getPhone());
|
||||||
Long[] role = new Long[1];
|
Long[] role = new Long[1];
|
||||||
role[0] = 4l;
|
role[0] = 4l;
|
||||||
sysUser.setRoleIds(role);
|
sysUser.setRoleIds(role);
|
||||||
AjaxResult ajaxResult = remoteSystemService.addUser(sysUser);
|
if (iXhpcUserService.checkUserNameUnique(sysUser.getUserName()) > 0) {
|
||||||
if (StringUtils.isNotNull(ajaxResult) && !"200".equals(StringUtils.valueOf(ajaxResult.get("code")))) {
|
return AjaxResult.error("新增用户'" + sysUser.getUserName() + "'失败,登录账号已存在");
|
||||||
return ajaxResult;
|
|
||||||
}
|
}
|
||||||
SysUser sysUser1 = iXhpcUserService.selectUserByUserName(sysUser.getUserName());
|
|
||||||
iXhpcInternetUserService.insert(xhpcInternetUser);
|
iXhpcInternetUserService.insert(xhpcInternetUser);
|
||||||
sysUser1.setInternetUserId(xhpcInternetUser.getInternetUserId());
|
sysUser = iXhpcUserService.insertUser(sysUser);
|
||||||
ajaxResult = remoteSystemService.editUser(sysUser1);
|
|
||||||
if (StringUtils.isNotNull(ajaxResult) && !"200".equals(StringUtils.valueOf(ajaxResult.get("code")))) {
|
|
||||||
return ajaxResult;
|
|
||||||
}
|
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,16 +77,7 @@ public class XhpcInternetUserController extends BaseController {
|
|||||||
sysUser.setUserName(xhpcInternetUser.getPhone());
|
sysUser.setUserName(xhpcInternetUser.getPhone());
|
||||||
sysUser.setNickName(xhpcInternetUser.getName());
|
sysUser.setNickName(xhpcInternetUser.getName());
|
||||||
sysUser.setPhonenumber(xhpcInternetUser.getPhone());
|
sysUser.setPhonenumber(xhpcInternetUser.getPhone());
|
||||||
sysUser.setDeptId(103l);
|
iXhpcUserService.updateUser(sysUser);
|
||||||
sysUser.setSex("0");
|
|
||||||
sysUser.setUserType(StatusConstants.INTERNET_USER_TYPE);
|
|
||||||
sysUser.setDataPowerType(StatusConstants.INTERNET_POWER_TYPE);
|
|
||||||
sysUser.setCreateBy(SecurityUtils.getUsername());
|
|
||||||
sysUser.setPassword(SecurityUtils.encryptPassword(xhpcInternetUser.getPhone()));
|
|
||||||
AjaxResult ajaxResult = remoteSystemService.editUser(sysUser);
|
|
||||||
if (StringUtils.isNotNull(ajaxResult) && !"200".equals(StringUtils.valueOf(ajaxResult.get("code")))) {
|
|
||||||
return ajaxResult;
|
|
||||||
}
|
|
||||||
return toAjax(iXhpcInternetUserService.update(xhpcInternetUser));
|
return toAjax(iXhpcInternetUserService.update(xhpcInternetUser));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
package com.xhpc.user.controller;
|
package com.xhpc.user.controller;
|
||||||
|
|
||||||
import com.xhpc.common.core.constant.HttpStatus;
|
import com.xhpc.common.core.constant.HttpStatus;
|
||||||
import com.xhpc.common.core.constant.StatusConstants;
|
|
||||||
import com.xhpc.common.core.constant.UserConstants;
|
|
||||||
import com.xhpc.common.core.utils.SecurityUtils;
|
import com.xhpc.common.core.utils.SecurityUtils;
|
||||||
import com.xhpc.common.core.utils.StringUtils;
|
import com.xhpc.common.core.utils.StringUtils;
|
||||||
import com.xhpc.common.core.web.controller.BaseController;
|
import com.xhpc.common.core.web.controller.BaseController;
|
||||||
@ -11,7 +9,6 @@ import com.xhpc.common.core.web.page.TableDataInfo;
|
|||||||
import com.xhpc.common.security.annotation.PreAuthorize;
|
import com.xhpc.common.security.annotation.PreAuthorize;
|
||||||
import com.xhpc.system.api.domain.SysUser;
|
import com.xhpc.system.api.domain.SysUser;
|
||||||
import com.xhpc.user.domain.XhpcOperator;
|
import com.xhpc.user.domain.XhpcOperator;
|
||||||
import com.xhpc.user.openfeign.RemoteSystemService;
|
|
||||||
import com.xhpc.user.service.IXhpcOperatorService;
|
import com.xhpc.user.service.IXhpcOperatorService;
|
||||||
import com.xhpc.user.service.IXhpcUserService;
|
import com.xhpc.user.service.IXhpcUserService;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
@ -34,9 +31,6 @@ public class XhpcOperatorController extends BaseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IXhpcOperatorService iXhpcOperatorService;
|
private IXhpcOperatorService iXhpcOperatorService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RemoteSystemService remoteSystemService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IXhpcUserService iXhpcUserService;
|
private IXhpcUserService iXhpcUserService;
|
||||||
|
|
||||||
@ -57,24 +51,16 @@ public class XhpcOperatorController extends BaseController {
|
|||||||
sysUser.setUserType("01");
|
sysUser.setUserType("01");
|
||||||
sysUser.setDataPowerType(1);
|
sysUser.setDataPowerType(1);
|
||||||
sysUser.setCreateBy(SecurityUtils.getUsername());
|
sysUser.setCreateBy(SecurityUtils.getUsername());
|
||||||
sysUser.setPassword(SecurityUtils.encryptPassword(xhpcOperator.getPhone()));
|
sysUser.setPassword(xhpcOperator.getPhone());
|
||||||
Long[] roleIds = new Long[1];
|
Long[] roleIds = new Long[1];
|
||||||
roleIds[0] = 3l;
|
roleIds[0] = 3l;
|
||||||
sysUser.setRoleIds(roleIds);
|
sysUser.setRoleIds(roleIds);
|
||||||
AjaxResult ajaxResult = remoteSystemService.addUser(sysUser);
|
if (iXhpcUserService.checkUserNameUnique(sysUser.getUserName()) > 0) {
|
||||||
if (StringUtils.isNotNull(ajaxResult) && !"200".equals(StringUtils.valueOf(ajaxResult.get("code")))) {
|
return AjaxResult.error("新增用户'" + sysUser.getUserName() + "'失败,登录账号已存在");
|
||||||
return ajaxResult;
|
|
||||||
}
|
|
||||||
if (UserConstants.NOT_UNIQUE.equals(iXhpcOperatorService.checkAccountUnique(xhpcOperator))) {
|
|
||||||
return AjaxResult.error(HttpStatus.ALREADY_EXISTING, "用户'" + xhpcOperator.getPhone() + "'失败,登录账号已存在");
|
|
||||||
}
|
}
|
||||||
iXhpcOperatorService.insert(xhpcOperator);
|
iXhpcOperatorService.insert(xhpcOperator);
|
||||||
SysUser sysUser1 = iXhpcUserService.selectUserByUserName(sysUser.getUserName());
|
sysUser.setOperatorId(xhpcOperator.getOperatorId());
|
||||||
sysUser1.setOperatorId(xhpcOperator.getOperatorId());
|
sysUser = iXhpcUserService.insertUser(sysUser);
|
||||||
ajaxResult = remoteSystemService.editUser(sysUser1);
|
|
||||||
if (StringUtils.isNotNull(ajaxResult) && !"200".equals(StringUtils.valueOf(ajaxResult.get("code")))) {
|
|
||||||
return ajaxResult;
|
|
||||||
}
|
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,23 +75,10 @@ public class XhpcOperatorController extends BaseController {
|
|||||||
return AjaxResult.error(HttpStatus.NOT_NULL, "运营商id不能为空");
|
return AjaxResult.error(HttpStatus.NOT_NULL, "运营商id不能为空");
|
||||||
}
|
}
|
||||||
SysUser sysUser = new SysUser();
|
SysUser sysUser = new SysUser();
|
||||||
sysUser.setUserName(xhpcOperator.getPhone());
|
|
||||||
sysUser.setNickName(xhpcOperator.getName());
|
sysUser.setNickName(xhpcOperator.getName());
|
||||||
sysUser.setEmail(xhpcOperator.getEmail());
|
sysUser.setEmail(xhpcOperator.getEmail());
|
||||||
sysUser.setPhonenumber(xhpcOperator.getPhone());
|
sysUser.setPhonenumber(xhpcOperator.getPhone());
|
||||||
sysUser.setDeptId(103l);
|
iXhpcUserService.updateUser(sysUser);
|
||||||
sysUser.setSex("0");
|
|
||||||
sysUser.setDataPowerType(StatusConstants.OPERATION_POWER_TYPE);
|
|
||||||
sysUser.setUserType(StatusConstants.OPERATION_USER_TYPE);
|
|
||||||
sysUser.setCreateBy(SecurityUtils.getUsername());
|
|
||||||
sysUser.setPassword(SecurityUtils.encryptPassword(xhpcOperator.getPhone()));
|
|
||||||
AjaxResult ajaxResult = remoteSystemService.editUser(sysUser);
|
|
||||||
if (StringUtils.isNotNull(ajaxResult) && !"200".equals(StringUtils.valueOf(ajaxResult.get("code")))) {
|
|
||||||
return ajaxResult;
|
|
||||||
}
|
|
||||||
if (UserConstants.NOT_UNIQUE.equals(iXhpcOperatorService.checkAccountUnique(xhpcOperator))) {
|
|
||||||
return AjaxResult.error(HttpStatus.ALREADY_EXISTING, "用户'" + xhpcOperator.getPhone() + "'失败,登录账号已存在");
|
|
||||||
}
|
|
||||||
return toAjax(iXhpcOperatorService.update(xhpcOperator));
|
return toAjax(iXhpcOperatorService.update(xhpcOperator));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import com.xhpc.common.core.web.page.TableDataInfo;
|
|||||||
import com.xhpc.common.security.annotation.PreAuthorize;
|
import com.xhpc.common.security.annotation.PreAuthorize;
|
||||||
import com.xhpc.system.api.domain.SysRole;
|
import com.xhpc.system.api.domain.SysRole;
|
||||||
import com.xhpc.system.api.domain.SysUser;
|
import com.xhpc.system.api.domain.SysUser;
|
||||||
import com.xhpc.user.openfeign.RemoteSystemService;
|
|
||||||
import com.xhpc.user.service.IXhpcOperatorService;
|
import com.xhpc.user.service.IXhpcOperatorService;
|
||||||
import com.xhpc.user.service.IXhpcUserService;
|
import com.xhpc.user.service.IXhpcUserService;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
@ -32,9 +31,6 @@ public class XhpcUserController extends BaseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IXhpcUserService iXhpcUserService;
|
private IXhpcUserService iXhpcUserService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RemoteSystemService remoteSystemService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IXhpcOperatorService iXhpcOperatorService;
|
private IXhpcOperatorService iXhpcOperatorService;
|
||||||
|
|
||||||
@ -56,27 +52,24 @@ public class XhpcUserController extends BaseController {
|
|||||||
@PreAuthorize(hasPermi = "user:pc:add")
|
@PreAuthorize(hasPermi = "user:pc:add")
|
||||||
@PostMapping("/pc/add")
|
@PostMapping("/pc/add")
|
||||||
public AjaxResult pcAdd(@RequestBody SysUser sysUser) {
|
public AjaxResult pcAdd(@RequestBody SysUser sysUser) {
|
||||||
|
if (iXhpcUserService.checkUserNameUnique(sysUser.getUserName()) > 0) {
|
||||||
|
return AjaxResult.error("新增用户'" + sysUser.getUserName() + "'失败,登录账号已存在");
|
||||||
|
}
|
||||||
SysRole role = new SysRole();
|
SysRole role = new SysRole();
|
||||||
role.setRoleName(sysUser.getUserName());
|
role.setRoleName(sysUser.getUserName());
|
||||||
role.setRoleKey(sysUser.getUserName());
|
role.setRoleKey(sysUser.getUserName());
|
||||||
AjaxResult ajaxResult = remoteSystemService.addRole(role);
|
role.setRoleSort("1");
|
||||||
if (StringUtils.isNotNull(ajaxResult) && !"200".equals(StringUtils.valueOf(ajaxResult.get("code")))) {
|
iXhpcUserService.insertRole(role);
|
||||||
return ajaxResult;
|
|
||||||
}
|
|
||||||
role = iXhpcUserService.selectUserByRoleName(sysUser.getUserName());
|
|
||||||
sysUser.setPhonenumber(sysUser.getUserName());
|
sysUser.setPhonenumber(sysUser.getUserName());
|
||||||
sysUser.setDeptId(103l);
|
sysUser.setDeptId(103l);
|
||||||
sysUser.setDataPowerType(StatusConstants.SON_POWER_TYPE);
|
sysUser.setDataPowerType(StatusConstants.SON_POWER_TYPE);
|
||||||
sysUser.setUserType(StatusConstants.SYSTEM_USER_TYPE);
|
sysUser.setUserType(StatusConstants.SYSTEM_USER_TYPE);
|
||||||
sysUser.setCreateBy(SecurityUtils.getUsername());
|
sysUser.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
sysUser.setPassword(sysUser.getUserName());
|
||||||
Long[] roles = new Long[1];
|
Long[] roles = new Long[1];
|
||||||
roles[0] = role.getRoleId();
|
roles[0] = role.getRoleId();
|
||||||
sysUser.setRoleIds(roles);
|
sysUser.setRoleIds(roles);
|
||||||
ajaxResult = remoteSystemService.addUser(sysUser);
|
iXhpcUserService.insertUser(sysUser);
|
||||||
if (StringUtils.isNotNull(ajaxResult) && !"200".equals(StringUtils.valueOf(ajaxResult.get("code")))) {
|
|
||||||
return ajaxResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,10 +83,10 @@ public class XhpcUserController extends BaseController {
|
|||||||
if (null == sysUser.getUserId()) {
|
if (null == sysUser.getUserId()) {
|
||||||
return AjaxResult.error(HttpStatus.NOT_NULL, "用户id不能为空");
|
return AjaxResult.error(HttpStatus.NOT_NULL, "用户id不能为空");
|
||||||
}
|
}
|
||||||
AjaxResult ajaxResult = remoteSystemService.editUser(sysUser);
|
if (iXhpcUserService.checkUserNameUnique(sysUser.getUserName()) > 0) {
|
||||||
if (StringUtils.isNotNull(ajaxResult) && !"200".equals(StringUtils.valueOf(ajaxResult.get("code")))) {
|
return AjaxResult.error("新增用户'" + sysUser.getUserName() + "'失败,登录账号已存在");
|
||||||
return ajaxResult;
|
|
||||||
}
|
}
|
||||||
|
iXhpcUserService.insertUser(sysUser);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,14 +123,14 @@ public class XhpcUserController extends BaseController {
|
|||||||
if (null == sysUser.getOperatorId()) {
|
if (null == sysUser.getOperatorId()) {
|
||||||
return AjaxResult.error(HttpStatus.NOT_NULL, "所属运营商不能为空");
|
return AjaxResult.error(HttpStatus.NOT_NULL, "所属运营商不能为空");
|
||||||
}
|
}
|
||||||
|
if (iXhpcUserService.checkUserNameUnique(sysUser.getUserName()) > 0) {
|
||||||
|
return AjaxResult.error("新增用户'" + sysUser.getUserName() + "'失败,登录账号已存在");
|
||||||
|
}
|
||||||
SysRole role = new SysRole();
|
SysRole role = new SysRole();
|
||||||
role.setRoleName(sysUser.getUserName());
|
role.setRoleName(sysUser.getUserName());
|
||||||
role.setRoleKey(sysUser.getUserName());
|
role.setRoleKey(sysUser.getUserName());
|
||||||
AjaxResult ajaxResult = remoteSystemService.addRole(role);
|
role.setRoleSort("1");
|
||||||
if (StringUtils.isNotNull(ajaxResult) && !"200".equals(StringUtils.valueOf(ajaxResult.get("code")))) {
|
iXhpcUserService.insertRole(role);
|
||||||
return ajaxResult;
|
|
||||||
}
|
|
||||||
role = iXhpcUserService.selectUserByRoleName(sysUser.getUserName());
|
|
||||||
sysUser.setPhonenumber(sysUser.getUserName());
|
sysUser.setPhonenumber(sysUser.getUserName());
|
||||||
sysUser.setDeptId(103l);
|
sysUser.setDeptId(103l);
|
||||||
sysUser.setDataPowerType(StatusConstants.SON_POWER_TYPE);
|
sysUser.setDataPowerType(StatusConstants.SON_POWER_TYPE);
|
||||||
@ -146,11 +139,8 @@ public class XhpcUserController extends BaseController {
|
|||||||
Long[] roles = new Long[1];
|
Long[] roles = new Long[1];
|
||||||
roles[0] = role.getRoleId();
|
roles[0] = role.getRoleId();
|
||||||
sysUser.setRoleIds(roles);
|
sysUser.setRoleIds(roles);
|
||||||
ajaxResult = remoteSystemService.addUser(sysUser);
|
sysUser.setPassword(sysUser.getUserName());
|
||||||
if (StringUtils.isNotNull(ajaxResult) && !"200".equals(StringUtils.valueOf(ajaxResult.get("code")))) {
|
iXhpcUserService.insertUser(sysUser);
|
||||||
return ajaxResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,10 +157,7 @@ public class XhpcUserController extends BaseController {
|
|||||||
if (null == sysUser.getOperatorId()) {
|
if (null == sysUser.getOperatorId()) {
|
||||||
return AjaxResult.error(HttpStatus.NOT_NULL, "所属运营上不能为空");
|
return AjaxResult.error(HttpStatus.NOT_NULL, "所属运营上不能为空");
|
||||||
}
|
}
|
||||||
AjaxResult ajaxResult = remoteSystemService.editUser(sysUser);
|
iXhpcUserService.updateUser(sysUser);
|
||||||
if (StringUtils.isNotNull(ajaxResult) && !"200".equals(StringUtils.valueOf(ajaxResult.get("code")))) {
|
|
||||||
return ajaxResult;
|
|
||||||
}
|
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,45 @@
|
|||||||
|
package com.xhpc.user.domain;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户和角色关联 sys_user_role
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class SysUserRole {
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色ID
|
||||||
|
*/
|
||||||
|
private Long roleId;
|
||||||
|
|
||||||
|
public Long getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(Long userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getRoleId() {
|
||||||
|
return roleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoleId(Long roleId) {
|
||||||
|
this.roleId = roleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("userId", getUserId())
|
||||||
|
.append("roleId", getRoleId())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,6 +2,7 @@ package com.xhpc.user.mapper;
|
|||||||
|
|
||||||
import com.xhpc.system.api.domain.SysRole;
|
import com.xhpc.system.api.domain.SysRole;
|
||||||
import com.xhpc.system.api.domain.SysUser;
|
import com.xhpc.system.api.domain.SysUser;
|
||||||
|
import com.xhpc.user.domain.SysUserRole;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -62,7 +63,7 @@ public interface XhpcUserMapper {
|
|||||||
* @param nickName 用户昵称
|
* @param nickName 用户昵称
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public List<Map<String, Object>> selectOperatorUserList(@Param("userName") String userName, @Param("nickName") String nickName, @Param("operatorId") Long operatorId, @Param("createBy") String createBy);
|
public List<Map<String, Object>> selectOperatorUserList(@Param("userName") String userName, @Param("nickName") String nickName, @Param("operatorId") Long operatorId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 运营商用户详情
|
* 运营商用户详情
|
||||||
@ -95,4 +96,46 @@ public interface XhpcUserMapper {
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public SysRole selectUserByRoleName(@Param("userName") String userName);
|
public SysRole selectUserByRoleName(@Param("userName") String userName);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增角色信息
|
||||||
|
*
|
||||||
|
* @param role 角色信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertRole(SysRole role);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户信息
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertUser(SysUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新增用户角色信息
|
||||||
|
*
|
||||||
|
* @param userRoleList 用户角色列表
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int batchUserRole(List<SysUserRole> userRoleList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验用户名称是否唯一
|
||||||
|
*
|
||||||
|
* @param userName 用户名称
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int checkUserNameUnique(String userName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户信息
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateUser(SysUser user);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,39 +0,0 @@
|
|||||||
package com.xhpc.user.openfeign;
|
|
||||||
|
|
||||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
|
||||||
import com.xhpc.system.api.domain.SysRole;
|
|
||||||
import com.xhpc.system.api.domain.SysUser;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户服务降级处理
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class RemoteSystemFallbackFactory implements FallbackFactory<RemoteSystemService> {
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(RemoteSystemFallbackFactory.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RemoteSystemService create(Throwable throwable) {
|
|
||||||
log.error("用户服务调用失败:{}", throwable.getMessage());
|
|
||||||
return new RemoteSystemService() {
|
|
||||||
@Override
|
|
||||||
public AjaxResult addUser(SysUser sysUser) {
|
|
||||||
return AjaxResult.error(throwable.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AjaxResult editUser(SysUser sysUser) {
|
|
||||||
return AjaxResult.error(throwable.getMessage());
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public AjaxResult addRole(SysRole role) {
|
|
||||||
return AjaxResult.error(throwable.getMessage());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
package com.xhpc.user.openfeign;
|
|
||||||
|
|
||||||
import com.xhpc.common.core.constant.ServiceNameConstants;
|
|
||||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
|
||||||
import com.xhpc.system.api.domain.SysRole;
|
|
||||||
import com.xhpc.system.api.domain.SysUser;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统服务
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@FeignClient(contextId = "remoteSystemService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteSystemFallbackFactory.class)
|
|
||||||
public interface RemoteSystemService {
|
|
||||||
/**
|
|
||||||
* 新增用户
|
|
||||||
*
|
|
||||||
* @param sysUser 用户信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@PostMapping(value = "/user")
|
|
||||||
public AjaxResult addUser(@Validated @RequestBody SysUser sysUser);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增用户
|
|
||||||
*
|
|
||||||
* @param sysUser 用户信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@PutMapping(value = "/user")
|
|
||||||
public AjaxResult editUser(@Validated @RequestBody SysUser sysUser);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增角色
|
|
||||||
*
|
|
||||||
* @param role 角色信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@PostMapping(value = "/role")
|
|
||||||
public AjaxResult addRole(@Validated @RequestBody SysRole role);
|
|
||||||
}
|
|
||||||
@ -81,4 +81,37 @@ public interface IXhpcUserService {
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public SysRole selectUserByRoleName(String userName);
|
public SysRole selectUserByRoleName(String userName);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增角色信息
|
||||||
|
*
|
||||||
|
* @param role 角色信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int insertRole(SysRole role);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增保存用户信息
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public SysUser insertUser(SysUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录账号是否存在
|
||||||
|
*
|
||||||
|
* @param userName 账号
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int checkUserNameUnique(String userName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改保存用户信息
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateUser(SysUser user);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import com.xhpc.user.mapper.XhpcAppUserMapper;
|
|||||||
import com.xhpc.user.service.IXhpcAppUserUserService;
|
import com.xhpc.user.service.IXhpcAppUserUserService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -48,6 +49,7 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService {
|
|||||||
* @param xhpcAppUser C端用户
|
* @param xhpcAppUser C端用户
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public int update(XhpcAppUser xhpcAppUser) {
|
public int update(XhpcAppUser xhpcAppUser) {
|
||||||
return xhpcAppUserMapper.update(xhpcAppUser);
|
return xhpcAppUserMapper.update(xhpcAppUser);
|
||||||
}
|
}
|
||||||
@ -98,6 +100,7 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService {
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public R<?> register(Map<String, Object> map) {
|
public R<?> register(Map<String, Object> map) {
|
||||||
String code = StringUtils.valueOf(map.get("code"));
|
String code = StringUtils.valueOf(map.get("code"));
|
||||||
String phone = StringUtils.valueOf(map.get("phone"));
|
String phone = StringUtils.valueOf(map.get("phone"));
|
||||||
@ -164,6 +167,7 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService {
|
|||||||
/**
|
/**
|
||||||
* 登录
|
* 登录
|
||||||
*/
|
*/
|
||||||
|
@Transactional
|
||||||
public R<?> appLogin(String username, String type, String openid) {
|
public R<?> appLogin(String username, String type, String openid) {
|
||||||
// 用户名或密码为空 错误
|
// 用户名或密码为空 错误
|
||||||
if (StringUtils.isAnyBlank(username)) {
|
if (StringUtils.isAnyBlank(username)) {
|
||||||
@ -213,6 +217,7 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService {
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public R<?> loginOut(HttpServletRequest request, String type) {
|
public R<?> loginOut(HttpServletRequest request, String type) {
|
||||||
LoginUser loginUser = tokenService.getLoginUser(request);
|
LoginUser loginUser = tokenService.getLoginUser(request);
|
||||||
if (StringUtils.isNotNull(loginUser)) {
|
if (StringUtils.isNotNull(loginUser)) {
|
||||||
@ -278,6 +283,7 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public void logout(Long appUserId) {
|
public void logout(Long appUserId) {
|
||||||
xhpcAppUserMapper.deleteById(appUserId);
|
xhpcAppUserMapper.deleteById(appUserId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,13 +3,17 @@ package com.xhpc.user.service.impl;
|
|||||||
import com.xhpc.common.core.constant.StatusConstants;
|
import com.xhpc.common.core.constant.StatusConstants;
|
||||||
import com.xhpc.common.core.constant.UserConstants;
|
import com.xhpc.common.core.constant.UserConstants;
|
||||||
import com.xhpc.common.core.utils.SecurityUtils;
|
import com.xhpc.common.core.utils.SecurityUtils;
|
||||||
|
import com.xhpc.common.core.utils.StringUtils;
|
||||||
import com.xhpc.system.api.domain.SysRole;
|
import com.xhpc.system.api.domain.SysRole;
|
||||||
import com.xhpc.system.api.domain.SysUser;
|
import com.xhpc.system.api.domain.SysUser;
|
||||||
|
import com.xhpc.user.domain.SysUserRole;
|
||||||
import com.xhpc.user.mapper.XhpcUserMapper;
|
import com.xhpc.user.mapper.XhpcUserMapper;
|
||||||
import com.xhpc.user.service.IXhpcUserService;
|
import com.xhpc.user.service.IXhpcUserService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -70,9 +74,9 @@ public class XhpcUserServiceImpl implements IXhpcUserService {
|
|||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
SysUser sysUser = xhpcUserMapper.selectUserByUserId(userId);
|
SysUser sysUser = xhpcUserMapper.selectUserByUserId(userId);
|
||||||
if (StatusConstants.SYSTEM_USER_TYPE.equals(sysUser.getUserType())) {
|
if (StatusConstants.SYSTEM_USER_TYPE.equals(sysUser.getUserType())) {
|
||||||
return xhpcUserMapper.selectOperatorUserList(userName, nickName, operatorId, null);
|
return xhpcUserMapper.selectOperatorUserList(userName, nickName, operatorId);
|
||||||
} else {
|
} else {
|
||||||
return xhpcUserMapper.selectOperatorUserList(userName, nickName, operatorId, sysUser.getUserName());
|
return xhpcUserMapper.selectOperatorUserList(userName, nickName, sysUser.getOperatorId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,4 +125,80 @@ public class XhpcUserServiceImpl implements IXhpcUserService {
|
|||||||
public SysRole selectUserByRoleName(String userName) {
|
public SysRole selectUserByRoleName(String userName) {
|
||||||
return xhpcUserMapper.selectUserByRoleName(userName);
|
return xhpcUserMapper.selectUserByRoleName(userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增角色信息
|
||||||
|
*
|
||||||
|
* @param role 角色信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertRole(SysRole role) {
|
||||||
|
return xhpcUserMapper.insertRole(role);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录账号是否存在
|
||||||
|
*
|
||||||
|
* @param userName 账号
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int checkUserNameUnique(String userName) {
|
||||||
|
return xhpcUserMapper.checkUserNameUnique(userName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增保存用户信息
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public SysUser insertUser(SysUser user) {
|
||||||
|
user.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||||
|
// 新增用户信息
|
||||||
|
xhpcUserMapper.insertUser(user);
|
||||||
|
// 新增用户与角色管理
|
||||||
|
insertUserRole(user);
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户角色信息
|
||||||
|
*
|
||||||
|
* @param user 用户对象
|
||||||
|
*/
|
||||||
|
public void insertUserRole(SysUser user) {
|
||||||
|
Long[] roles = user.getRoleIds();
|
||||||
|
if (StringUtils.isNotNull(roles)) {
|
||||||
|
// 新增用户与角色管理
|
||||||
|
List<SysUserRole> list = new ArrayList<SysUserRole>();
|
||||||
|
for (Long roleId : roles) {
|
||||||
|
SysUserRole ur = new SysUserRole();
|
||||||
|
ur.setUserId(user.getUserId());
|
||||||
|
ur.setRoleId(roleId);
|
||||||
|
list.add(ur);
|
||||||
|
}
|
||||||
|
if (list.size() > 0) {
|
||||||
|
xhpcUserMapper.batchUserRole(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改保存用户信息
|
||||||
|
*
|
||||||
|
* @param user 用户信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public int updateUser(SysUser user) {
|
||||||
|
return xhpcUserMapper.updateUser(user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -115,9 +115,6 @@
|
|||||||
<if test="operatorId != null and operatorId != ''">
|
<if test="operatorId != null and operatorId != ''">
|
||||||
and operator_id = #{operatorId}
|
and operator_id = #{operatorId}
|
||||||
</if>
|
</if>
|
||||||
<if test="createBy != null and createBy != ''">
|
|
||||||
and create_by = #{createBy}
|
|
||||||
</if>
|
|
||||||
ORDER BY su.update_time DESC
|
ORDER BY su.update_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@ -205,4 +202,109 @@
|
|||||||
from sys_role
|
from sys_role
|
||||||
where role_name = #{userName} ORDER BY create_time DESC LIMIT 1
|
where role_name = #{userName} ORDER BY create_time DESC LIMIT 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertRole" parameterType="com.xhpc.system.api.domain.SysRole" useGeneratedKeys="true"
|
||||||
|
keyProperty="roleId">
|
||||||
|
insert into sys_role(
|
||||||
|
<if test="roleId != null and roleId != 0">role_id,</if>
|
||||||
|
<if test="roleName != null and roleName != ''">role_name,</if>
|
||||||
|
<if test="roleKey != null and roleKey != ''">role_key,</if>
|
||||||
|
<if test="roleSort != null and roleSort != ''">role_sort,</if>
|
||||||
|
<if test="dataScope != null and dataScope != ''">data_scope,</if>
|
||||||
|
<if test="menuCheckStrictly != null">menu_check_strictly,</if>
|
||||||
|
<if test="deptCheckStrictly != null">dept_check_strictly,</if>
|
||||||
|
<if test="status != null and status != ''">status,</if>
|
||||||
|
<if test="remark != null and remark != ''">remark,</if>
|
||||||
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||||
|
create_time
|
||||||
|
)values(
|
||||||
|
<if test="roleId != null and roleId != 0">#{roleId},</if>
|
||||||
|
<if test="roleName != null and roleName != ''">#{roleName},</if>
|
||||||
|
<if test="roleKey != null and roleKey != ''">#{roleKey},</if>
|
||||||
|
<if test="roleSort != null and roleSort != ''">#{roleSort},</if>
|
||||||
|
<if test="dataScope != null and dataScope != ''">#{dataScope},</if>
|
||||||
|
<if test="menuCheckStrictly != null">#{menuCheckStrictly},</if>
|
||||||
|
<if test="deptCheckStrictly != null">#{deptCheckStrictly},</if>
|
||||||
|
<if test="status != null and status != ''">#{status},</if>
|
||||||
|
<if test="remark != null and remark != ''">#{remark},</if>
|
||||||
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||||
|
sysdate()
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert id="insertUser" parameterType="com.xhpc.system.api.domain.SysUser" useGeneratedKeys="true"
|
||||||
|
keyProperty="userId">
|
||||||
|
insert into sys_user(
|
||||||
|
<if test="userId != null and userId != 0">user_id,</if>
|
||||||
|
<if test="deptId != null and deptId != 0">dept_id,</if>
|
||||||
|
<if test="userName != null and userName != ''">user_name,</if>
|
||||||
|
<if test="userTpe != null and userTpe != ''">user_type,</if>
|
||||||
|
<if test="nickName != null and nickName != ''">nick_name,</if>
|
||||||
|
<if test="email != null and email != ''">email,</if>
|
||||||
|
<if test="avatar != null and avatar != ''">avatar,</if>
|
||||||
|
<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
|
||||||
|
<if test="operatorId != null and operatorId != ''">operator_id,</if>
|
||||||
|
<if test="internetUserId != null and internetUserId != ''">internet_user_id,</if>
|
||||||
|
<if test="dataPowerType != null and dataPowerType != ''">data_power_type,</if>
|
||||||
|
<if test="sex != null and sex != ''">sex,</if>
|
||||||
|
<if test="password != null and password != ''">password,</if>
|
||||||
|
<if test="status != null and status != ''">status,</if>
|
||||||
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||||
|
<if test="remark != null and remark != ''">remark,</if>
|
||||||
|
create_time
|
||||||
|
)values(
|
||||||
|
<if test="userId != null and userId != ''">#{userId},</if>
|
||||||
|
<if test="deptId != null and deptId != ''">#{deptId},</if>
|
||||||
|
<if test="userName != null and userName != ''">#{userName},</if>
|
||||||
|
<if test="userTpe != null and userTpe != ''">#{userTpe},</if>
|
||||||
|
<if test="nickName != null and nickName != ''">#{nickName},</if>
|
||||||
|
<if test="email != null and email != ''">#{email},</if>
|
||||||
|
<if test="avatar != null and avatar != ''">#{avatar},</if>
|
||||||
|
<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
|
||||||
|
<if test="operatorId != null and operatorId != ''">#{operatorId},</if>
|
||||||
|
<if test="internetUserId != null and internetUserId != ''">#{internetUserId},</if>
|
||||||
|
<if test="dataPowerType != null and dataPowerType != ''">#{dataPowerType},</if>
|
||||||
|
<if test="sex != null and sex != ''">#{sex},</if>
|
||||||
|
<if test="password != null and password != ''">#{password},</if>
|
||||||
|
<if test="status != null and status != ''">#{status},</if>
|
||||||
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||||
|
<if test="remark != null and remark != ''">#{remark},</if>
|
||||||
|
sysdate()
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateUser" parameterType="com.xhpc.system.api.domain.SysUser">
|
||||||
|
update sys_user
|
||||||
|
<set>
|
||||||
|
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
|
||||||
|
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
||||||
|
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
|
||||||
|
<if test="email != null ">email = #{email},</if>
|
||||||
|
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
|
||||||
|
<if test="operatorId != null and operatorId != ''">operator_id = #{operatorId},</if>
|
||||||
|
<if test="internetUserId != null and internetUserId != ''">internet_user_id = #{internetUserId},</if>
|
||||||
|
<if test="dataPowerType != null and dataPowerType != ''">data_power_type = #{dataPowerType},</if>
|
||||||
|
<if test="sex != null and sex != ''">sex = #{sex},</if>
|
||||||
|
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
|
||||||
|
<if test="password != null and password != ''">password = #{password},</if>
|
||||||
|
<if test="status != null and status != ''">status = #{status},</if>
|
||||||
|
<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
|
||||||
|
<if test="loginDate != null">login_date = #{loginDate},</if>
|
||||||
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||||
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
|
update_time = sysdate()
|
||||||
|
</set>
|
||||||
|
where user_id = #{userId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<insert id="batchUserRole">
|
||||||
|
insert into sys_user_role(user_id, role_id) values
|
||||||
|
<foreach item="item" index="index" collection="list" separator=",">
|
||||||
|
(#{item.userId},#{item.roleId})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<select id="checkUserNameUnique" parameterType="java.lang.String" resultType="int">
|
||||||
|
select count(1) from sys_user where user_name = #{userName} limit 1
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user