1.提交一次
This commit is contained in:
parent
6e1b1d9b0e
commit
56050b10fa
7
pom.xml
7
pom.xml
|
@ -55,16 +55,21 @@
|
||||||
<!-- Sa-Token 权限认证,在线文档:https://sa-token.cc -->
|
<!-- Sa-Token 权限认证,在线文档:https://sa-token.cc -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.dev33</groupId>
|
<groupId>cn.dev33</groupId>
|
||||||
<artifactId>sa-token-spring-boot-starter</artifactId>
|
<artifactId>sa-token-spring-boot3-starter</artifactId>
|
||||||
<version>1.37.0</version>
|
<version>1.37.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- Sa-Token 整合 Redis (使用 jackson 序列化方式) -->
|
<!-- Sa-Token 整合 Redis (使用 jackson 序列化方式) -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.dev33</groupId>
|
<groupId>cn.dev33</groupId>
|
||||||
<artifactId>sa-token-redis-jackson</artifactId>
|
<artifactId>sa-token-redis-jackson</artifactId>
|
||||||
<version>1.37.0</version>
|
<version>1.37.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package org.aohe.ssotoken.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
||||||
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class RedisConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
|
||||||
|
RedisTemplate<String, Object> template = new RedisTemplate<>();
|
||||||
|
template.setConnectionFactory(connectionFactory);
|
||||||
|
template.setKeySerializer(new StringRedisSerializer());
|
||||||
|
template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package org.aohe.ssotoken.controller;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RequestMapping("api")
|
||||||
|
@RestController
|
||||||
|
public class LoginController {
|
||||||
|
|
||||||
|
@PostMapping("login")
|
||||||
|
public String login(String username, String password){
|
||||||
|
StpUtil.login(username);
|
||||||
|
return "success";
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package org.aohe.ssotoken.controller;
|
package org.aohe.ssotoken.controller;
|
||||||
|
|
||||||
import org.aohe.ssotoken.utils.RedisUtil;
|
import org.aohe.ssotoken.utils.RedisUtil;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@ -13,20 +14,20 @@ public class RedisController {
|
||||||
public RedisController(RedisUtil redisUtil) {
|
public RedisController(RedisUtil redisUtil) {
|
||||||
this.redisUtil = redisUtil;
|
this.redisUtil = redisUtil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("add")
|
@PostMapping("add")
|
||||||
public String addKey(String key, String value) {
|
public String addKey(String key, String value, Long time) {
|
||||||
redisUtil.set(key, value, 60);
|
redisUtil.set(key, value, time);
|
||||||
return "success";
|
return "success";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("get")
|
@PostMapping("get")
|
||||||
public String getKey(String key) {
|
public String getKey(String key) {
|
||||||
redisUtil.get(key);
|
redisUtil.get(key);
|
||||||
return "success";
|
return "success";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("del")
|
@PostMapping("del")
|
||||||
public String delKey(String key) {
|
public String delKey(String key) {
|
||||||
redisUtil.del(key);
|
redisUtil.del(key);
|
||||||
return "success";
|
return "success";
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
package org.aohe.ssotoken.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @TableName t_user
|
||||||
|
*/
|
||||||
|
@TableName(value ="t_user")
|
||||||
|
@Data
|
||||||
|
public class UserDO implements Serializable {
|
||||||
|
/**
|
||||||
|
* 自增主键
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 姓名
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
private String createdBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createdTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新人
|
||||||
|
*/
|
||||||
|
private String updatedBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
private Date updatedTime;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object that) {
|
||||||
|
if (this == that) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (that == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != that.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
UserDO other = (UserDO) that;
|
||||||
|
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||||
|
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
|
||||||
|
&& (this.getPassword() == null ? other.getPassword() == null : this.getPassword().equals(other.getPassword()))
|
||||||
|
&& (this.getCreatedBy() == null ? other.getCreatedBy() == null : this.getCreatedBy().equals(other.getCreatedBy()))
|
||||||
|
&& (this.getCreatedTime() == null ? other.getCreatedTime() == null : this.getCreatedTime().equals(other.getCreatedTime()))
|
||||||
|
&& (this.getUpdatedBy() == null ? other.getUpdatedBy() == null : this.getUpdatedBy().equals(other.getUpdatedBy()))
|
||||||
|
&& (this.getUpdatedTime() == null ? other.getUpdatedTime() == null : this.getUpdatedTime().equals(other.getUpdatedTime()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||||
|
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
|
||||||
|
result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode());
|
||||||
|
result = prime * result + ((getCreatedBy() == null) ? 0 : getCreatedBy().hashCode());
|
||||||
|
result = prime * result + ((getCreatedTime() == null) ? 0 : getCreatedTime().hashCode());
|
||||||
|
result = prime * result + ((getUpdatedBy() == null) ? 0 : getUpdatedBy().hashCode());
|
||||||
|
result = prime * result + ((getUpdatedTime() == null) ? 0 : getUpdatedTime().hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(getClass().getSimpleName());
|
||||||
|
sb.append(" [");
|
||||||
|
sb.append("Hash = ").append(hashCode());
|
||||||
|
sb.append(", id=").append(id);
|
||||||
|
sb.append(", name=").append(name);
|
||||||
|
sb.append(", password=").append(password);
|
||||||
|
sb.append(", createdBy=").append(createdBy);
|
||||||
|
sb.append(", createdTime=").append(createdTime);
|
||||||
|
sb.append(", updatedBy=").append(updatedBy);
|
||||||
|
sb.append(", updatedTime=").append(updatedTime);
|
||||||
|
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||||
|
sb.append("]");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package org.aohe.ssotoken.mapper;
|
||||||
|
|
||||||
|
import org.aohe.ssotoken.entity.UserDO;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
public interface UserDOMapper extends BaseMapper<UserDO> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
package org.aohe.ssotoken.service;
|
||||||
|
|
||||||
|
public class LoginService {
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package org.aohe.ssotoken.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.aohe.ssotoken.entity.UserDO;
|
||||||
|
import org.aohe.ssotoken.mapper.UserDOMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UserService extends ServiceImpl<UserDOMapper, UserDO>
|
||||||
|
implements IService<UserDO> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="org.aohe.ssotoken.mapper.UserDOMapper">
|
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="org.aohe.ssotoken.entity.UserDO">
|
||||||
|
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||||
|
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||||
|
<result property="password" column="password" jdbcType="VARCHAR"/>
|
||||||
|
<result property="createdBy" column="created_by" jdbcType="VARCHAR"/>
|
||||||
|
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
|
||||||
|
<result property="updatedBy" column="updated_by" jdbcType="VARCHAR"/>
|
||||||
|
<result property="updatedTime" column="updated_time" jdbcType="TIMESTAMP"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id,name,password,
|
||||||
|
created_by,created_time,updated_by,
|
||||||
|
updated_time
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue