feat(新增): acl服务初始化

This commit is contained in:
bunny 2024-04-01 19:22:38 +08:00
parent 0d1f2260f9
commit 25074b395c
23 changed files with 307 additions and 29 deletions

View File

@ -13,6 +13,7 @@
<file url="file://$PROJECT_DIR$/model/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/model/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/model/src/main/resources-filtered" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/service/service-acl/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/service/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/service/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/service/src/main/resources-filtered" charset="UTF-8" />

View File

@ -49,7 +49,6 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -23,6 +23,11 @@
<artifactId>common-util</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.atguigu</groupId>
<artifactId>model</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- redis -->
<dependency>
@ -50,11 +55,5 @@
<artifactId>mybatis-plus-boot-starter</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atguigu</groupId>
<artifactId>model</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@ -15,7 +15,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
*/
@EnableTransactionManagement
@Configuration
@MapperScan("com.atguigu.ssyx.*.mapper")
@Slf4j
public class MybatisPlusConfig {
/**
@ -23,6 +23,8 @@ public class MybatisPlusConfig {
*/
@Bean
public MybatisPlusInterceptor optimisticLockerInnerInterceptor() {
log.info("注入MybatisPlus配置类...");
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
// 向Mybatis过滤器链中添加分页拦截器
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));

View File

@ -0,0 +1,25 @@
package com.atguigu.ssyx.common.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
@Slf4j
public class WebMvcConfiguration implements WebMvcConfigurer {
/**
* * 解决跨域
*
* @param registry 跨域注册表
*/
@Override
public void addCorsMappings(CorsRegistry registry) {
log.info("WebMvcConfiguration===>开始跨域注册表...");
registry.addMapping("/admin/**")// 添加路径规则
.allowCredentials(true)// 是否允许在跨域的情况下传递Cookie
.allowedOrigins("*")// 允许请求来源的域规则
.allowedMethods("*").allowedHeaders("*");// 允许所有的请求头
}
}

View File

@ -1,24 +1,24 @@
package com.atguigu.ssyx.enums;
import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson.parser.deserializer.EnumDeserializer;
import com.alibaba.fastjson.serializer.EnumSerializer;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.databind.deser.std.EnumDeserializer;
import com.fasterxml.jackson.databind.ser.std.EnumSerializer;
import lombok.Getter;
@JSONType(serializer = EnumSerializer.class, deserializer = EnumDeserializer.class, serializeEnumAsJavaBean = true)
@Getter
public enum BillType {
ORDER(0,"订单佣金"),
WITHDRAW(1,"提现" ),
REFUND(1,"订单退款" );
ORDER(0, "订单佣金"),
WITHDRAW(1, "提现"),
REFUND(1, "订单退款");
@EnumValue
private Integer code ;
private String comment ;
private final Integer code;
private final String comment;
BillType(Integer code, String comment ){
this.code=code;
this.comment=comment;
BillType(Integer code, String comment) {
this.code = code;
this.comment = comment;
}
}

View File

@ -1,23 +1,23 @@
package com.atguigu.ssyx.enums;
import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson.parser.deserializer.EnumDeserializer;
import com.alibaba.fastjson.serializer.EnumSerializer;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.databind.deser.std.EnumDeserializer;
import com.fasterxml.jackson.databind.ser.std.EnumSerializer;
import lombok.Getter;
@JSONType(serializer = EnumSerializer.class, deserializer = EnumDeserializer.class, serializeEnumAsJavaBean = true)
@Getter
public enum UserType {
USER(0,"会员"),
LEADER(1,"团长" );
USER(0, "会员"),
LEADER(1, "团长");
@EnumValue
private Integer code ;
private String comment ;
private final Integer code;
private final String comment;
UserType(Integer code, String comment ){
this.code=code;
this.comment=comment;
UserType(Integer code, String comment) {
this.code = code;
this.comment = comment;
}
}

View File

@ -8,10 +8,13 @@
</parent>
<artifactId>service</artifactId>
<packaging>jar</packaging>
<packaging>pom</packaging>
<name>service</name>
<url>https://maven.apache.org</url>
<modules>
<module>service-acl</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -0,0 +1,21 @@
FROM openjdk:17
MAINTAINER bunny
#系统编码
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
# 设置时区,构建镜像时执行的命令
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo "Asia/Shanghai" > /etc/timezone
# 设定工作目录
WORKDIR /home/bunny
# 复制jar包
COPY target/*.jar /home/bunny/app.jar
#启动容器时的进程
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
#暴露 8080 端口
EXPOSE 8080

View File

@ -0,0 +1,23 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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.atguigu</groupId>
<artifactId>service</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>service-acl</artifactId>
<packaging>jar</packaging>
<name>service-acl</name>
<url>https://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
</dependencies>
</project>

View File

@ -0,0 +1,15 @@
package com.atguigu.ssyx.acl;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan("com.atguigu.ssyx.common")
@MapperScan("com.atguigu.ssyx.*.mapper")
public class ServiceAclApplication {
public static void main(String[] args) {
SpringApplication.run(ServiceAclApplication.class, args);
}
}

View File

@ -0,0 +1,12 @@
package com.atguigu.ssyx.acl.controller;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/admin/acl/user")
@Api(tags = "用户管理")
public class AdminController {
}

View File

@ -0,0 +1,22 @@
package com.atguigu.ssyx.acl.controller;
import com.atguigu.ssyx.common.result.Result;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
@Api(tags = "登录相关管理")
@RestController
@RequestMapping("/admin/acl/index")
public class IndexController {
@PostMapping("login")
public Result<Map<String, Object>> login() {
Map<String, Object> map = new HashMap<>();
map.put("token", "admin-token");
return Result.success(map);
}
}

View File

@ -0,0 +1,10 @@
package com.atguigu.ssyx.acl.mapper;
import com.atguigu.ssyx.model.acl.Admin;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface AdminMapper extends BaseMapper<Admin> {
}

View File

@ -0,0 +1,7 @@
package com.atguigu.ssyx.acl.mapper;
import com.atguigu.ssyx.model.acl.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
public interface RoleMapper extends BaseMapper<Role> {
}

View File

@ -0,0 +1,8 @@
package com.atguigu.ssyx.acl.service;
import com.atguigu.ssyx.model.acl.Admin;
import com.baomidou.mybatisplus.extension.service.IService;
public interface AdminService extends IService<Admin> {
}

View File

@ -0,0 +1,7 @@
package com.atguigu.ssyx.acl.service;
import com.atguigu.ssyx.model.acl.Role;
import com.baomidou.mybatisplus.extension.service.IService;
public interface RoleService extends IService<Role> {
}

View File

@ -0,0 +1,17 @@
package com.atguigu.ssyx.acl.service.impl;
import com.atguigu.ssyx.acl.mapper.AdminMapper;
import com.atguigu.ssyx.acl.service.AdminService;
import com.atguigu.ssyx.model.acl.Admin;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {
@Override
public boolean save(Admin entity) {
return super.save(entity);
}
}

View File

@ -0,0 +1,13 @@
package com.atguigu.ssyx.acl.service.impl;
import com.atguigu.ssyx.acl.mapper.RoleMapper;
import com.atguigu.ssyx.acl.service.RoleService;
import com.atguigu.ssyx.model.acl.Role;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
}

View File

@ -0,0 +1,31 @@
server:
port: 8201
bunny:
datasource:
host: 106.15.251.123
port: 3305
sqlData: shequ-acl
username: root
password: "02120212"
nacos:
server-addr: z-bunny.cn:8848
discovery:
namespace: ssyx
redis:
host: 47.120.65.66
port: 6379
database: 2
password: "02120212"
logging:
level:
com.atguigu.ssyx.acl.mapper: debug
com.atguigu.ssyx.acl.controller: info
com.atguigu.ssyx.acl.service: info
pattern:
dateformat: HH:mm:ss:SSS
file:
path: "logs/${spring.application.name}"

View File

@ -0,0 +1,47 @@
server:
port: 8291
spring:
application:
name: service-acl
profiles:
active: dev
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://${bunny.datasource.host}:${bunny.datasource.port}/${bunny.datasource.sqlData}?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true
username: ${bunny.datasource.username}
password: "${bunny.datasource.password}"
cloud:
sentinel:
log:
dir: logs/${spring.application.name}/sentinel
nacos:
discovery:
namespace: ${bunny.nacos.discovery.namespace}
server-addr: ${bunny.nacos.server-addr}
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
mybatis-plus:
type-aliases-package: com.atguigu.model # 配置每个包前缀
mapper-locations: classpath:mapper/*.xml
configuration:
map-underscore-to-camel-case: true
auto-mapping-behavior: full
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 查看日志
# global-config:
# db-config:
# 设置表名前缀不用在每个tableName添加前缀
# table-prefix: t_
# 全局配置主键值方式
# id-type: assign_id
# 指定逻辑删除-未删除
# logic-not-delete-value: 0 # 未删除默认为0
# 指定逻辑删除-删除
# logic-delete-value: 1 # 删除
# logic-delete-field: deleted # 全局配置逻辑删除

View File

@ -0,0 +1,16 @@
-----------------▄██-█▄---------
-----------------███▄██▄--------
-----------------███████--------
-----------------▀███████-------
-------------------██████▄▄-----
-------------------█████████▄---
-------------------██████▄████--
-------▄███████████████████████-
-----▄███████████████████████▀--
---▄██████████████████████------
---███████████████████████------
---███████████████████████------
-▄▄██████████████████████▀------
-█████████████████▀█████--------
-▀██████████████▀▀-▀█████▄------
-------▀▀▀▀▀▀▀▀▀------▀▀▀▀------

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB