Merge pull request '1、单点登录调整' (#3) from develop into master

Reviewed-on: #3
pull/4/head^2
chenyuan 1 year ago
commit d1b7f58b13

@ -95,6 +95,10 @@
<artifactId>knife4j-spring-boot-starter</artifactId> <artifactId>knife4j-spring-boot-starter</artifactId>
<version>3.0.3</version> <version>3.0.3</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.security.oauth</groupId> <groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId> <artifactId>spring-security-oauth2</artifactId>

@ -5,19 +5,14 @@ import com.sztzjy.forex.trading_trading.config.exception.UnAuthorizedException;
import io.jsonwebtoken.*; import io.jsonwebtoken.*;
import io.jsonwebtoken.security.Keys; import io.jsonwebtoken.security.Keys;
import io.jsonwebtoken.security.SignatureException; import io.jsonwebtoken.security.SignatureException;
import org.springframework.http.HttpStatus;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.security.Key; import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.Base64;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -122,11 +117,11 @@ public class TokenProvider {
.getBody(); .getBody();
JwtUser jwtUser = new JwtUser(); JwtUser jwtUser = new JwtUser();
jwtUser.setName(claims.get("name").toString()); jwtUser.setName(claims.get("name")==null?null:claims.get("name").toString());
jwtUser.setUserId(claims.get("userId").toString()); jwtUser.setUserId(claims.get("userId")==null?null:claims.get("userId").toString());
jwtUser.setRoleId(Integer.valueOf(claims.get("roleId").toString())); jwtUser.setRoleId(Integer.valueOf(claims.get("roleId")==null?"0":claims.get("roleId").toString()));
jwtUser.setClassId(Integer.valueOf(claims.get("classId").toString())); jwtUser.setClassId(Integer.valueOf(claims.get("classId")==null?"0":claims.get("classId").toString()));
jwtUser.setSchoolId(Integer.valueOf(claims.get("schoolId").toString())); jwtUser.setSchoolId(Integer.valueOf(claims.get("schoolId")==null?"0":claims.get("schoolId").toString()));
jwtUser.setUsername(claims.get("username").toString()); jwtUser.setUsername(claims.get("username").toString());
return jwtUser; return jwtUser;
} catch (Exception e) { } catch (Exception e) {

@ -1,50 +0,0 @@
package com.sztzjy.forex.trading_trading.controller;
import com.sztzjy.forex.trading_trading.annotation.AnonymousAccess;
import com.sztzjy.forex.trading_trading.config.security.JwtUser;
import com.sztzjy.forex.trading_trading.dto.PageVO;
import com.sztzjy.forex.trading_trading.entity.Log;
import com.sztzjy.forex.trading_trading.service.LogService;
import com.sztzjy.forex.trading_trading.util.ResultEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.session.SessionInformation;
import org.springframework.security.core.session.SessionRegistry;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
@Api(tags = "系统:操作日志")
@RestController
@RequestMapping("api/syslog")
@RequiredArgsConstructor
public class LogController {
private final LogService logService;
@ApiOperation("根据条件查询操作日志(分页)")
@GetMapping("findAll")
@AnonymousAccess
public ResultEntity<PageVO<Log>> findAll(@ApiParam("ip地址") @RequestParam(required = false) String ipAddress,
@ApiParam("开始时间") @RequestParam(required = false) Long startTime,
@ApiParam("结束时间") @RequestParam(required = false) Long endTime,
@ApiParam("分页索引:{0}为第一页") @RequestParam(required = false) Integer index,
@ApiParam("页量") @RequestParam(required = false) Integer size,
@ApiParam("操作人") @RequestParam(required = false) String operatorName
) {
Page<Log> page = logService.findByConditions(index, size, ipAddress, startTime, endTime, operatorName);
PageVO<Log> pageVO = new PageVO<>();
pageVO.setPageInfo(page, page.getContent());
return new ResultEntity<>(HttpStatus.OK, pageVO);
}
}

@ -1,32 +1,337 @@
package com.sztzjy.forex.trading_trading.entity; package com.sztzjy.forex.trading_trading.entity;
import io.swagger.annotations.ApiModel; import cn.hutool.core.util.IdUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import java.util.Date;
import lombok.Setter;
public class Log {
import javax.persistence.Entity; /**
import javax.persistence.Table; *
* This field was generated by MyBatis Generator.
@ApiModel("日志") * This field corresponds to the database column system_log.id
@Getter *
@Setter * @mbg.generated Tue Oct 10 22:07:46 CST 2023
@Entity */
@Table(name = "sys_log") private String id= IdUtil.simpleUUID();
public class Log extends Base {
@ApiModelProperty("执行的操作") /**
private String action; *
@ApiModelProperty("操作来源IP地址") * This field was generated by MyBatis Generator.
private String ipAddress; * This field corresponds to the database column system_log.create_time
@ApiModelProperty("操作人ID") *
private String operatorId; * @mbg.generated Tue Oct 10 22:07:46 CST 2023
@ApiModelProperty("操作人姓名") */
private String operatorName; private Date createTime;
@ApiModelProperty("客户端")
private String userAgent; /**
@ApiModelProperty("执行参数") *
private String params; * This field was generated by MyBatis Generator.
@ApiModelProperty("描述") * This field corresponds to the database column system_log.update_time
private String description; *
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
} */
private Date updateTime;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column system_log.action
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
private String action;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column system_log.description
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
private String description;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column system_log.ip_address
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
private String ipAddress;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column system_log.operator_id
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
private String operatorId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column system_log.operator_name
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
private String operatorName;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column system_log.params
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
private String params;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column system_log.user_agent
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
private String userAgent;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column system_log.id
*
* @return the value of system_log.id
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public String getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column system_log.id
*
* @param id the value for system_log.id
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column system_log.create_time
*
* @return the value of system_log.create_time
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public Date getCreateTime() {
return createTime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column system_log.create_time
*
* @param createTime the value for system_log.create_time
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column system_log.update_time
*
* @return the value of system_log.update_time
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public Date getUpdateTime() {
return updateTime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column system_log.update_time
*
* @param updateTime the value for system_log.update_time
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column system_log.action
*
* @return the value of system_log.action
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public String getAction() {
return action;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column system_log.action
*
* @param action the value for system_log.action
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public void setAction(String action) {
this.action = action == null ? null : action.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column system_log.description
*
* @return the value of system_log.description
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public String getDescription() {
return description;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column system_log.description
*
* @param description the value for system_log.description
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public void setDescription(String description) {
this.description = description == null ? null : description.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column system_log.ip_address
*
* @return the value of system_log.ip_address
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public String getIpAddress() {
return ipAddress;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column system_log.ip_address
*
* @param ipAddress the value for system_log.ip_address
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress == null ? null : ipAddress.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column system_log.operator_id
*
* @return the value of system_log.operator_id
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public String getOperatorId() {
return operatorId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column system_log.operator_id
*
* @param operatorId the value for system_log.operator_id
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public void setOperatorId(String operatorId) {
this.operatorId = operatorId == null ? null : operatorId.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column system_log.operator_name
*
* @return the value of system_log.operator_name
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public String getOperatorName() {
return operatorName;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column system_log.operator_name
*
* @param operatorName the value for system_log.operator_name
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public void setOperatorName(String operatorName) {
this.operatorName = operatorName == null ? null : operatorName.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column system_log.params
*
* @return the value of system_log.params
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public String getParams() {
return params;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column system_log.params
*
* @param params the value for system_log.params
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public void setParams(String params) {
this.params = params == null ? null : params.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column system_log.user_agent
*
* @return the value of system_log.user_agent
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public String getUserAgent() {
return userAgent;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column system_log.user_agent
*
* @param userAgent the value for system_log.user_agent
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public void setUserAgent(String userAgent) {
this.userAgent = userAgent == null ? null : userAgent.trim();
}
}

@ -0,0 +1,982 @@
package com.sztzjy.forex.trading_trading.entity;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class LogExample {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
protected String orderByClause;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
protected boolean distinct;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
protected List<Criteria> oredCriteria;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public LogExample() {
oredCriteria = new ArrayList<>();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public String getOrderByClause() {
return orderByClause;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public boolean isDistinct() {
return distinct;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(String value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(String value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(String value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(String value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(String value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(String value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdLike(String value) {
addCriterion("id like", value, "id");
return (Criteria) this;
}
public Criteria andIdNotLike(String value) {
addCriterion("id not like", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<String> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<String> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(String value1, String value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(String value1, String value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Date value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Date value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Date value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Date value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Date> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Date> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Date value1, Date value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andActionIsNull() {
addCriterion("action is null");
return (Criteria) this;
}
public Criteria andActionIsNotNull() {
addCriterion("action is not null");
return (Criteria) this;
}
public Criteria andActionEqualTo(String value) {
addCriterion("action =", value, "action");
return (Criteria) this;
}
public Criteria andActionNotEqualTo(String value) {
addCriterion("action <>", value, "action");
return (Criteria) this;
}
public Criteria andActionGreaterThan(String value) {
addCriterion("action >", value, "action");
return (Criteria) this;
}
public Criteria andActionGreaterThanOrEqualTo(String value) {
addCriterion("action >=", value, "action");
return (Criteria) this;
}
public Criteria andActionLessThan(String value) {
addCriterion("action <", value, "action");
return (Criteria) this;
}
public Criteria andActionLessThanOrEqualTo(String value) {
addCriterion("action <=", value, "action");
return (Criteria) this;
}
public Criteria andActionLike(String value) {
addCriterion("action like", value, "action");
return (Criteria) this;
}
public Criteria andActionNotLike(String value) {
addCriterion("action not like", value, "action");
return (Criteria) this;
}
public Criteria andActionIn(List<String> values) {
addCriterion("action in", values, "action");
return (Criteria) this;
}
public Criteria andActionNotIn(List<String> values) {
addCriterion("action not in", values, "action");
return (Criteria) this;
}
public Criteria andActionBetween(String value1, String value2) {
addCriterion("action between", value1, value2, "action");
return (Criteria) this;
}
public Criteria andActionNotBetween(String value1, String value2) {
addCriterion("action not between", value1, value2, "action");
return (Criteria) this;
}
public Criteria andDescriptionIsNull() {
addCriterion("description is null");
return (Criteria) this;
}
public Criteria andDescriptionIsNotNull() {
addCriterion("description is not null");
return (Criteria) this;
}
public Criteria andDescriptionEqualTo(String value) {
addCriterion("description =", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionNotEqualTo(String value) {
addCriterion("description <>", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionGreaterThan(String value) {
addCriterion("description >", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionGreaterThanOrEqualTo(String value) {
addCriterion("description >=", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionLessThan(String value) {
addCriterion("description <", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionLessThanOrEqualTo(String value) {
addCriterion("description <=", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionLike(String value) {
addCriterion("description like", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionNotLike(String value) {
addCriterion("description not like", value, "description");
return (Criteria) this;
}
public Criteria andDescriptionIn(List<String> values) {
addCriterion("description in", values, "description");
return (Criteria) this;
}
public Criteria andDescriptionNotIn(List<String> values) {
addCriterion("description not in", values, "description");
return (Criteria) this;
}
public Criteria andDescriptionBetween(String value1, String value2) {
addCriterion("description between", value1, value2, "description");
return (Criteria) this;
}
public Criteria andDescriptionNotBetween(String value1, String value2) {
addCriterion("description not between", value1, value2, "description");
return (Criteria) this;
}
public Criteria andIpAddressIsNull() {
addCriterion("ip_address is null");
return (Criteria) this;
}
public Criteria andIpAddressIsNotNull() {
addCriterion("ip_address is not null");
return (Criteria) this;
}
public Criteria andIpAddressEqualTo(String value) {
addCriterion("ip_address =", value, "ipAddress");
return (Criteria) this;
}
public Criteria andIpAddressNotEqualTo(String value) {
addCriterion("ip_address <>", value, "ipAddress");
return (Criteria) this;
}
public Criteria andIpAddressGreaterThan(String value) {
addCriterion("ip_address >", value, "ipAddress");
return (Criteria) this;
}
public Criteria andIpAddressGreaterThanOrEqualTo(String value) {
addCriterion("ip_address >=", value, "ipAddress");
return (Criteria) this;
}
public Criteria andIpAddressLessThan(String value) {
addCriterion("ip_address <", value, "ipAddress");
return (Criteria) this;
}
public Criteria andIpAddressLessThanOrEqualTo(String value) {
addCriterion("ip_address <=", value, "ipAddress");
return (Criteria) this;
}
public Criteria andIpAddressLike(String value) {
addCriterion("ip_address like", value, "ipAddress");
return (Criteria) this;
}
public Criteria andIpAddressNotLike(String value) {
addCriterion("ip_address not like", value, "ipAddress");
return (Criteria) this;
}
public Criteria andIpAddressIn(List<String> values) {
addCriterion("ip_address in", values, "ipAddress");
return (Criteria) this;
}
public Criteria andIpAddressNotIn(List<String> values) {
addCriterion("ip_address not in", values, "ipAddress");
return (Criteria) this;
}
public Criteria andIpAddressBetween(String value1, String value2) {
addCriterion("ip_address between", value1, value2, "ipAddress");
return (Criteria) this;
}
public Criteria andIpAddressNotBetween(String value1, String value2) {
addCriterion("ip_address not between", value1, value2, "ipAddress");
return (Criteria) this;
}
public Criteria andOperatorIdIsNull() {
addCriterion("operator_id is null");
return (Criteria) this;
}
public Criteria andOperatorIdIsNotNull() {
addCriterion("operator_id is not null");
return (Criteria) this;
}
public Criteria andOperatorIdEqualTo(String value) {
addCriterion("operator_id =", value, "operatorId");
return (Criteria) this;
}
public Criteria andOperatorIdNotEqualTo(String value) {
addCriterion("operator_id <>", value, "operatorId");
return (Criteria) this;
}
public Criteria andOperatorIdGreaterThan(String value) {
addCriterion("operator_id >", value, "operatorId");
return (Criteria) this;
}
public Criteria andOperatorIdGreaterThanOrEqualTo(String value) {
addCriterion("operator_id >=", value, "operatorId");
return (Criteria) this;
}
public Criteria andOperatorIdLessThan(String value) {
addCriterion("operator_id <", value, "operatorId");
return (Criteria) this;
}
public Criteria andOperatorIdLessThanOrEqualTo(String value) {
addCriterion("operator_id <=", value, "operatorId");
return (Criteria) this;
}
public Criteria andOperatorIdLike(String value) {
addCriterion("operator_id like", value, "operatorId");
return (Criteria) this;
}
public Criteria andOperatorIdNotLike(String value) {
addCriterion("operator_id not like", value, "operatorId");
return (Criteria) this;
}
public Criteria andOperatorIdIn(List<String> values) {
addCriterion("operator_id in", values, "operatorId");
return (Criteria) this;
}
public Criteria andOperatorIdNotIn(List<String> values) {
addCriterion("operator_id not in", values, "operatorId");
return (Criteria) this;
}
public Criteria andOperatorIdBetween(String value1, String value2) {
addCriterion("operator_id between", value1, value2, "operatorId");
return (Criteria) this;
}
public Criteria andOperatorIdNotBetween(String value1, String value2) {
addCriterion("operator_id not between", value1, value2, "operatorId");
return (Criteria) this;
}
public Criteria andOperatorNameIsNull() {
addCriterion("operator_name is null");
return (Criteria) this;
}
public Criteria andOperatorNameIsNotNull() {
addCriterion("operator_name is not null");
return (Criteria) this;
}
public Criteria andOperatorNameEqualTo(String value) {
addCriterion("operator_name =", value, "operatorName");
return (Criteria) this;
}
public Criteria andOperatorNameNotEqualTo(String value) {
addCriterion("operator_name <>", value, "operatorName");
return (Criteria) this;
}
public Criteria andOperatorNameGreaterThan(String value) {
addCriterion("operator_name >", value, "operatorName");
return (Criteria) this;
}
public Criteria andOperatorNameGreaterThanOrEqualTo(String value) {
addCriterion("operator_name >=", value, "operatorName");
return (Criteria) this;
}
public Criteria andOperatorNameLessThan(String value) {
addCriterion("operator_name <", value, "operatorName");
return (Criteria) this;
}
public Criteria andOperatorNameLessThanOrEqualTo(String value) {
addCriterion("operator_name <=", value, "operatorName");
return (Criteria) this;
}
public Criteria andOperatorNameLike(String value) {
addCriterion("operator_name like", value, "operatorName");
return (Criteria) this;
}
public Criteria andOperatorNameNotLike(String value) {
addCriterion("operator_name not like", value, "operatorName");
return (Criteria) this;
}
public Criteria andOperatorNameIn(List<String> values) {
addCriterion("operator_name in", values, "operatorName");
return (Criteria) this;
}
public Criteria andOperatorNameNotIn(List<String> values) {
addCriterion("operator_name not in", values, "operatorName");
return (Criteria) this;
}
public Criteria andOperatorNameBetween(String value1, String value2) {
addCriterion("operator_name between", value1, value2, "operatorName");
return (Criteria) this;
}
public Criteria andOperatorNameNotBetween(String value1, String value2) {
addCriterion("operator_name not between", value1, value2, "operatorName");
return (Criteria) this;
}
public Criteria andParamsIsNull() {
addCriterion("params is null");
return (Criteria) this;
}
public Criteria andParamsIsNotNull() {
addCriterion("params is not null");
return (Criteria) this;
}
public Criteria andParamsEqualTo(String value) {
addCriterion("params =", value, "params");
return (Criteria) this;
}
public Criteria andParamsNotEqualTo(String value) {
addCriterion("params <>", value, "params");
return (Criteria) this;
}
public Criteria andParamsGreaterThan(String value) {
addCriterion("params >", value, "params");
return (Criteria) this;
}
public Criteria andParamsGreaterThanOrEqualTo(String value) {
addCriterion("params >=", value, "params");
return (Criteria) this;
}
public Criteria andParamsLessThan(String value) {
addCriterion("params <", value, "params");
return (Criteria) this;
}
public Criteria andParamsLessThanOrEqualTo(String value) {
addCriterion("params <=", value, "params");
return (Criteria) this;
}
public Criteria andParamsLike(String value) {
addCriterion("params like", value, "params");
return (Criteria) this;
}
public Criteria andParamsNotLike(String value) {
addCriterion("params not like", value, "params");
return (Criteria) this;
}
public Criteria andParamsIn(List<String> values) {
addCriterion("params in", values, "params");
return (Criteria) this;
}
public Criteria andParamsNotIn(List<String> values) {
addCriterion("params not in", values, "params");
return (Criteria) this;
}
public Criteria andParamsBetween(String value1, String value2) {
addCriterion("params between", value1, value2, "params");
return (Criteria) this;
}
public Criteria andParamsNotBetween(String value1, String value2) {
addCriterion("params not between", value1, value2, "params");
return (Criteria) this;
}
public Criteria andUserAgentIsNull() {
addCriterion("user_agent is null");
return (Criteria) this;
}
public Criteria andUserAgentIsNotNull() {
addCriterion("user_agent is not null");
return (Criteria) this;
}
public Criteria andUserAgentEqualTo(String value) {
addCriterion("user_agent =", value, "userAgent");
return (Criteria) this;
}
public Criteria andUserAgentNotEqualTo(String value) {
addCriterion("user_agent <>", value, "userAgent");
return (Criteria) this;
}
public Criteria andUserAgentGreaterThan(String value) {
addCriterion("user_agent >", value, "userAgent");
return (Criteria) this;
}
public Criteria andUserAgentGreaterThanOrEqualTo(String value) {
addCriterion("user_agent >=", value, "userAgent");
return (Criteria) this;
}
public Criteria andUserAgentLessThan(String value) {
addCriterion("user_agent <", value, "userAgent");
return (Criteria) this;
}
public Criteria andUserAgentLessThanOrEqualTo(String value) {
addCriterion("user_agent <=", value, "userAgent");
return (Criteria) this;
}
public Criteria andUserAgentLike(String value) {
addCriterion("user_agent like", value, "userAgent");
return (Criteria) this;
}
public Criteria andUserAgentNotLike(String value) {
addCriterion("user_agent not like", value, "userAgent");
return (Criteria) this;
}
public Criteria andUserAgentIn(List<String> values) {
addCriterion("user_agent in", values, "userAgent");
return (Criteria) this;
}
public Criteria andUserAgentNotIn(List<String> values) {
addCriterion("user_agent not in", values, "userAgent");
return (Criteria) this;
}
public Criteria andUserAgentBetween(String value1, String value2) {
addCriterion("user_agent between", value1, value2, "userAgent");
return (Criteria) this;
}
public Criteria andUserAgentNotBetween(String value1, String value2) {
addCriterion("user_agent not between", value1, value2, "userAgent");
return (Criteria) this;
}
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table system_log
*
* @mbg.generated do_not_delete_during_merge Tue Oct 10 22:07:46 CST 2023
*/
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

@ -0,0 +1,99 @@
package com.sztzjy.forex.trading_trading.mappers;
import com.sztzjy.forex.trading_trading.entity.Log;
import com.sztzjy.forex.trading_trading.entity.LogExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface LogMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
long countByExample(LogExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
int deleteByExample(LogExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
int deleteByPrimaryKey(String id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
int insert(Log record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
int insertSelective(Log record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
List<Log> selectByExample(LogExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
Log selectByPrimaryKey(String id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
int updateByExampleSelective(@Param("record") Log record, @Param("example") LogExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
int updateByExample(@Param("record") Log record, @Param("example") LogExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
int updateByPrimaryKeySelective(Log record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table system_log
*
* @mbg.generated Tue Oct 10 22:07:46 CST 2023
*/
int updateByPrimaryKey(Log record);
}

@ -1,7 +0,0 @@
package com.sztzjy.forex.trading_trading.repository;
import com.sztzjy.forex.trading_trading.entity.Log;
public interface ILogRepository extends IBaseJpaRepository<Log, String> {
}

@ -1,59 +1,21 @@
package com.sztzjy.forex.trading_trading.service; package com.sztzjy.forex.trading_trading.service;
import com.sztzjy.forex.trading_trading.entity.Log; import com.sztzjy.forex.trading_trading.entity.Log;
import com.sztzjy.forex.trading_trading.repository.ILogRepository; import com.sztzjy.forex.trading_trading.mappers.LogMapper;
import com.sztzjy.forex.trading_trading.util.PageUtil; import org.springframework.beans.factory.annotation.Autowired;
import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.domain.Specification; import java.util.Date;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; @Service
public class LogService {
import javax.persistence.criteria.Predicate;
import java.util.ArrayList; @Autowired
import java.util.Date; private LogMapper logMapper;
import java.util.List;
public void add(Log log) {
/** log.setCreateTime(new Date());
* log.setUpdateTime(new Date());
*/ logMapper.insert(log);
@Service }
@RequiredArgsConstructor }
public class LogService {
private final ILogRepository logRepository;
public Page<Log> findAll(Integer index, Integer size) {
PageUtil pageUtil = new PageUtil(index, size);
pageUtil.addSort("operatedTime", false);
return logRepository.findAll(pageUtil.getPageable());
}
@Transactional(rollbackFor = Exception.class)
public Log add(Log logRecord) {
logRecord.setCreateTime(new Date());
logRepository.save(logRecord);
return logRecord;
}
public Page<Log> findByConditions(Integer index, Integer size, String ipAddress, Long startTime, Long endTime, String operatorName) {
Specification<Log> specification = (Specification<Log>) (root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> andPredicate = new ArrayList<>();
if (ipAddress != null && !ipAddress.isEmpty()) {
andPredicate.add(criteriaBuilder.equal(root.get("ipAddress"), ipAddress));
}
if (startTime != null && startTime != 0) {
andPredicate.add(criteriaBuilder.greaterThanOrEqualTo(root.get("createTime"), new Date(startTime)));
}
if (endTime != null && endTime != 0) {
andPredicate.add(criteriaBuilder.lessThanOrEqualTo(root.get("createTime"), new Date(endTime)));
}
if (operatorName != null && !operatorName.isEmpty()) {
andPredicate.add(criteriaBuilder.like(root.get("operatorName"), operatorName + '%'));
}
return criteriaQuery.where(andPredicate.toArray(new Predicate[]{})).getRestriction();
};
PageUtil pageUtil = new PageUtil(index, size);
pageUtil.addSort("createTime", false);
return logRepository.findAll(specification, pageUtil.getPageable());
}
}

Loading…
Cancel
Save