区分政府端登录
This commit is contained in:
parent
637a2ce55f
commit
b3ede7b516
|
|
@ -2,12 +2,14 @@ package com.rzyc.bean.user.dto;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
@ApiModel("登录")
|
@ApiModel("登录")
|
||||||
public class LoginDto {
|
public class LoginDto {
|
||||||
|
|
||||||
|
|
||||||
@NotNull(message = "用户名不能为空")
|
@NotNull(message = "用户名不能为空")
|
||||||
@ApiModelProperty(value = "用户名",required = true)
|
@ApiModelProperty(value = "用户名",required = true)
|
||||||
public String sysusername;
|
public String sysusername;
|
||||||
|
|
@ -20,6 +22,7 @@ public class LoginDto {
|
||||||
@ApiModelProperty(value = "验证码",required = true)
|
@ApiModelProperty(value = "验证码",required = true)
|
||||||
public String generateCode;
|
public String generateCode;
|
||||||
|
|
||||||
|
|
||||||
public String getSysusername() {
|
public String getSysusername() {
|
||||||
return sysusername;
|
return sysusername;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
22
inventory-dao/src/main/java/com/rzyc/enums/IsManage.java
Normal file
22
inventory-dao/src/main/java/com/rzyc/enums/IsManage.java
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.rzyc.enums;
|
||||||
|
|
||||||
|
//是否为管理员 1.管理员 2.政府用户
|
||||||
|
public enum IsManage {
|
||||||
|
|
||||||
|
MANAGE(1),
|
||||||
|
GOVERNMENT(2);
|
||||||
|
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
|
IsManage(Integer state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(Integer state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -53,6 +53,7 @@ public class SysUser implements Serializable {
|
||||||
@ApiModelProperty("用户名")
|
@ApiModelProperty("用户名")
|
||||||
private String sysusername;
|
private String sysusername;
|
||||||
|
|
||||||
|
@ApiModelProperty("用户密码")
|
||||||
private String syspassword;
|
private String syspassword;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -224,8 +225,19 @@ public class SysUser implements Serializable {
|
||||||
@ApiModelProperty("用户属地级别 2、区级 3、街道 4、社区")
|
@ApiModelProperty("用户属地级别 2、区级 3、街道 4、社区")
|
||||||
private Integer orglevel;
|
private Integer orglevel;
|
||||||
|
|
||||||
|
@ApiModelProperty("是否为管理员 1.管理员 2.政府用户")
|
||||||
|
private Integer manageState;
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public Integer getManageState() {
|
||||||
|
return manageState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setManageState(Integer manageState) {
|
||||||
|
this.manageState = manageState;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getOrglevel() {
|
public Integer getOrglevel() {
|
||||||
return orglevel;
|
return orglevel;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@
|
||||||
<result column="Email" jdbcType="VARCHAR" property="email" />
|
<result column="Email" jdbcType="VARCHAR" property="email" />
|
||||||
<result column="QQInter" jdbcType="VARCHAR" property="qqinter" />
|
<result column="QQInter" jdbcType="VARCHAR" property="qqinter" />
|
||||||
<result column="WeixinInter" jdbcType="VARCHAR" property="weixininter" />
|
<result column="WeixinInter" jdbcType="VARCHAR" property="weixininter" />
|
||||||
|
<result column="manage_state" property="manageState" />
|
||||||
<result column="ModifiedBy" jdbcType="VARCHAR" property="modifiedby" />
|
<result column="ModifiedBy" jdbcType="VARCHAR" property="modifiedby" />
|
||||||
<result column="ModifiedOn" jdbcType="TIMESTAMP" property="modifiedon" />
|
<result column="ModifiedOn" jdbcType="TIMESTAMP" property="modifiedon" />
|
||||||
<result column="CreatedBy" jdbcType="VARCHAR" property="createdby" />
|
<result column="CreatedBy" jdbcType="VARCHAR" property="createdby" />
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ public class LoginAspect {
|
||||||
* @return
|
* @return
|
||||||
* @throws Throwable
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
@Around("login()")
|
//@Around("login()")
|
||||||
public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
|
public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
|
||||||
//操作日志
|
//操作日志
|
||||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import org.springframework.web.multipart.MaxUploadSizeExceededException;
|
||||||
|
|
||||||
import javax.validation.ConstraintViolationException;
|
import javax.validation.ConstraintViolationException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统一异常处理
|
* 统一异常处理
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ public class LoginAspect {
|
||||||
* @return
|
* @return
|
||||||
* @throws Throwable
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
@Around("login()")
|
// @Around("login()")
|
||||||
public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
|
public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
|
||||||
//操作日志
|
//操作日志
|
||||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||||
http
|
http
|
||||||
.authorizeRequests()
|
.authorizeRequests()
|
||||||
// 对于登录接口 允许匿名访问
|
// 对于登录接口 允许匿名访问
|
||||||
.antMatchers("/personal/login","/personal/entlogin","/common/generateCode").anonymous()
|
.antMatchers("/pcPersonal/pclogin","/pcPersonal/pcManageLogin","/generateCode").anonymous()
|
||||||
//放行swagger
|
//放行swagger
|
||||||
.antMatchers("/swagger-ui.html","/swagger-resources/**","/webjars/**","/v2/**","/api/**").permitAll()
|
.antMatchers("/swagger-ui.html","/swagger-resources/**","/webjars/**","/v2/**","/api/**").permitAll()
|
||||||
// 除上面外的所有请求全部需要鉴权认证,配置退出路径
|
// 除上面外的所有请求全部需要鉴权认证,配置退出路径
|
||||||
|
|
|
||||||
|
|
@ -586,6 +586,7 @@ public class OtherController extends BaseController{
|
||||||
BufferedImage image = Verification.getVerify(constantsConfigure.getGenerateCodeKey(),request);
|
BufferedImage image = Verification.getVerify(constantsConfigure.getGenerateCodeKey(),request);
|
||||||
OutputStream out = response.getOutputStream();
|
OutputStream out = response.getOutputStream();
|
||||||
ImageIO.write(image, "JPEG", out);
|
ImageIO.write(image, "JPEG", out);
|
||||||
|
System.out.println("图片=========" + image);
|
||||||
out.flush();
|
out.flush();
|
||||||
out.close();
|
out.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import com.rzyc.bean.user.dutyTree.DutyTrees;
|
||||||
import com.rzyc.bean.user.task.TaskDetailDto;
|
import com.rzyc.bean.user.task.TaskDetailDto;
|
||||||
import com.rzyc.bean.user.task.TaskPageDto;
|
import com.rzyc.bean.user.task.TaskPageDto;
|
||||||
import com.rzyc.bean.user.dto.*;
|
import com.rzyc.bean.user.dto.*;
|
||||||
|
import com.rzyc.config.MethodAnnotation;
|
||||||
import com.rzyc.enums.*;
|
import com.rzyc.enums.*;
|
||||||
import com.rzyc.model.*;
|
import com.rzyc.model.*;
|
||||||
import com.rzyc.model.ent.SysEnterprise;
|
import com.rzyc.model.ent.SysEnterprise;
|
||||||
|
|
@ -32,6 +33,7 @@ import com.rzyc.model.personal.SysResource;
|
||||||
import com.rzyc.model.user.*;
|
import com.rzyc.model.user.*;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.apache.commons.beanutils.BeanUtils;
|
import org.apache.commons.beanutils.BeanUtils;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
@ -58,8 +60,10 @@ public class PcPersonalController extends com.rzyc.controller.BaseController {
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "PC登录", notes = "PC登录")
|
@ApiOperation(value = "PC政府用户登录", notes = "PC政府用户登录")
|
||||||
@PostMapping(value = "/pclogin")
|
@PostMapping(value = "/pclogin")
|
||||||
|
/*@PreAuthorize("hasAnyAuthority('pclogin','pclogin:update')")
|
||||||
|
@MethodAnnotation(authorizations = {"pclogin","pclogin:update"},name = "PC政府用户登录")*/
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public SingleResult<SysUser> pclogin(@Valid LoginDto loginDto)throws Exception{
|
public SingleResult<SysUser> pclogin(@Valid LoginDto loginDto)throws Exception{
|
||||||
SingleResult<SysUser> result = new SingleResult<>();
|
SingleResult<SysUser> result = new SingleResult<>();
|
||||||
|
|
@ -67,13 +71,16 @@ public class PcPersonalController extends com.rzyc.controller.BaseController {
|
||||||
String sysusername = loginDto.getSysusername();
|
String sysusername = loginDto.getSysusername();
|
||||||
String syspassword = loginDto.getSyspassword();
|
String syspassword = loginDto.getSyspassword();
|
||||||
|
|
||||||
|
//获取验证码
|
||||||
String generateCode = request.getSession().getAttribute(constantsConfigure.getGenerateCodeKey())+"";
|
String generateCode = request.getSession().getAttribute(constantsConfigure.getGenerateCodeKey())+"";
|
||||||
//验证码只能使用一次
|
//验证码只能使用一次
|
||||||
request.getSession().removeAttribute(constantsConfigure.getGenerateCodeKey());
|
request.getSession().removeAttribute(constantsConfigure.getGenerateCodeKey());
|
||||||
|
|
||||||
if(loginDto.getGenerateCode().equals(generateCode)){
|
if(loginDto.getGenerateCode().equals(generateCode)){
|
||||||
SysUser sysUser = sysUserMapper.findBySysUserName(sysusername);
|
SysUser sysUser = sysUserMapper.findBySysUserName(sysusername);
|
||||||
if(null != sysUser && StringUtils.isNotBlank(sysUser.getUsertype()) && sysUser.getUsertype().equals("政府用户")){
|
|
||||||
|
//登录的是政府用户
|
||||||
|
if(null != sysUser && StringUtils.isNotBlank(sysUser.getUsertype()) && sysUser.getUsertype().equals("政府用户") & sysUser.getManageState() == IsManage.GOVERNMENT.getState()){
|
||||||
String ps = PasswdFactory.encryptPasswd(sysUser.getSysuserid(), sysusername, syspassword);
|
String ps = PasswdFactory.encryptPasswd(sysUser.getSysuserid(), sysusername, syspassword);
|
||||||
System.out.println("========" + ps);
|
System.out.println("========" + ps);
|
||||||
if(sysUser.getSyspassword().equals(ps)){
|
if(sysUser.getSyspassword().equals(ps)){
|
||||||
|
|
@ -111,6 +118,69 @@ public class PcPersonalController extends com.rzyc.controller.BaseController {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: PC管理员登录
|
||||||
|
* @Author ZQW
|
||||||
|
* @CreateTime 2022/10/12 14:08
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "PC管理员登录", notes = "PC管理员登录")
|
||||||
|
@PostMapping(value = "/pcManageLogin")
|
||||||
|
/*@PreAuthorize("hasAnyAuthority('pcManageLogin','pcManageLogin:update')")
|
||||||
|
@MethodAnnotation(authorizations = {"pcManageLogin","pcManageLogin:update"},name = "PC管理员登录")*/
|
||||||
|
@ResponseBody
|
||||||
|
public SingleResult<SysUser> pcManageLogin(@Valid LoginDto loginDto)throws Exception{
|
||||||
|
SingleResult<SysUser> result = new SingleResult<>();
|
||||||
|
System.out.println("loginDto -> "+JSONArray.toJSONString(loginDto));
|
||||||
|
String sysusername = loginDto.getSysusername();
|
||||||
|
String syspassword = loginDto.getSyspassword();
|
||||||
|
|
||||||
|
//获取验证码
|
||||||
|
String generateCode = request.getSession().getAttribute(constantsConfigure.getGenerateCodeKey())+"";
|
||||||
|
|
||||||
|
//验证码只能使用一次
|
||||||
|
request.getSession().removeAttribute(constantsConfigure.getGenerateCodeKey());
|
||||||
|
|
||||||
|
if(loginDto.getGenerateCode().equals(generateCode)){
|
||||||
|
SysUser sysUser = sysUserMapper.findBySysUserName(sysusername);
|
||||||
|
|
||||||
|
//登录的是管理员
|
||||||
|
if(null != sysUser && StringUtils.isNotBlank(sysUser.getUsertype()) && sysUser.getUsertype().equals("政府用户") & sysUser.getManageState() == IsManage.MANAGE.getState()){
|
||||||
|
String ps = PasswdFactory.encryptPasswd(sysUser.getSysuserid(), sysusername, syspassword);
|
||||||
|
System.out.println("========" + ps);
|
||||||
|
if(sysUser.getSyspassword().equals(ps)){
|
||||||
|
sysUser.setSyspassword("");
|
||||||
|
|
||||||
|
//获取职务
|
||||||
|
sysUser = getUserDuty(sysUser);
|
||||||
|
|
||||||
|
//通过角色判断是否为安办 或者 部门管理员
|
||||||
|
if(StringUtils.isNotBlank(sysUser.getUserroles())){
|
||||||
|
Integer userRole = this.getUserRole(sysUser.getUserroles());
|
||||||
|
sysUser.setUserRole(userRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取用户令牌
|
||||||
|
String userToken = JwtUtil.createToken(sysUser.getSysuserid());
|
||||||
|
sysUser.setUserToken(userToken);
|
||||||
|
|
||||||
|
this.addLogAuth(sysUser.getSysuserid(),"登录","成功","");
|
||||||
|
result.setData(sysUser);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
this.addLogAuth(sysUser.getSysuserid(),"登录","失败","");
|
||||||
|
result.setCode(Code.PASSWORD_ERROR.getCode());
|
||||||
|
result.setMessage(Message.PASSWORD_ERROR);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
result.setCode(Code.PASSWORD_ERROR.getCode());
|
||||||
|
result.setMessage(Message.PASSWORD_ERROR);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
result.setCode(Code.CODE_ERROT.getCode());
|
||||||
|
result.setMessage(Message.CODE_ERROT);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户功能项
|
* 用户功能项
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user