dongdingding
杜函宇 11 months ago
parent af77bf73bb
commit 36067a43ee

@ -33,6 +33,9 @@ public class ApprovalDeclarationRecordsQueryDto implements Serializable {
@ApiModelProperty(value = "申报单位")
private String enterpriseName;
@ApiModelProperty(value = "申报单位ID")
private Long enterpriseId;
@ApiModelProperty(value = "扶持方式")
private Integer supportMethods;

@ -37,6 +37,9 @@ public class ApprovalDeclarationRecordsQueryVo implements Serializable {
@ApiModelProperty(value = "申报单位")
private String enterpriseName;
@ApiModelProperty(value = "申报单位Id")
private Long enterpriseId;
@ApiModelProperty(value = "扶持方式")
private Integer supportMethods;

@ -6,33 +6,15 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.context.SecurityContextHolder;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.jjh.declaration.entity.BmsApprovalInfo;
import com.ruoyi.jjh.declaration.entity.BmsDeclarationRecords;
import com.ruoyi.jjh.declaration.entity.BmsEnterpriseBasicInfo;
import com.ruoyi.jjh.declaration.entity.BmsFieldInfo;
import com.ruoyi.jjh.declaration.entity.BmsFileInfo;
import com.ruoyi.jjh.declaration.entity.BmsProcessInfo;
import com.ruoyi.jjh.declaration.entity.dto.ApprovalDeclarationRecordsQueryDto;
import com.ruoyi.jjh.declaration.entity.dto.BmsApprovalInfoUpdateDto;
import com.ruoyi.jjh.declaration.entity.dto.BmsDeclarationRecordsAddDto;
import com.ruoyi.jjh.declaration.entity.dto.BmsDeclarationRecordsDto;
import com.ruoyi.jjh.declaration.entity.dto.BmsFieldInfoAddDto;
import com.ruoyi.jjh.declaration.entity.dto.BmsFileInfoAddDto;
import com.ruoyi.jjh.declaration.entity.dto.BmsMunicipalBureauReviewQueryDto;
import com.ruoyi.jjh.declaration.entity.dto.MunicipalReviewDto;
import com.ruoyi.jjh.declaration.entity.dto.MunicipalReviewInfoDto;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.jjh.declaration.entity.*;
import com.ruoyi.jjh.declaration.entity.dto.*;
import com.ruoyi.jjh.declaration.entity.vo.ApprovalDeclarationRecordsQueryVo;
import com.ruoyi.jjh.declaration.entity.vo.BmsDeclarationRecordsQueryVo;
import com.ruoyi.jjh.declaration.entity.vo.BmsMunicipalBureauReviewQueryVo;
import com.ruoyi.jjh.declaration.entity.vo.DeclarationRecordsVo;
import com.ruoyi.jjh.declaration.mapper.BmsDeclarationRecordsMapper;
import com.ruoyi.jjh.declaration.service.IBmsApprovalInfoService;
import com.ruoyi.jjh.declaration.service.IBmsDeclarationRecordsService;
import com.ruoyi.jjh.declaration.service.IBmsEnterpriseBasicInfoService;
import com.ruoyi.jjh.declaration.service.IBmsFieldInfoService;
import com.ruoyi.jjh.declaration.service.IBmsFileInfoService;
import com.ruoyi.jjh.declaration.service.IBmsProcessInfoService;
import com.ruoyi.jjh.declaration.service.ICommonService;
import com.ruoyi.jjh.declaration.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -134,7 +116,12 @@ public class BmsDeclarationRecordsServiceImpl extends ServiceImpl<BmsDeclaration
@Override
public List<ApprovalDeclarationRecordsQueryVo> approvalList(ApprovalDeclarationRecordsQueryDto approvalDeclarationRecordsQueryDto) {
// approvalDeclarationRecordsQueryDto.setUserIds(iCommonService.getUserIds(SecurityContextHolder.getUserId()));
approvalDeclarationRecordsQueryDto.setApprovalById(SecurityContextHolder.getUserId());
if (SecurityUtils.getUserId().equals(1L)) {
approvalDeclarationRecordsQueryDto.setApprovalById(null);
} else {
// todo SecurityContextHolder.getUserId()失效换成SecurityUtils.getUserId()
approvalDeclarationRecordsQueryDto.setApprovalById(SecurityUtils.getUserId());
}
return baseMapper.approvalList(approvalDeclarationRecordsQueryDto);
}
@ -176,7 +163,7 @@ public class BmsDeclarationRecordsServiceImpl extends ServiceImpl<BmsDeclaration
List<BmsProcessInfo> bmsProcessInfoList = iBmsProcessInfoService.lambdaQuery().eq(BmsProcessInfo::getApprovalType, 0).list();
BmsProcessInfo bmsProcessInfo = new BmsProcessInfo();
bmsProcessInfoList.forEach(x -> {
boolean flag = Arrays.asList(x.getApprovalByIds().split(",")).contains(String.valueOf(SecurityContextHolder.getUserId()));
boolean flag = Arrays.asList(x.getApprovalByIds().split(",")).contains(String.valueOf(SecurityUtils.getUserId()));
if (flag) {
BeanUtil.copyProperties(x, bmsProcessInfo);
}
@ -193,7 +180,7 @@ public class BmsDeclarationRecordsServiceImpl extends ServiceImpl<BmsDeclaration
// bmsApprovalInfoUpdateDto.setSort(x.getSort());
BeanUtil.copyProperties(bmsApprovalInfoUpdateDto, x);
x.setSort(sort);
x.setApprovalById(SecurityContextHolder.getUserId());
x.setApprovalById(SecurityUtils.getUserId());
x.setApprovalTime(DateUtils.getNowDate());
x.setIsReview(2);
iBmsApprovalInfoService.saveOrUpdate(x);
@ -221,7 +208,6 @@ public class BmsDeclarationRecordsServiceImpl extends ServiceImpl<BmsDeclaration
}
// 更新记录状态
int num = approval(bmsApprovalInfoUpdateDto, bmsProcessInfo);
return num;
}

@ -122,6 +122,7 @@
b.project_name,
b.product_area,
c.enterprise_name,
c.id as enterpriseId,
b.support_methods,
b.start_time,
b.end_time,

@ -118,7 +118,7 @@ public class LogAspect
// 处理设置注解上的参数
getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult);
// 设置消耗时间
operLog.setCostTime(System.currentTimeMillis() - TIME_THREADLOCAL.get());
// operLog.setCostTime(System.currentTimeMillis() - TIME_THREADLOCAL.get());
// 保存数据库
AsyncManager.me().execute(AsyncFactory.recordOper(operLog));
}

@ -0,0 +1,44 @@
package com.ruoyi.framework.config;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.Objects;
/**
*
*
* @author wu
* @since 2023/5/4 10:16
*/
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
@Override
public void insertFill(MetaObject metaObject) {
// 获取当前登录用户
LoginUser loginUser = SecurityUtils.getLoginUser();
String userName = loginUser.getUsername();
if (!Objects.equals(userName, "")) {
this.strictInsertFill(metaObject, "createBy", String.class, userName);
}
this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now());
}
@Override
public void updateFill(MetaObject metaObject) {
// 获取当前登录用户
LoginUser loginUser = SecurityUtils.getLoginUser();
String userName = loginUser.getUsername();
if (!Objects.equals(userName, "")) {
this.strictInsertFill(metaObject, "createBy", String.class, userName);
}
this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now());
}
}

@ -1,48 +1,45 @@
package com.ruoyi.framework.web.service;
import javax.annotation.Resource;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.UserStatus;
import com.ruoyi.common.utils.*;
import com.ruoyi.system.domain.SysLogininfor;
import com.ruoyi.system.service.ISysLogininforService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.enums.UserStatus;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.exception.user.BlackListException;
import com.ruoyi.common.exception.user.CaptchaException;
import com.ruoyi.common.exception.user.CaptchaExpireException;
import com.ruoyi.common.exception.user.UserNotExistsException;
import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.MessageUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.ip.IpUtils;
import com.ruoyi.framework.manager.AsyncManager;
import com.ruoyi.framework.manager.factory.AsyncFactory;
import com.ruoyi.framework.security.context.AuthenticationContextHolder;
import com.ruoyi.system.domain.SysLogininfor;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysLogininforService;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Map;
import java.util.Set;
/**
*
*
*
* @author ruoyi
*/
@Component
public class SysLoginService
{
public class SysLoginService {
@Autowired
private TokenService tokenService;
@ -51,7 +48,7 @@ public class SysLoginService
@Autowired
private RedisCache redisCache;
@Autowired
private ISysUserService userService;
@ -67,45 +64,37 @@ public class SysLoginService
@Autowired
private SysPasswordService sysPasswordService;
/**
*
*
*
* @param username
* @param password
* @param code
* @param uuid
* @param code
* @param uuid
* @return
*/
public Map<String, Object> login(String username, String password, String code, String uuid,String userType)
{
public Map<String, Object> login(String username, String password, String code, String uuid, String userType) {
// 验证码校验
validateCaptcha(username, code, uuid);
// 登录前置校验
loginPreCheck(username, password);
// 用户验证
Authentication authentication = null;
try
{
try {
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
AuthenticationContextHolder.setContext(authenticationToken);
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
authentication = authenticationManager.authenticate(authenticationToken);
}
catch (Exception e)
{
if (e instanceof BadCredentialsException)
{
} catch (Exception e) {
if (e instanceof BadCredentialsException) {
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
throw new UserPasswordNotMatchException();
}
else
{
} else {
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
throw new ServiceException(e.getMessage());
}
}
finally
{
} finally {
AuthenticationContextHolder.clearContext();
}
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
@ -118,8 +107,8 @@ public class SysLoginService
SysUser user = loginUser.getUser();
// 判断用户类型
if (!"admin".equals(username)){
if (!userType.equals(user.getUserType())){
if (!"admin".equals(username)) {
if (!userType.equals(user.getUserType())) {
throw new ServiceException("该用户类型错误");
}
}
@ -132,7 +121,7 @@ public class SysLoginService
addRecord(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
}
sysPasswordService.validate(user);
// sysPasswordService.validate(user);
addRecord(username, Constants.LOGIN_SUCCESS, "登录成功");
// 生成token
return tokenService.createToken(loginUser);
@ -140,27 +129,23 @@ public class SysLoginService
/**
*
*
*
* @param username
* @param code
* @param uuid
* @param code
* @param uuid
* @return
*/
public void validateCaptcha(String username, String code, String uuid)
{
public void validateCaptcha(String username, String code, String uuid) {
boolean captchaEnabled = configService.selectCaptchaEnabled();
if (captchaEnabled)
{
if (captchaEnabled) {
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
String captcha = redisCache.getCacheObject(verifyKey);
redisCache.deleteObject(verifyKey);
if (captcha == null)
{
if (captcha == null) {
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
throw new CaptchaExpireException();
}
if (!code.equalsIgnoreCase(captcha))
{
if (!code.equalsIgnoreCase(captcha)) {
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
throw new CaptchaException();
}
@ -169,11 +154,11 @@ public class SysLoginService
/**
*
*
* @param username
* @param password
*/
public void loginPreCheck(String username, String password)
{
public void loginPreCheck(String username, String password) {
// 用户名或密码为空 错误
if (StringUtils.isAnyBlank(username, password)) {
this.addRecord(username, Constants.LOGIN_FAIL, "用户/密码必须填写");
@ -206,8 +191,7 @@ public class SysLoginService
*
* @param userId ID
*/
public void recordLoginInfo(Long userId)
{
public void recordLoginInfo(Long userId) {
SysUser sysUser = new SysUser();
sysUser.setUserId(userId);
sysUser.setLoginIp(IpUtils.getIpAddr());
@ -219,8 +203,8 @@ public class SysLoginService
*
*
* @param username
* @param status
* @param message
* @param status
* @param message
* @return
*/
public void addRecord(String username, String status, String message) {

@ -1,10 +1,5 @@
package com.ruoyi.framework.web.service;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.redis.RedisCache;
@ -12,15 +7,20 @@ import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
import com.ruoyi.common.exception.user.UserPasswordRetryLimitExceedException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.security.context.AuthenticationContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;
import java.util.concurrent.TimeUnit;
/**
*
*
*
* @author ruoyi
*/
@Component
public class SysPasswordService
{
public class SysPasswordService {
@Autowired
private RedisCache redisCache;
@ -32,54 +32,44 @@ public class SysPasswordService
/**
*
*
*
* @param username
* @return key
*/
private String getCacheKey(String username)
{
private String getCacheKey(String username) {
return CacheConstants.PWD_ERR_CNT_KEY + username;
}
public void validate(SysUser user)
{
public void validate(SysUser user) {
Authentication usernamePasswordAuthenticationToken = AuthenticationContextHolder.getContext();
String username = usernamePasswordAuthenticationToken.getName();
String password = usernamePasswordAuthenticationToken.getCredentials().toString();
Integer retryCount = redisCache.getCacheObject(getCacheKey(username));
if (retryCount == null)
{
if (retryCount == null) {
retryCount = 0;
}
if (retryCount >= Integer.valueOf(maxRetryCount).intValue())
{
if (retryCount >= Integer.valueOf(maxRetryCount).intValue()) {
throw new UserPasswordRetryLimitExceedException(maxRetryCount, lockTime);
}
if (!matches(user, password))
{
if (!matches(user, password)) {
retryCount = retryCount + 1;
redisCache.setCacheObject(getCacheKey(username), retryCount, lockTime, TimeUnit.MINUTES);
throw new UserPasswordNotMatchException();
}
else
{
} else {
clearLoginRecordCache(username);
}
}
public boolean matches(SysUser user, String rawPassword)
{
public boolean matches(SysUser user, String rawPassword) {
return SecurityUtils.matchesPassword(rawPassword, user.getPassword());
}
public void clearLoginRecordCache(String loginName)
{
if (redisCache.hasKey(getCacheKey(loginName)))
{
public void clearLoginRecordCache(String loginName) {
if (redisCache.hasKey(getCacheKey(loginName))) {
redisCache.deleteObject(getCacheKey(loginName));
}
}

@ -83,9 +83,9 @@ public class SysOperLog extends BaseEntity
@Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date operTime;
/** 消耗时间 */
@Excel(name = "消耗时间", suffix = "毫秒")
private Long costTime;
// /** 消耗时间 */
// @Excel(name = "消耗时间", suffix = "毫秒")
// private Long costTime;
public Long getOperId()
{
@ -257,13 +257,13 @@ public class SysOperLog extends BaseEntity
this.operTime = operTime;
}
public Long getCostTime()
{
return costTime;
}
// public Long getCostTime()
// {
// return costTime;
// }
public void setCostTime(Long costTime)
{
this.costTime = costTime;
}
// public void setCostTime(Long costTime)
// {
// this.costTime = costTime;
// }
}

@ -21,7 +21,7 @@
<result property="status" column="status"/>
<result property="errorMsg" column="error_msg"/>
<result property="operTime" column="oper_time"/>
<result property="costTime" column="cost_time"/>
<!-- <result property="costTime" column="cost_time"/>-->
</resultMap>
<sql id="selectOperLogVo">
@ -40,18 +40,17 @@
json_result,
status,
error_msg,
oper_time,
cost_time
oper_time
from sys_oper_log
</sql>
<insert id="insertOperlog" parameterType="com.ruoyi.system.domain.SysOperLog">
insert into sys_oper_log(title, business_type, method, request_method, operator_type, oper_name, dept_name,
oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg,
cost_time, oper_time)
oper_time)
values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName},
#{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg},
#{costTime}, sysdate())
sysdate())
</insert>
<select id="selectOperLogList" parameterType="com.ruoyi.system.domain.SysOperLog" resultMap="SysOperLogResult">

Loading…
Cancel
Save