feat: 修改模块名称
This commit is contained in:
56
qing-yu-club-auth/pom.xml
Normal file
56
qing-yu-club-auth/pom.xml
Normal file
@@ -0,0 +1,56 @@
|
||||
<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.landaiqing</groupId>
|
||||
<artifactId>qing-yu-club-auth</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>qing-yu-club-auth</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
<modules>
|
||||
<module>qing-yu-club-auth-application</module>
|
||||
<module>qing-yu-club-auth-common</module>
|
||||
<module>qing-yu-club-auth-domain</module>
|
||||
<module>qing-yu-club-auth-infra</module>
|
||||
<module>qing-yu-club-auth-starter</module>
|
||||
<module>qing-yu-club-auth-api</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>
|
||||
28
qing-yu-club-auth/qing-yu-club-auth-api/pom.xml
Normal file
28
qing-yu-club-auth/qing-yu-club-auth-api/pom.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<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.landaiqing</groupId>
|
||||
<artifactId>qing-yu-club-auth</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>qing-yu-club-auth-api</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>qing-yu-club-auth-api</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.landaiqing;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*
|
||||
*/
|
||||
public class App
|
||||
{
|
||||
public static void main( String[] args )
|
||||
{
|
||||
System.out.println( "Hello World!" );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.landaiqing;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest
|
||||
extends TestCase
|
||||
{
|
||||
/**
|
||||
* Create the test case
|
||||
*
|
||||
* @param testName name of the test case
|
||||
*/
|
||||
public AppTest( String testName )
|
||||
{
|
||||
super( testName );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the suite of tests being tested
|
||||
*/
|
||||
public static Test suite()
|
||||
{
|
||||
return new TestSuite( AppTest.class );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rigourous Test :-)
|
||||
*/
|
||||
public void testApp()
|
||||
{
|
||||
assertTrue( true );
|
||||
}
|
||||
}
|
||||
33
qing-yu-club-auth/qing-yu-club-auth-application/pom.xml
Normal file
33
qing-yu-club-auth/qing-yu-club-auth-application/pom.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<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.landaiqing</groupId>
|
||||
<artifactId>qing-yu-club-auth</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>qing-yu-club-auth-application</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>qing-yu-club-auth-application</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
<modules>
|
||||
<module>qing-yu-club-auth-application-controller</module>
|
||||
<module>qing-yu-club-auth-application-job</module>
|
||||
<module>qing-yu-club-auth-application-mq</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -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.landaiqing</groupId>
|
||||
<artifactId>qing-yu-club-auth-application</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>qing-yu-club-auth-application-controller</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>qing-yu-club-auth-application-controller</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.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.landaiqing</groupId>
|
||||
<artifactId>qing-yu-club-auth-domain</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.landaiqing.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.landaiqing.subject.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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.landaiqing.auth.application.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.landaiqing.auth.application.convert.AuthPermissionDTOConverter;
|
||||
import com.landaiqing.auth.application.dto.AuthPermissionDTO;
|
||||
import com.landaiqing.auth.domain.entity.AuthPermissionBO;
|
||||
import com.landaiqing.auth.domain.service.AuthPermissionDomainService;
|
||||
import com.landaiqing.auth.common.entity.Result;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 权限controller
|
||||
*
|
||||
* @author: landaiqing
|
||||
* @date: 2024/2/19
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/permission/")
|
||||
@Slf4j
|
||||
public class PermissionController {
|
||||
|
||||
@Resource
|
||||
private AuthPermissionDomainService authPermissionDomainService;
|
||||
|
||||
/**
|
||||
* 新增权限
|
||||
*/
|
||||
@RequestMapping("add")
|
||||
public Result<Boolean> add(@RequestBody AuthPermissionDTO authPermissionDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("PermissionController.add.dto:{}", JSON.toJSONString(authPermissionDTO));
|
||||
}
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(authPermissionDTO.getName()), "权限名称不能为空");
|
||||
Preconditions.checkNotNull(authPermissionDTO.getParentId(), "权限父id不能为空");
|
||||
AuthPermissionBO permissionBO = AuthPermissionDTOConverter.INSTANCE.convertDTOToBO(authPermissionDTO);
|
||||
return Result.ok(authPermissionDomainService.add(permissionBO));
|
||||
} catch (Exception e) {
|
||||
log.error("PermissionController.add.error:{}", e.getMessage(), e);
|
||||
return Result.fail("新增权限失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改权限
|
||||
*/
|
||||
@RequestMapping("update")
|
||||
public Result<Boolean> update(@RequestBody AuthPermissionDTO authPermissionDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("PermissionController.update.dto:{}", JSON.toJSONString(authPermissionDTO));
|
||||
}
|
||||
Preconditions.checkNotNull(authPermissionDTO.getId(), "权限id不能为空");
|
||||
AuthPermissionBO permissionBO = AuthPermissionDTOConverter.INSTANCE.convertDTOToBO(authPermissionDTO);
|
||||
return Result.ok(authPermissionDomainService.update(permissionBO));
|
||||
} catch (Exception e) {
|
||||
log.error("PermissionController.update.error:{}", e.getMessage(), e);
|
||||
return Result.fail("更新权限信息失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除权限
|
||||
*/
|
||||
@RequestMapping("delete")
|
||||
public Result<Boolean> delete(@RequestBody AuthPermissionDTO authPermissionDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("PermissionController.delete.dto:{}", JSON.toJSONString(authPermissionDTO));
|
||||
}
|
||||
Preconditions.checkNotNull(authPermissionDTO.getId(), "权限id不能为空");
|
||||
AuthPermissionBO permissionBO = AuthPermissionDTOConverter.INSTANCE.convertDTOToBO(authPermissionDTO);
|
||||
return Result.ok(authPermissionDomainService.delete(permissionBO));
|
||||
} catch (Exception e) {
|
||||
log.error("PermissionController.delete.error:{}", e.getMessage(), e);
|
||||
return Result.fail("删除权限信息失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户权限
|
||||
*/
|
||||
@RequestMapping("getPermission")
|
||||
public Result<Boolean> getPermission(String userName) {
|
||||
try {
|
||||
log.info("PermissionController.getPermission.userName:{}",userName);
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(userName), "用户id不能为空");
|
||||
return Result.ok(authPermissionDomainService.getPermission(userName));
|
||||
} catch (Exception e) {
|
||||
log.error("PermissionController.getPermission.error:{}", e.getMessage(), e);
|
||||
return Result.fail("查询用户权限信息失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.landaiqing.auth.application.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.landaiqing.auth.application.convert.AuthRoleDTOConverter;
|
||||
import com.landaiqing.auth.application.dto.AuthRoleDTO;
|
||||
import com.landaiqing.auth.common.entity.Result;
|
||||
import com.landaiqing.auth.domain.entity.AuthRoleBO;
|
||||
import com.landaiqing.auth.domain.service.AuthRoleDomainService;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @Classname RoleController
|
||||
* @BelongsProject: qing-yu-club
|
||||
* @BelongsPackage: com.landaiqing.auth.application.controller
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-02-19 15:34
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/role/")
|
||||
@Slf4j
|
||||
public class RoleController {
|
||||
@Resource
|
||||
private AuthRoleDomainService authRoleDomainService;
|
||||
/**
|
||||
* @description: 新增角色
|
||||
* @param: [authRoleDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/19 15:36
|
||||
*/
|
||||
@PostMapping("add")
|
||||
public Result<Boolean> add(@RequestBody AuthRoleDTO authRoleDTO){
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("RoleController.add.dto:{}", JSON.toJSONString(authRoleDTO));
|
||||
}
|
||||
Preconditions.checkNotNull(authRoleDTO.getRoleName(),"角色名称不能为空");
|
||||
Preconditions.checkNotNull(authRoleDTO.getRoleKey(),"角色Key不能为空");
|
||||
AuthRoleBO authRoleBO = AuthRoleDTOConverter.INSTANCE.convertDTOToBO(authRoleDTO);
|
||||
return Result.ok(authRoleDomainService.add(authRoleBO));
|
||||
} catch (Exception e) {
|
||||
log.error("RoleController.add.error:{}", e.getMessage(), e);
|
||||
return Result.fail("新增角色失败");
|
||||
}
|
||||
}
|
||||
@PostMapping("update")
|
||||
public Result<Boolean> update(@RequestBody AuthRoleDTO authRoleDTO){
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("RoleController.update.dto:{}", JSON.toJSONString(authRoleDTO));
|
||||
}
|
||||
Preconditions.checkNotNull(authRoleDTO.getId(),"角色id不能为空");
|
||||
|
||||
AuthRoleBO authRoleBO = AuthRoleDTOConverter.INSTANCE.convertDTOToBO(authRoleDTO);
|
||||
return Result.ok(authRoleDomainService.update(authRoleBO));
|
||||
} catch (Exception e) {
|
||||
log.error("RoleController.update.error:{}", e.getMessage(), e);
|
||||
return Result.fail("更新角色信息失败");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @description: 删除角色
|
||||
* @param: [authRoleDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/19 15:53
|
||||
*/
|
||||
@PostMapping("delete")
|
||||
public Result<Boolean> delete(@RequestBody AuthRoleDTO authRoleDTO){
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("RoleController.delete.dto:{}", JSON.toJSONString(authRoleDTO));
|
||||
}
|
||||
AuthRoleBO authRoleBO = AuthRoleDTOConverter.INSTANCE.convertDTOToBO(authRoleDTO);
|
||||
return Result.ok(authRoleDomainService.delete(authRoleBO));
|
||||
} catch (Exception e) {
|
||||
log.error("RoleController.delete.error:{}", e.getMessage(), e);
|
||||
return Result.fail("删除角色信息失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.landaiqing.auth.application.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.landaiqing.auth.application.convert.AuthRolePermissionDTOConverter;
|
||||
import com.landaiqing.auth.application.dto.AuthRolePermissionDTO;
|
||||
import com.landaiqing.auth.common.entity.Result;
|
||||
import com.landaiqing.auth.domain.entity.AuthRolePermissionBO;
|
||||
import com.landaiqing.auth.domain.service.AuthRolePermissionDomainService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 角色权限controller
|
||||
*
|
||||
* @author: landaiqing
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/rolePermission/")
|
||||
@Slf4j
|
||||
public class RolePermissionController {
|
||||
|
||||
@Resource
|
||||
private AuthRolePermissionDomainService authRolePermissionDomainService;
|
||||
|
||||
/**
|
||||
* 新增角色权限关联关系
|
||||
*/
|
||||
@RequestMapping("add")
|
||||
public Result<Boolean> add(@RequestBody AuthRolePermissionDTO authRolePermissionDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("RolePermissionController.add.dto:{}", JSON.toJSONString(authRolePermissionDTO));
|
||||
}
|
||||
Preconditions.checkArgument(!CollectionUtils.isEmpty(authRolePermissionDTO.getPermissionIdList()),"权限关联不能为空");
|
||||
Preconditions.checkNotNull(authRolePermissionDTO.getRoleId(),"角色不能为空!");
|
||||
AuthRolePermissionBO rolePermissionBO = AuthRolePermissionDTOConverter.INSTANCE.convertDTOToBO(authRolePermissionDTO);
|
||||
return Result.ok(authRolePermissionDomainService.add(rolePermissionBO));
|
||||
} catch (Exception e) {
|
||||
log.error("PermissionController.add.error:{}", e.getMessage(), e);
|
||||
return Result.fail("新增角色权限失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.landaiqing.auth.application.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.landaiqing.auth.application.convert.AuthUserDTOConverter;
|
||||
import com.landaiqing.auth.application.dto.AuthUserDTO;
|
||||
import com.landaiqing.auth.common.entity.Result;
|
||||
import com.landaiqing.auth.domain.entity.AuthUserBO;
|
||||
import com.landaiqing.auth.domain.service.AuthUserDomainService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @Classname UserController
|
||||
* @BelongsProject: qing-yu-club
|
||||
* @BelongsPackage: com.landaiqing.auth.application.controller
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-02-19 13:46
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user/")
|
||||
@Slf4j
|
||||
public class UserController {
|
||||
|
||||
@Resource
|
||||
private AuthUserDomainService authUserDomainService;
|
||||
/**
|
||||
* @description: 用户注册
|
||||
* @param: []
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/19 13:57
|
||||
*/
|
||||
@PostMapping("register")
|
||||
public Result<Boolean> register(@RequestBody AuthUserDTO authUserDTO){
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("UserController.register.dto:{}", JSON.toJSONString(authUserDTO));
|
||||
}
|
||||
checkUserInfo(authUserDTO);
|
||||
AuthUserBO authUserBO = AuthUserDTOConverter.INSTANCE.convertDTOToBO(authUserDTO);
|
||||
return Result.ok(authUserDomainService.register(authUserBO));
|
||||
} catch (Exception e) {
|
||||
log.error("UserController.register.error:{}", e.getMessage(), e);
|
||||
return Result.fail("注册用户失败");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @description: 修改用户信息
|
||||
* @param: [authUserDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/19 14:38
|
||||
*/
|
||||
@PostMapping("update")
|
||||
public Result<Boolean> update(@RequestBody AuthUserDTO authUserDTO){
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("UserController.update.dto:{}", JSON.toJSONString(authUserDTO));
|
||||
}
|
||||
checkUserInfo(authUserDTO);
|
||||
AuthUserBO authUserBO = AuthUserDTOConverter.INSTANCE.convertDTOToBO(authUserDTO);
|
||||
return Result.ok(authUserDomainService.update(authUserBO));
|
||||
} catch (Exception e) {
|
||||
log.error("UserController.update.error:{}", e.getMessage(), e);
|
||||
return Result.fail("更新用户信息失败");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @description: 用户启用/禁用
|
||||
* @param: [authUserDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/19 14:56
|
||||
*/
|
||||
@PostMapping("changeStatus")
|
||||
public Result<Boolean> changeStatus(@RequestBody AuthUserDTO authUserDTO){
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("UserController.changeStatus.dto:{}", JSON.toJSONString(authUserDTO));
|
||||
}
|
||||
Preconditions.checkNotNull(authUserDTO.getStatus(),"用户名状态不能为空");
|
||||
AuthUserBO authUserBO = AuthUserDTOConverter.INSTANCE.convertDTOToBO(authUserDTO);
|
||||
return Result.ok(authUserDomainService.update(authUserBO));
|
||||
} catch (Exception e) {
|
||||
log.error("UserController.changeStatus.error:{}", e.getMessage(), e);
|
||||
return Result.fail("启用/禁用用户信息失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description: 删除用户
|
||||
* @param: [authUserDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/19 14:50
|
||||
*/
|
||||
@PostMapping("delete")
|
||||
public Result<Boolean> delete(@RequestBody AuthUserDTO authUserDTO){
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("UserController.update.dto:{}", JSON.toJSONString(authUserDTO));
|
||||
}
|
||||
AuthUserBO authUserBO = AuthUserDTOConverter.INSTANCE.convertDTOToBO(authUserDTO);
|
||||
return Result.ok(authUserDomainService.delete(authUserBO));
|
||||
} catch (Exception e) {
|
||||
log.error("UserController.update.error:{}", e.getMessage(), e);
|
||||
return Result.fail("删除用户信息失败");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUserInfo(@RequestBody AuthUserDTO authUserDTO) {
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(authUserDTO.getUserName()),"用户名不能为空");
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(authUserDTO.getEmail()),"邮箱不能为空");
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(authUserDTO.getPassword()),"密码不能为空");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.landaiqing.auth.application.convert;
|
||||
|
||||
import com.landaiqing.auth.application.dto.AuthPermissionDTO;
|
||||
import com.landaiqing.auth.domain.entity.AuthPermissionBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 权限dto转换器
|
||||
*
|
||||
* @author: landaiqing
|
||||
* @date: 2024/2/19
|
||||
*/
|
||||
@Mapper
|
||||
public interface AuthPermissionDTOConverter {
|
||||
|
||||
AuthPermissionDTOConverter INSTANCE = Mappers.getMapper(AuthPermissionDTOConverter.class);
|
||||
|
||||
AuthPermissionBO convertDTOToBO(AuthPermissionDTO authPermissionDTO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.landaiqing.auth.application.convert;
|
||||
|
||||
import com.landaiqing.auth.application.dto.AuthRoleDTO;
|
||||
import com.landaiqing.auth.domain.entity.AuthRoleBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 角色dto转换器
|
||||
*
|
||||
* @author: landaiqing
|
||||
*/
|
||||
@Mapper
|
||||
public interface AuthRoleDTOConverter {
|
||||
|
||||
AuthRoleDTOConverter INSTANCE = Mappers.getMapper(AuthRoleDTOConverter.class);
|
||||
|
||||
AuthRoleBO convertDTOToBO(AuthRoleDTO authRoleDTO);
|
||||
|
||||
AuthRoleDTO convertBOToDTO(AuthRoleBO authRoleBO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.landaiqing.auth.application.convert;
|
||||
|
||||
import com.landaiqing.auth.application.dto.AuthRolePermissionDTO;
|
||||
import com.landaiqing.auth.domain.entity.AuthRolePermissionBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 权限dto转换器
|
||||
*
|
||||
* @author: landaiqing
|
||||
*/
|
||||
@Mapper
|
||||
public interface AuthRolePermissionDTOConverter {
|
||||
|
||||
AuthRolePermissionDTOConverter INSTANCE = Mappers.getMapper(AuthRolePermissionDTOConverter.class);
|
||||
|
||||
AuthRolePermissionBO convertDTOToBO(AuthRolePermissionDTO authRolePermissionDTO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.landaiqing.auth.application.convert;
|
||||
|
||||
import com.landaiqing.auth.application.dto.AuthUserDTO;
|
||||
import com.landaiqing.auth.domain.entity.AuthUserBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 用户dto转换器
|
||||
*
|
||||
* @author: landaiqing
|
||||
*/
|
||||
@Mapper
|
||||
public interface AuthUserDTOConverter {
|
||||
|
||||
AuthUserDTOConverter INSTANCE = Mappers.getMapper(AuthUserDTOConverter.class);
|
||||
|
||||
AuthUserBO convertDTOToBO(AuthUserDTO authUserDTO);
|
||||
|
||||
AuthUserDTO convertBOToDTO(AuthUserBO authUserBO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.landaiqing.auth.application.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 权限dto
|
||||
*
|
||||
* @author: landaiqing
|
||||
* @date: 2024/2/19
|
||||
*/
|
||||
@Data
|
||||
public class AuthPermissionDTO 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.landaiqing.auth.application.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 角色dto
|
||||
*
|
||||
* @author: landaiqing
|
||||
* @date: 2024/2/19
|
||||
*/
|
||||
@Data
|
||||
public class AuthRoleDTO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String roleName;
|
||||
|
||||
private String roleKey;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.landaiqing.auth.application.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (AuthRolePermission)实体类
|
||||
*
|
||||
* @author landaiqing
|
||||
*/
|
||||
@Data
|
||||
public class AuthRolePermissionDTO implements Serializable {
|
||||
private static final long serialVersionUID = 459343371709166261L;
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long roleId;
|
||||
|
||||
private Long permissionId;
|
||||
|
||||
private List<Long> permissionIdList;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.landaiqing.auth.application.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* (AuthUser)DTO
|
||||
*/
|
||||
@Data
|
||||
public class AuthUserDTO implements Serializable {
|
||||
|
||||
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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<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.landaiqing</groupId>
|
||||
<artifactId>qing-yu-club-auth-application</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>qing-yu-club-auth-application-job</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>qing-yu-club-auth-application-job</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.landaiqing;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*
|
||||
*/
|
||||
public class App
|
||||
{
|
||||
public static void main( String[] args )
|
||||
{
|
||||
System.out.println( "Hello World!" );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.landaiqing;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest
|
||||
extends TestCase
|
||||
{
|
||||
/**
|
||||
* Create the test case
|
||||
*
|
||||
* @param testName name of the test case
|
||||
*/
|
||||
public AppTest( String testName )
|
||||
{
|
||||
super( testName );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the suite of tests being tested
|
||||
*/
|
||||
public static Test suite()
|
||||
{
|
||||
return new TestSuite( AppTest.class );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rigourous Test :-)
|
||||
*/
|
||||
public void testApp()
|
||||
{
|
||||
assertTrue( true );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<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.landaiqing</groupId>
|
||||
<artifactId>qing-yu-club-auth-application</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>qing-yu-club-auth-application-mq</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>qing-yu-club-auth-application-mq</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.landaiqing;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*
|
||||
*/
|
||||
public class App
|
||||
{
|
||||
public static void main( String[] args )
|
||||
{
|
||||
System.out.println( "Hello World!" );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.landaiqing;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest
|
||||
extends TestCase
|
||||
{
|
||||
/**
|
||||
* Create the test case
|
||||
*
|
||||
* @param testName name of the test case
|
||||
*/
|
||||
public AppTest( String testName )
|
||||
{
|
||||
super( testName );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the suite of tests being tested
|
||||
*/
|
||||
public static Test suite()
|
||||
{
|
||||
return new TestSuite( AppTest.class );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rigourous Test :-)
|
||||
*/
|
||||
public void testApp()
|
||||
{
|
||||
assertTrue( true );
|
||||
}
|
||||
}
|
||||
81
qing-yu-club-auth/qing-yu-club-auth-common/pom.xml
Normal file
81
qing-yu-club-auth/qing-yu-club-auth-common/pom.xml
Normal file
@@ -0,0 +1,81 @@
|
||||
<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.landaiqing</groupId>
|
||||
<artifactId>qing-yu-club-auth</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>qing-yu-club-auth-common</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>qing-yu-club-auth-common</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.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.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>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.landaiqing.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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.landaiqing.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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.landaiqing.auth.common.entity;
|
||||
|
||||
import com.landaiqing.auth.common.enums.ResultCodeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.landaiqing.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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.landaiqing.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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.landaiqing.auth.common.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum ResultCodeEnum {
|
||||
SUCCESS(200,"成功"),
|
||||
FAIL(500,"失败");
|
||||
private int code;
|
||||
private 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;
|
||||
}
|
||||
}
|
||||
59
qing-yu-club-auth/qing-yu-club-auth-domain/pom.xml
Normal file
59
qing-yu-club-auth/qing-yu-club-auth-domain/pom.xml
Normal file
@@ -0,0 +1,59 @@
|
||||
<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.landaiqing</groupId>
|
||||
<artifactId>qing-yu-club-auth</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>qing-yu-club-auth-domain</artifactId>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>qing-yu-club-auth-domain</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.landaiqing</groupId>
|
||||
<artifactId>qing-yu-club-auth-infra</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.landaiqing</groupId>
|
||||
<artifactId>qing-yu-club-auth-common</artifactId>
|
||||
<version>1.0-SNAPSHOT</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>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.6</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.landaiqing.auth.domain.constants;
|
||||
|
||||
/**
|
||||
* auth服务常量
|
||||
*
|
||||
* @author: landaiqing
|
||||
* @date: 2024/2/19
|
||||
*/
|
||||
public class AuthConstant {
|
||||
|
||||
public static final String NORMAL_USER = "normal_user";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.landaiqing.auth.domain.convert;
|
||||
|
||||
import com.landaiqing.auth.domain.entity.AuthPermissionBO;
|
||||
import com.landaiqing.auth.infra.basic.entity.AuthPermission;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 权限bo转换器
|
||||
*
|
||||
* @author: landaiqing
|
||||
* @date: 2024/2/19
|
||||
*/
|
||||
@Mapper
|
||||
public interface AuthPermissionBOConverter {
|
||||
|
||||
AuthPermissionBOConverter INSTANCE = Mappers.getMapper(AuthPermissionBOConverter.class);
|
||||
|
||||
AuthPermission convertBOToEntity(AuthPermissionBO authPermissionBO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.landaiqing.auth.domain.convert;
|
||||
|
||||
import com.landaiqing.auth.domain.entity.AuthRoleBO;
|
||||
import com.landaiqing.auth.infra.basic.entity.AuthRole;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 角色bo转换器
|
||||
*
|
||||
* @author: landaiqing
|
||||
* @date: 2024/2/19
|
||||
*/
|
||||
@Mapper
|
||||
public interface AuthRoleBOConverter {
|
||||
|
||||
AuthRoleBOConverter INSTANCE = Mappers.getMapper(AuthRoleBOConverter.class);
|
||||
|
||||
AuthRole convertBOToEntity(AuthRoleBO authRoleBO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.landaiqing.auth.domain.convert;
|
||||
|
||||
import com.landaiqing.auth.domain.entity.AuthUserBO;
|
||||
import com.landaiqing.auth.infra.basic.entity.AuthUser;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 用户bo转换器
|
||||
*
|
||||
* @author: landaiqing
|
||||
* @date: 2024/2/19
|
||||
*/
|
||||
@Mapper
|
||||
public interface AuthUserBOConverter {
|
||||
|
||||
AuthUserBOConverter INSTANCE = Mappers.getMapper(AuthUserBOConverter.class);
|
||||
|
||||
AuthUser convertBOToEntity(AuthUserBO authUserBO);
|
||||
|
||||
AuthUserBO convertEntityToBO(AuthUser authUser);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.landaiqing.auth.domain.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 权限dto
|
||||
*
|
||||
* @author: landaiqing
|
||||
* @date: 2024/2/19
|
||||
*/
|
||||
@Data
|
||||
public class AuthPermissionBO 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.landaiqing.auth.domain.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 角色bo
|
||||
*
|
||||
* @author: landaiqing
|
||||
*/
|
||||
@Data
|
||||
public class AuthRoleBO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String roleName;
|
||||
|
||||
private String roleKey;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.landaiqing.auth.domain.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (AuthRolePermission)实体类
|
||||
*
|
||||
* @author landaiqing
|
||||
*/
|
||||
@Data
|
||||
public class AuthRolePermissionBO implements Serializable {
|
||||
private static final long serialVersionUID = 459343371709166261L;
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long roleId;
|
||||
|
||||
private Long permissionId;
|
||||
|
||||
private List<Long> permissionIdList;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.landaiqing.auth.domain.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 用戶信息dto
|
||||
*
|
||||
* @author: landaiqing
|
||||
*/
|
||||
@Data
|
||||
public class AuthUserBO implements Serializable {
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.landaiqing.auth.domain.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: landaiqing
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.landaiqing.auth.domain.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: landaiqing
|
||||
* @date: 2024/2/19
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.landaiqing.auth.domain.service;
|
||||
|
||||
import com.landaiqing.auth.domain.entity.AuthPermissionBO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 权限领域service
|
||||
*
|
||||
* @author: landaiqing
|
||||
* @date: 2024/2/19
|
||||
*/
|
||||
public interface AuthPermissionDomainService {
|
||||
|
||||
Boolean add(AuthPermissionBO authPermissionBO);
|
||||
|
||||
Boolean update(AuthPermissionBO authPermissionBO);
|
||||
|
||||
Boolean delete(AuthPermissionBO authPermissionBO);
|
||||
|
||||
List<String> getPermission(String userName);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.landaiqing.auth.domain.service;
|
||||
|
||||
|
||||
import com.landaiqing.auth.domain.entity.AuthRoleBO;
|
||||
|
||||
/**
|
||||
* 角色领域service
|
||||
*
|
||||
* @author: landaiqing
|
||||
* @date: 2024/2/19
|
||||
*/
|
||||
public interface AuthRoleDomainService {
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
Boolean add(AuthRoleBO authRoleBO);
|
||||
|
||||
Boolean update(AuthRoleBO authRoleBO);
|
||||
|
||||
Boolean delete(AuthRoleBO authRoleBO);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.landaiqing.auth.domain.service;
|
||||
|
||||
import com.landaiqing.auth.domain.entity.AuthRolePermissionBO;
|
||||
|
||||
/**
|
||||
* 角色领域service
|
||||
*
|
||||
* @author: landaiqing
|
||||
*/
|
||||
public interface AuthRolePermissionDomainService {
|
||||
|
||||
Boolean add(AuthRolePermissionBO authRolePermissionBO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.landaiqing.auth.domain.service;
|
||||
|
||||
|
||||
import com.landaiqing.auth.domain.entity.AuthUserBO;
|
||||
|
||||
/**
|
||||
* 用户领域service
|
||||
*
|
||||
* @author: landaiqing
|
||||
* @date: 2024/2/19
|
||||
*/
|
||||
public interface AuthUserDomainService {
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
Boolean register(AuthUserBO authUserBO);
|
||||
|
||||
/**
|
||||
* 更新用户信息
|
||||
*/
|
||||
Object update(AuthUserBO authUserBO);
|
||||
|
||||
Object delete(AuthUserBO authUserBO);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.landaiqing.auth.domain.service.impl;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.landaiqing.auth.common.enums.IsDeletedFlagEnum;
|
||||
import com.landaiqing.auth.domain.convert.AuthPermissionBOConverter;
|
||||
import com.landaiqing.auth.domain.entity.AuthPermissionBO;
|
||||
import com.landaiqing.auth.domain.redis.RedisUtil;
|
||||
import com.landaiqing.auth.domain.service.AuthPermissionDomainService;
|
||||
import com.landaiqing.auth.infra.basic.entity.AuthPermission;
|
||||
import com.landaiqing.auth.infra.basic.service.AuthPermissionService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AuthPermissionDomainServiceImpl implements AuthPermissionDomainService {
|
||||
|
||||
@Resource
|
||||
private AuthPermissionService authPermissionService;
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
private String authPermissionPrefix = "auth.permission";
|
||||
|
||||
@Override
|
||||
public Boolean add(AuthPermissionBO authPermissionBO) {
|
||||
AuthPermission authPermission = AuthPermissionBOConverter.INSTANCE.convertBOToEntity(authPermissionBO);
|
||||
authPermission.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
Integer count = authPermissionService.insert(authPermission);
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean update(AuthPermissionBO authPermissionBO) {
|
||||
AuthPermission authPermission = AuthPermissionBOConverter.INSTANCE.convertBOToEntity(authPermissionBO);
|
||||
Integer count = authPermissionService.update(authPermission);
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean delete(AuthPermissionBO authPermissionBO) {
|
||||
AuthPermission authPermission = new AuthPermission();
|
||||
authPermission.setId(authPermissionBO.getId());
|
||||
authPermission.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
|
||||
Integer count = authPermissionService.update(authPermission);
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPermission(String userName) {
|
||||
String permissionKey = redisUtil.buildKey(authPermissionPrefix, userName);
|
||||
String permissionValue = redisUtil.get(permissionKey);
|
||||
if (StringUtils.isBlank(permissionValue)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<AuthPermission> permissionList = new Gson().fromJson(permissionValue,
|
||||
new TypeToken<List<AuthPermission>>() {
|
||||
}.getType());
|
||||
List<String> authList = permissionList.stream().map(AuthPermission::getPermissionKey).collect(Collectors.toList());
|
||||
return authList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.landaiqing.auth.domain.service.impl;
|
||||
|
||||
import com.landaiqing.auth.common.enums.IsDeletedFlagEnum;
|
||||
import com.landaiqing.auth.domain.convert.AuthRoleBOConverter;
|
||||
import com.landaiqing.auth.domain.entity.AuthRoleBO;
|
||||
import com.landaiqing.auth.domain.service.AuthRoleDomainService;
|
||||
import com.landaiqing.auth.infra.basic.entity.AuthRole;
|
||||
import com.landaiqing.auth.infra.basic.service.AuthRoleService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AuthRoleDomainServiceImpl implements AuthRoleDomainService {
|
||||
|
||||
@Resource
|
||||
private AuthRoleService authRoleService;
|
||||
|
||||
@Override
|
||||
public Boolean add(AuthRoleBO authRoleBO) {
|
||||
AuthRole authRole = AuthRoleBOConverter.INSTANCE.convertBOToEntity(authRoleBO);
|
||||
authRole.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
Integer count = authRoleService.insert(authRole);
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean update(AuthRoleBO authRoleBO) {
|
||||
AuthRole authRole = AuthRoleBOConverter.INSTANCE.convertBOToEntity(authRoleBO);
|
||||
int count = authRoleService.update(authRole);
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean delete(AuthRoleBO authRoleBO) {
|
||||
AuthRole authRole = new AuthRole();
|
||||
authRole.setId(authRoleBO.getId());
|
||||
authRole.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
|
||||
int count = authRoleService.update(authRole);
|
||||
return count > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.landaiqing.auth.domain.service.impl;
|
||||
|
||||
import com.landaiqing.auth.common.enums.IsDeletedFlagEnum;
|
||||
import com.landaiqing.auth.domain.entity.AuthRolePermissionBO;
|
||||
import com.landaiqing.auth.domain.service.AuthRolePermissionDomainService;
|
||||
import com.landaiqing.auth.infra.basic.entity.AuthRolePermission;
|
||||
import com.landaiqing.auth.infra.basic.service.AuthRolePermissionService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AuthRolePermissionDomainServiceImpl implements AuthRolePermissionDomainService {
|
||||
|
||||
@Resource
|
||||
private AuthRolePermissionService authRolePermissionService;
|
||||
|
||||
@Override
|
||||
public Boolean add(AuthRolePermissionBO authRolePermissionBO) {
|
||||
List<AuthRolePermission> rolePermissionList = new LinkedList<>();
|
||||
Long roleId = authRolePermissionBO.getRoleId();
|
||||
authRolePermissionBO.getPermissionIdList().forEach(permissionId -> {
|
||||
AuthRolePermission authRolePermission = new AuthRolePermission();
|
||||
authRolePermission.setRoleId(roleId);
|
||||
authRolePermission.setPermissionId(permissionId);
|
||||
authRolePermission.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
rolePermissionList.add(authRolePermission);
|
||||
});
|
||||
int count = authRolePermissionService.batchInsert(rolePermissionList);
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.landaiqing.auth.domain.service.impl;
|
||||
|
||||
import cn.dev33.satoken.secure.SaSecureUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.landaiqing.auth.common.enums.AuthUserStatusEnum;
|
||||
import com.landaiqing.auth.common.enums.IsDeletedFlagEnum;
|
||||
import com.landaiqing.auth.domain.constants.AuthConstant;
|
||||
import com.landaiqing.auth.domain.convert.AuthUserBOConverter;
|
||||
import com.landaiqing.auth.domain.entity.AuthUserBO;
|
||||
import com.landaiqing.auth.domain.redis.RedisUtil;
|
||||
import com.landaiqing.auth.domain.service.AuthUserDomainService;
|
||||
import com.landaiqing.auth.infra.basic.entity.*;
|
||||
import com.landaiqing.auth.infra.basic.service.*;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AuthUserDomainServiceImpl implements AuthUserDomainService {
|
||||
|
||||
@Resource
|
||||
private AuthUserService authUserService;
|
||||
|
||||
@Resource
|
||||
private AuthUserRoleService authUserRoleService;
|
||||
|
||||
@Resource
|
||||
private AuthRoleService authRoleService;
|
||||
|
||||
@Resource
|
||||
private AuthPermissionService authPermissionService;
|
||||
|
||||
@Resource
|
||||
private AuthRolePermissionService authRolePermissionService;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
private String authPermissionPrefix = "auth.permission";
|
||||
|
||||
private String authRolePrefix = "auth.role";
|
||||
|
||||
private String salt="landaiqing";
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean register(AuthUserBO authUserBO) {
|
||||
AuthUser authUser = AuthUserBOConverter.INSTANCE.convertBOToEntity(authUserBO);
|
||||
authUser.setPassword(SaSecureUtil.md5BySalt(authUser.getPassword(),salt));
|
||||
authUser.setStatus(AuthUserStatusEnum.OPEN.getCode());
|
||||
authUser.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
Integer count = authUserService.insert(authUser);
|
||||
|
||||
// 用户和角色关联
|
||||
AuthRole authRole=new AuthRole();
|
||||
authRole.setRoleKey(AuthConstant.NORMAL_USER);
|
||||
AuthRole roleResult = authRoleService.queryByCondition(authRole);
|
||||
Long roleId = roleResult.getId();
|
||||
Long userId = authUser.getId();
|
||||
AuthUserRole authUserRole=new AuthUserRole();
|
||||
authUserRole.setUserId(userId);
|
||||
authUserRole.setRoleId(roleId);
|
||||
authUserRole.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
authUserRoleService.insert(authUserRole);
|
||||
|
||||
String roleKey = redisUtil.buildKey(authRolePrefix, authUser.getUserName());
|
||||
List<AuthRole> roleList = new LinkedList<>();
|
||||
roleList.add(authRole);
|
||||
redisUtil.set(roleKey, new Gson().toJson(roleList));
|
||||
|
||||
AuthRolePermission authRolePermission = new AuthRolePermission();
|
||||
authRolePermission.setRoleId(roleId);
|
||||
List<AuthRolePermission> rolePermissionList = authRolePermissionService.
|
||||
queryByCondition(authRolePermission);
|
||||
|
||||
List<Long> permissionIdList = rolePermissionList.stream()
|
||||
.map(AuthRolePermission::getPermissionId).collect(Collectors.toList());
|
||||
//根据roleId查权限
|
||||
List<AuthPermission> permissionList = authPermissionService.queryByRoleList(permissionIdList);
|
||||
String permissionKey = redisUtil.buildKey(authPermissionPrefix, authUser.getUserName());
|
||||
redisUtil.set(permissionKey, new Gson().toJson(permissionList));
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object update(AuthUserBO authUserBO) {
|
||||
AuthUser authUser = AuthUserBOConverter.INSTANCE.convertBOToEntity(authUserBO);
|
||||
Integer count = authUserService.update(authUser);
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object delete(AuthUserBO authUserBO) {
|
||||
AuthUser authUser = new AuthUser();
|
||||
authUser.setId(authUserBO.getId());
|
||||
authUser.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
|
||||
Integer count = authUserService.update(authUser);
|
||||
return count > 0;
|
||||
}
|
||||
}
|
||||
55
qing-yu-club-auth/qing-yu-club-auth-infra/pom.xml
Normal file
55
qing-yu-club-auth/qing-yu-club-auth-infra/pom.xml
Normal file
@@ -0,0 +1,55 @@
|
||||
<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.landaiqing</groupId>
|
||||
<artifactId>qing-yu-club-auth</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>qing-yu-club-auth-infra</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>qing-yu-club-auth-infra</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.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.landaiqing</groupId>
|
||||
<artifactId>qing-yu-club-auth-common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.landaiqing.auth.infra.basic.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* (AuthPermission)实体类
|
||||
*/
|
||||
@Data
|
||||
public class AuthPermission 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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.landaiqing.auth.infra.basic.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* (AuthRole)实体类
|
||||
*/
|
||||
@Data
|
||||
public class AuthRole implements Serializable {
|
||||
private Long id;
|
||||
|
||||
private String roleName;
|
||||
|
||||
private String roleKey;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdTime;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.landaiqing.auth.infra.basic.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* (AuthRolePermission)实体类
|
||||
*/
|
||||
@Data
|
||||
public class AuthRolePermission implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long roleId;
|
||||
|
||||
private Long permissionId;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdTime;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
private Integer isDeleted;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.landaiqing.auth.infra.basic.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* (AuthUser)实体类
|
||||
*/
|
||||
@Data
|
||||
public class AuthUser implements Serializable {
|
||||
|
||||
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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.landaiqing.auth.infra.basic.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* (AuthUserRole)实体类
|
||||
*/
|
||||
@Data
|
||||
public class AuthUserRole implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private Long roleId;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdTime;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.landaiqing.auth.infra.basic.mapper;
|
||||
|
||||
import com.landaiqing.auth.infra.basic.entity.AuthPermission;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (AuthPermission)表数据库访问层
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-2-18 18:55:50
|
||||
*/
|
||||
public interface AuthPermissionDao {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
AuthPermission queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询指定行数据
|
||||
*
|
||||
* @param authPermission 查询条件
|
||||
* @return 对象列表
|
||||
*/
|
||||
List<AuthPermission> queryAllByLimit(AuthPermission authPermission);
|
||||
|
||||
/**
|
||||
* 统计总行数
|
||||
*
|
||||
* @param authPermission 查询条件
|
||||
* @return 总行数
|
||||
*/
|
||||
long count(AuthPermission authPermission);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param authPermission 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insert(AuthPermission authPermission);
|
||||
|
||||
/**
|
||||
* 批量新增数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<AuthPermission> 实例对象列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertBatch(@Param("entities") List<AuthPermission> entities);
|
||||
|
||||
/**
|
||||
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<AuthPermission> 实例对象列表
|
||||
* @return 影响行数
|
||||
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
|
||||
*/
|
||||
int insertOrUpdateBatch(@Param("entities") List<AuthPermission> entities);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param authPermission 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int update(AuthPermission authPermission);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteById(Long id);
|
||||
|
||||
List<AuthPermission> queryByRoleList(@Param("list") List<Long> roleIdList);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.landaiqing.auth.infra.basic.mapper;
|
||||
|
||||
import com.landaiqing.auth.infra.basic.entity.AuthRole;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (AuthRole)表数据库访问层
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-2-18 18:55:50
|
||||
*/
|
||||
public interface AuthRoleDao {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
AuthRole queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询指定行数据
|
||||
*
|
||||
* @param authRole 查询条件
|
||||
* @return 对象列表
|
||||
*/
|
||||
AuthRole queryAllByLimit(AuthRole authRole);
|
||||
|
||||
/**
|
||||
* 统计总行数
|
||||
*
|
||||
* @param authRole 查询条件
|
||||
* @return 总行数
|
||||
*/
|
||||
long count(AuthRole authRole);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param authRole 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insert(AuthRole authRole);
|
||||
|
||||
/**
|
||||
* 批量新增数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<AuthRole> 实例对象列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertBatch(@Param("entities") List<AuthRole> entities);
|
||||
|
||||
/**
|
||||
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<AuthRole> 实例对象列表
|
||||
* @return 影响行数
|
||||
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
|
||||
*/
|
||||
int insertOrUpdateBatch(@Param("entities") List<AuthRole> entities);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param authRole 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int update(AuthRole authRole);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteById(Long id);
|
||||
|
||||
List<AuthRole> queryByRoleList(@Param("list") List<Long> roleIdList);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.landaiqing.auth.infra.basic.mapper;
|
||||
|
||||
import com.landaiqing.auth.infra.basic.entity.AuthRolePermission;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (AuthRolePermission)表数据库访问层
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-2-18 18:55:50
|
||||
*/
|
||||
public interface AuthRolePermissionDao {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
AuthRolePermission queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询指定行数据
|
||||
*
|
||||
* @param authRolePermission 查询条件
|
||||
* @return 对象列表
|
||||
*/
|
||||
List<AuthRolePermission> queryAllByLimit(AuthRolePermission authRolePermission);
|
||||
|
||||
/**
|
||||
* 统计总行数
|
||||
*
|
||||
* @param authRolePermission 查询条件
|
||||
* @return 总行数
|
||||
*/
|
||||
long count(AuthRolePermission authRolePermission);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param authRolePermission 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insert(AuthRolePermission authRolePermission);
|
||||
|
||||
/**
|
||||
* 批量新增数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<AuthRolePermission> 实例对象列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertBatch(@Param("entities") List<AuthRolePermission> entities);
|
||||
|
||||
/**
|
||||
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<AuthRolePermission> 实例对象列表
|
||||
* @return 影响行数
|
||||
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
|
||||
*/
|
||||
int insertOrUpdateBatch(@Param("entities") List<AuthRolePermission> entities);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param authRolePermission 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int update(AuthRolePermission authRolePermission);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteById(Long id);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.landaiqing.auth.infra.basic.mapper;
|
||||
|
||||
import com.landaiqing.auth.infra.basic.entity.AuthUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (AuthUser)表数据库访问层
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-2-18 18:55:50
|
||||
*/
|
||||
public interface AuthUserDao {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
AuthUser queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询指定行数据
|
||||
*
|
||||
* @param authUser 查询条件
|
||||
* @return 对象列表
|
||||
*/
|
||||
List<AuthUser> queryAllByLimit(AuthUser authUser);
|
||||
|
||||
/**
|
||||
* 统计总行数
|
||||
*
|
||||
* @param authUser 查询条件
|
||||
* @return 总行数
|
||||
*/
|
||||
long count(AuthUser authUser);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param authUser 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insert(AuthUser authUser);
|
||||
|
||||
/**
|
||||
* 批量新增数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<AuthUser> 实例对象列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertBatch(@Param("entities") List<AuthUser> entities);
|
||||
|
||||
/**
|
||||
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<AuthUser> 实例对象列表
|
||||
* @return 影响行数
|
||||
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
|
||||
*/
|
||||
int insertOrUpdateBatch(@Param("entities") List<AuthUser> entities);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param authUser 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int update(AuthUser authUser);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteById(Long id);
|
||||
|
||||
Integer updateByUserName(AuthUser authUser);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.landaiqing.auth.infra.basic.mapper;
|
||||
|
||||
import com.landaiqing.auth.infra.basic.entity.AuthUserRole;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (AuthUserRole)表数据库访问层
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-2-18 18:55:50
|
||||
*/
|
||||
public interface AuthUserRoleDao {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
AuthUserRole queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询指定行数据
|
||||
*
|
||||
* @param authUserRole 查询条件
|
||||
* @return 对象列表
|
||||
*/
|
||||
List<AuthUserRole> queryAllByLimit(AuthUserRole authUserRole);
|
||||
|
||||
/**
|
||||
* 统计总行数
|
||||
*
|
||||
* @param authUserRole 查询条件
|
||||
* @return 总行数
|
||||
*/
|
||||
long count(AuthUserRole authUserRole);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param authUserRole 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insert(AuthUserRole authUserRole);
|
||||
|
||||
/**
|
||||
* 批量新增数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<AuthUserRole> 实例对象列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertBatch(@Param("entities") List<AuthUserRole> entities);
|
||||
|
||||
/**
|
||||
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<AuthUserRole> 实例对象列表
|
||||
* @return 影响行数
|
||||
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
|
||||
*/
|
||||
int insertOrUpdateBatch(@Param("entities") List<AuthUserRole> entities);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param authUserRole 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int update(AuthUserRole authUserRole);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteById(Long id);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.landaiqing.auth.infra.basic.service;
|
||||
|
||||
import com.landaiqing.auth.infra.basic.entity.AuthPermission;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (AuthPermission)表服务接口
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-2-18 18:55:50
|
||||
*/
|
||||
public interface AuthPermissionService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
AuthPermission queryById(Long id);
|
||||
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param authPermission 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int insert(AuthPermission authPermission);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param authPermission 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int update(AuthPermission authPermission);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteById(Long id);
|
||||
|
||||
List<AuthPermission> queryByRoleList(List<Long> roleIdList);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.landaiqing.auth.infra.basic.service;
|
||||
|
||||
import com.landaiqing.auth.infra.basic.entity.AuthRolePermission;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (AuthRolePermission)表服务接口
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-2-18 18:55:50
|
||||
*/
|
||||
public interface AuthRolePermissionService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
AuthRolePermission queryById(Long id);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param authRolePermission 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
AuthRolePermission insert(AuthRolePermission authRolePermission);
|
||||
|
||||
int batchInsert(List<AuthRolePermission> authRolePermissionList);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param authRolePermission 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
AuthRolePermission update(AuthRolePermission authRolePermission);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteById(Long id);
|
||||
|
||||
List<AuthRolePermission> queryByCondition(AuthRolePermission authRolePermission);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.landaiqing.auth.infra.basic.service;
|
||||
|
||||
import com.landaiqing.auth.infra.basic.entity.AuthRole;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (AuthRole)表服务接口
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-2-18 18:55:50
|
||||
*/
|
||||
public interface AuthRoleService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
AuthRole queryById(Long id);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param authRole 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
Integer insert(AuthRole authRole);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param authRole 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
Integer update(AuthRole authRole);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteById(Long id);
|
||||
|
||||
|
||||
/**
|
||||
* 根据条件查询角色
|
||||
*/
|
||||
AuthRole queryByCondition(AuthRole authRole);
|
||||
|
||||
List<AuthRole> queryByRoleList(List<Long> roleIdList);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.landaiqing.auth.infra.basic.service;
|
||||
|
||||
import com.landaiqing.auth.infra.basic.entity.AuthUserRole;
|
||||
|
||||
/**
|
||||
* (AuthUserRole)表服务接口
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-2-18 18:55:50
|
||||
*/
|
||||
public interface AuthUserRoleService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
AuthUserRole queryById(Long id);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param authUserRole 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
AuthUserRole insert(AuthUserRole authUserRole);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param authUserRole 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
AuthUserRole update(AuthUserRole authUserRole);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteById(Long id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.landaiqing.auth.infra.basic.service;
|
||||
|
||||
import com.landaiqing.auth.infra.basic.entity.AuthUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (AuthUser)表服务接口
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-2-18 18:55:50
|
||||
*/
|
||||
public interface AuthUserService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
AuthUser queryById(Long id);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param authUser 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
Integer insert(AuthUser authUser);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param authUser 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
Integer update(AuthUser authUser);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteById(Long id);
|
||||
|
||||
/**
|
||||
* 根据条件查询数量
|
||||
*/
|
||||
List<AuthUser> queryByCondition(AuthUser authUser);
|
||||
|
||||
Integer updateByUserName(AuthUser authUser);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.landaiqing.auth.infra.basic.service.impl;
|
||||
|
||||
import com.landaiqing.auth.infra.basic.entity.AuthPermission;
|
||||
import com.landaiqing.auth.infra.basic.mapper.AuthPermissionDao;
|
||||
import com.landaiqing.auth.infra.basic.service.AuthPermissionService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (AuthPermission)表服务实现类
|
||||
*
|
||||
* @author landaiqing
|
||||
*/
|
||||
@Service("authPermissionService")
|
||||
public class AuthPermissionServiceImpl implements AuthPermissionService {
|
||||
@Resource
|
||||
private AuthPermissionDao authPermissionDao;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public AuthPermission queryById(Long id) {
|
||||
return this.authPermissionDao.queryById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param authPermission 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int insert(AuthPermission authPermission) {
|
||||
return this.authPermissionDao.insert(authPermission);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param authPermission 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int update(AuthPermission authPermission) {
|
||||
return this.authPermissionDao.update(authPermission);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Long id) {
|
||||
return this.authPermissionDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthPermission> queryByRoleList(List<Long> roleIdList) {
|
||||
return this.authPermissionDao.queryByRoleList(roleIdList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.landaiqing.auth.infra.basic.service.impl;
|
||||
|
||||
import com.landaiqing.auth.infra.basic.entity.AuthRolePermission;
|
||||
import com.landaiqing.auth.infra.basic.mapper.AuthRolePermissionDao;
|
||||
import com.landaiqing.auth.infra.basic.service.AuthRolePermissionService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (AuthRolePermission)表服务实现类
|
||||
*
|
||||
* @author landaiqing
|
||||
*/
|
||||
@Service("authRolePermissionService")
|
||||
public class AuthRolePermissionServiceImpl implements AuthRolePermissionService {
|
||||
@Resource
|
||||
private AuthRolePermissionDao authRolePermissionDao;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public AuthRolePermission queryById(Long id) {
|
||||
return this.authRolePermissionDao.queryById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param authRolePermission 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public AuthRolePermission insert(AuthRolePermission authRolePermission) {
|
||||
this.authRolePermissionDao.insert(authRolePermission);
|
||||
return authRolePermission;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchInsert(List<AuthRolePermission> authRolePermissionList) {
|
||||
return this.authRolePermissionDao.insertBatch(authRolePermissionList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param authRolePermission 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public AuthRolePermission update(AuthRolePermission authRolePermission) {
|
||||
this.authRolePermissionDao.update(authRolePermission);
|
||||
return this.queryById(authRolePermission.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Long id) {
|
||||
return this.authRolePermissionDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthRolePermission> queryByCondition(AuthRolePermission authRolePermission) {
|
||||
return this.authRolePermissionDao.queryAllByLimit(authRolePermission);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.landaiqing.auth.infra.basic.service.impl;
|
||||
|
||||
import com.landaiqing.auth.infra.basic.entity.AuthRole;
|
||||
import com.landaiqing.auth.infra.basic.mapper.AuthRoleDao;
|
||||
import com.landaiqing.auth.infra.basic.service.AuthRoleService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (AuthRole)表服务实现类
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-2-18 18:55:50
|
||||
*/
|
||||
@Service("authRoleService")
|
||||
public class AuthRoleServiceImpl implements AuthRoleService {
|
||||
@Resource
|
||||
private AuthRoleDao authRoleDao;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public AuthRole queryById(Long id) {
|
||||
return this.authRoleDao.queryById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param authRole 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public Integer insert(AuthRole authRole) {
|
||||
return this.authRoleDao.insert(authRole);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param authRole 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public Integer update(AuthRole authRole) {
|
||||
return this.authRoleDao.update(authRole);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Long id) {
|
||||
return this.authRoleDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthRole queryByCondition(AuthRole authRole) {
|
||||
return authRoleDao.queryAllByLimit(authRole);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthRole> queryByRoleList(List<Long> roleIdList) {
|
||||
return authRoleDao.queryByRoleList(roleIdList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.landaiqing.auth.infra.basic.service.impl;
|
||||
|
||||
import com.landaiqing.auth.infra.basic.entity.AuthUserRole;
|
||||
import com.landaiqing.auth.infra.basic.mapper.AuthUserRoleDao;
|
||||
import com.landaiqing.auth.infra.basic.service.AuthUserRoleService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* (AuthUserRole)表服务实现类
|
||||
*
|
||||
* @author landaiqing
|
||||
*/
|
||||
@Service("authUserRoleService")
|
||||
public class AuthUserRoleServiceImpl implements AuthUserRoleService {
|
||||
@Resource
|
||||
private AuthUserRoleDao authUserRoleDao;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public AuthUserRole queryById(Long id) {
|
||||
return this.authUserRoleDao.queryById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param authUserRole 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public AuthUserRole insert(AuthUserRole authUserRole) {
|
||||
this.authUserRoleDao.insert(authUserRole);
|
||||
return authUserRole;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param authUserRole 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public AuthUserRole update(AuthUserRole authUserRole) {
|
||||
this.authUserRoleDao.update(authUserRole);
|
||||
return this.queryById(authUserRole.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Long id) {
|
||||
return this.authUserRoleDao.deleteById(id) > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.landaiqing.auth.infra.basic.service.impl;
|
||||
|
||||
import com.landaiqing.auth.infra.basic.entity.AuthUser;
|
||||
import com.landaiqing.auth.infra.basic.mapper.AuthUserDao;
|
||||
import com.landaiqing.auth.infra.basic.service.AuthUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (AuthUser)表服务实现类
|
||||
*
|
||||
* @author landaiqing
|
||||
*/
|
||||
@Service("authUserService")
|
||||
public class AuthUserServiceImpl implements AuthUserService {
|
||||
@Resource
|
||||
private AuthUserDao authUserDao;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public AuthUser queryById(Long id) {
|
||||
return this.authUserDao.queryById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param authUser 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public Integer insert(AuthUser authUser) {
|
||||
return this.authUserDao.insert(authUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param authUser 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public Integer update(AuthUser authUser) {
|
||||
return this.authUserDao.update(authUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Long id) {
|
||||
return this.authUserDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthUser> queryByCondition(AuthUser authUser) {
|
||||
return this.authUserDao.queryAllByLimit(authUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer updateByUserName(AuthUser authUser) {
|
||||
return this.authUserDao.updateByUserName(authUser);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.landaiqing.auth.infra.basic.utils;
|
||||
|
||||
import com.alibaba.druid.filter.config.ConfigTools;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.NoSuchProviderException;
|
||||
|
||||
/**
|
||||
* 数据库加密util
|
||||
*
|
||||
* @author: landaiqing
|
||||
* @date: 2024-2-18 18:55:50
|
||||
*/
|
||||
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("123456");
|
||||
System.out.println("encrypt:" + encrypt);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.landaiqing.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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.landaiqing.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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.landaiqing.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) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
<?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.landaiqing.auth.infra.basic.mapper.AuthPermissionDao">
|
||||
|
||||
<resultMap type="com.landaiqing.auth.infra.basic.entity.AuthPermission" id="AuthPermissionMap">
|
||||
<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="AuthPermissionMap">
|
||||
select id,
|
||||
name,
|
||||
parent_id,
|
||||
type,
|
||||
menu_url,
|
||||
status, `show`, icon, permission_key, created_by, created_time, update_by, update_time, is_deleted
|
||||
from auth_permission
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<!--查询指定行数据-->
|
||||
<select id="queryAllByLimit" resultMap="AuthPermissionMap">
|
||||
select
|
||||
id, name, parent_id, type, menu_url, status, `show`, icon, permission_key, created_by, created_time, update_by,
|
||||
update_time, is_deleted
|
||||
from 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>
|
||||
|
||||
<!--统计总行数-->
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
select count(1)
|
||||
from 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>
|
||||
<select id="queryByRoleList" resultMap="AuthPermissionMap">
|
||||
select * from auth_permission
|
||||
where id in
|
||||
<foreach open="(" close=")" collection="list" item="id" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!--新增所有列-->
|
||||
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into 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 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 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 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 auth_permission where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
<?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.landaiqing.auth.infra.basic.mapper.AuthRoleDao">
|
||||
|
||||
<resultMap type="com.landaiqing.auth.infra.basic.entity.AuthRole" id="AuthRoleMap">
|
||||
<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="AuthRoleMap">
|
||||
select id,
|
||||
role_name,
|
||||
role_key,
|
||||
created_by,
|
||||
created_time,
|
||||
update_by,
|
||||
update_time,
|
||||
is_deleted
|
||||
from auth_role
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<!--查询指定行数据-->
|
||||
<select id="queryAllByLimit" resultMap="AuthRoleMap">
|
||||
select
|
||||
id, role_name, role_key, created_by, created_time, update_by, update_time, is_deleted
|
||||
from 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>
|
||||
|
||||
<!--统计总行数-->
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
select count(1)
|
||||
from 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>
|
||||
|
||||
<select id="queryByRoleList" resultMap="AuthRoleMap">
|
||||
select *
|
||||
from auth_role
|
||||
where id in
|
||||
<foreach open="(" close=")" collection="list" item="id" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!--新增所有列-->
|
||||
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into 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 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 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 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 auth_role
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
<?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.landaiqing.auth.infra.basic.mapper.AuthRolePermissionDao">
|
||||
|
||||
<resultMap type="com.landaiqing.auth.infra.basic.entity.AuthRolePermission" id="AuthRolePermissionMap">
|
||||
<result property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="roleId" column="role_id" jdbcType="INTEGER"/>
|
||||
<result property="permissionId" column="permission_id" jdbcType="INTEGER"/>
|
||||
<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="AuthRolePermissionMap">
|
||||
select
|
||||
id, role_id, permission_id, created_by, created_time, update_by, update_time, is_deleted
|
||||
from auth_role_premission
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<!--查询指定行数据-->
|
||||
<select id="queryAllByLimit" resultMap="AuthRolePermissionMap">
|
||||
select
|
||||
id, role_id, permission_id, created_by, created_time, update_by, update_time, is_deleted
|
||||
from auth_role_permission
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="roleId != null">
|
||||
and role_id = #{roleId}
|
||||
</if>
|
||||
<if test="permissionId != null">
|
||||
and permission_id = #{permissionId}
|
||||
</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>
|
||||
|
||||
<!--统计总行数-->
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
select count(1)
|
||||
from auth_role_permission
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="roleId != null">
|
||||
and role_id = #{roleId}
|
||||
</if>
|
||||
<if test="permissionId != null">
|
||||
and permission_id = #{permissionId}
|
||||
</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 auth_role_premission(role_id, permission_id, created_by, created_time, update_by, update_time, is_deleted)
|
||||
values (#{roleId}, #{permissionId}, #{createdBy}, #{createdTime}, #{updateBy}, #{updateTime}, #{isDeleted})
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into auth_role_permission(role_id, permission_id, created_by, created_time, update_by, update_time,
|
||||
is_deleted)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.roleId}, #{entity.permissionId}, #{entity.createdBy}, #{entity.createdTime}, #{entity.updateBy},
|
||||
#{entity.updateTime}, #{entity.isDeleted})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into auth_role_permission(role_id, permission_id, created_by, created_time, update_by, update_time, is_deleted)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.roleId}, #{entity.permissionId}, #{entity.createdBy}, #{entity.createdTime}, #{entity.updateBy}, #{entity.updateTime}, #{entity.isDeleted})
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
role_id = values(role_id),
|
||||
permission_id = values(permission_id),
|
||||
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 auth_role_permission
|
||||
<set>
|
||||
<if test="roleId != null">
|
||||
role_id = #{roleId},
|
||||
</if>
|
||||
<if test="permissionId != null">
|
||||
permission_id = #{permissionId},
|
||||
</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 auth_role_premission where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,294 @@
|
||||
<?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.landaiqing.auth.infra.basic.mapper.AuthUserDao">
|
||||
|
||||
<resultMap type="com.landaiqing.auth.infra.basic.entity.AuthUser" id="AuthUserMap">
|
||||
<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="AuthUserMap">
|
||||
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 auth_user
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<!--查询指定行数据-->
|
||||
<select id="queryAllByLimit" resultMap="AuthUserMap">
|
||||
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 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>
|
||||
|
||||
<!--统计总行数-->
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
select count(1)
|
||||
from 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">
|
||||
<selectKey resultType="java.lang.Long" keyProperty="id" order="AFTER">
|
||||
SELECT LAST_INSERT_ID()
|
||||
</selectKey>
|
||||
insert into 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 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 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 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>
|
||||
|
||||
<update id="updateByUserName">
|
||||
update auth_user
|
||||
<set>
|
||||
<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 user_name = #{userName}
|
||||
</update>
|
||||
|
||||
<!--通过主键删除-->
|
||||
<delete id="deleteById">
|
||||
delete from auth_user where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
<?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.landaiqing.auth.infra.basic.mapper.AuthUserRoleDao">
|
||||
|
||||
<resultMap type="com.landaiqing.auth.infra.basic.entity.AuthUserRole" id="AuthUserRoleMap">
|
||||
<result property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="userId" column="user_id" jdbcType="INTEGER"/>
|
||||
<result property="roleId" column="role_id" jdbcType="INTEGER"/>
|
||||
<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="AuthUserRoleMap">
|
||||
select
|
||||
id, user_id, role_id, created_by, created_time, update_by, update_time, is_deleted
|
||||
from auth_user_role
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<!--查询指定行数据-->
|
||||
<select id="queryAllByLimit" resultMap="AuthUserRoleMap">
|
||||
select
|
||||
id, user_id, role_id, created_by, created_time, update_by, update_time, is_deleted
|
||||
from auth_user_role
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="userId != null">
|
||||
and user_id = #{userId}
|
||||
</if>
|
||||
<if test="roleId != null">
|
||||
and role_id = #{roleId}
|
||||
</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>
|
||||
|
||||
<!--统计总行数-->
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
select count(1)
|
||||
from auth_user_role
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="userId != null">
|
||||
and user_id = #{userId}
|
||||
</if>
|
||||
<if test="roleId != null">
|
||||
and role_id = #{roleId}
|
||||
</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 auth_user_role(user_id, role_id, created_by, created_time, update_by, update_time, is_deleted)
|
||||
values (#{userId}, #{roleId}, #{createdBy}, #{createdTime}, #{updateBy}, #{updateTime}, #{isDeleted})
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into auth_user_role(user_id, role_id, created_by, created_time, update_by, update_time, is_deleted)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.userId}, #{entity.roleId}, #{entity.createdBy}, #{entity.createdTime}, #{entity.updateBy}, #{entity.updateTime}, #{entity.isDeleted})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into auth_user_role(user_id, role_id, created_by, created_time, update_by, update_time, is_deleted)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.userId}, #{entity.roleId}, #{entity.createdBy}, #{entity.createdTime}, #{entity.updateBy}, #{entity.updateTime}, #{entity.isDeleted})
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
user_id = values(user_id),
|
||||
role_id = values(role_id),
|
||||
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 auth_user_role
|
||||
<set>
|
||||
<if test="userId != null">
|
||||
user_id = #{userId},
|
||||
</if>
|
||||
<if test="roleId != null">
|
||||
role_id = #{roleId},
|
||||
</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 auth_user_role where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
||||
105
qing-yu-club-auth/qing-yu-club-auth-starter/pom.xml
Normal file
105
qing-yu-club-auth/qing-yu-club-auth-starter/pom.xml
Normal file
@@ -0,0 +1,105 @@
|
||||
<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.landaiqing</groupId>
|
||||
<artifactId>qing-yu-club-auth</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>qing-yu-club-auth-starter</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>qing-yu-club-auth-starter</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<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>com.landaiqing</groupId>
|
||||
<artifactId>qing-yu-club-auth-application-controller</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.landaiqing</groupId>
|
||||
<artifactId>qing-yu-club-auth-infra</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</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>
|
||||
</project>
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.landaiqing.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/2/7
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@ComponentScan("com.landaiqing")
|
||||
@MapperScan("com.landaiqing.**.mapper")
|
||||
public class AuthApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AuthApplication.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
server:
|
||||
port: 3001
|
||||
spring:
|
||||
datasource:
|
||||
username: landaiqing
|
||||
password: iPHzskWvLGI2TrPw2AV7pu4C8O4bfxSSeQrkIqq0ZwM5tpBmx4aI6xN/8xjYgSmIir5v2Cv35Fn2732AypFKww==
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://116.196.80.239:3306/qing-yu-club?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: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKsYR+P7j9DehNkZaLxNeeoqU6ThCw3SNYCoPt1S7yeP1gEzpdS1cCQcz7/7OLQI/iFFjIJgXQDM2CA85yIomTMCAwEAAQ==
|
||||
logging:
|
||||
config: classpath:log4j2-spring.xml
|
||||
|
||||
#mybatis-plus:
|
||||
# configuration:
|
||||
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
############## Sa-Token 配置 (文档: https://sa-token.cc) ##############
|
||||
sa-token:
|
||||
# token 名称(同时也是 cookie 名称)
|
||||
token-name: satoken
|
||||
# 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: auth
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
spring:
|
||||
application:
|
||||
name: qing-yu-club-auth
|
||||
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
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--Configuration后面的status,这个用于设置log4j2自身内部的信息输出,可以不设置,当设置成trace时,你会看到log4j2内部各种详细输出-->
|
||||
<!--monitorInterval:Log4j能够自动检测修改配置 文件和重新配置本身,设置间隔秒数-->
|
||||
<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="qing-yuClub.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并引入的appender,appender才会生效-->
|
||||
<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>
|
||||
Reference in New Issue
Block a user