🎉 init

This commit is contained in:
landaiqing
2024-04-19 23:30:48 +08:00
parent 37ec6b7879
commit 2ee19525ad
87 changed files with 4799 additions and 79 deletions

90
.gitignore vendored
View File

@@ -1,4 +1,15 @@
# ---> Java
#IDE
.idea
*.iml
# ---> Gradle
.gradle
/build/
# ---> Maven
target/
# Compiled class file
*.class
@@ -24,82 +35,3 @@
hs_err_pid*
replay_pid*
# ---> JetBrains
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# AWS User-specific
.idea/**/aws.xml
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# SonarLint plugin
.idea/sonarlint/
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

View File

@@ -0,0 +1,57 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.schisandra</groupId>
<artifactId>schisandra-cloud-storage-auth</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>schisandra-cloud-storage-auth</name>
<modules>
<module>schisandra-cloud-storage-auth-api</module>
<module>schisandra-cloud-storage-auth-application</module>
<module>schisandra-cloud-storage-auth-common</module>
<module>schisandra-cloud-storage-auth-domain</module>
<module>schisandra-cloud-storage-auth-infra</module>
<module>schisandra-cloud-storage-auth-starter</module>
<module>schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-controller</module>
<module>schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-job</module>
<module>schisandra-cloud-storage-auth-application/schisandra-cloud-storage-auth-application-mq</module>
</modules>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.4.2</spring-boot.version>
<spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>
<spring-cloud.version>2020.0.6</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.4.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>central</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>

View File

@@ -0,0 +1,37 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.schisandra</groupId>
<artifactId>schisandra-cloud-storage-auth</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>schisandra-cloud-storage-auth-api</artifactId>
<name>schisandra-cloud-storage-auth-api</name>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>3.0.7</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-loadbalancer</artifactId>
<version>3.0.6</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.28</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,19 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.schisandra</groupId>
<artifactId>schisandra-cloud-storage-auth</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>schisandra-cloud-storage-auth-application</artifactId>
<name>schisandra-cloud-storage-auth-application</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
</dependencies>
</project>

View File

@@ -0,0 +1,38 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.schisandra</groupId>
<artifactId>schisandra-cloud-storage-auth</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>schisandra-cloud-storage-auth-application-controller</artifactId>
<name>schisandra-cloud-storage-auth-application-controller</name>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>com.schisandra</groupId>
<artifactId>schisandra-cloud-storage-auth-domain</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.schisandra</groupId>
<artifactId>schisandra-cloud-storage-auth-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,37 @@
package com.schisandra.auth.application.config;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import java.util.List;
/**
* @Classname GlobalConfig
* @BelongsProject: qing-yu-club
* @BelongsPackage: com.schisandra.auth.application.config
* @Author: landaiqing
* @CreateTime: 2024-02-16 15:57
* @Description: MVC全局处理
* @Version: 1.0
*/
@Configuration
public class GlobalConfig extends WebMvcConfigurationSupport {
@Override
protected void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
super.configureMessageConverters(converters);
converters.add(mappingJackson2HttpMessageConverter());
}
private MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(objectMapper);
return converter;
}
}

View File

@@ -0,0 +1,119 @@
package com.schisandra.auth.application.controller;
import com.alibaba.fastjson.JSON;
import com.schisandra.auth.application.convert.SchisandraAuthPermissionDTOConvert;
import com.schisandra.auth.application.dto.SchisandraAuthPermissionDTO;
import com.schisandra.auth.common.entity.Result;
import com.schisandra.auth.domain.bo.SchisandraAuthPermissionBO;
import com.schisandra.auth.domain.service.SchisandraAuthPermissionDomainService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
@RequestMapping("/authPermission/")
@Slf4j
public class SchisandraAuthPermissionController {
@Resource
private SchisandraAuthPermissionDomainService schisandraAuthPermissionDomainService;
/**
* @description: 更新权限信息
* @param: [schisandraAuthPermissionDTO]
* @return: com.schisandra.auth.common.entity.Result
* @author zhang
* @date: 2024/4/17 16:44
*/
@PostMapping("update")
public Result update(@RequestBody SchisandraAuthPermissionDTO schisandraAuthPermissionDTO) {
try {
if (log.isInfoEnabled()) {
log.info("authPermissionController.update.dto:{}", JSON.toJSONString(schisandraAuthPermissionDTO));
}
// checkRoleInfo(schisandraAuthPermissionDTO);
SchisandraAuthPermissionBO schisandraAuthPermissionBO = SchisandraAuthPermissionDTOConvert.INSTANCE.convertDTOToBO(schisandraAuthPermissionDTO);
return Result.ok(schisandraAuthPermissionDomainService.update(schisandraAuthPermissionBO));
} catch (Exception e) {
log.error("authPermissionController.update.error:{}", e.getMessage(), e);
return Result.fail("更新权限信息失败");
}
}
/**
* @description: 添加权限信息
* @param: [schisandraAuthPermissionDTO]
* @return: com.schisandra.auth.common.entity.Result
* @author zhang
* @date: 2024/4/17 16:55
*/
@PostMapping("insert")
public Result insert(@RequestBody SchisandraAuthPermissionDTO schisandraAuthPermissionDTO) {
try {
if (log.isInfoEnabled()) {
log.info("authPermissionController.insert.dto:{}", JSON.toJSONString(schisandraAuthPermissionDTO));
}
// checkRoleInfo(schisandraAuthPermissionDTO);
SchisandraAuthPermissionBO schisandraAuthPermissionBO = SchisandraAuthPermissionDTOConvert.INSTANCE.convertDTOToBO(schisandraAuthPermissionDTO);
return Result.ok(schisandraAuthPermissionDomainService.insert(schisandraAuthPermissionBO));
} catch (Exception e) {
log.error("authPermissionController.insert.error:{}", e.getMessage(), e);
return Result.fail("插入权限信息失败");
}
}
/**
* @description:查询权限信息
* @param: [schisandraAuthPermissionDTO]
* @return: com.schisandra.auth.common.entity.Result
* @author zlg
* @date: 2024/4/17 16:54
*/
@PostMapping("select")
public Result select(@RequestBody SchisandraAuthPermissionDTO schisandraAuthPermissionDTO) {
try {
if (log.isInfoEnabled()) {
log.info("authPermissionController.update.dto:{}", JSON.toJSONString(schisandraAuthPermissionDTO));
}
// checkRoleInfo(schisandraAuthPermissionDTO);
if (schisandraAuthPermissionDTO.getId()==null){
return Result.fail("id不能为空");
}
SchisandraAuthPermissionBO schisandraAuthPermissionBO = SchisandraAuthPermissionDTOConvert.INSTANCE.convertDTOToBO(schisandraAuthPermissionDTO);
System.out.println("bo:"+schisandraAuthPermissionBO.getId());
return Result.ok(schisandraAuthPermissionDomainService.select(schisandraAuthPermissionBO));
} catch (Exception e) {
log.error("authPermissionController.select.error:{}", e.getMessage(), e);
return Result.fail("查询权限信息失败");
}
}
/**
* @description: 删除权限信息
* @param: [schisandraAuthPermissionDTO]
* @return: com.schisandra.auth.common.entity.Result
* @author zhang
* @date: 2024/4/17 16:54
*/
@PostMapping("delete")
public Result delete(@RequestBody SchisandraAuthPermissionDTO schisandraAuthPermissionDTO) {
try {
if (log.isInfoEnabled()) {
log.info("authPermissionController.update.dto:{}", JSON.toJSONString(schisandraAuthPermissionDTO));
}
// checkRoleInfo(schisandraAuthPermissionDTO);
SchisandraAuthPermissionBO schisandraAuthPermissionBO = SchisandraAuthPermissionDTOConvert.INSTANCE.convertDTOToBO(schisandraAuthPermissionDTO);
return Result.ok(schisandraAuthPermissionDomainService.delete(schisandraAuthPermissionBO));
} catch (Exception e) {
log.error("authPermissionController.select.error:{}", e.getMessage(), e);
return Result.fail("删除权限信息失败");
}
}
private void checkRoleInfo(@RequestBody SchisandraAuthPermissionDTO schisandraAuthPermissionDTO) {
// Preconditions.checkArgument(!Utils.isBlank(schisandraAuthPermissionDTO.getId()), "角色名不能为空");
// Preconditions.checkArgument(!StringUtils.isBlank(schisandraAuthPermissionDTO.getName()), "角色key值不能为空");
}
}

View File

@@ -0,0 +1,118 @@
package com.schisandra.auth.application.controller;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Preconditions;
import com.schisandra.auth.application.convert.SchisandraAuthRoleDTOConverter;
import com.schisandra.auth.application.dto.SchisandraAuthRoleDTO;
import com.schisandra.auth.common.entity.Result;
import com.schisandra.auth.domain.bo.SchisandraAuthRoleBO;
import com.schisandra.auth.domain.service.SchisandraAuthRoleDomainService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* ClassName:SchisandraAuthRoleController
* Package:com.schisandra.auth.application.controller
* Description:AuthRoleController层
*
* @Author:fanyang
* @Create:2024/4/4 - 20:47
* @Version: v1.0
*/
@RestController
@RequestMapping("/role/")
@Slf4j
public class SchisandraAuthRoleController {
@Resource
private SchisandraAuthRoleDomainService schisandraAuthRoleDomainService;
/**
* @description 更新角色信息
* @param schisandraAuthRoleDTO
* @return
* @author fanyang
* @date 2024/4/3 22:05
*/
@PostMapping("update")
public Object update(@RequestBody SchisandraAuthRoleDTO schisandraAuthRoleDTO) {
try {
if (log.isInfoEnabled()) {
log.info("RoleController.update.dto:{}", JSON.toJSONString(schisandraAuthRoleDTO));
}
checkRoleInfo(schisandraAuthRoleDTO);
SchisandraAuthRoleBO authRoleBO = SchisandraAuthRoleDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthRoleDTO);
return Result.ok(schisandraAuthRoleDomainService.update(authRoleBO));
} catch (Exception e) {
log.error("RoleController.update.error:{}", e.getMessage(), e);
return Result.fail("更新角色信息失败");
}
}
/**
* @description 查询角色信息
* @param schisandraAuthRoleDTO
* @return
* @author fanyang
* @date 2024/4/3 22:05
*/
@PostMapping("query")
public Result query(@RequestBody SchisandraAuthRoleDTO schisandraAuthRoleDTO){
try{
if(log.isInfoEnabled()){
log.info("RoleController.select.dto:{}", JSON.toJSONString(schisandraAuthRoleDTO));
}
checkRoleInfo(schisandraAuthRoleDTO);
SchisandraAuthRoleBO authRoleBO = SchisandraAuthRoleDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthRoleDTO);
return Result.ok(schisandraAuthRoleDomainService.select(authRoleBO));
} catch (Exception e) {
log.error("RoleController.select.error:{}", e.getMessage(), e);
return Result.fail("查询角色信息失败");
}
}
/**
* @description 添加角色信息
* @param schisandraAuthRoleDTO
* @return
* @author fanyang
* @date 2024/4/3 22:12
*/
@PostMapping("insert")
public Result insert(@RequestBody SchisandraAuthRoleDTO schisandraAuthRoleDTO){
try{
if(log.isInfoEnabled()){
log.info("RoleController.insert.dto:{}", JSON.toJSONString(schisandraAuthRoleDTO));
}
checkRoleInfo(schisandraAuthRoleDTO);
SchisandraAuthRoleBO authRoleBO = SchisandraAuthRoleDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthRoleDTO);
return Result.ok(schisandraAuthRoleDomainService.update(authRoleBO));
} catch (Exception e) {
log.error("RoleController.insert.error:{}", e.getMessage(), e);
return Result.fail("添加角色信息失败");
}
}
/**
* @description 删除角色信息
* @param id
* @return
* @author fanyang
* @date 2024/4/3 22:12
*/
@GetMapping("delete/{id}")
public Result delete(@PathVariable Long id){
try{
if(log.isInfoEnabled()){
log.info("RoleController.insert.dto:{}",id);
}
return Result.ok(schisandraAuthRoleDomainService.delete(id));
} catch (Exception e) {
log.error("RoleController.insert.error:{}", e.getMessage(), e);
return Result.fail("删除角色信息失败");
}
}
private void checkRoleInfo(@RequestBody SchisandraAuthRoleDTO schisandraAuthRoleDTO) {
// Preconditions.checkArgument(!StringUtils.isBlank(schisandraAuthRoleDTO.getRoleName()), "角色名不能为空");
// Preconditions.checkArgument(!StringUtils.isBlank(schisandraAuthRoleDTO.getRoleKey()), "角色key值不能为空");
}
}

View File

@@ -0,0 +1,126 @@
package com.schisandra.auth.application.controller;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Preconditions;
import com.schisandra.auth.application.convert.SchisandraAuthUserDTOConverter;
import com.schisandra.auth.application.dto.SchisandraAuthUserDTO;
import com.schisandra.auth.common.entity.Result;
import com.schisandra.auth.domain.bo.SchisandraAuthUserBO;
import com.schisandra.auth.domain.service.SchisandraAuthUserDomainService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @Classname SchisandraAuthUserController
* @BelongsProject: schisandra-cloud-storage
* @BelongsPackage: com.schisandra.auth.application.controller
* @Author: landaiqing
* @CreateTime: 2024-03-21 22:48
* @Description: AuthUserController层
* @Version: 1.0
*/
@RestController
@RequestMapping("/user/")
@Slf4j
public class SchisandraAuthUserController {
@Resource
private SchisandraAuthUserDomainService schisandraAuthUserDomainService;
/**
* @description 更新用户信息
* @param schisandraAuthUserDTO
* @return com.schisandra.auth.common.entity.Result<java.lang.Boolean>
* @author landaiqing
* @date 2024/3/21 23:06
*/
@PostMapping("update")
public Result update(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO) {
try {
if (log.isInfoEnabled()) {
log.info("UserController.update.dto:{}", JSON.toJSONString(schisandraAuthUserDTO));
}
checkUserInfo(schisandraAuthUserDTO);
SchisandraAuthUserBO authUserBO = SchisandraAuthUserDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthUserDTO);
return Result.ok(schisandraAuthUserDomainService.update(authUserBO));
} catch (Exception e) {
log.error("UserController.update.error:{}", e.getMessage(), e);
return Result.fail("更新用户信息失败");
}
}
/**
* @description 查询用户信息
* @param schisandraAuthUserDTO
* @return
* @author msz
* @date 2024/4/3 22:05
*/
@PostMapping("/query")
public Result query(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO){
try{
if(log.isInfoEnabled()){
log.info("UserController.select.dto:{}", JSON.toJSONString(schisandraAuthUserDTO));
}
checkUserInfo(schisandraAuthUserDTO);
SchisandraAuthUserBO authUserBO = SchisandraAuthUserDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthUserDTO);
return Result.ok(schisandraAuthUserDomainService.queryById(authUserBO));
} catch (Exception e) {
log.error("UserController.select.error:{}", e.getMessage(), e);
return Result.fail("查询用户信息失败");
}
}
/**
* @description 添加用户信息
* @param schisandraAuthUserDTO
* @return
* @author msz
* @date 2024/4/3 22:12
*/
@PostMapping("/insert")
public Result insert(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO){
try{
if(log.isInfoEnabled()){
log.info("UserController.insert.dto:{}", JSON.toJSONString(schisandraAuthUserDTO));
}
checkUserInfo(schisandraAuthUserDTO);
SchisandraAuthUserBO authUserBO = SchisandraAuthUserDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthUserDTO);
return Result.ok(schisandraAuthUserDomainService.update(authUserBO));
} catch (Exception e) {
log.error("UserController.insert.error:{}", e.getMessage(), e);
return Result.fail("添加用户信息失败");
}
}
/**
* @description 删除用户信息
* @param id
* @return
* @author msz
* @date 2024/4/3 22:12
*/
@GetMapping("/delete/{id}")
public Result delete(@PathVariable Long id){
try{
if(log.isInfoEnabled()){
log.info("UserController.insert.dto:{}",id);
}
return Result.ok(schisandraAuthUserDomainService.deleteById(id));
} catch (Exception e) {
log.error("UserController.insert.error:{}", e.getMessage(), e);
return Result.fail("删除用户信息失败");
}
}
/**
* @description 用户信息断言校验
* @param schisandraAuthUserDTO
* @return void
* @author landaiqing
* @date 2024/3/21 23:09
*/
private void checkUserInfo(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO) {
// Preconditions.checkArgument(!StringUtils.isBlank(schisandraAuthUserDTO.getUserName()), "用户名不能为空");
// Preconditions.checkArgument(!StringUtils.isBlank(schisandraAuthUserDTO.getEmail()), "邮箱不能为空");
// Preconditions.checkArgument(!StringUtils.isBlank(schisandraAuthUserDTO.getPassword()), "密码不能为空");
}
}

View File

@@ -0,0 +1,18 @@
package com.schisandra.auth.application.convert;
import com.schisandra.auth.application.dto.SchisandraAuthPermissionDTO;
import com.schisandra.auth.domain.bo.SchisandraAuthPermissionBO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper(componentModel = "spring")
public interface SchisandraAuthPermissionDTOConvert {
SchisandraAuthPermissionDTOConvert INSTANCE = Mappers.getMapper(SchisandraAuthPermissionDTOConvert.class);
// 将SchisandraAuthPermissionDTO对象转换为SchisandraAuthPermissionBO对象
SchisandraAuthPermissionBO convertDTOToBO(SchisandraAuthPermissionDTO schisandraAuthPermissionDTO);
// 将SchisandraAuthPermissionBO对象转换为SchisandraAuthPermissionDTO对象
SchisandraAuthPermissionDTO convertBOToDTO(SchisandraAuthPermissionBO authRoleBO);
}

View File

@@ -0,0 +1,43 @@
package com.schisandra.auth.application.convert;
import com.schisandra.auth.application.dto.SchisandraAuthRoleDTO;
import com.schisandra.auth.application.dto.SchisandraAuthUserDTO;
import com.schisandra.auth.domain.bo.SchisandraAuthRoleBO;
import com.schisandra.auth.domain.bo.SchisandraAuthUserBO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* ClassName:SchisandraAuthRoleDTOConvert
* Package:com.schisandra.auth.application.convert
* Description:
*
* @Author:
* @Create:2024/4/4 - 21:40
* @Version: v1.0
*/
@Mapper(componentModel = "spring")
public interface SchisandraAuthRoleDTOConverter {
SchisandraAuthRoleDTOConverter INSTANCE = Mappers.getMapper(SchisandraAuthRoleDTOConverter.class);
/**
* @param authRoleDTO
* @return com.schisandra.auth.domain.bo.SchisandraAuthRoleBO
* @description DTO转BO
* @author landaiqing
* @date 2024/3/21 23:11
*/
SchisandraAuthRoleBO convertDTOToBO(SchisandraAuthRoleDTO authRoleDTO);
/**
* @description: BO转DTO
* @param: [authUserBO]
* @return: com.schisandra.auth.application.dto.SchisandraAuthRoleDTO
* @author: landaiqing
* @date: 2024/3/21 23:26
*/
SchisandraAuthRoleDTO convertBOToDTO(SchisandraAuthRoleBO authRoleBO);
}

View File

@@ -0,0 +1,37 @@
package com.schisandra.auth.application.convert;
import com.schisandra.auth.application.dto.SchisandraAuthUserDTO;
import com.schisandra.auth.domain.bo.SchisandraAuthUserBO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* 用户dto转换器
*
* @author landaiqing
*/
@Mapper(componentModel = "spring")
public interface SchisandraAuthUserDTOConverter {
SchisandraAuthUserDTOConverter INSTANCE = Mappers.getMapper(SchisandraAuthUserDTOConverter.class);
/**
* @param authUserDTO
* @return com.schisandra.auth.domain.bo.SchisandraAuthUserBO
* @description DTO转BO
* @author landaiqing
* @date 2024/3/21 23:11
*/
SchisandraAuthUserBO convertDTOToBO(SchisandraAuthUserDTO authUserDTO);
/**
* @description: BO转DTO
* @param: [authUserBO]
* @return: com.schisandra.auth.application.dto.SchisandraAuthUserDTO
* @author: landaiqing
* @date: 2024/3/21 23:26
*/
SchisandraAuthUserDTO convertBOToDTO(SchisandraAuthUserBO authUserBO);
}

View File

@@ -0,0 +1,40 @@
package com.schisandra.auth.application.dto;
import lombok.Data;
import java.util.Date;
import java.io.Serializable;
/**
*
* @author makejava
* @since 2024-04-17 12:05:46
*/
@Data
public class SchisandraAuthPermissionDTO implements Serializable {
private Long id;
private String name;
private Long parentId;
private Integer type;
private String menuUrl;
private Integer status;
private Integer show;
private String icon;
private String permissionKey;
private Integer isDeleted;
}

View File

@@ -0,0 +1,38 @@
package com.schisandra.auth.application.dto;
import lombok.Data;
import java.io.Serializable;
/**
* ClassName:SchisandraAuthRoleDTO
* Package:com.schisandra.auth.application.dto
* Description:角色DTO
*
* @Author:fanyang
* @Create:2024/4/4 - 21:34
* @Version: v1.0
*/
@Data
public class SchisandraAuthRoleDTO implements Serializable {
/**
* id
*/
private Long id;
/**
* 角色名称
*/
private String roleName;
/**
* 角色关键字
*/
private String roleKey;
/**
* 是否删除
*/
private Integer isDeleted;
}

View File

@@ -0,0 +1,76 @@
package com.schisandra.auth.application.dto;
import lombok.Data;
import java.io.Serializable;
/**
* (SchisandraAuthUserDTO)实体类
*
* @author labdaiqing
* @since 2024-03-21 20:15:43
*/
@Data
public class SchisandraAuthUserDTO implements Serializable {
/**
* id主键
*/
private Long id;
/**
* 用户名
*/
private String userName;
/**
* 昵称
*/
private String nickName;
/**
* 邮箱
*/
private String email;
/**
* 手机号
*/
private String phone;
/**
* 密码
*/
private String password;
/**
* 性别
*/
private Integer sex;
/**
* 头像
*/
private String avatar;
/**
* 状态
*/
private Integer status;
/**
* 介绍
*/
private String introduce;
/**
* 额外字段
*/
private String extJson;
/**
* 是否删除
*/
private Integer isDeleted;
}

View File

@@ -0,0 +1,24 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.schisandra</groupId>
<artifactId>schisandra-cloud-storage-auth</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>schisandra-cloud-storage-auth-application-job</artifactId>
<name>schisandra-cloud-storage-auth-application-job</name>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
</dependencies>
</project>

View File

@@ -0,0 +1,24 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.schisandra</groupId>
<artifactId>schisandra-cloud-storage-auth</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>schisandra-cloud-storage-auth-application-mq</artifactId>
<name>schisandra-cloud-storage-auth-application-mq</name>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
</dependencies>
</project>

View File

@@ -0,0 +1,104 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.schisandra</groupId>
<artifactId>schisandra-cloud-storage-auth</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>schisandra-cloud-storage-auth-common</artifactId>
<name>schisandra-cloud-storage-auth-common</name>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.12.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.7</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.4.2.Final</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.4.2.Final</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.79</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
</dependency>
<!-- Sa-Token 权限认证在线文档https://sa-token.cc -->
<dependency>
<groupId>cn.dev33</groupId>
<artifactId>sa-token-spring-boot-starter</artifactId>
<version>1.37.0</version>
</dependency>
<!-- Sa-Token 整合 Redis (使用 jackson 序列化方式) -->
<dependency>
<groupId>cn.dev33</groupId>
<artifactId>sa-token-redis-jackson</artifactId>
<version>1.37.0</version>
</dependency>
<!-- 提供Redis连接池 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>org.dromara.sms4j</groupId>
<artifactId>sms4j-spring-boot-starter</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>org.dromara.sms4j</groupId>
<artifactId>sms4j-Email-core</artifactId>
<version>3.2.1</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,29 @@
package com.schisandra.auth.common.entity;
/**
* 分页请求实体
*
* @author: landaiqing
*/
public class PageInfo {
private Integer pageNo = 1;
private Integer pageSize = 20;
public Integer getPageNo() {
if (pageNo == null || pageNo < 1) {
return 1;
}
return pageNo;
}
public Integer getPageSize() {
if (pageSize == null || pageSize < 1 || pageSize > Integer.MAX_VALUE) {
return 20;
}
return pageSize;
}
}

View File

@@ -0,0 +1,57 @@
package com.schisandra.auth.common.entity;
import lombok.Data;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
/**
* 分页返回实体
*
* @author: landaiqing
*/
@Data
public class PageResult<T> implements Serializable {
private Integer pageNo = 1;
private Integer pageSize = 20;
private Integer total = 0;
private Integer totalPages = 0;
private List<T> result = Collections.emptyList();
private Integer start = 1;
private Integer end = 0;
public void setRecords(List<T> result) {
this.result = result;
if (result != null && result.size() > 0) {
setTotal(result.size());
}
}
public void setTotal(Integer total) {
this.total = total;
if (this.pageSize > 0) {
this.totalPages = (total / this.pageSize) + (total % this.pageSize == 0 ? 0 : 1);
} else {
this.totalPages = 0;
}
this.start = (this.pageSize > 0 ? (this.pageNo - 1) * this.pageSize : 0) + 1;
this.end = (this.start - 1 + this.pageSize * (this.pageNo > 0 ? 1 : 0));
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public void setPageNo(Integer pageNo) {
this.pageNo = pageNo;
}
}

View File

@@ -0,0 +1,56 @@
package com.schisandra.auth.common.entity;
import com.schisandra.auth.common.enums.ResultCodeEnum;
import lombok.Data;
/**
* @description: 返回结果泛型类
* @author: landaiqing
* @date: 2024/3/22 13:09
*/
@Data
public class Result<T> {
private Boolean success;
private Integer code;
private String message;
private T data;
public static Result ok() {
Result result = new Result();
result.setSuccess(true);
result.setCode(ResultCodeEnum.SUCCESS.getCode());
result.setMessage(ResultCodeEnum.SUCCESS.getDesc());
return result;
}
public static <T> Result ok(T data) {
Result result = new Result();
result.setSuccess(true);
result.setCode(ResultCodeEnum.SUCCESS.getCode());
result.setMessage(ResultCodeEnum.SUCCESS.getDesc());
result.setData(data);
return result;
}
public static Result fail() {
Result result = new Result();
result.setSuccess(false);
result.setCode(ResultCodeEnum.FAIL.getCode());
result.setMessage(ResultCodeEnum.FAIL.getDesc());
return result;
}
public static <T> Result fail(T data) {
Result result = new Result();
result.setSuccess(false);
result.setCode(ResultCodeEnum.FAIL.getCode());
result.setMessage(ResultCodeEnum.FAIL.getDesc());
result.setData(data);
return result;
}
}

View File

@@ -0,0 +1,34 @@
package com.schisandra.auth.common.enums;
import lombok.Getter;
/**
* 用户状态枚举
*
* @author: landaiqing
*/
@Getter
public enum AuthUserStatusEnum {
OPEN(0,"启用"),
CLOSE(1,"禁用");
public int code;
public String desc;
AuthUserStatusEnum(int code, String desc){
this.code = code;
this.desc = desc;
}
public static AuthUserStatusEnum getByCode(int codeVal){
for(AuthUserStatusEnum resultCodeEnum : AuthUserStatusEnum.values()){
if(resultCodeEnum.code == codeVal){
return resultCodeEnum;
}
}
return null;
}
}

View File

@@ -0,0 +1,34 @@
package com.schisandra.auth.common.enums;
import lombok.Getter;
/**
* 删除状态枚举
*
* @author: landaiqing
*/
@Getter
public enum IsDeletedFlagEnum {
DELETED(1,"已删除"),
UN_DELETED(0,"未删除");
public int code;
public String desc;
IsDeletedFlagEnum(int code, String desc){
this.code = code;
this.desc = desc;
}
public static IsDeletedFlagEnum getByCode(int codeVal){
for(IsDeletedFlagEnum resultCodeEnum : IsDeletedFlagEnum.values()){
if(resultCodeEnum.code == codeVal){
return resultCodeEnum;
}
}
return null;
}
}

View File

@@ -0,0 +1,34 @@
package com.schisandra.auth.common.enums;
import lombok.Getter;
/**
* @description: 返回结果状态枚举
* @author: landaiqing
* @date: 2024/3/22 13:10
*/
@Getter
public enum ResultCodeEnum {
SUCCESS(200, "成功"),
FAIL(500, "失败");
public int code;
public String desc;
ResultCodeEnum(int code, String desc) {
this.code = code;
this.desc = desc;
}
public static ResultCodeEnum getByCode(int codeVal) {
for (ResultCodeEnum resultCodeEnum : ResultCodeEnum.values()) {
if (resultCodeEnum.code == codeVal) {
return resultCodeEnum;
}
}
return null;
}
}

View File

@@ -0,0 +1,64 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.schisandra</groupId>
<artifactId>schisandra-cloud-storage-auth</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>schisandra-cloud-storage-auth-domain</artifactId>
<name>schisandra-cloud-storage-auth-domain</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<annotationProcessorPaths>
<!-- 必须要加, 否则生成不了 MapperImpl 实现类 -->
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.4.2.Final</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
</path>
<!-- 如果是 0.1.0 有可能出现生成了maptruct的实现类, 但该类只创建了对象, 没有进行赋值 -->
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.schisandra</groupId>
<artifactId>schisandra-cloud-storage-auth-infra</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.schisandra</groupId>
<artifactId>schisandra-cloud-storage-auth-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,42 @@
package com.schisandra.auth.domain.bo;
import lombok.Data;
import java.util.Date;
import java.io.Serializable;
/**
* (SchisandraAuthPermission)实体类
*
* @author makejava
* @since 2024-04-15 19:04:11
*/
@Data
public class SchisandraAuthPermissionBO implements Serializable {
private Long id;
private String name;
private Long parentId;
private Integer type;
private String menuUrl;
private Integer status;
private Integer show;
private String icon;
private String permissionKey;
private Integer isDeleted;
}

View File

@@ -0,0 +1,41 @@
package com.schisandra.auth.domain.bo;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* ClassName:SchisandraAuthRoleBO
* Package:com.schisandra.auth.domain.bo
* Description:(SchisandraAuthRoleBO)实体类
*
* @Author:fanyang
* @Create:2024/4/1 - 0:20
* @Version: v1.0
*/
@Data
public class SchisandraAuthRoleBO implements Serializable {
/**
* id
*/
private Long id;
/**
* 角色名称
*/
private String roleName;
/**
* 角色关键字
*/
private String roleKey;
/**
* 是否删除
*/
private Integer isDeleted;
}

View File

@@ -0,0 +1,77 @@
package com.schisandra.auth.domain.bo;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* (SchisandraAuthUserBO)实体类
*
* @author labdaiqing
* @since 2024-03-21 20:15:43
*/
@Data
public class SchisandraAuthUserBO implements Serializable {
/**
* id主键
*/
private Long id;
/**
* 用户名
*/
private String userName;
/**
* 昵称
*/
private String nickName;
/**
* 邮箱
*/
private String email;
/**
* 手机号
*/
private String phone;
/**
* 密码
*/
private String password;
/**
* 性别
*/
private Integer sex;
/**
* 头像
*/
private String avatar;
/**
* 状态
*/
private Integer status;
/**
* 介绍
*/
private String introduce;
/**
* 额外字段
*/
private String extJson;
/**
* 是否删除
*/
private Integer isDeleted;
}

View File

@@ -0,0 +1,28 @@
package com.schisandra.auth.domain.convert;
import com.schisandra.auth.domain.bo.SchisandraAuthPermissionBO;
import com.schisandra.auth.domain.bo.SchisandraAuthRoleBO;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthPermission;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthRole;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper(componentModel = "spring")
public interface SchisandraAuthPermissionBOConverter {
SchisandraAuthPermissionBOConverter INSTANCE = Mappers.getMapper(SchisandraAuthPermissionBOConverter.class);
/**
* @description: BO 转 实体
* @param: [schisandraAuthPermissionBO]
* @return: com.schisandra.auth.infra.basic.entity.SchisandraAuthPermission
* @author zhang
* @date: 2024/4/17 16:59
*/
SchisandraAuthPermission convertBOToEntity(SchisandraAuthPermissionBO schisandraAuthPermissionBO);
/**
* @description: 实体 转 BO
* @param: [schisandraAuthPermission]
* @return: com.schisandra.auth.domain.bo.SchisandraAuthPermissionBO
* @author zhang
* @date: 2024/4/17 17:00
*/
SchisandraAuthPermissionBO convertEntityToBO(SchisandraAuthPermission schisandraAuthPermission);
}

View File

@@ -0,0 +1,40 @@
package com.schisandra.auth.domain.convert;
import com.schisandra.auth.domain.bo.SchisandraAuthRoleBO;
import com.schisandra.auth.domain.bo.SchisandraAuthUserBO;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthRole;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUser;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* ClassName:SchisandraAuthRoleBOConverter
* Package:com.schisandra.auth.domain.convert
* Description:角色Bo对象和entity对象的转换
*
* @Author:fanyang
* @Create:2024/4/4 - 21:14
* @Version: v1.0
*/
@Mapper(componentModel = "spring")
public interface SchisandraAuthRoleBOConverter {
SchisandraAuthRoleBOConverter INSTANCE = Mappers.getMapper(SchisandraAuthRoleBOConverter.class);
/**
* @description 将bo转换为实体
* @param schisandraAuthRoleBO
* @return com.schisandra.auth.infra.basic.entity.SchisandraRoleUser
* @author landaiqing
* @date 2024/3/21 23:13
*/
SchisandraAuthRole convertBOToEntity(SchisandraAuthRoleBO schisandraAuthRoleBO);
/**
* @description 将实体转换为bo
* @param schisandraAuthRole
* @return com.schisandra.auth.domain.bo.SchisandraAuthRoleBO
* @author landaiqing
* @date 2024/3/21 23:13
*/
SchisandraAuthRoleBO convertEntityToBO(SchisandraAuthRole schisandraAuthRole);
}

View File

@@ -0,0 +1,37 @@
package com.schisandra.auth.domain.convert;
import com.schisandra.auth.domain.bo.SchisandraAuthUserBO;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUser;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* 用户bo转换器
*
* @author landaiqing
* @date 2024/3/21
*/
@Mapper(componentModel = "spring")
public interface SchisandraAuthUserBOConverter {
SchisandraAuthUserBOConverter INSTANCE = Mappers.getMapper(SchisandraAuthUserBOConverter.class);
/**
* @description 将bo转换为实体
* @param schisandraAuthUserBO
* @return com.schisandra.auth.infra.basic.entity.SchisandraAuthUser
* @author landaiqing
* @date 2024/3/21 23:13
*/
SchisandraAuthUser convertBOToEntity(SchisandraAuthUserBO schisandraAuthUserBO);
/**
* @description 将实体转换为bo
* @param schisandraAuthUser
* @return com.schisandra.auth.domain.bo.SchisandraAuthUserBO
* @author landaiqing
* @date 2024/3/21 23:13
*/
SchisandraAuthUserBO convertEntityToBO(SchisandraAuthUser schisandraAuthUser);
}

View File

@@ -0,0 +1,12 @@
package com.schisandra.auth.domain.service;
import com.schisandra.auth.domain.bo.SchisandraAuthPermissionBO;
public interface SchisandraAuthPermissionDomainService {
Object update(SchisandraAuthPermissionBO schisandraAuthPermissionBO);
Object delete(SchisandraAuthPermissionBO schisandraAuthPermissionBO);
Object insert(SchisandraAuthPermissionBO schisandraAuthPermissionBO);
Object select(SchisandraAuthPermissionBO schisandraAuthPermissionBO);
}

View File

@@ -0,0 +1,51 @@
package com.schisandra.auth.domain.service;
import com.schisandra.auth.domain.bo.SchisandraAuthRoleBO;
import org.springframework.stereotype.Service;
/**
* ClassName:SchisandraAuthRoleDomainService
* Package:com.schisandra.auth.domain.service
* Description:角色领域Service
*
* @Author:fanyang
* @Create:2024/4/4 - 20:56
* @Version: v1.0
*/
public interface SchisandraAuthRoleDomainService {
/***
*@ClassName: SchisandraAuthRoleDomainService
*@Description 更新角色信息
*@Author Fanyang
*@Date 2024/4/4
*@Time 21:02
*/
Object update(SchisandraAuthRoleBO schisandraAuthRoleBO);
/***
*@ClassName: SchisandraAuthRoleDomainService
*@Description 删除角色信息
*@Author Fanyang
*@Date 2024/4/4
*@Time 21:03
*/
Object delete(Long id);
/***
*@ClassName: SchisandraAuthRoleDomainService
*@Description 新增角色信息
*@Author Fanyang
*@Date 2024/4/4
*@Time 21:03
*/
Object insert(SchisandraAuthRoleBO schisandraAuthRoleBO);
/***
*@ClassName: SchisandraAuthRoleDomainService
*@Description 查询角色信息
*@Author Fanyang
*@Date 2024/4/4
*@Time 21:04
*/
Object select(SchisandraAuthRoleBO schisandraAuthRoleBO);
}

View File

@@ -0,0 +1,46 @@
package com.schisandra.auth.domain.service;
import com.schisandra.auth.domain.bo.SchisandraAuthUserBO;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUser;
/**
* 用户领域service
*
* @author landaiqing
* @date 2024/3/21
*/
public interface SchisandraAuthUserDomainService {
/**
* @description 更新用户信息
* @param schisandraAuthUserBO
* @return java.lang.Object
* @author landaiqing
* @date 2024/3/21 23:14
*/
Object update(SchisandraAuthUserBO schisandraAuthUserBO);
/**
* @description 查询用户信息
* @param schisandraAuthUserBO
* @author msz
* @return com.schisandra.auth.infra.basic.entity.SchisandraAuthUser
*/
SchisandraAuthUser queryById(SchisandraAuthUserBO schisandraAuthUserBO);
/**
* @description 添加用户信息
* @param schisandraAuthUserBO
* @author msz
* @return java.lang.object
*/
Object insert(SchisandraAuthUserBO schisandraAuthUserBO);
/**
* @description 删除用户(物理)
* @param id
* @author msz
* @return java.lang.object
*/
Object deleteById(Long id);
}

View File

@@ -0,0 +1,69 @@
package com.schisandra.auth.domain.service.impl;
import com.schisandra.auth.domain.bo.SchisandraAuthPermissionBO;
import com.schisandra.auth.domain.convert.SchisandraAuthPermissionBOConverter;
import com.schisandra.auth.domain.service.SchisandraAuthPermissionDomainService;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthPermission;
import com.schisandra.auth.infra.basic.service.SchisandraAuthPermissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class SchisandraAuthPermissionDomainServiceImpl implements SchisandraAuthPermissionDomainService {
SchisandraAuthPermissionService schisandraAuthPermissionService;
/**
* @description: 更新
* @param: [schisandraAuthPermissionBO]
* @return: java.lang.Object
* @author zhang
* @date: 2024/4/17 17:06
*/
@Override
public Object update(SchisandraAuthPermissionBO schisandraAuthPermissionBO) {
SchisandraAuthPermission schisandraAuthPermission = SchisandraAuthPermissionBOConverter.INSTANCE.convertBOToEntity(schisandraAuthPermissionBO);
SchisandraAuthPermission schisandraAuthPermission1 =schisandraAuthPermissionService.update(schisandraAuthPermission);
return schisandraAuthPermission1;
}
/**
* @description: 删除
* @param: [schisandraAuthPermissionBO]
* @return: java.lang.Object
* @author zhang
* @date: 2024/4/17 17:06
*/
@Override
public Object delete(SchisandraAuthPermissionBO schisandraAuthPermissionBO) {
SchisandraAuthPermission schisandraAuthPermission = SchisandraAuthPermissionBOConverter.INSTANCE.convertBOToEntity(schisandraAuthPermissionBO);
boolean schisandraAuthPermission1 =schisandraAuthPermissionService.deleteById(schisandraAuthPermission.getId());
return schisandraAuthPermission1;
}
/**
* @description: 插入
* @param: [schisandraAuthPermissionBO]
* @return: java.lang.Object
* @author zhang
* @date: 2024/4/17 17:06
*/
@Override
public Object insert(SchisandraAuthPermissionBO schisandraAuthPermissionBO) {
SchisandraAuthPermission schisandraAuthPermission = SchisandraAuthPermissionBOConverter.INSTANCE.convertBOToEntity(schisandraAuthPermissionBO);
SchisandraAuthPermission schisandraAuthPermission1 =schisandraAuthPermissionService.insert(schisandraAuthPermission);
return schisandraAuthPermission1;
}
/**
* @description: 查询
* @param: [schisandraAuthPermissionBO]
* @return: java.lang.Object
* @author zhang
* @date: 2024/4/17 17:07
*/
@Override
public Object select(SchisandraAuthPermissionBO schisandraAuthPermissionBO) {
SchisandraAuthPermission schisandraAuthPermission = SchisandraAuthPermissionBOConverter.INSTANCE.convertBOToEntity(schisandraAuthPermissionBO);
SchisandraAuthPermission schisandraAuthPermission1 =schisandraAuthPermissionService.queryById(schisandraAuthPermission.getId());
return schisandraAuthPermission1;
}
}

View File

@@ -0,0 +1,56 @@
package com.schisandra.auth.domain.service.impl;
import com.schisandra.auth.domain.bo.SchisandraAuthRoleBO;
import com.schisandra.auth.domain.convert.SchisandraAuthRoleBOConverter;
import com.schisandra.auth.domain.service.SchisandraAuthRoleDomainService;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthRole;
import com.schisandra.auth.infra.basic.service.SchisandraAuthRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* ClassName:SchisandraAuthRoleDomainServiceImpl
* Package:com.schisandra.auth.domain.service.impl
* Description:角色信息的增删改查
*
* @Author:
* @Create:2024/4/4 - 21:05
* @Version: v1.0
*/
@Service
@Slf4j
public class SchisandraAuthRoleDomainServiceImpl implements SchisandraAuthRoleDomainService {
@Resource
private SchisandraAuthRoleService schisandraAuthRoleService;
@Override
public Object update(SchisandraAuthRoleBO schisandraAuthRoleBO) {
SchisandraAuthRole schisandraAuthRole =SchisandraAuthRoleBOConverter.INSTANCE.convertBOToEntity(schisandraAuthRoleBO);
SchisandraAuthRole schisandraAuthRole1=schisandraAuthRoleService.update(schisandraAuthRole);
return schisandraAuthRole1;
}
@Override
public Object delete(Long id) {
boolean isDeleted=schisandraAuthRoleService.deleteById(id);
return isDeleted;
}
@Override
public Object insert(SchisandraAuthRoleBO schisandraAuthRoleBO) {
SchisandraAuthRole schisandraAuthRole =SchisandraAuthRoleBOConverter.INSTANCE.convertBOToEntity(schisandraAuthRoleBO);
SchisandraAuthRole schisandraAuthRole1=schisandraAuthRoleService.insert(schisandraAuthRole);
return schisandraAuthRole1;
}
@Override
public Object select(SchisandraAuthRoleBO schisandraAuthRoleBO) {
SchisandraAuthRole schisandraAuthRole =SchisandraAuthRoleBOConverter.INSTANCE.convertBOToEntity(schisandraAuthRoleBO);
if(schisandraAuthRoleBO.getId()!=null){
SchisandraAuthRole schisandraAuthRole1=schisandraAuthRoleService.queryById(schisandraAuthRoleBO.getId());
return schisandraAuthRole1;
}
return null;
}
}

View File

@@ -0,0 +1,70 @@
package com.schisandra.auth.domain.service.impl;
import com.schisandra.auth.domain.bo.SchisandraAuthUserBO;
import com.schisandra.auth.domain.convert.SchisandraAuthUserBOConverter;
import com.schisandra.auth.domain.service.SchisandraAuthUserDomainService;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUser;
import com.schisandra.auth.infra.basic.service.SchisandraAuthUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
@Slf4j
public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDomainService {
@Resource
private SchisandraAuthUserService schisandraAuthUserService;
/**
* @description 更新用户信息
* @param schisandraAuthUserBO
* @return java.lang.Object
* @author landaiqing
* @date 2024/3/21 23:14
*/
@Override
public Object update(SchisandraAuthUserBO schisandraAuthUserBO) {
SchisandraAuthUser schisandraAuthUser = SchisandraAuthUserBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserBO);
Integer count = schisandraAuthUserService.update(schisandraAuthUser);
return count > 0;
}
/**
* @description 查询用户信息
* @param schisandraAuthUserBO
* @return
* @author msz
* @date 2024/4/3 22:10
*/
@Override
public SchisandraAuthUser queryById(SchisandraAuthUserBO schisandraAuthUserBO) {
SchisandraAuthUser schisandraAuthUser = schisandraAuthUserService.queryById(schisandraAuthUserBO.getId());
return schisandraAuthUser;
}
/**
* @description 添加用户信息
* @param schisandraAuthUserBO
* @return java.lang.Object
* @author msz
* @date 2024/4/3 22:17
*/
@Override
public Object insert(SchisandraAuthUserBO schisandraAuthUserBO) {
SchisandraAuthUser schisandraAuthUser = SchisandraAuthUserBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserBO);
SchisandraAuthUser user = schisandraAuthUserService.insert(schisandraAuthUser);
return user!=null;
}
/**
* @description 添加用户信息
* @param id
* @return java.lang.Object
* @author msz
* @date 2024/4/3 22:30
*/
@Override
public Object deleteById(Long id) {
boolean flag = schisandraAuthUserService.deleteById(id);
return flag;
}
}

View File

@@ -0,0 +1,51 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.schisandra</groupId>
<artifactId>schisandra-cloud-storage-auth</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>schisandra-cloud-storage-auth-infra</artifactId>
<name>schisandra-cloud-storage-auth-infra</name>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<!--jdbcStarter-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>2.4.2</version>
</dependency>
<!--druid连接池-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.21</version>
</dependency>
<!--mysql-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.33</version>
</dependency>
<!--mybatis plus-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>com.schisandra</groupId>
<artifactId>schisandra-cloud-storage-auth-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,84 @@
package com.schisandra.auth.infra.basic.dao;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthPermission;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;
import java.util.List;
/**
* (SchisandraAuthPermission)表数据库访问层
*
* @author makejava
* @since 2024-04-11 13:00:10
*/
public interface SchisandraAuthPermissionDao {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
SchisandraAuthPermission queryById(Long id);
/**
* 查询指定行数据
*
* @param schisandraAuthPermission 查询条件
* @param pageable 分页对象
* @return 对象列表
*/
List<SchisandraAuthPermission> queryAllByLimit(SchisandraAuthPermission schisandraAuthPermission, @Param("pageable") Pageable pageable);
/**
* 统计总行数
*
* @param schisandraAuthPermission 查询条件
* @return 总行数
*/
long count(SchisandraAuthPermission schisandraAuthPermission);
/**
* 新增数据
*
* @param schisandraAuthPermission 实例对象
* @return 影响行数
*/
int insert(SchisandraAuthPermission schisandraAuthPermission);
/**
* 批量新增数据MyBatis原生foreach方法
*
* @param entities List<SchisandraAuthPermission> 实例对象列表
* @return 影响行数
*/
int insertBatch(@Param("entities") List<SchisandraAuthPermission> entities);
/**
* 批量新增或按主键更新数据MyBatis原生foreach方法
*
* @param entities List<SchisandraAuthPermission> 实例对象列表
* @return 影响行数
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常请自行校验入参
*/
int insertOrUpdateBatch(@Param("entities") List<SchisandraAuthPermission> entities);
/**
* 修改数据
*
* @param schisandraAuthPermission 实例对象
* @return 影响行数
*/
int update(SchisandraAuthPermission schisandraAuthPermission);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 影响行数
*/
int deleteById(Long id);
}

View File

@@ -0,0 +1,84 @@
package com.schisandra.auth.infra.basic.dao;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthRole;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;
import java.util.List;
/**
* (SchisandraAuthRole)表数据库访问层
*
* @author makejava
* @since 2024-03-22 21:35:31
*/
public interface SchisandraAuthRoleDao {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
SchisandraAuthRole queryById(Long id);
/**
* 查询指定行数据
*
* @param schisandraAuthRole 查询条件
* @param pageable 分页对象
* @return 对象列表
*/
List<SchisandraAuthRole> queryAllByLimit(SchisandraAuthRole schisandraAuthRole, @Param("pageable") Pageable pageable);
/**
* 统计总行数
*
* @param schisandraAuthRole 查询条件
* @return 总行数
*/
long count(SchisandraAuthRole schisandraAuthRole);
/**
* 新增数据
*
* @param schisandraAuthRole 实例对象
* @return 影响行数
*/
int insert(SchisandraAuthRole schisandraAuthRole);
/**
* 批量新增数据MyBatis原生foreach方法
*
* @param entities List<SchisandraAuthRole> 实例对象列表
* @return 影响行数
*/
int insertBatch(@Param("entities") List<SchisandraAuthRole> entities);
/**
* 批量新增或按主键更新数据MyBatis原生foreach方法
*
* @param entities List<SchisandraAuthRole> 实例对象列表
* @return 影响行数
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常请自行校验入参
*/
int insertOrUpdateBatch(@Param("entities") List<SchisandraAuthRole> entities);
/**
* 修改数据
*
* @param schisandraAuthRole 实例对象
* @return 影响行数
*/
int update(SchisandraAuthRole schisandraAuthRole);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 影响行数
*/
int deleteById(Long id);
}

View File

@@ -0,0 +1,83 @@
package com.schisandra.auth.infra.basic.dao;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUser;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;
import java.util.List;
/**
* (SchisandraAuthUser)表数据库访问层
*
* @author landaiqing
* @since 2024-03-21 20:15:43
*/
public interface SchisandraAuthUserDao {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
SchisandraAuthUser queryById(Long id);
/**
* 查询指定行数据
*
* @param schisandraAuthUser 查询条件
* @param pageable 分页对象
* @return 对象列表
*/
List<SchisandraAuthUser> queryAllByLimit(SchisandraAuthUser schisandraAuthUser, @Param("pageable") Pageable pageable);
/**
* 统计总行数
*
* @param schisandraAuthUser 查询条件
* @return 总行数
*/
long count(SchisandraAuthUser schisandraAuthUser);
/**
* 新增数据
*
* @return 影响行数
*/
int insert(SchisandraAuthUser schisandraAuthUser);
/**
* 批量新增数据MyBatis原生foreach方法
*
* @param entities List<SchisandraAuthUser> 实例对象列表
* @return 影响行数
*/
int insertBatch(@Param("entities") List<SchisandraAuthUser> entities);
/**
* 批量新增或按主键更新数据MyBatis原生foreach方法
*
* @param entities List<SchisandraAuthUser> 实例对象列表
* @return 影响行数
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常请自行校验入参
*/
int insertOrUpdateBatch(@Param("entities") List<SchisandraAuthUser> entities);
/**
* 修改数据
*
* @param schisandraAuthUser 实例对象
* @return 影响行数
*/
int update(SchisandraAuthUser schisandraAuthUser);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 影响行数
*/
int deleteById(Long id);
}

View File

@@ -0,0 +1,56 @@
package com.schisandra.auth.infra.basic.entity;
import lombok.Data;
import java.util.Date;
import java.io.Serializable;
/**
* (SchisandraAuthPermission)实体类
*
* @author makejava
* @since 2024-04-11 13:00:10
*/
@Data
public class SchisandraAuthPermission implements Serializable {
private Long id;
private String name;
private Long parentId;
private Integer type;
private String menuUrl;
private Integer status;
private Integer show;
private String icon;
private String permissionKey;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updateBy;
/**
* 更新时间
*/
private Date updateTime;
private Integer isDeleted;
}

View File

@@ -0,0 +1,59 @@
package com.schisandra.auth.infra.basic.entity;
import lombok.Data;
import java.util.Date;
import java.io.Serializable;
/**
* (SchisandraAuthRole)实体类
*
* @author makejava
* @since 2024-03-22 21:35:31
*/
@Data
public class SchisandraAuthRole implements Serializable {
/**
* id
*/
private Long id;
/**
* 角色名称
*/
private String roleName;
/**
* 角色关键字
*/
private String roleKey;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updateBy;
/**
* 更新时间
*/
private Date updateTime;
/**
* 是否删除
*/
private Integer isDeleted;
}

View File

@@ -0,0 +1,97 @@
package com.schisandra.auth.infra.basic.entity;
import lombok.Data;
import java.util.Date;
import java.io.Serializable;
/**
* (SchisandraAuthUser)实体类
*
* @author labdaiqing
* @since 2024-03-21 20:15:43
*/
@Data
public class SchisandraAuthUser implements Serializable {
/**
* id主键
*/
private Long id;
/**
* 用户名
*/
private String userName;
/**
* 昵称
*/
private String nickName;
/**
* 邮箱
*/
private String email;
/**
* 手机号
*/
private String phone;
/**
* 密码
*/
private String password;
/**
* 性别
*/
private Integer sex;
/**
* 头像
*/
private String avatar;
/**
* 状态
*/
private Integer status;
/**
* 介绍
*/
private String introduce;
/**
* 额外字段
*/
private String extJson;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updateBy;
/**
* 更新时间
*/
private Date updateTime;
/**
* 是否删除
*/
private Integer isDeleted;
}

View File

@@ -0,0 +1,56 @@
package com.schisandra.auth.infra.basic.service;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthPermission;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
/**
* (SchisandraAuthPermission)表服务接口
*
* @author makejava
* @since 2024-04-11 13:00:10
*/
public interface SchisandraAuthPermissionService {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
SchisandraAuthPermission queryById(Long id);
/**
* 分页查询
*
* @param schisandraAuthPermission 筛选条件
* @param pageRequest 分页对象
* @return 查询结果
*/
Page<SchisandraAuthPermission> queryByPage(SchisandraAuthPermission schisandraAuthPermission, PageRequest pageRequest);
/**
* 新增数据
*
* @param schisandraAuthPermission 实例对象
* @return 实例对象
*/
SchisandraAuthPermission insert(SchisandraAuthPermission schisandraAuthPermission);
/**
* 修改数据
*
* @param schisandraAuthPermission 实例对象
* @return 实例对象
*/
SchisandraAuthPermission update(SchisandraAuthPermission schisandraAuthPermission);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
boolean deleteById(Long id);
}

View File

@@ -0,0 +1,56 @@
package com.schisandra.auth.infra.basic.service;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthRole;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
/**
* (SchisandraAuthRole)表服务接口
*
* @author makejava
* @since 2024-03-22 21:35:31
*/
public interface SchisandraAuthRoleService {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
SchisandraAuthRole queryById(Long id);
/**
* 分页查询
*
* @param schisandraAuthRole 筛选条件
* @param pageRequest 分页对象
* @return 查询结果
*/
Page<SchisandraAuthRole> queryByPage(SchisandraAuthRole schisandraAuthRole, PageRequest pageRequest);
/**
* 新增数据
*
* @param schisandraAuthRole 实例对象
* @return 实例对象
*/
SchisandraAuthRole insert(SchisandraAuthRole schisandraAuthRole);
/**
* 修改数据
*
* @param schisandraAuthRole 实例对象
* @return 实例对象
*/
SchisandraAuthRole update(SchisandraAuthRole schisandraAuthRole);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
boolean deleteById(Long id);
}

View File

@@ -0,0 +1,56 @@
package com.schisandra.auth.infra.basic.service;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUser;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
/**
* (SchisandraAuthUser)表服务接口
*
* @author landaiqing
* @since 2024-03-21 20:15:44
*/
public interface SchisandraAuthUserService {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
SchisandraAuthUser queryById(Long id);
/**
* 分页查询
*
* @param schisandraAuthUser 筛选条件
* @param pageRequest 分页对象
* @return 查询结果
*/
Page<SchisandraAuthUser> queryByPage(SchisandraAuthUser schisandraAuthUser, PageRequest pageRequest);
/**
* 新增数据
*
* @param schisandraAuthUser 实例对象
* @return 实例对象
*/
SchisandraAuthUser insert(SchisandraAuthUser schisandraAuthUser);
/**
* 修改数据
*
* @param schisandraAuthUser 实例对象
* @return 实例对象
*/
Integer update(SchisandraAuthUser schisandraAuthUser);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
boolean deleteById(Long id);
}

View File

@@ -0,0 +1,82 @@
package com.schisandra.auth.infra.basic.service.impl;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthPermission;
import com.schisandra.auth.infra.basic.dao.SchisandraAuthPermissionDao;
import com.schisandra.auth.infra.basic.service.SchisandraAuthPermissionService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import javax.annotation.Resource;
/**
* (SchisandraAuthPermission)表服务实现类
*
* @author makejava
* @since 2024-04-11 13:00:10
*/
@Service("schisandraAuthPermissionService")
public class SchisandraAuthPermissionServiceImpl implements SchisandraAuthPermissionService {
@Resource
private SchisandraAuthPermissionDao schisandraAuthPermissionDao;
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
@Override
public SchisandraAuthPermission queryById(Long id) {
return this.schisandraAuthPermissionDao.queryById(id);
}
/**
* 分页查询
*
* @param schisandraAuthPermission 筛选条件
* @param pageRequest 分页对象
* @return 查询结果
*/
@Override
public Page<SchisandraAuthPermission> queryByPage(SchisandraAuthPermission schisandraAuthPermission, PageRequest pageRequest) {
long total = this.schisandraAuthPermissionDao.count(schisandraAuthPermission);
return new PageImpl<>(this.schisandraAuthPermissionDao.queryAllByLimit(schisandraAuthPermission, pageRequest), pageRequest, total);
}
/**
* 新增数据
*
* @param schisandraAuthPermission 实例对象
* @return 实例对象
*/
@Override
public SchisandraAuthPermission insert(SchisandraAuthPermission schisandraAuthPermission) {
this.schisandraAuthPermissionDao.insert(schisandraAuthPermission);
return schisandraAuthPermission;
}
/**
* 修改数据
*
* @param schisandraAuthPermission 实例对象
* @return 实例对象
*/
@Override
public SchisandraAuthPermission update(SchisandraAuthPermission schisandraAuthPermission) {
this.schisandraAuthPermissionDao.update(schisandraAuthPermission);
return this.queryById(schisandraAuthPermission.getId());
}
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
@Override
public boolean deleteById(Long id) {
return this.schisandraAuthPermissionDao.deleteById(id) > 0;
}
}

View File

@@ -0,0 +1,84 @@
package com.schisandra.auth.infra.basic.service.impl;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthRole;
import com.schisandra.auth.infra.basic.dao.SchisandraAuthRoleDao;
import com.schisandra.auth.infra.basic.service.SchisandraAuthRoleService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import javax.annotation.Resource;
/**
* (SchisandraAuthRole)表服务实现类
*
* @author makejava
* @since 2024-03-22 21:35:31
*/
@Service("schisandraAuthRoleService")
public class SchisandraAuthRoleServiceImpl implements SchisandraAuthRoleService {
@Resource
private SchisandraAuthRoleDao schisandraAuthRoleDao;
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
@Override
public SchisandraAuthRole queryById(Long id) {
return this.schisandraAuthRoleDao.queryById(id);
}
/**
* 分页查询
*
* @param schisandraAuthRole 筛选条件
* @param pageRequest 分页对象
* @return 查询结果
*/
@Override
public Page<SchisandraAuthRole> queryByPage(SchisandraAuthRole schisandraAuthRole, PageRequest pageRequest) {
long total = this.schisandraAuthRoleDao.count(schisandraAuthRole);
return new PageImpl<>(this.schisandraAuthRoleDao.queryAllByLimit(schisandraAuthRole, pageRequest), pageRequest, total);
}
/**
* 新增数据
*
* @param schisandraAuthRole 实例对象
* @return 实例对象
*/
@Override
public SchisandraAuthRole insert(SchisandraAuthRole schisandraAuthRole) {
this.schisandraAuthRoleDao.insert(schisandraAuthRole);
return schisandraAuthRole;
}
/**
* 修改数据
*
* @param schisandraAuthRole 实例对象
* @return 实例对象
*/
@Override
public SchisandraAuthRole update(SchisandraAuthRole schisandraAuthRole) {
this.schisandraAuthRoleDao.update(schisandraAuthRole);
return this.queryById(schisandraAuthRole.getId());
}
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
@Override
public boolean deleteById(Long id) {
return this.schisandraAuthRoleDao.deleteById(id) > 0;
}
}

View File

@@ -0,0 +1,82 @@
package com.schisandra.auth.infra.basic.service.impl;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUser;
import com.schisandra.auth.infra.basic.dao.SchisandraAuthUserDao;
import com.schisandra.auth.infra.basic.service.SchisandraAuthUserService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import javax.annotation.Resource;
/**
* (SchisandraAuthUser)表服务实现类
*
* @author landaiqing
* @since 2024-03-21 20:15:44
*/
@Service("schisandraAuthUserService")
public class SchisandraAuthUserServiceImpl implements SchisandraAuthUserService {
@Resource
private SchisandraAuthUserDao schisandraAuthUserDao;
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
@Override
public SchisandraAuthUser queryById(Long id) {
return this.schisandraAuthUserDao.queryById(id);
}
/**
* 分页查询
*
* @param schisandraAuthUser 筛选条件
* @param pageRequest 分页对象
* @return 查询结果
*/
@Override
public Page<SchisandraAuthUser> queryByPage(SchisandraAuthUser schisandraAuthUser, PageRequest pageRequest) {
long total = this.schisandraAuthUserDao.count(schisandraAuthUser);
return new PageImpl<>(this.schisandraAuthUserDao.queryAllByLimit(schisandraAuthUser, pageRequest), pageRequest, total);
}
/**
* 新增数据
*
* @param schisandraAuthUser 实例对象
* @return 实例对象
*/
@Override
public SchisandraAuthUser insert(SchisandraAuthUser schisandraAuthUser) {
this.schisandraAuthUserDao.insert(schisandraAuthUser);
return schisandraAuthUser;
}
/**
* 修改数据
*
* @param schisandraAuthUser 实例对象
* @return 实例对象
*/
@Override
public Integer update(SchisandraAuthUser schisandraAuthUser) {
return this.schisandraAuthUserDao.update(schisandraAuthUser);
}
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
@Override
public boolean deleteById(Long id) {
return this.schisandraAuthUserDao.deleteById(id) > 0;
}
}

View File

@@ -0,0 +1,51 @@
package com.schisandra.auth.infra.basic.utils;
import com.alibaba.druid.filter.config.ConfigTools;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
/**
* 数据库加密util
*
* @author: landaiqing
* @date: 2024/3/21
*/
public class DruidEncryptUtil {
private static String publicKey;
private static String privateKey;
static {
try {
String[] keyPair = ConfigTools.genKeyPair(512);
privateKey = keyPair[0];
System.out.println("privateKey:" + privateKey);
publicKey = keyPair[1];
System.out.println("publicKey:" + publicKey);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchProviderException e) {
e.printStackTrace();
}
}
public static String encrypt(String plainText) throws Exception {
String encrypt = ConfigTools.encrypt(privateKey, plainText);
System.out.println("encrypt:" + encrypt);
return encrypt;
}
public static String decrypt(String encryptText) throws Exception {
String decrypt = ConfigTools.decrypt(publicKey, encryptText);
System.out.println("decrypt:" + decrypt);
return decrypt;
}
public static void main(String[] args) throws Exception {
String encrypt = encrypt("$LDQ20020618xxx$");
System.out.println("encrypt:" + encrypt);
}
}

View File

@@ -0,0 +1,17 @@
package com.schisandra.auth.infra.config;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class MybatisConfiguration {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor(){
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
mybatisPlusInterceptor.addInnerInterceptor(new MybatisPlusAllSqlLog());
return mybatisPlusInterceptor;
}
}

View File

@@ -0,0 +1,116 @@
package com.schisandra.auth.infra.config;
import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.ParameterMapping;
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.type.TypeHandlerRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.CollectionUtils;
import java.sql.SQLException;
import java.text.DateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.regex.Matcher;
public class MybatisPlusAllSqlLog implements InnerInterceptor {
public static final Logger log = LoggerFactory.getLogger("sys-sql");
@Override
public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) throws SQLException {
logInfo(boundSql, ms, parameter);
}
@Override
public void beforeUpdate(Executor executor, MappedStatement ms, Object parameter) throws SQLException {
BoundSql boundSql = ms.getBoundSql(parameter);
logInfo(boundSql, ms, parameter);
}
private static void logInfo(BoundSql boundSql, MappedStatement ms, Object parameter) {
try {
log.info("parameter = " + parameter);
// 获取到节点的id,即sql语句的id
String sqlId = ms.getId();
log.info("sqlId = " + sqlId);
// 获取节点的配置
Configuration configuration = ms.getConfiguration();
// 获取到最终的sql语句
String sql = getSql(configuration, boundSql, sqlId);
log.info("完整的sql:{}", sql);
} catch (Exception e) {
log.error("异常:{}", e.getLocalizedMessage(), e);
}
}
// 封装了一下sql语句使得结果返回完整xml路径下的sql语句节点id + sql语句
public static String getSql(Configuration configuration, BoundSql boundSql, String sqlId) {
return sqlId + ":" + showSql(configuration, boundSql);
}
// 进行?的替换
public static String showSql(Configuration configuration, BoundSql boundSql) {
// 获取参数
Object parameterObject = boundSql.getParameterObject();
List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
// sql语句中多个空格都用一个空格代替
String sql = boundSql.getSql().replaceAll("[\\s]+", " ");
if (!CollectionUtils.isEmpty(parameterMappings) && parameterObject != null) {
// 获取类型处理器注册器类型处理器的功能是进行java类型和数据库类型的转换
TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry();
// 如果根据parameterObject.getClass()可以找到对应的类型,则替换
if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) {
sql = sql.replaceFirst("\\?",
Matcher.quoteReplacement(getParameterValue(parameterObject)));
} else {
// MetaObject主要是封装了originalObject对象提供了get和set的方法用于获取和设置originalObject的属性值,主要支持对JavaBean、Collection、Map三种类型对象的操作
MetaObject metaObject = configuration.newMetaObject(parameterObject);
for (ParameterMapping parameterMapping : parameterMappings) {
String propertyName = parameterMapping.getProperty();
if (metaObject.hasGetter(propertyName)) {
Object obj = metaObject.getValue(propertyName);
sql = sql.replaceFirst("\\?",
Matcher.quoteReplacement(getParameterValue(obj)));
} else if (boundSql.hasAdditionalParameter(propertyName)) {
// 该分支是动态sql
Object obj = boundSql.getAdditionalParameter(propertyName);
sql = sql.replaceFirst("\\?",
Matcher.quoteReplacement(getParameterValue(obj)));
} else {
// 打印出缺失,提醒该参数缺失并防止错位
sql = sql.replaceFirst("\\?", "缺失");
}
}
}
}
return sql;
}
// 如果参数是String则添加单引号 如果是日期,则转换为时间格式器并加单引号; 对参数是null和不是null的情况作了处理
private static String getParameterValue(Object obj) {
String value;
if (obj instanceof String) {
value = "'" + obj.toString() + "'";
} else if (obj instanceof Date) {
DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.DEFAULT,
DateFormat.DEFAULT, Locale.CHINA);
value = "'" + formatter.format(new Date()) + "'";
} else {
if (obj != null) {
value = obj.toString();
} else {
value = "";
}
}
return value;
}
}

View File

@@ -0,0 +1,52 @@
package com.schisandra.auth.infra.config;
import org.apache.ibatis.cache.CacheKey;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.plugin.*;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Properties;
@Intercepts({
@Signature(type = Executor.class, method = "update", args = {MappedStatement.class,
Object.class}),
@Signature(type = Executor.class, method = "query", args = {MappedStatement.class,
Object.class, RowBounds.class, ResultHandler.class, CacheKey.class, BoundSql.class})})
public class SqlStatementInterceptor implements Interceptor {
public static final Logger log = LoggerFactory.getLogger("sys-sql");
@Override
public Object intercept(Invocation invocation) throws Throwable {
long startTime = System.currentTimeMillis();
try {
return invocation.proceed();
} finally {
long timeConsuming = System.currentTimeMillis() - startTime;
log.info("执行SQL:{}ms", timeConsuming);
if (timeConsuming > 999 && timeConsuming < 5000) {
log.info("执行SQL大于1s:{}ms", timeConsuming);
} else if (timeConsuming >= 5000 && timeConsuming < 10000) {
log.info("执行SQL大于5s:{}ms", timeConsuming);
} else if (timeConsuming >= 10000) {
log.info("执行SQL大于10s:{}ms", timeConsuming);
}
}
}
@Override
public Object plugin(Object target) {
return Plugin.wrap(target, this);
}
@Override
public void setProperties(Properties properties) {
}
}

View File

@@ -0,0 +1,215 @@
<?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="com.schisandra.auth.infra.basic.dao.SchisandraAuthPermissionDao">
<resultMap type="com.schisandra.auth.infra.basic.entity.SchisandraAuthPermission" id="SchisandraAuthPermissionMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="parentId" column="parent_id" jdbcType="INTEGER"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="menuUrl" column="menu_url" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="INTEGER"/>
<result property="show" column="show" jdbcType="INTEGER"/>
<result property="icon" column="icon" jdbcType="VARCHAR"/>
<result property="permissionKey" column="permission_key" jdbcType="VARCHAR"/>
<result property="createdBy" column="created_by" jdbcType="VARCHAR"/>
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="isDeleted" column="is_deleted" jdbcType="INTEGER"/>
</resultMap>
<!--查询单个-->
<select id="queryById" resultMap="SchisandraAuthPermissionMap">
select id,name,parent_id,type,menu_url,status,`show`,icon,permission_key,created_by,created_time,update_by,update_time,is_deleted
from schisandra_auth_permission
where id = #{id}
</select>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="SchisandraAuthPermissionMap">
select
id,name,parent_id,type,menu_url,status,`show`,icon,permission_key,created_by,created_time,update_by,update_time,is_deleted
from schisandra_auth_permission
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="name != null and name != ''">
and name = #{name}
</if>
<if test="parentId != null">
and parent_id = #{parentId}
</if>
<if test="type != null">
and type = #{type}
</if>
<if test="menuUrl != null and menuUrl != ''">
and menu_url = #{menuUrl}
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="show != null">
and show = #{show}
</if>
<if test="icon != null and icon != ''">
and icon = #{icon}
</if>
<if test="permissionKey != null and permissionKey != ''">
and permission_key = #{permissionKey}
</if>
<if test="createdBy != null and createdBy != ''">
and created_by = #{createdBy}
</if>
<if test="createdTime != null">
and created_time = #{createdTime}
</if>
<if test="updateBy != null and updateBy != ''">
and update_by = #{updateBy}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="isDeleted != null">
and is_deleted = #{isDeleted}
</if>
</where>
limit #{pageable.offset}, #{pageable.pageSize}
</select>
<!--统计总行数-->
<select id="count" resultType="java.lang.Long">
select count(1)
from schisandra_auth_permission
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="name != null and name != ''">
and name = #{name}
</if>
<if test="parentId != null">
and parent_id = #{parentId}
</if>
<if test="type != null">
and type = #{type}
</if>
<if test="menuUrl != null and menuUrl != ''">
and menu_url = #{menuUrl}
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="show != null">
and show = #{show}
</if>
<if test="icon != null and icon != ''">
and icon = #{icon}
</if>
<if test="permissionKey != null and permissionKey != ''">
and permission_key = #{permissionKey}
</if>
<if test="createdBy != null and createdBy != ''">
and created_by = #{createdBy}
</if>
<if test="createdTime != null">
and created_time = #{createdTime}
</if>
<if test="updateBy != null and updateBy != ''">
and update_by = #{updateBy}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="isDeleted != null">
and is_deleted = #{isDeleted}
</if>
</where>
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into schisandra_auth_permission(name,parent_id,`type`,menu_url,status,`show`,icon,permission_key,created_by,created_time,update_by,update_time,is_deleted)
values (#{name},#{parentId},#{type},#{menuUrl},#{status},#{show},#{icon},#{permissionKey},#{createdBy},#{createdTime},#{updateBy},#{updateTime},#{isDeleted})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into
schisandra_auth_permission(name,parent_id,type,menu_url,status,`show`,icon,permission_key,created_by,created_time,update_by,update_time,is_deleted)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.name},#{entity.parentId},#{entity.type},#{entity.menuUrl},#{entity.status},#{entity.show},#{entity.icon},#{entity.permissionKey},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
</foreach>
</insert>
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into
schisandra_auth_permission(name,parent_id,type,menu_url,status,`show`,icon,permission_key,created_by,created_time,update_by,update_time,is_deleted)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.name},#{entity.parentId},#{entity.type},#{entity.menuUrl},#{entity.status},#{entity.show},#{entity.icon},#{entity.permissionKey},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
</foreach>
on duplicate key update
name = values(name)parent_id = values(parent_id)type = values(type)menu_url = values(menu_url)status =
values(status)show = values(show)icon = values(icon)permission_key = values(permission_key)created_by =
values(created_by)created_time = values(created_time)update_by = values(update_by)update_time =
values(update_time)is_deleted = values(is_deleted)
</insert>
<!--通过主键修改数据-->
<update id="update">
update schisandra_auth_permission
<set>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="parentId != null">
parent_id = #{parentId},
</if>
<if test="type != null">
type = #{type},
</if>
<if test="menuUrl != null and menuUrl != ''">
menu_url = #{menuUrl},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="show != null">
show = #{show},
</if>
<if test="icon != null and icon != ''">
icon = #{icon},
</if>
<if test="permissionKey != null and permissionKey != ''">
permission_key = #{permissionKey},
</if>
<if test="createdBy != null and createdBy != ''">
created_by = #{createdBy},
</if>
<if test="createdTime != null">
created_time = #{createdTime},
</if>
<if test="updateBy != null and updateBy != ''">
update_by = #{updateBy},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="isDeleted != null">
is_deleted = #{isDeleted},
</if>
</set>
where id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete
from schisandra_auth_permission
where id = #{id}
</delete>
</mapper>

View File

@@ -0,0 +1,152 @@
<?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="com.schisandra.auth.infra.basic.dao.SchisandraAuthRoleDao">
<resultMap type="com.schisandra.auth.infra.basic.entity.SchisandraAuthRole" id="SchisandraAuthRoleMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="roleName" column="role_name" jdbcType="VARCHAR"/>
<result property="roleKey" column="role_key" jdbcType="VARCHAR"/>
<result property="createdBy" column="created_by" jdbcType="VARCHAR"/>
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="isDeleted" column="is_deleted" jdbcType="INTEGER"/>
</resultMap>
<!--查询单个-->
<select id="queryById" resultMap="SchisandraAuthRoleMap">
select id,role_name,role_key,created_by,created_time,update_by,update_time,is_deleted
from schisandra_auth_role
where id = #{id}
</select>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="SchisandraAuthRoleMap">
select
id,role_name,role_key,created_by,created_time,update_by,update_time,is_deleted
from schisandra_auth_role
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="roleName != null and roleName != ''">
and role_name = #{roleName}
</if>
<if test="roleKey != null and roleKey != ''">
and role_key = #{roleKey}
</if>
<if test="createdBy != null and createdBy != ''">
and created_by = #{createdBy}
</if>
<if test="createdTime != null">
and created_time = #{createdTime}
</if>
<if test="updateBy != null and updateBy != ''">
and update_by = #{updateBy}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="isDeleted != null">
and is_deleted = #{isDeleted}
</if>
</where>
limit #{pageable.offset}, #{pageable.pageSize}
</select>
<!--统计总行数-->
<select id="count" resultType="java.lang.Long">
select count(1)
from schisandra_auth_role
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="roleName != null and roleName != ''">
and role_name = #{roleName}
</if>
<if test="roleKey != null and roleKey != ''">
and role_key = #{roleKey}
</if>
<if test="createdBy != null and createdBy != ''">
and created_by = #{createdBy}
</if>
<if test="createdTime != null">
and created_time = #{createdTime}
</if>
<if test="updateBy != null and updateBy != ''">
and update_by = #{updateBy}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="isDeleted != null">
and is_deleted = #{isDeleted}
</if>
</where>
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into schisandra_auth_role(role_name,role_key,created_by,created_time,update_by,update_time,is_deleted)
values (#{roleName},#{roleKey},#{createdBy},#{createdTime},#{updateBy},#{updateTime},#{isDeleted})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into schisandra_auth_role(role_name,role_key,created_by,created_time,update_by,update_time,is_deleted)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.roleName},#{entity.roleKey},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
</foreach>
</insert>
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into schisandra_auth_role(role_name,role_key,created_by,created_time,update_by,update_time,is_deleted)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.roleName},#{entity.roleKey},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
</foreach>
on duplicate key update
role_name = values(role_name)role_key = values(role_key)created_by = values(created_by)created_time =
values(created_time)update_by = values(update_by)update_time = values(update_time)is_deleted =
values(is_deleted)
</insert>
<!--通过主键修改数据-->
<update id="update">
update schisandra_auth_role
<set>
<if test="roleName != null and roleName != ''">
role_name = #{roleName},
</if>
<if test="roleKey != null and roleKey != ''">
role_key = #{roleKey},
</if>
<if test="createdBy != null and createdBy != ''">
created_by = #{createdBy},
</if>
<if test="createdTime != null">
created_time = #{createdTime},
</if>
<if test="updateBy != null and updateBy != ''">
update_by = #{updateBy},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="isDeleted != null">
is_deleted = #{isDeleted},
</if>
</set>
where id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete
from schisandra_auth_role
where id = #{id}
</delete>
</mapper>

View File

@@ -0,0 +1,236 @@
<?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="com.schisandra.auth.infra.basic.dao.SchisandraAuthUserDao">
<resultMap type="com.schisandra.auth.infra.basic.entity.SchisandraAuthUser" id="SchisandraAuthUserMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="userName" column="user_name" jdbcType="VARCHAR"/>
<result property="nickName" column="nick_name" jdbcType="VARCHAR"/>
<result property="email" column="email" jdbcType="VARCHAR"/>
<result property="phone" column="phone" jdbcType="VARCHAR"/>
<result property="password" column="password" jdbcType="VARCHAR"/>
<result property="sex" column="sex" jdbcType="INTEGER"/>
<result property="avatar" column="avatar" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="INTEGER"/>
<result property="introduce" column="introduce" jdbcType="VARCHAR"/>
<result property="extJson" column="ext_json" jdbcType="VARCHAR"/>
<result property="createdBy" column="created_by" jdbcType="VARCHAR"/>
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="isDeleted" column="is_deleted" jdbcType="INTEGER"/>
</resultMap>
<!--查询单个-->
<select id="queryById" resultMap="SchisandraAuthUserMap">
select id,user_name,nick_name,email,phone,password,sex,avatar,status,introduce,ext_json,created_by,created_time,update_by,update_time,is_deleted
from schisandra_auth_user
where id = #{id}
</select>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="SchisandraAuthUserMap">
select
id,user_name,nick_name,email,phone,password,sex,avatar,status,introduce,ext_json,created_by,created_time,update_by,update_time,is_deleted
from schisandra_auth_user
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="userName != null and userName != ''">
and user_name = #{userName}
</if>
<if test="nickName != null and nickName != ''">
and nick_name = #{nickName}
</if>
<if test="email != null and email != ''">
and email = #{email}
</if>
<if test="phone != null and phone != ''">
and phone = #{phone}
</if>
<if test="password != null and password != ''">
and password = #{password}
</if>
<if test="sex != null">
and sex = #{sex}
</if>
<if test="avatar != null and avatar != ''">
and avatar = #{avatar}
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="introduce != null and introduce != ''">
and introduce = #{introduce}
</if>
<if test="extJson != null and extJson != ''">
and ext_json = #{extJson}
</if>
<if test="createdBy != null and createdBy != ''">
and created_by = #{createdBy}
</if>
<if test="createdTime != null">
and created_time = #{createdTime}
</if>
<if test="updateBy != null and updateBy != ''">
and update_by = #{updateBy}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="isDeleted != null">
and is_deleted = #{isDeleted}
</if>
</where>
limit #{pageable.offset}, #{pageable.pageSize}
</select>
<!--统计总行数-->
<select id="count" resultType="java.lang.Long">
select count(1)
from schisandra_auth_user
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="userName != null and userName != ''">
and user_name = #{userName}
</if>
<if test="nickName != null and nickName != ''">
and nick_name = #{nickName}
</if>
<if test="email != null and email != ''">
and email = #{email}
</if>
<if test="phone != null and phone != ''">
and phone = #{phone}
</if>
<if test="password != null and password != ''">
and password = #{password}
</if>
<if test="sex != null">
and sex = #{sex}
</if>
<if test="avatar != null and avatar != ''">
and avatar = #{avatar}
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="introduce != null and introduce != ''">
and introduce = #{introduce}
</if>
<if test="extJson != null and extJson != ''">
and ext_json = #{extJson}
</if>
<if test="createdBy != null and createdBy != ''">
and created_by = #{createdBy}
</if>
<if test="createdTime != null">
and created_time = #{createdTime}
</if>
<if test="updateBy != null and updateBy != ''">
and update_by = #{updateBy}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="isDeleted != null">
and is_deleted = #{isDeleted}
</if>
</where>
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into schisandra_auth_user(user_name,nick_name,email,phone,password,sex,avatar,status,introduce,ext_json,created_by,created_time,update_by,update_time,is_deleted)
values (#{userName},#{nickName},#{email},#{phone},#{password},#{sex},#{avatar},#{status},#{introduce},#{extJson},#{createdBy},#{createdTime},#{updateBy},#{updateTime},#{isDeleted})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into
schisandra_auth_user(user_name,nick_name,email,phone,password,sex,avatar,status,introduce,ext_json,created_by,created_time,update_by,update_time,is_deleted)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.userName},#{entity.nickName},#{entity.email},#{entity.phone},#{entity.password},#{entity.sex},#{entity.avatar},#{entity.status},#{entity.introduce},#{entity.extJson},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
</foreach>
</insert>
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into
schisandra_auth_user(user_name,nick_name,email,phone,password,sex,avatar,status,introduce,ext_json,created_by,created_time,update_by,update_time,is_deleted)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.userName},#{entity.nickName},#{entity.email},#{entity.phone},#{entity.password},#{entity.sex},#{entity.avatar},#{entity.status},#{entity.introduce},#{entity.extJson},#{entity.createdBy},#{entity.createdTime},#{entity.updateBy},#{entity.updateTime},#{entity.isDeleted})
</foreach>
on duplicate key update
user_name = values(user_name)nick_name = values(nick_name)email = values(email)phone = values(phone)password =
values(password)sex = values(sex)avatar = values(avatar)status = values(status)introduce =
values(introduce)ext_json = values(ext_json)created_by = values(created_by)created_time =
values(created_time)update_by = values(update_by)update_time = values(update_time)is_deleted =
values(is_deleted)
</insert>
<!--通过主键修改数据-->
<update id="update">
update schisandra_auth_user
<set>
<if test="userName != null and userName != ''">
user_name = #{userName},
</if>
<if test="nickName != null and nickName != ''">
nick_name = #{nickName},
</if>
<if test="email != null and email != ''">
email = #{email},
</if>
<if test="phone != null and phone != ''">
phone = #{phone},
</if>
<if test="password != null and password != ''">
password = #{password},
</if>
<if test="sex != null">
sex = #{sex},
</if>
<if test="avatar != null and avatar != ''">
avatar = #{avatar},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="introduce != null and introduce != ''">
introduce = #{introduce},
</if>
<if test="extJson != null and extJson != ''">
ext_json = #{extJson},
</if>
<if test="createdBy != null and createdBy != ''">
created_by = #{createdBy},
</if>
<if test="createdTime != null">
created_time = #{createdTime},
</if>
<if test="updateBy != null and updateBy != ''">
update_by = #{updateBy},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="isDeleted != null">
is_deleted = #{isDeleted},
</if>
</set>
where id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete
from schisandra_auth_user
where id = #{id}
</delete>
</mapper>

View File

@@ -0,0 +1,106 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.schisandra</groupId>
<artifactId>schisandra-cloud-storage-auth</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>schisandra-cloud-storage-auth-starter</artifactId>
<name>schisandra-cloud-storage-auth-starter</name>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.4.2</spring-boot.version>
<spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>
<spring-cloud.version>2020.0.6</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.4.2</version>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-logging</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency>
<groupId>com.schisandra</groupId>
<artifactId>schisandra-cloud-storage-auth-application-controller</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.schisandra</groupId>
<artifactId>schisandra-cloud-storage-auth-infra</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>${spring-cloud-alibaba.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<finalName>${project.artifactId}</finalName>
<!--打包成jar包时的名字-->
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.0.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>
<!-- 打包的时候忽略lombok因为lombok值在编译器起作用 -->
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,21 @@
package com.schisandra.auth;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
/**
* 鉴权微服务启动类
*
* @author: landaiqing
* @date: 2024/3/21
*/
@SpringBootApplication
@ComponentScan("com.schisandra")
@MapperScan("com.schisandra.**.dao")
public class AuthApplication {
public static void main(String[] args) {
SpringApplication.run(AuthApplication.class);
}
}

View File

@@ -0,0 +1,106 @@
server:
port: 3000
spring:
datasource:
username: landaiqing
password: Z1JyO9hVmDLYbpWnM7oiFO3BEoDCrV6njYjl/2oudBHwTepxLxnaZ1aDfohrYwYpGWUodgu7gnRcZ5mfIm6lIg==
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://116.196.80.239:3306/schisandra-cloud-storage?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=true
type: com.alibaba.druid.pool.DruidDataSource
druid:
initial-size: 20
min-idle: 20
max-active: 100
max-wait: 60000
connectionProperties: config.decrypt=true;config.decrypt.key=${publicKey};
stat-view-servlet:
enabled: true
url-pattern: /druid/*
login-username: admin
login-password: 123456
filter:
stat:
enabled: true
slow-sql-millis: 2000
log-slow-sql: true
wall:
enabled: true
config:
enabled: true
# redis配置
redis:
# Redis数据库索引默认为0
database: 1
# Redis服务器地址
host: 116.196.80.239
# Redis服务器连接端口
port: 6379
# Redis服务器连接密码默认为空
password: LDQ20020618xxx
# 连接超时时间
timeout: 2s
lettuce:
pool:
# 连接池最大连接数
max-active: 200
# 连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
# 连接池中的最大空闲连接
max-idle: 10
# 连接池中的最小空闲连接
min-idle: 0
publicKey: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKXX1HPAKowh8Ub9fDTGI5exGLMRppbVQFDlDBBxAWcbfdLN5hXgfg02D7wy+jCe9uCdV5vgZR72PFoe+mnLp80CAwEAAQ==
logging:
config: classpath:log4j2-spring.xml
############## Sa-Token 配置 (文档: https://sa-token.cc) ##############
sa-token:
# token 名称(同时也是 cookie 名称)
token-name: token
# token 有效期(单位:秒) 默认30天-1 代表永久有效
timeout: 2592000
# token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
active-timeout: -1
# 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
is-concurrent: true
# 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token
is-share: true
# token 风格默认可取值uuid、simple-uuid、random-32、random-64、random-128、tik
token-style: random-32
# 是否输出操作日志
is-log: true
token-prefix: schisandra
#sms:
# # 标注从yml读取配置
# config-type: yaml
# blends:
# # 自定义的标识也就是configId这里可以是任意值最好不要是中文
# tx1:
# #厂商标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
# supplier: tencent
# #您的accessKey
# access-key-id: 您的accessKey
# #您的accessKeySecret
# access-key-secret: 您的accessKeySecret
# #您的短信签名
# signature: 您的短信签名
# #模板ID 非必须配置如果使用sendMessage的快速发送需此配置
# template-id: xxxxxxxx
# #您的sdkAppId
# sdk-app-id: 您的sdkAppId
# # 自定义的标识也就是configId这里可以是任意值最好不要是中文
# tx2:
# #厂商标识,标定此配置是哪个厂商,详细请看厂商标识介绍部分
# supplier: tencent
# #您的accessKey
# access-key-id: 您的accessKey
# #您的accessKeySecret
# access-key-secret: 您的accessKeySecret
# #您的短信签名
# signature: 您的短信签名
# #模板ID 非必须配置如果使用sendMessage的快速发送需此配置
# template-id: xxxxxxxx
# #您的sdkAppId
# sdk-app-id: 您的sdkAppId

View File

@@ -0,0 +1,18 @@
${AnsiColor.GREEN}
,---,
,--.' | ,--, ,---,
| | : ,--.'| ,---, ,---.'| __ ,-.
.--.--. : : : | |, .--.--. ,-+-. / | | | :,' ,'/ /|
/ / ' ,---. : | |,--.`--'_ / / ' ,--.--. ,--.'|' | | | |' | |' | ,--.--.
| : /`./ / \ | : ' |,' ,'| | : /`./ / \ | | ,"' | ,--.__| || | ,'/ \
| : ;_ / / ' | | /' :' | | | : ;_ .--. .-. | | | / | | / ,' |' : / .--. .-. |
\ \ `. . ' / ' : | | || | : \ \ `. \__\/: . . | | | | |. ' / || | ' \__\/: . .
`----. \' ; :__ | | ' | :' : |__ `----. \ ," .--.; | | | | |/ ' ; |: |; : | ," .--.; |
/ /`--' /' | '.'|| : :_:,'| | '.'| / /`--' // / ,. | | | |--' | | '/ '| , ; / / ,. |
'--'. / | : :| | ,' ; : ;'--'. /; : .' \| |/ | : :| ---' ; : .' \
`--'---' \ \ / `--'' | , / `--'---' | , .-./'---' \ \ / | , .-./
`----' ---`-' `--`---' `----' `--`---'
Spring Boot: ${spring-boot.formatted-version}
五味子云存储

View File

@@ -0,0 +1,17 @@
spring:
application:
name: schisandra-cloud-storage-auth-dev
profiles:
active: dev
cloud:
nacos:
config:
server-addr: 116.196.80.239:8848
prefix: ${spring.application.name}
group: DEFAULT_GROUP
namespace:
file-extension: yaml
discovery:
enabled: true
server-addr: 116.196.80.239:8848

View File

@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Configuration后面的status这个用于设置log4j2自身内部的信息输出可以不设置当设置成trace时你会看到log4j2内部各种详细输出-->
<!--monitorIntervalLog4j能够自动检测修改配置 文件和重新配置本身,设置间隔秒数-->
<configuration status="INFO" monitorInterval="5">
<!--日志级别以及优先级排序: OFF > FATAL > ERROR > WARN > INFO > DEBUG > TRACE > ALL -->
<!--变量配置-->
<Properties>
<!-- 格式化输出:%date表示日期%thread表示线程名%-5level级别从左显示5个字符宽度 %msg日志消息%n是换行符-->
<!-- %logger{36} 表示 Logger 名字最长36个字符 -->
<property name="LOG_PATTERN" value="%date{HH:mm:ss.SSS} %X{PFTID} [%thread] %-5level %logger{36} - %msg%n" />
<!-- 定义日志存储的路径 -->
<property name="FILE_PATH" value="../log" />
<property name="FILE_NAME" value="schisandra-cloud-album.log" />
</Properties>
<!--https://logging.apache.org/log4j/2.x/manual/appenders.html-->
<appenders>
<console name="Console" target="SYSTEM_OUT">
<!--输出日志的格式-->
<PatternLayout pattern="${LOG_PATTERN}"/>
<!--控制台只输出level及其以上级别的信息onMatch其他的直接拒绝onMismatch-->
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
</console>
<!--文件会打印出所有信息这个log每次运行程序会自动清空由append属性决定适合临时测试用-->
<File name="fileLog" fileName="${FILE_PATH}/temp.log" append="false">
<PatternLayout pattern="${LOG_PATTERN}"/>
</File>
<!-- 这个会打印出所有的info及以下级别的信息每次大小超过size则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
<RollingFile name="RollingFileInfo" fileName="${FILE_PATH}/info.log" filePattern="${FILE_PATH}/${FILE_NAME}-INFO-%d{yyyy-MM-dd}_%i.log.gz">
<!--控制台只输出level及以上级别的信息onMatch其他的直接拒绝onMismatch-->
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout pattern="${LOG_PATTERN}"/>
<Policies>
<!--interval属性用来指定多久滚动一次默认是1 hour-->
<TimeBasedTriggeringPolicy interval="1"/>
<SizeBasedTriggeringPolicy size="10MB"/>
</Policies>
<!-- DefaultRolloverStrategy属性如不设置则默认为最多同一文件夹下7个文件开始覆盖-->
<DefaultRolloverStrategy max="15"/>
</RollingFile>
<!-- 这个会打印出所有的warn及以下级别的信息每次大小超过size则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
<RollingFile name="RollingFileWarn" fileName="${FILE_PATH}/warn.log" filePattern="${FILE_PATH}/${FILE_NAME}-WARN-%d{yyyy-MM-dd}_%i.log.gz">
<!--控制台只输出level及以上级别的信息onMatch其他的直接拒绝onMismatch-->
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout pattern="${LOG_PATTERN}"/>
<Policies>
<!--interval属性用来指定多久滚动一次默认是1 hour-->
<TimeBasedTriggeringPolicy interval="1"/>
<SizeBasedTriggeringPolicy size="10MB"/>
</Policies>
<!-- DefaultRolloverStrategy属性如不设置则默认为最多同一文件夹下7个文件开始覆盖-->
<DefaultRolloverStrategy max="15"/>
</RollingFile>
<!-- 这个会打印出所有的error及以下级别的信息每次大小超过size则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
<RollingFile name="RollingFileError" fileName="${FILE_PATH}/error.log" filePattern="${FILE_PATH}/${FILE_NAME}-ERROR-%d{yyyy-MM-dd}_%i.log.gz">
<!--控制台只输出level及以上级别的信息onMatch其他的直接拒绝onMismatch-->
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout pattern="${LOG_PATTERN}"/>
<Policies>
<!--interval属性用来指定多久滚动一次默认是1 hour-->
<TimeBasedTriggeringPolicy interval="1"/>
<SizeBasedTriggeringPolicy size="10MB"/>
</Policies>
<!-- DefaultRolloverStrategy属性如不设置则默认为最多同一文件夹下7个文件开始覆盖-->
<DefaultRolloverStrategy max="15"/>
</RollingFile>
</appenders>
<!--Logger节点用来单独指定日志的形式比如要为指定包下的class指定不同的日志级别等。-->
<!--然后定义loggers只有定义了logger并引入的appenderappender才会生效-->
<loggers>
<root level="info">
<appender-ref ref="Console"/>
<appender-ref ref="RollingFileInfo"/>
<appender-ref ref="RollingFileWarn"/>
<appender-ref ref="RollingFileError"/>
<appender-ref ref="fileLog"/>
</root>
</loggers>
</configuration>

View File

@@ -0,0 +1,18 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.schisandra</groupId>
<artifactId>schisandra-cloud-storage-gateway</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>schisandra-cloud-storage-gateway</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
</dependencies>
</project>

View File

@@ -0,0 +1,120 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.schisandra</groupId>
<artifactId>schisandra-cloud-storage-oss</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>schisandra-cloud-storage-oss</name>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.4.2</spring-boot.version>
<spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>
<spring-cloud.version>2020.0.6</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-logging</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>8.2.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.28</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>${spring-cloud-alibaba.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<finalName>${project.artifactId}</finalName>
<!--打包成jar包时的名字-->
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.0.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>central</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>

View File

@@ -0,0 +1,6 @@
server:
port: 4000
minio:
url: http://116.196.80.239:9000/
accessKey: landaiqing
secretKey: LDQ20020618xxx

View File

@@ -0,0 +1,17 @@
spring:
application:
name: schisandra-cloud-storage-oss-dev
profiles:
active: dev
cloud:
nacos:
config:
server-addr: 116.196.80.239:8848
prefix: ${spring.application.name}
group: DEFAULT_GROUP
namespace:
file-extension: yaml
discovery:
enabled: true
server-addr: 116.196.80.239:8848

View File

@@ -0,0 +1,121 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.schisandra</groupId>
<artifactId>schisandra-cloud-storage-wechat</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>schisandra-cloud-storage-wechat</name>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.4.2</spring-boot.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-logging</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.28</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.18</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.12.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.7</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.9.0</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<id>central</id>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<build>
<finalName>${project.artifactId}</finalName>
<!--打包成jar包时的名字-->
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.0.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,19 @@
package com.schisandra.wechat;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
/**
* 微信微服务启动类
*
* @author: landaiqing
* @date: 2024/4/9
*/
@SpringBootApplication
@ComponentScan("com.schisandra")
public class WeChatApplication {
public static void main(String[] args) {
SpringApplication.run(WeChatApplication.class);
}
}

View File

@@ -0,0 +1,87 @@
package com.schisandra.wechat.controller;
import com.schisandra.wechat.handler.WeChatMsgFactory;
import com.schisandra.wechat.handler.WeChatMsgHandler;
import com.schisandra.wechat.utils.MessageUtil;
import com.schisandra.wechat.utils.SHA1;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Map;
import java.util.Objects;
/**
* @Classname CallBackController
* @BelongsProject: qing-yu-club
* @BelongsPackage: com.schisandra.wechat.controller
* @Author: schisandra
* @CreateTime: 2024-02-21 16:41
* @Description: TODO
* @Version: 1.0
*/
@RestController
@Slf4j
public class CallBackController {
@Resource
private WeChatMsgFactory weChatMsgFactory;
private static final String token = "LDQ20020618xxx";
@RequestMapping("/test")
public String test() {
return "HELLO WORLD";
}
/**
* @description: 回调消息校验
* @param: [signature, timestamp, nonce, echostr]
* @return: java.lang.String
* @author schisandra
* @date: 2024/2/21 17:16
*/
@GetMapping("/callback")
public String callback(@RequestParam("signature") String signature,
@RequestParam("timestamp") String timestamp,
@RequestParam("nonce") String nonce,
@RequestParam("echostr") String echostr) {
log.info("get验签请求参数:signature: {}timestamp: {} nonce: {}echostr: {}",
signature, timestamp, nonce, echostr);
String shaStr = SHA1.getSHA1(token, timestamp, nonce, "");
if (signature.equals(shaStr)) {
return echostr;
}
return "unKnown";
}
@PostMapping(value = "callback", produces = "application/xml;charset=UTF-8")
public String callback(
@RequestBody String requestBody,
@RequestParam("signature") String signature,
@RequestParam("timestamp") String timestamp,
@RequestParam("nonce") String nonce,
@RequestParam(value = "msg_signature", required = false) String msgSignature) {
log.info("接收到微信消息requestBody{}", requestBody);
Map<String, String> messageMap = MessageUtil.parseXml(requestBody);
String msgType = messageMap.get("MsgType");
String event = messageMap.get("Event") == null ? "" : messageMap.get("Event");
log.info("msgType:{},event:{}", msgType, event);
StringBuilder sb = new StringBuilder();
sb.append(msgType);
if (!StringUtils.isEmpty(event)) {
sb.append(".");
sb.append(event);
}
String msgTypeKey = sb.toString();
WeChatMsgHandler weChatMsgHandler = weChatMsgFactory.getHandlerByMsgType(msgTypeKey);
if (Objects.isNull(weChatMsgHandler)) {
return "unknown";
}
String replyContent = weChatMsgHandler.dealMsg(messageMap);
log.info("replyContent:{}", replyContent);
return replyContent;
}
}

View File

@@ -0,0 +1,54 @@
package com.schisandra.wechat.handler;
import com.schisandra.wechat.redis.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.TimeUnit;
@Component
@Slf4j
public class ReceiveTextMsgHandler implements WeChatMsgHandler {
private static final String KEY_WORD = "验证码";
private static final String LOGIN_PREFIX = "loginCode";
@Resource
private RedisUtil redisUtil;
@Override
public WeChatMsgTypeEnum getMsgType() {
return WeChatMsgTypeEnum.TEXT_MSG;
}
@Override
public String dealMsg(Map<String, String> messageMap) {
log.info("接收到文本消息事件");
String content = messageMap.get("Content");
if (!KEY_WORD.equals(content)) {
return "";
}
String fromUserName = messageMap.get("FromUserName");
String toUserName = messageMap.get("ToUserName");
Random random = new Random();
int num = random.nextInt(1000);
String numKey = redisUtil.buildKey(LOGIN_PREFIX, String.valueOf(num));
redisUtil.setNx(numKey, fromUserName, 5L, TimeUnit.MINUTES);
String numContent = "您当前的验证码是:【" + num + " 5分钟内有效";
String replyContent = "<xml>\n" +
" <ToUserName><![CDATA[" + fromUserName + "]]></ToUserName>\n" +
" <FromUserName><![CDATA[" + toUserName + "]]></FromUserName>\n" +
" <CreateTime>12345678</CreateTime>\n" +
" <MsgType><![CDATA[text]]></MsgType>\n" +
" <Content><![CDATA[" + numContent + "]]></Content>\n" +
"</xml>";
return replyContent;
}
}

View File

@@ -0,0 +1,33 @@
package com.schisandra.wechat.handler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
@Slf4j
public class SubscribeMsgHandler implements WeChatMsgHandler {
@Override
public WeChatMsgTypeEnum getMsgType() {
return WeChatMsgTypeEnum.SUBSCRIBE;
}
@Override
public String dealMsg(Map<String, String> messageMap) {
log.info("触发用户关注事件!");
String fromUserName = messageMap.get("FromUserName");
String toUserName = messageMap.get("ToUserName");
String subscribeContent = "感谢您的关注,我是清语博客!";
String content = "<xml>\n" +
" <ToUserName><![CDATA[" + fromUserName + "]]></ToUserName>\n" +
" <FromUserName><![CDATA[" + toUserName + "]]></FromUserName>\n" +
" <CreateTime>12345678</CreateTime>\n" +
" <MsgType><![CDATA[text]]></MsgType>\n" +
" <Content><![CDATA[" + subscribeContent + "]]></Content>\n" +
"</xml>";
return content;
}
}

View File

@@ -0,0 +1,31 @@
package com.schisandra.wechat.handler;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component
public class WeChatMsgFactory implements InitializingBean {
@Resource
private List<WeChatMsgHandler> weChatMsgHandlerList;
private Map<WeChatMsgTypeEnum, WeChatMsgHandler> handlerMap = new HashMap<>();
public WeChatMsgHandler getHandlerByMsgType(String msgType) {
WeChatMsgTypeEnum msgTypeEnum = WeChatMsgTypeEnum.getByMsgType(msgType);
return handlerMap.get(msgTypeEnum);
}
@Override
public void afterPropertiesSet() throws Exception {
for (WeChatMsgHandler weChatMsgHandler : weChatMsgHandlerList) {
handlerMap.put(weChatMsgHandler.getMsgType(), weChatMsgHandler);
}
}
}

View File

@@ -0,0 +1,11 @@
package com.schisandra.wechat.handler;
import java.util.Map;
public interface WeChatMsgHandler {
WeChatMsgTypeEnum getMsgType();
String dealMsg(Map<String, String> messageMap);
}

View File

@@ -0,0 +1,26 @@
package com.schisandra.wechat.handler;
public enum WeChatMsgTypeEnum {
SUBSCRIBE("event.subscribe", "用户关注事件"),
TEXT_MSG("text", "接收用户文本消息");
private String msgType;
private String desc;
WeChatMsgTypeEnum(String msgType, String desc) {
this.msgType = msgType;
this.desc = desc;
}
public static WeChatMsgTypeEnum getByMsgType(String msgType) {
for (WeChatMsgTypeEnum weChatMsgTypeEnum : WeChatMsgTypeEnum.values()) {
if (weChatMsgTypeEnum.msgType.equals(msgType)) {
return weChatMsgTypeEnum;
}
}
return null;
}
}

View File

@@ -0,0 +1,47 @@
package com.schisandra.wechat.redis;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
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.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
/**
* Redis的config处理
*
* @author: ChickenWing
* @date: 2023/10/28
*/
@Configuration
public class RedisConfig {
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
RedisSerializer<String> redisSerializer = new StringRedisSerializer();
redisTemplate.setConnectionFactory(redisConnectionFactory);
redisTemplate.setKeySerializer(redisSerializer);
redisTemplate.setHashKeySerializer(redisSerializer);
redisTemplate.setValueSerializer(jackson2JsonRedisSerializer());
redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer());
return redisTemplate;
}
private Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer() {
Jackson2JsonRedisSerializer<Object> jsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
jsonRedisSerializer.setObjectMapper(objectMapper);
return jsonRedisSerializer;
}
}

View File

@@ -0,0 +1,107 @@
package com.schisandra.wechat.redis;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* RedisUtil工具类
*
* @author: ChickenWing
* @date: 2023/10/28
*/
@Component
@Slf4j
public class RedisUtil {
@Resource
private RedisTemplate redisTemplate;
private static final String CACHE_KEY_SEPARATOR = ".";
/**
* 构建缓存key
*/
public String buildKey(String... strObjs) {
return Stream.of(strObjs).collect(Collectors.joining(CACHE_KEY_SEPARATOR));
}
/**
* 是否存在key
*/
public boolean exist(String key) {
return redisTemplate.hasKey(key);
}
/**
* 删除key
*/
public boolean del(String key) {
return redisTemplate.delete(key);
}
/**
* set(不带过期)
*/
public void set(String key, String value) {
redisTemplate.opsForValue().set(key, value);
}
/**
* set(带过期)
*/
public boolean setNx(String key, String value, Long time, TimeUnit timeUnit) {
return redisTemplate.opsForValue().setIfAbsent(key, value, time, timeUnit);
}
/**
* 获取string类型缓存
*/
public String get(String key) {
return (String) redisTemplate.opsForValue().get(key);
}
public Boolean zAdd(String key, String value, Long score) {
return redisTemplate.opsForZSet().add(key, value, Double.valueOf(String.valueOf(score)));
}
public Long countZset(String key) {
return redisTemplate.opsForZSet().size(key);
}
public Set<String> rangeZset(String key, long start, long end) {
return redisTemplate.opsForZSet().range(key, start, end);
}
public Long removeZset(String key, Object value) {
return redisTemplate.opsForZSet().remove(key, value);
}
public void removeZsetList(String key, Set<String> value) {
value.stream().forEach((val) -> redisTemplate.opsForZSet().remove(key, val));
}
public Double score(String key, Object value) {
return redisTemplate.opsForZSet().score(key, value);
}
public Set<String> rangeByScore(String key, long start, long end) {
return redisTemplate.opsForZSet().rangeByScore(key, Double.valueOf(String.valueOf(start)), Double.valueOf(String.valueOf(end)));
}
public Object addScore(String key, Object obj, double score) {
return redisTemplate.opsForZSet().incrementScore(key, obj, score);
}
public Object rank(String key, Object obj) {
return redisTemplate.opsForZSet().rank(key, obj);
}
}

View File

@@ -0,0 +1,47 @@
package com.schisandra.wechat.utils;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MessageUtil {
/**
* 解析微信发来的请求XML.
*
* @param msg 消息
* @return map
*/
public static Map<String, String> parseXml(final String msg) {
// 将解析结果存储在HashMap中
Map<String, String> map = new HashMap<String, String>();
// 从request中取得输入流
try (InputStream inputStream = new ByteArrayInputStream(msg.getBytes(StandardCharsets.UTF_8.name()))) {
// 读取输入流
SAXReader reader = new SAXReader();
Document document = reader.read(inputStream);
// 得到xml根元素
Element root = document.getRootElement();
// 得到根元素的所有子节点
List<Element> elementList = root.elements();
// 遍历所有子节点
for (Element e : elementList) {
map.put(e.getName(), e.getText());
}
} catch (Exception e) {
e.printStackTrace();
}
return map;
}
}

View File

@@ -0,0 +1,56 @@
package com.schisandra.wechat.utils;
import lombok.extern.slf4j.Slf4j;
import java.security.MessageDigest;
import java.util.Arrays;
/**
* sha1生成签名工具
*
* @author: landaiqing
* @date: 2023/11/5
*/
@Slf4j
public class SHA1 {
/**
* 用SHA1算法生成安全签名
*
* @param token 票据
* @param timestamp 时间戳
* @param nonce 随机字符串
* @param encrypt 密文
* @return 安全签名
*/
public static String getSHA1(String token, String timestamp, String nonce, String encrypt) {
try {
String[] array = new String[]{token, timestamp, nonce, encrypt};
StringBuffer sb = new StringBuffer();
// 字符串排序
Arrays.sort(array);
for (int i = 0; i < 4; i++) {
sb.append(array[i]);
}
String str = sb.toString();
// SHA1签名生成
MessageDigest md = MessageDigest.getInstance("SHA-1");
md.update(str.getBytes());
byte[] digest = md.digest();
StringBuffer hexStr = new StringBuffer();
String shaHex = "";
for (int i = 0; i < digest.length; i++) {
shaHex = Integer.toHexString(digest[i] & 0xFF);
if (shaHex.length() < 2) {
hexStr.append(0);
}
hexStr.append(shaHex);
}
return hexStr.toString();
} catch (Exception e) {
log.error("sha加密生成签名失败:", e);
return null;
}
}
}

View File

@@ -0,0 +1,25 @@
server:
port: 3010
spring:
# redis配置
redis:
# Redis数据库索引默认为0
database: 1
# Redis服务器地址
host: 116.196.80.239
# Redis服务器连接端口
port: 6379
# Redis服务器连接密码默认为空
password: LDQ20020618xxx
# 连接超时时间
timeout: 2s
lettuce:
pool:
# 连接池最大连接数
max-active: 200
# 连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
# 连接池中的最大空闲连接
max-idle: 10
# 连接池中的最小空闲连接
min-idle: 0