customQuery(@Param("param") String param);`
-- XML in `src/main/resources/mapper/UserMapper.xml`
-
-### Model/Entity Guidelines
-
-**Annotations**:
-- `@TableName("table_name")` - Map to specific table
-- `@TableId(type = IdType.AUTO)` - Primary key with auto-increment
-- `@TableLogic` - Mark logic delete field
-- `@TableField(exist = false)` - Non-database fields (e.g., DTOs, transient data)
-
-**DTO Pattern**:
-- If extending model with non-DB fields (e.g., join queries), prefer creating separate DTO class
-- Alternative: Use `@TableField(exist = false)` on extended fields in Model
-
-**Lombok Support**:
-- All models use: `@Data`, `@EqualsAndHashCode(callSuper = false)`, `@Accessors(chain = true)`
-
-## Key Configuration Files
-
-**Profile-specific configs**:
-- `application.yml` - Base configuration (active profile: dev, server port: 8080)
-- `application-dev.yml` - Development (local MySQL, Redis, multi-datasource setup)
-- `application-test.yml` - Testing environment
-- `application-prod.yml` - Production (knife4j docs disabled)
-
-**Redis Configuration** (`application-dev.yml`):
-```yaml
-redis:
- key.prefix.userToken: "user:token:"
- key.prefix.passwordError: "user:password:error:"
- key.expire.userToken: 604800 # 7 days
- key.expire.passwordError: 3600 # 1 hour
- allowMultipleLogin: false # Single login mode
-```
-
-**MyBatis-Plus Configuration**:
-```yaml
-mybatis-plus:
- configuration.log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
- mapper-locations: classpath:mapper/*.xml
-```
-
-## Development Patterns
-
-### Creating New Endpoints
-
-1. **Generate Code**: Use `CodeGenerator` for table-based CRUD
-2. **Service Layer**: Business logic in `service/impl/`, throw `ServiceException` for errors
-3. **Controller Layer**: REST endpoints in `web/`, use `ResultGenerator` for responses
-4. **Request Validation**: Use `@Valid` on request bodies with validation annotations
-5. **Authentication**: Protected endpoints auto-validated by `LoginInterceptor`
-6. **Get Current User**: `JSONObject session = httpSessionService.getCurrentSession();`
- - Returns: `{"userId": 123, "username": "admin"}`
-
-### Working with Redis
-
-Use `RedisService` for all Redis operations:
-```java
-@Autowired
-private RedisService redisService;
-
-redisService.set(key, value, expireSeconds);
-String value = redisService.get(key);
-boolean exists = redisService.exists(key);
-redisService.remove(key);
-redisService.delKeys(pattern); // Pattern-based deletion
-```
-
-### Custom Exception Handling
-
-Throw `ServiceException` anywhere in service/controller layer:
-```java
-if (user == null) {
- throw new ServiceException("User not found");
-}
-```
-Will automatically return: `{"code": 400, "success": false, "message": "User not found"}`
-
-## Important Files Reference
-
-- `Application.java` - Main entry point, enables mapper scanning
-- `WebMvcConfigurer.java` - Global exception handler, CORS, interceptors
-- `LoginInterceptor.java` - Token validation interceptor
-- `HttpSessionService.java` - Session lifecycle management
-- `RedisService.java` - Redis operations wrapper
-- `UserController.java` - Example auth endpoints (login, register, logout, password change)
-- `CodeGenerator.java` - Code generation tool (in test directory)
-
-## Testing API
-
-**Login Flow**:
-```bash
-# 1. Login
-curl -X POST http://localhost:8080/api/user/login \
- -H "Content-Type: application/json" \
- -d '{"username":"admin","password":"123456"}'
-
-# Response: {"code":200,"data":{"token":"xyz123...#1","username":"admin"}}
-
-# 2. Use token in subsequent requests
-curl -X GET http://localhost:8080/api/user/getById/1 \
- -H "Authorization: xyz123...#1"
-```
-
-**Access Documentation**: http://localhost:8080/doc.html (Knife4j UI with all endpoints)
diff --git a/java_project_template/jun-mybatisplus-api-v2/README.md b/java_project_template/jun-mybatisplus-api-v2/README.md
deleted file mode 100644
index a4be665995..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/README.md
+++ /dev/null
@@ -1,43 +0,0 @@
-## 简介
-Spring Boot API 是一个基于Spring Boot & MyBatis plus的种子项目,用于快速构建中小型API项目,特点稳定、简单、快速,摆脱那些重复劳动
-
-## 特征&提供
-- 统一响应结果封装及生成工具
-- 统一异常处理
-- 采用redis token认证,支持单登陆端/多登陆端登陆
-- 使用Druid Spring Boot Starter 集成Druid数据库连接池与监控
-- 集成MyBatis-Plus,实现单表业务零SQL
-- 支持多数据源,自由切换,只需方法或类上用 @DS 切换数据源
-- 集成国人风格的knife4j,自动生成接口文档
-- 提供代码生成器,生成controller,service,serviceImpl,dao,mapper.xml
-
-## 快速开始
-1. 克隆项目
-2. 导入```test```包里的mysql脚本user.sql
-3. 对```test```包内的代码生成器```CodeGenerator```进行配置,主要是JDBC,因为要根据表名来生成代码
-4. 输入表名,运行```CodeGenerator.main()```方法,生成基础代码(可能需要刷新项目目录才会出来)
-5. 根据业务在基础代码上进行扩展
-6. 对开发环境配置文件```application-dev.yml```进行配置,启动项目,Have Fun!
-
-## 开发建议
-- post调用接口ip:8080/api/user/login,参数json: {"username":"admin","password":"123456"},调用成功后, 返回token。以后调用api接口,header中传token
-- 已写好注册、登陆、登出、修改密码接口, 支持单登陆端/多登陆端登陆, 具体看UserController.java 类。用户登陆之后获取session信息 JSONObject sessionInfo = httpSession.getCurrentSession();
-- 正式环境已禁用接口文档的查看,配置文件添加knife4j:production: true 即可
-- 是否允许多个登陆端,修改配置文件 redis:allowMultipleLogin:true
-- Model内成员变量建议与表字段数量对应,如需扩展成员变量(比如连表查询)建议创建DTO,否则需在扩展的成员变量上加@TableField(exist = false),详见[MyBatis-Plus](https://mp.baomidou.com/guide/)文档说明
-- 建议业务失败直接使用ServiceException("ErrorMessage")抛出,由统一异常处理器来封装业务失败的响应结果,会直接被封装为{"code":400,"message":"ErrorMessage"}返回,尽情抛出;body方式传参,@Valid校验Model,更无需自己处理;
-
-## 接口文档效果图
-
-
-## 相关文档
-- Spring Boot([springboot官方](https://spring.io/projects/spring-boot/))
-- MyBatis-Plus ([查看官方中文文档](https://mp.baomidou.com/guide/))
-- MyBatis-Plus分页插件([查看官方中文文档](https://mp.baomidou.com/guide/page.html))
-- Druid Spring Boot Starter([查看官方中文文档](https://github.com/alibaba/druid/tree/master/druid-spring-boot-starter/))
-- Fastjson([查看官方中文文档](https://github.com/Alibaba/fastjson/wiki/%E9%A6%96%E9%A1%B5))
-- 阿里巴巴Java开发手册[最新版下载](https://github.com/alibaba/p3c)
-其他
-
-## License
-纯粹开源分享,感谢大家 [Star](https://github.com/aitangbao/springboot-api-v2) 的支持。
diff --git a/java_project_template/jun-mybatisplus-api-v2/pom.xml b/java_project_template/jun-mybatisplus-api-v2/pom.xml
deleted file mode 100644
index a581e8039d..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/pom.xml
+++ /dev/null
@@ -1,160 +0,0 @@
-
-
- 4.0.0
-
- com.company.project
- jun-mybatisplus-api-v2
- 1.0
- jar
-
-
- 1.8
- 3.3.0
-
-
-
-
- org.springframework.boot
- spring-boot-starter-parent
- 2.2.2.RELEASE
-
-
-
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-starter-jdbc
-
-
-
- org.springframework.boot
- spring-boot-starter-data-redis
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
- com.baomidou
- dynamic-datasource-spring-boot-starter
- 2.5.5
-
-
- com.baomidou
- mybatis-plus
- ${mybatis-plus.version}
-
-
- com.baomidou
- mybatis-plus-boot-starter
- ${mybatis-plus.version}
-
-
- com.baomidou
- mybatis-plus-generator
- ${mybatis-plus.version}
-
-
- org.projectlombok
- lombok
- 1.18.10
- provided
-
-
-
-
-
- commons-codec
- commons-codec
-
-
- org.apache.commons
- commons-lang3
- 3.6
-
-
-
- mysql
- mysql-connector-java
- runtime
-
-
-
-
- com.alibaba
- fastjson
- 1.2.47
-
-
-
- com.alibaba
- druid-spring-boot-starter
- 1.1.10
-
-
-
- org.freemarker
- freemarker
- 2.3.30
- test
-
-
-
- com.github.xiaoymin
- knife4j-spring-boot-starter
- 2.0.2
-
-
- cn.hutool
- hutool-all
- 5.8.41
- compile
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
- maven-compiler-plugin
-
- ${java.version}
- ${java.version}
- UTF-8
-
-
-
-
-
-
-
- aliyun-repos
- http://maven.aliyun.com/nexus/content/groups/public/
-
- false
-
-
-
-
-
-
- aliyun-plugin
- http://maven.aliyun.com/nexus/content/groups/public/
-
- false
-
-
-
-
-
\ No newline at end of file
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/Application.java b/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/Application.java
deleted file mode 100644
index 2d366a4211..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/Application.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.company.project;
-
-import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
-import org.mybatis.spring.annotation.MapperScan;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.core.env.Environment;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
-
-import java.net.InetAddress;
-
-@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)
-@MapperScan("com.company.project.dao")
-public class Application {
-
- private static Logger logger= LoggerFactory.getLogger(Application.class);
-
- public static void main(String[] args) throws Exception {
-
- ConfigurableApplicationContext application = SpringApplication.run(Application.class, args);
-
- Environment env = application.getEnvironment();
- logger.info("\n----------------------------------------------------------\n\t" +
- "Application '{}' is running! Access URLs:\n\t" +
- "Local: \t\thttp://localhost:{}\n\t" +
- "External: \thttp://{}:{}\n\t" +
- "Doc: \thttp://{}:{}/doc.html\n" +
- "----------------------------------------------------------",
- env.getProperty("spring.application.name"),
- env.getProperty("server.port"),
- InetAddress.getLocalHost().getHostAddress(),
- env.getProperty("server.port"),
- InetAddress.getLocalHost().getHostAddress(),
- env.getProperty("server.port"));
- }
-}
-
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/configurer/LoginInterceptor.java b/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/configurer/LoginInterceptor.java
deleted file mode 100644
index b0d7c2949c..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/configurer/LoginInterceptor.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.company.project.configurer;
-
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.company.project.core.Result;
-import com.company.project.core.ResultCode;
-import com.company.project.service.HttpSessionService;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import java.io.IOException;
-
-/**
- * @author wenbin
- * @since 2019/10/30 15:29
- * 登陆拦截器
- */
-public class LoginInterceptor extends HandlerInterceptorAdapter {
-
- @Autowired
- private HttpSessionService httpSession;
-
- private final Logger logger = LoggerFactory.getLogger(WebMvcConfigurer.class);
-
- @Override
- public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
- //用户当前session信息
- JSONObject currentSession;
- //拦截接口
- //从header中获取token
- String token = request.getHeader("token");
- //如果header中不存在token,则从参数中获取token
- if (StringUtils.isBlank(token)) {
- token = request.getParameter("token");
- }
- //token为空返回
- if (StringUtils.isBlank(token)) {
- Result result = new Result();
- result.setCode(ResultCode.UNAUTHORIZED).setMessage("token不能为空").setSuccess(false);
- responseResult(response, result);
- return false;
- }// 校验并解析token,如果token过期或者篡改,则会返回null
- currentSession = httpSession.getCurrentSession();
- if (null != currentSession) {
- return true;
- } else {
- Result result = new Result();
- result.setCode(ResultCode.UNAUTHORIZED).setMessage("用户未登陆!").setSuccess(false);
- responseResult(response, result);
- return false;
- }
- }
-
-
- private void responseResult(HttpServletResponse response, Result result) {
- response.setCharacterEncoding("UTF-8");
- response.setHeader("Content-type", "application/json;charset=UTF-8");
- try {
- response.getWriter().write(JSON.toJSONString(result));
- } catch (IOException ex) {
- logger.error(ex.getMessage());
- }
- }
-}
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/configurer/MyBatisPlusConfig.java b/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/configurer/MyBatisPlusConfig.java
deleted file mode 100644
index f75a63819c..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/configurer/MyBatisPlusConfig.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.company.project.configurer;
-
-import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * @ClassName MyBatisPlusConfig
- * @Version 1.0
- **/
-@Configuration
-public class MyBatisPlusConfig {
- /**
- * 配置mybatis-plus 分页查件
- * @return
- */
- @Bean
- public PaginationInterceptor paginationInterceptor() {
- PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
- return paginationInterceptor;
- }
-}
\ No newline at end of file
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/configurer/SwaggerConfiguration.java b/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/configurer/SwaggerConfiguration.java
deleted file mode 100644
index d5bca5303f..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/configurer/SwaggerConfiguration.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.company.project.configurer;
-
-import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Import;
-import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
-import springfox.documentation.builders.ApiInfoBuilder;
-import springfox.documentation.builders.PathSelectors;
-import springfox.documentation.builders.RequestHandlerSelectors;
-import springfox.documentation.service.ApiInfo;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
-
-@Configuration
-@EnableSwagger2
-@EnableKnife4j
-@Import(BeanValidatorPluginsConfiguration.class)
-public class SwaggerConfiguration {
-
- @Bean
- public Docket createRestApi() {
- return new Docket(DocumentationType.SWAGGER_2)
- .apiInfo(apiInfo())
- .select()
- .apis(RequestHandlerSelectors.basePackage("com.company.project.web"))
- .paths(PathSelectors.any())
- .build();
- }
-
- private ApiInfo apiInfo() {
- return new ApiInfoBuilder()
- .title("Springboot-api APIs")
- .description("Springboot-api APIs")
- .termsOfServiceUrl("http://localhost:8080/")
- .contact("xxxxxxxxxx@163.com")
- .version("1.0")
- .build();
- }
-}
\ No newline at end of file
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/configurer/WebMvcConfigurer.java b/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/configurer/WebMvcConfigurer.java
deleted file mode 100644
index c960c54e8f..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/configurer/WebMvcConfigurer.java
+++ /dev/null
@@ -1,179 +0,0 @@
-package com.company.project.configurer;
-
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.serializer.SerializerFeature;
-import com.alibaba.fastjson.support.config.FastJsonConfig;
-import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
-
-import com.company.project.core.Result;
-import com.company.project.core.ResultCode;
-import com.company.project.core.ResultGenerator;
-import com.company.project.core.ServiceException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.MediaType;
-import org.springframework.http.converter.HttpMessageConverter;
-import org.springframework.web.bind.MethodArgumentNotValidException;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.method.HandlerMethod;
-import org.springframework.web.servlet.HandlerExceptionResolver;
-import org.springframework.web.servlet.ModelAndView;
-import org.springframework.web.servlet.NoHandlerFoundException;
-import org.springframework.web.servlet.config.annotation.*;
-
-/**
- * Spring MVC 配置
- */
-@Configuration
-public class WebMvcConfigurer extends WebMvcConfigurerAdapter {
-
- private final Logger logger = LoggerFactory.getLogger(WebMvcConfigurer.class);
-
- @Bean
- LoginInterceptor loginInterceptor() {
-
- return new LoginInterceptor();
- }
-
- //使用阿里 FastJson 作为JSON MessageConverter
- @Override
- public void configureMessageConverters(List> converters) {
- FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
- FastJsonConfig config = new FastJsonConfig();
- config.setSerializerFeatures(SerializerFeature.WriteMapNullValue);//保留空的字段
- //SerializerFeature.WriteNullStringAsEmpty,//String null -> ""
- //SerializerFeature.WriteNullNumberAsZero//Number null -> 0
- // 按需配置,更多参考FastJson文档哈
-
- converter.setFastJsonConfig(config);
- converter.setDefaultCharset(Charset.forName("UTF-8"));
- converter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON_UTF8));
- converters.add(converter);
- }
-
-
- //统一异常处理
- @Override
- public void configureHandlerExceptionResolvers(List exceptionResolvers) {
- exceptionResolvers.add(new HandlerExceptionResolver() {
- public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception e) {
- Result result = new Result();
- if (e instanceof ServiceException) {//业务失败的异常,如“账号或密码错误”
- result.setCode(ResultCode.FAIL).setMessage(e.getMessage()).setSuccess(false);
- } else if (e instanceof MethodArgumentNotValidException) {//@valid注解验证参数
- MethodArgumentNotValidException m = (MethodArgumentNotValidException) e;
- m.getBindingResult().getFieldError().getDefaultMessage();
- result.setCode(ResultCode.PARAM_FAIL).setMessage(m.getBindingResult().getFieldError().getDefaultMessage()).setSuccess(false);
- } else if (e instanceof NoHandlerFoundException) {
- result.setCode(ResultCode.NOT_FOUND).setMessage("接口 [" + request.getRequestURI() + "] 不存在").setSuccess(false);
- } else if (e instanceof ServletException) {
- result.setCode(ResultCode.FAIL).setMessage(e.getMessage()).setSuccess(false);
- } else {
- result.setCode(ResultCode.INTERNAL_SERVER_ERROR).setMessage("接口 [" + request.getRequestURI() + "] 内部错误,请联系管理员").setSuccess(false);
- String message;
- if (handler instanceof HandlerMethod) {
- HandlerMethod handlerMethod = (HandlerMethod) handler;
- message = String.format("接口 [%s] 出现异常,方法:%s.%s,异常摘要:%s",
- request.getRequestURI(),
- handlerMethod.getBean().getClass().getName(),
- handlerMethod.getMethod().getName(),
- e.getMessage());
- } else {
- message = e.getMessage();
- }
- logger.error(message, e);
- }
- responseResult(response, result);
- return new ModelAndView();
- }
-
- });
- }
-
- @ExceptionHandler(MethodArgumentNotValidException.class)
- public Result handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
- return ResultGenerator.genFailResult(e.getBindingResult().getFieldError().getDefaultMessage());
- }
-
- /**
- * 页面跨域访问Controller过滤
- *
- * @return
- */
- @Override
- public void addCorsMappings(CorsRegistry registry) {
- WebMvcConfigurer.super.addCorsMappings(registry);
- registry.addMapping("/**")
- .allowedHeaders("*")
- .allowedMethods("POST","GET")
- .allowedOrigins("*");
- }
-
- //添加拦截器
- @Override
- public void addInterceptors(InterceptorRegistry registry) {
- registry.addInterceptor(loginInterceptor())
- .excludePathPatterns("/doc.html")
- .excludePathPatterns("/swagger-resources/**")
- .excludePathPatterns("/error")
- .excludePathPatterns("/webjars/**")
- .excludePathPatterns("/api/user/login")
- .excludePathPatterns("/api/user/register")
- .addPathPatterns("/**");
- }
-
-
- private void responseResult(HttpServletResponse response, Result result) {
- response.setCharacterEncoding("UTF-8");
- response.setHeader("Content-type", "application/json;charset=UTF-8");
- response.setStatus(200);
- try {
- response.getWriter().write(JSON.toJSONString(result));
- } catch (IOException ex) {
- logger.error(ex.getMessage());
- }
- }
-
- /**
- * 发现如果继承了WebMvcConfigurationSupport,则在yml中配置的相关内容会失效。 需要重新指定静态资源
- *
- * @param registry
- */
- @Override
- public void addResourceHandlers(ResourceHandlerRegistry registry) {
- registry.addResourceHandler("/**").addResourceLocations(
- "classpath:/static/");
- registry.addResourceHandler("doc.html").addResourceLocations(
- "classpath:/META-INF/resources/");
- registry.addResourceHandler("/webjars/**").addResourceLocations(
- "classpath:/META-INF/resources/webjars/");
- super.addResourceHandlers(registry);
- }
-
-
- /**
- * 配置servlet处理
- */
- @Override
- public void configureDefaultServletHandling(
- DefaultServletHandlerConfigurer configurer) {
- configurer.enable();
- }
-
-
-
-
-}
-
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/core/ApplicationContextUtil.java b/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/core/ApplicationContextUtil.java
deleted file mode 100644
index 8121fb4b4b..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/core/ApplicationContextUtil.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.company.project.core;
-
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.stereotype.Component;
-
-/**
- * @className: ApplicationContextUtil
- * @Description: 解决定时任务获取不到service的问题
- * @Author moneylee
- * @Date 2019-05-11 14:28
- * @Version 1.0
- **/
-@Component
-public class ApplicationContextUtil implements ApplicationContextAware {
-
- private static ApplicationContext applicationContext;
-
- public static ApplicationContext getApplicationContext() {
- return applicationContext;
- }
-
-
- @Override
- public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
- ApplicationContextUtil.applicationContext = applicationContext;
-
- }
-
- public static Object getBean(String beanName) {
- return applicationContext.getBean(beanName);
- }
-
-}
\ No newline at end of file
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/core/Result.java b/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/core/Result.java
deleted file mode 100644
index b208a52ae2..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/core/Result.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package com.company.project.core;
-
-import com.alibaba.fastjson.JSON;
-
-/**
- * 统一API响应结果封装
- */
-public class Result {
- private int code;
- private String message;
- private T data;
- private Boolean success;
-
- public Result setCode(ResultCode resultCode) {
- this.code = resultCode.code();
- return this;
- }
-
- public int getCode() {
- return code;
- }
-
- public String getMessage() {
- return message;
- }
-
- public Result setMessage(String message) {
- this.message = message;
- return this;
- }
-
- public T getData() {
- return data;
- }
-
- public Result setData(T data) {
- this.data = data;
- return this;
- }
-
- public Boolean getSuccess() {
- return success;
- }
-
- public Result setSuccess(Boolean success) {
- this.success = success;
- return this;
- }
-
- @Override
- public String toString() {
- return JSON.toJSONString(this);
- }
-}
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/core/ResultCode.java b/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/core/ResultCode.java
deleted file mode 100644
index 651c04d826..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/core/ResultCode.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.company.project.core;
-
-/**
- * 响应码枚举,参考HTTP状态码的语义
- */
-public enum ResultCode {
- SUCCESS(200),//成功
- FAIL(400),//失败
- UNAUTHORIZED(401),//未认证(签名错误)
- NOT_FOUND(404),//接口不存在
- INTERNAL_SERVER_ERROR(500),//服务器内部错误
- PARAM_FAIL(10001);//参数异常
-
- private final int code;
-
- ResultCode(int code) {
- this.code = code;
- }
-
- public int code() {
- return code;
- }
-}
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/core/ResultGenerator.java b/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/core/ResultGenerator.java
deleted file mode 100644
index de79f955e9..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/core/ResultGenerator.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.company.project.core;
-
-/**
- * 响应结果生成工具
- */
-public class ResultGenerator {
- private static final String DEFAULT_SUCCESS_MESSAGE = "SUCCESS";
-
- public static Result genSuccessResult() {
- return new Result()
- .setSuccess(true)
- .setCode(ResultCode.SUCCESS)
- .setMessage(DEFAULT_SUCCESS_MESSAGE);
- }
-
- public static Result genSuccessResult(T data) {
- return new Result()
- .setSuccess(true)
- .setCode(ResultCode.SUCCESS)
- .setMessage(DEFAULT_SUCCESS_MESSAGE)
- .setData(data);
- }
-
- public static Result genFailResult(String message) {
- return new Result()
- .setSuccess(false)
- .setCode(ResultCode.FAIL)
- .setMessage(message);
- }
-}
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/core/ServiceException.java b/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/core/ServiceException.java
deleted file mode 100644
index e698bce9da..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/core/ServiceException.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.company.project.core;
-
-/**
- * 服务(业务)异常如“ 账号或密码错误 ”,该异常只做INFO级别的日志记录 @see WebMvcConfigurer
- */
-public class ServiceException extends RuntimeException {
- public ServiceException() {
- }
-
- public ServiceException(String message) {
- super(message);
- }
-
- public ServiceException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/dao/UserMapper.java b/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/dao/UserMapper.java
deleted file mode 100644
index f731dd72d1..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/dao/UserMapper.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.company.project.dao;
-
-import com.company.project.model.User;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-
-/**
- *
- * Mapper 接口
- *
- *
- * @author project
- * @since 2020-01-08
- */
-public interface UserMapper extends BaseMapper {
-
-}
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/model/User.java b/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/model/User.java
deleted file mode 100644
index ccb159e35c..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/model/User.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package com.company.project.model;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableLogic;
-import java.io.Serializable;
-import java.util.Date;
-
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-import javax.validation.constraints.NotEmpty;
-
-/**
- *
- *
- *
- *
- * @author project
- * @since 2020-01-08
- */
-@Data
-@EqualsAndHashCode(callSuper = false)
-@Accessors(chain = true)
-public class User implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * 主键
- */
- @TableId(value = "id", type = IdType.AUTO)
- private Integer id;
-
- /**
- * 用户名
- */
- @NotEmpty(message = "用户名不能为空!")
- private String username;
-
- /**
- * 密码
- */
- @NotEmpty(message = "密码不能为空!")
- private String password;
-
- /**
- * 昵称
- */
- private String nickName;
-
- /**
- * 性别
- */
- private Integer sex;
-
- /**
- * 创建时间
- */
- private Date createDate;
-
- /**
- * 创建人
- */
- private Integer createUser;
-
- /**
- * 修改时间
- */
- private Date updateDate;
-
- /**
- * 修改人
- */
- private Integer updateUser;
-
- /**
- * 删除标志0未删 1删除
- */
- @TableLogic
- private Integer delFlag;
-
- /**
- * 登陆返回token
- */
- @TableField(exist = false)
- private String token;
-
-}
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/service/HttpSessionService.java b/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/service/HttpSessionService.java
deleted file mode 100644
index c28c14b817..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/service/HttpSessionService.java
+++ /dev/null
@@ -1,148 +0,0 @@
-package com.company.project.service;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.company.project.model.User;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.Random;
-
-/**
- * session管理器
- *
- * @author aitangbao
- */
-@Service
-public class HttpSessionService {
-
- @Autowired
- private RedisService redisDB;
-
- @Autowired
- private HttpServletRequest request;
-
- @Value("${redis.key.prefix.userToken}")
- private String USER_TOKEN_PREFIX;
-
- @Value("${redis.key.expire.userToken}")
- private int EXPIRE ;
-
- public String createTokenAndUser(User user) {
- //方便根据id找到redis的key, 修改密码/退出登陆 方便使用
- String token = getRandomToken(32) + "#" + user.getId();
- JSONObject sessionInfo = new JSONObject();
- sessionInfo.put("userId", user.getId());
- sessionInfo.put("username", user.getUsername());
- String key = USER_TOKEN_PREFIX + token;
- //设置该用户已登录的token
- redisDB.setAndExpire(key, sessionInfo.toJSONString(), EXPIRE);
- return token;
- }
-
- /**
- * 根据token获取userid
- *
- * @param token
- * @return
- */
- public static String getUserIdByToken(String token) {
- if (StringUtils.isBlank(token) || !token.contains("#")) {
- return "";
- } else {
- return token.substring(token.indexOf("#") + 1);
- }
- }
-
- /**
- * 获取参数中的token
- *
- * @return
- */
- public String getTokenFromHeader() {
- String token = request.getHeader("token");
- //如果header中不存在token,则从参数中获取token
- if (StringUtils.isBlank(token)) {
- token = request.getParameter("token");
- }
- return token;
- }
-
- /**
- * 获取当前session信息
- *
- * @return
- */
- public JSONObject getCurrentSession() {
- String token = getTokenFromHeader();
- if (null != token) {
- if (redisDB.exists(USER_TOKEN_PREFIX + token)) {
- String sessionInfoStr = redisDB.get(USER_TOKEN_PREFIX + token);
- JSONObject sessionInfo = JSON.parseObject(sessionInfoStr);
- return sessionInfo;
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
-
- /**
- * 使当前用户的token失效
- */
- public void abortUserByToken() {
- String token = getTokenFromHeader();
- redisDB.del(USER_TOKEN_PREFIX + token);
- }
-
- /**
- * 使所有用户的token失效
- */
- public void abortAllUserByToken() {
- String token = getTokenFromHeader();
- String userId = getUserIdByToken(token);
- redisDB.delKeys(USER_TOKEN_PREFIX+"*#" + userId);
- }
-
- /**
- * 使用户的token失效
- */
- public void abortUserByUserId(Integer userId) {
- redisDB.delKeys(USER_TOKEN_PREFIX+"*#" + userId);
- }
-
-
- /**
- * 生成随机的token
- *
- * @param length
- * @return
- */
- private String getRandomToken(int length) {
- Random random = new Random();
- StringBuilder randomStr = new StringBuilder();
-
- // 根据length生成相应长度的随机字符串
- for (int i = 0; i < length; i++) {
- String charOrNum = random.nextInt(2) % 2 == 0 ? "char" : "num";
-
- //输出字母还是数字
- if ("char".equalsIgnoreCase(charOrNum)) {
- //输出是大写字母还是小写字母
- int temp = random.nextInt(2) % 2 == 0 ? 65 : 97;
- randomStr.append((char) (random.nextInt(26) + temp));
- } else if ("num".equalsIgnoreCase(charOrNum)) {
- randomStr.append(String.valueOf(random.nextInt(10)));
- }
- }
-
- return randomStr.toString();
- }
-
-
-}
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/service/IUserService.java b/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/service/IUserService.java
deleted file mode 100644
index 97ab829ead..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/service/IUserService.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.company.project.service;
-
-import com.company.project.core.Result;
-import com.company.project.model.User;
-import com.baomidou.mybatisplus.extension.service.IService;
-
-/**
- *
- * 服务类
- *
- *
- * @author project
- * @since 2020-01-08
- */
-public interface IUserService extends IService {
-
- Result checkPassword(User userParam);
-}
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/service/RedisService.java b/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/service/RedisService.java
deleted file mode 100644
index 238e4bee99..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/service/RedisService.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package com.company.project.service;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.StringRedisTemplate;
-import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
-
-import java.util.Date;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-
-/**
- * @author : aitangbao
- */
-
-@Service
-public class RedisService {
- @Autowired
- private StringRedisTemplate redisTemplate;
-
- public boolean exists(String key) {
- return this.redisTemplate.hasKey(key);
- }
-
- public String get(String key) {
- String value = this.redisTemplate.opsForValue().get(key);
- return value;
- }
-
-
- public void del(String key) {
- if (this.exists(key)) {
- this.redisTemplate.delete(key);
- }
-
- }
-
- public void setAndExpire(String key, String value, int seconds) {
- this.redisTemplate.opsForValue().set(key, value);
- this.redisTemplate.expire(key, (long) seconds, TimeUnit.SECONDS);
- }
-
-
- public void setExpire(String key, Date endTime) {
- long seconds = endTime.getTime() - (new Date()).getTime();
- this.redisTemplate.expire(key, (long) ((int) (seconds / 1000L)), TimeUnit.SECONDS);
- }
-
-
- public Set keys(String pattern) {
- return redisTemplate.keys("*" + pattern);
- }
-
- public void delKeys(String pattern) {
- Set keys = redisTemplate.keys(pattern);
- if (!CollectionUtils.isEmpty(keys)) {
- this.redisTemplate.delete(keys);
- }
- }
-}
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/service/impl/UserServiceImpl.java b/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/service/impl/UserServiceImpl.java
deleted file mode 100644
index 67f595f402..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/service/impl/UserServiceImpl.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package com.company.project.service.impl;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.company.project.core.Result;
-import com.company.project.core.ResultGenerator;
-import com.company.project.model.User;
-import com.company.project.dao.UserMapper;
-import com.company.project.service.IUserService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.company.project.service.RedisService;
-import com.company.project.utils.MD5Utils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
-
-/**
- *
- * 服务实现类
- *
- *
- * @author project
- * @since 2020-01-08
- */
-@Service
-public class UserServiceImpl extends ServiceImpl implements IUserService {
-
- @Autowired
- private UserMapper userMapper;
-
-
- @Autowired
- private RedisService redis;
- @Value("${redis.key.prefix.passwordError}")
- private String PASSWORD_ERROR_PREFIX;
- @Value("${redis.key.expire.passwordError}")
- private int PASSWORD_ERROR_EXPIRE;
-
- @Override
- public Result checkPassword(User userParam) {
-
- String username = userParam.getUsername();
- String password = userParam.getPassword();
- //redis key
- String redisPasswordErrorKey = PASSWORD_ERROR_PREFIX + username;
- //判断账户是否锁定
- String errorCount = redis.get(redisPasswordErrorKey);
- if (errorCount != null && Integer.parseInt(errorCount) == 5) {
- return ResultGenerator.genFailResult("密码连续错误5次,请1小时后重试");
- }
- //根据用户名获取用户信息
- QueryWrapper queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("username", username);
- User user = userMapper.selectOne(queryWrapper);
- if (user == null) {
- return ResultGenerator.genFailResult("账号未找到");
- }
-
- if (!MD5Utils.Encrypt(password, true).equals(user.getPassword())) {
- if (errorCount == null) {
- errorCount = "1";
- } else {
- errorCount = String.valueOf(Integer.parseInt(errorCount) + 1);
- }
- redis.setAndExpire(redisPasswordErrorKey, errorCount, PASSWORD_ERROR_EXPIRE);
- if ("5".equals(errorCount)) {
- return ResultGenerator.genFailResult("密码连续错误5次,请1小时后重试");
- } else {
- return ResultGenerator.genFailResult("密码错误,剩余次数" + (5 - Integer.parseInt(errorCount)));
- }
- } else {
- //登录成功删除错误登录次数
- redis.del(redisPasswordErrorKey);
- return ResultGenerator.genSuccessResult(user);
- }
- }
-}
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/utils/ImageCodeUtil.java b/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/utils/ImageCodeUtil.java
deleted file mode 100644
index d87c21e8c2..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/utils/ImageCodeUtil.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package com.company.project.utils;
-
-import cn.hutool.log.StaticLog;
-import lombok.extern.slf4j.Slf4j;
-
-import javax.imageio.ImageIO;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.util.Random;
-
-@Slf4j
-public class ImageCodeUtil {
-
-
- public static final String IMAGE_RANDOM_CODEKEY = "RANDOMVALIDATECODEKEY";//放到session中的key
- private String randString = "0123456789";//随机产生只有数字的字符串 private String
- //private String randString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";//随机产生只有字母的字符串
- //private String randString = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";//随机产生数字与字母组合的字符串
- private int width = 95;// 图片宽
- private int height = 25;// 图片高
- private int lineSize = 40;// 干扰线数量
- private int stringNum = 4;// 随机产生字符数量
-
-
- private Random random = new Random();
-
- /**
- * 获得字体
- */
- private Font getFont() {
- return new Font("Fixedsys", Font.CENTER_BASELINE, 18);
- }
-
- /**
- * 获得颜色
- */
- private Color getRandColor(int fc, int bc) {
- if (fc > 255)
- fc = 255;
- if (bc > 255)
- bc = 255;
- int r = fc + random.nextInt(bc - fc - 16);
- int g = fc + random.nextInt(bc - fc - 14);
- int b = fc + random.nextInt(bc - fc - 18);
- return new Color(r, g, b);
- }
-
- /**
- * 生成随机图片
- */
- public void getRandcode(HttpServletRequest request, HttpServletResponse response) {
- HttpSession session = request.getSession();
- // BufferedImage类是具有缓冲区的Image类,Image类是用于描述图像信息的类
- BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
- Graphics g = image.getGraphics();// 产生Image对象的Graphics对象,改对象可以在图像上进行各种绘制操作
- g.fillRect(0, 0, width, height);//图片大小
- g.setFont(new Font("Times New Roman", Font.ROMAN_BASELINE, 18));//字体大小
- g.setColor(getRandColor(110, 133));//字体颜色
- // 绘制干扰线
- for (int i = 0; i <= lineSize; i++) {
- drowLine(g);
- }
- // 绘制随机字符
- String randomString = "";
- for (int i = 1; i <= stringNum; i++) {
- randomString = drowString(g, randomString, i);
- }
- StaticLog.info(randomString);
- //将生成的随机字符串保存到session中
- session.removeAttribute(IMAGE_RANDOM_CODEKEY);
- session.setAttribute(IMAGE_RANDOM_CODEKEY, randomString);
- g.dispose();
- try {
- // 将内存中的图片通过流动形式输出到客户端
- ImageIO.write(image, "JPEG", response.getOutputStream());
- } catch (Exception e) {
- StaticLog.error("将内存中的图片通过流动形式输出到客户端失败>>>> ", e);
- }
-
- }
-
- /**
- * 绘制字符串
- */
- private String drowString(Graphics g, String randomString, int i) {
- g.setFont(getFont());
- g.setColor(new Color(random.nextInt(101), random.nextInt(111), random
- .nextInt(121)));
- String rand = String.valueOf(getRandomString(random.nextInt(randString
- .length())));
- randomString += rand;
- g.translate(random.nextInt(3), random.nextInt(3));
- g.drawString(rand, 13 * i, 16);
- return randomString;
- }
-
- /**
- * 绘制干扰线
- */
- private void drowLine(Graphics g) {
- int x = random.nextInt(width);
- int y = random.nextInt(height);
- int xl = random.nextInt(13);
- int yl = random.nextInt(15);
- g.drawLine(x, y, x + xl, y + yl);
- }
-
- /**
- * 获取随机的字符
- */
- public String getRandomString(int num) {
- return String.valueOf(randString.charAt(num));
- }
-}
\ No newline at end of file
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/utils/MD5Utils.java b/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/utils/MD5Utils.java
deleted file mode 100644
index c7a3dff75c..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/utils/MD5Utils.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package com.company.project.utils;
-
-import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
-
-public class MD5Utils {
-
- private static String salt = "springboot_api";
-
- /**
- * 加密字符串
- * @param password 要加密的明文
- * @param isAddSalt 是否加默认盐
- * @return 加密之后的结果
- */
- public static String Encrypt(String password, boolean isAddSalt){
- if (StringUtils.isNotEmpty(password)){
- if (isAddSalt){
- return DigestUtils.md5Hex(DigestUtils.md5(password + salt));
- } else {
- return DigestUtils.md5Hex(DigestUtils.md5(password));
- }
- }
- return null;
- }
-
- /**
- *
- * @param bytes
- * @return
- */
- public static String Encrypt(byte[] bytes){
- if (ArrayUtils.isNotEmpty(bytes)){
- return DigestUtils.md5Hex(DigestUtils.md5(bytes));
- }
- return null;
- }
-
- /**
- * MD5加盐加密
- * @param password 要加密的明文
- * @param salt 盐
- * @return 加密之后的结果
- */
- public static String Encrypt(String password, String salt){
- if (StringUtils.isNotEmpty(password)){
- return DigestUtils.md5Hex(DigestUtils.md5(password + salt));
- }
- return null;
- }
-
- public static void main(String[] args){
- System.out.println(MD5Utils.Encrypt("admin", true));
- }
-}
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/web/UserController.java b/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/web/UserController.java
deleted file mode 100644
index 48aa0249b6..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/java/com/company/project/web/UserController.java
+++ /dev/null
@@ -1,203 +0,0 @@
-package com.company.project.web;
-
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.company.project.core.Result;
-import com.company.project.core.ResultGenerator;
-import com.company.project.service.HttpSessionService;
-import com.company.project.utils.MD5Utils;
-import com.company.project.utils.ImageCodeUtil;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.web.bind.annotation.*;
-import com.company.project.service.IUserService;
-import com.company.project.model.User;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import javax.validation.Valid;
-
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- *
- * 前端控制器
- *
- *
- * @author project
- * @since 2020-01-08
- */
-@Slf4j
-@RestController
-@RequestMapping("/api/user")
-public class UserController {
-
- @Resource
- private IUserService userService;
- @Autowired
- private HttpSessionService httpSession;
-
- @Value("${redis.allowMultipleLogin}")
- private Boolean allowMultipleLogin;
-
- @ApiOperation("登陆")
- @PostMapping("/login")
- public Result login(@RequestBody @Valid User userParam) {
-
- //校验密码,5次错误锁定账户
- Result result = userService.checkPassword(userParam);
- if (!result.getSuccess()) {
- return result;
- }
- //成功之后返回user
- User user = (User)result.getData();
-
- //是否删除之前token, 此处控制是否支持多登陆端;
- // true:允许多处登陆; false:只能单处登陆,顶掉之前登陆
- if (!allowMultipleLogin) {
- httpSession.abortUserByUserId(user.getId());
- }
-
- //生成token
- String token = httpSession.createTokenAndUser(user);
-
- Map resultMap = new HashMap<>(2);
- resultMap.put("token", token);
- resultMap.put("username", userParam.getUsername());
- return ResultGenerator.genSuccessResult(resultMap);
- }
-
- @ApiOperation("注册")
- @PostMapping("/register")
- public Result register(@RequestBody @Valid User user) {
- QueryWrapper queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("username", user.getUsername());
- User userO = userService.getOne(queryWrapper);
- if (userO != null) {
- return ResultGenerator.genFailResult("账号已存在");
- }
- user.setPassword(MD5Utils.Encrypt(user.getPassword(), true));
- userService.save(user);
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation("修改密码")
- @PostMapping("/updatePassword")
- public Result updatePassword(@RequestBody JSONObject param) {
- String oldPassword = param.getString("oldPassword");
- String newPassword = param.getString("newPassword");
- if (StringUtils.isBlank(oldPassword) || StringUtils.isBlank(newPassword)) {
- return ResultGenerator.genFailResult("密码不能为空");
- }
- //获取登陆信息
- JSONObject sessionInfo = httpSession.getCurrentSession();
- String userId = sessionInfo.getString("userId");
-
- User user = userService.getById(userId);
- if (user == null) {
- return ResultGenerator.genFailResult("账号未找到");
- }
- if (!MD5Utils.Encrypt(oldPassword, true).equals(user.getPassword())) {
- return ResultGenerator.genFailResult("旧密码错误");
- }
- User updateUser = new User();
- updateUser.setId(user.getId());
- updateUser.setPassword(MD5Utils.Encrypt(newPassword, true));
- userService.updateById(updateUser);
-
- //重置密码后删除原所有token
- httpSession.abortAllUserByToken();
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation("登出")
- @GetMapping("/logout")
- public Result logout() {
- //退出删除token
- httpSession.abortUserByToken();
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation("校验token是否有效")
- @GetMapping("/validateToken")
- public Result validateToken() {
- //拦截器拦截已判断,直接返回成功
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation(value = "删除")
- @PostMapping("delete/{id}")
- public Result delete(@PathVariable("id") Long id) {
- userService.removeById(id);
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation(value = "更新")
- @PostMapping("update")
- public Result update(@RequestBody User user) {
- //密码不更新
- user.setPassword(null);
- userService.updateById(user);
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation(value = "查询分页数据")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "currentPage", value = "页码"),
- @ApiImplicitParam(name = "pageCount", value = "每页条数")
- })
- @GetMapping("listByPage")
- public Result findListByPage(@RequestParam(defaultValue = "1") Integer currentPage,
- @RequestParam(defaultValue = "10") Integer pageCount) {
- Page page = new Page(currentPage, pageCount);
- IPage iPage = userService.page(page);
- return ResultGenerator.genSuccessResult(iPage);
- }
-
- @ApiOperation(value = "id查询")
- @GetMapping("getById/{id}")
- public Result findById(@PathVariable Long id) {
- return ResultGenerator.genSuccessResult(userService.getById(id));
- }
-
- @ApiOperation(value = "生成验证码")
- @GetMapping(value = "/getVerify")
- public void getVerify(HttpServletRequest request, HttpServletResponse response) {
- response.setContentType("image/jpeg");//设置相应类型,告诉浏览器输出的内容为图片
- response.setHeader("Pragma", "No-cache");//设置响应头信息,告诉浏览器不要缓存此内容
- response.setHeader("Cache-Control", "no-cache");
- response.setDateHeader("Expire", 0);
- try {
- ImageCodeUtil randomValidateCode = new ImageCodeUtil();
- randomValidateCode.getRandcode(request, response);//输出验证码图片方法
- } catch (Exception e) {
- log.error("生成验证码失败");
- }
- }
-
- @ApiOperation(value = "校验验证码")
- @PostMapping(value = "/checkVerify")
- public Result checkVerify(@RequestParam String imageCode, HttpSession session) {
- //从session中获取随机数
- Object random = session.getAttribute(ImageCodeUtil.IMAGE_RANDOM_CODEKEY);
- if (random != null && String.valueOf(random).equals(imageCode)) {
- return ResultGenerator.genSuccessResult();
- }
- return ResultGenerator.genFailResult("校验失败");
- }
-
-
-}
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/resources/application-dev.yml b/java_project_template/jun-mybatisplus-api-v2/src/main/resources/application-dev.yml
deleted file mode 100644
index b16e34f2cd..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/resources/application-dev.yml
+++ /dev/null
@@ -1,53 +0,0 @@
-# 开发环境配置
-spring:
- datasource:
- dynamic:
- primary: master #设置默认的数据源或者数据源组,默认值即为master
- datasource:
- master:
- username: root
- password: 123456
- driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://localhost:3306/project?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2b8
- slave_1:
- username: root
- password: 123456
- driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://xx.xx.xx.xx:3307/dynamic?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2b8
- slave_2:
- username: root
- password: 123456
- driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://xx.xx.xx.xx:3308/dynamic?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2b8
- #......省略
- #以上会配置一个默认库master,一个组slave下有两个子库slave_1,slave_2
-
-redis:
- key:
- prefix:
- userToken: "user:token:"
- passwordError: "user:password:error:"
- expire:
- userToken: 604800 # 7天 7*24*3600
- passwordError: 3600 # 一个小时
- allowMultipleLogin: false # 允许多处登陆
- host: localhost # Redis服务器地址
- database: 0 # Redis数据库索引(默认为0)
- port: 6379 # Redis服务器连接端口
- password: # Redis服务器连接密码(默认为空)
- jedis:
- pool:
- max-active: 8 # 连接池最大连接数(使用负值表示没有限制)
- max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
- max-idle: 8 # 连接池中的最大空闲连接
- min-idle: 0 # 连接池中的最小空闲连接
- timeout: 3000ms # 连接超时时间(毫秒
-
-mybatis-plus:
- configuration:
- log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
- mapper-locations: classpath:mapper/*.xml
- global-config:
- db-config:
- logic-delete-value: 1
- logic-not-delete-value: 0
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/resources/application-prod.yml b/java_project_template/jun-mybatisplus-api-v2/src/main/resources/application-prod.yml
deleted file mode 100644
index 27cc9a1df0..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/resources/application-prod.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-# 生产环境配置
-
-knife4j:
- production: true #生成环境禁用查看文档
\ No newline at end of file
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/resources/application-test.yml b/java_project_template/jun-mybatisplus-api-v2/src/main/resources/application-test.yml
deleted file mode 100644
index 287da7b20e..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/resources/application-test.yml
+++ /dev/null
@@ -1 +0,0 @@
-# 测试环境配置
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/resources/application.yml b/java_project_template/jun-mybatisplus-api-v2/src/main/resources/application.yml
deleted file mode 100644
index facce6d372..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/resources/application.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-spring:
- profiles:
- active: dev
- mvc:
- throw-exception-if-no-handler-found: true
- resources:
- add-mappings: false
- application:
- name: Springboot-api
- jackson:
- date-format: yyyy-MM-dd HH:mm:ss
- time-zone: GMT+8
-server:
- port: 8080
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/resources/banner.txt b/java_project_template/jun-mybatisplus-api-v2/src/main/resources/banner.txt
deleted file mode 100644
index 152e179398..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/resources/banner.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-////////////////////////////////////////////////////////////////////
-// _ooOoo_ //
-// o8888888o //
-// 88" . "88 //
-// (| ^_^ |) //
-// O\ = /O //
-// ____/`---'\____ //
-// .' \\| |// `. //
-// / \\||| : |||// \ //
-// / _||||| -:- |||||- \ //
-// | | \\\ - /// | | //
-// | \_| ''\---/'' | | //
-// \ .-\__ `-` ___/-. / //
-// ___`. .' /--.--\ `. . ___ //
-// ."" '< `.___\_<|>_/___.' >'"". //
-// | | : `- \`.;`\ _ /`;.`/ - ` : | | //
-// \ \ `-. \_ __\ /__ _/ .-` / / //
-// ========`-.____`-.___\_____/___.-`____.-'======== //
-// `=---=' //
-// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
-// 佛祖保佑 永不宕机 永无BUG //
-////////////////////////////////////////////////////////////////////
\ No newline at end of file
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/main/resources/mapper/UserMapper.xml b/java_project_template/jun-mybatisplus-api-v2/src/main/resources/mapper/UserMapper.xml
deleted file mode 100644
index 87ab7e4161..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/main/resources/mapper/UserMapper.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- id, username, password, nick_name, sex, create_date, create_user, update_date, update_user, del_flag
-
-
-
\ No newline at end of file
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/test/java/CodeGenerator.java b/java_project_template/jun-mybatisplus-api-v2/src/test/java/CodeGenerator.java
deleted file mode 100644
index 027a50e707..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/test/java/CodeGenerator.java
+++ /dev/null
@@ -1,113 +0,0 @@
-import com.baomidou.mybatisplus.core.toolkit.StringPool;
-import com.baomidou.mybatisplus.generator.AutoGenerator;
-import com.baomidou.mybatisplus.generator.InjectionConfig;
-import com.baomidou.mybatisplus.generator.config.*;
-import com.baomidou.mybatisplus.generator.config.po.TableInfo;
-import com.baomidou.mybatisplus.generator.config.rules.DateType;
-import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
-import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
-
-import java.util.ArrayList;
-import java.util.List;
-
-// 演示例子,执行 main 方法控制台输入模块表名回车自动生成对应项目目录中
-public class CodeGenerator {
-
-
- //多个表逗号分隔
- static String tableName = "biz_mail";
- //逻辑删除字段名, 假如表没有逻辑删除字段,请忽视
- static String logicDeleteFieldName = "del_flag";
-
- public static void main(String[] args) {
- // 代码生成器
- AutoGenerator mpg = new AutoGenerator();
-
- // 全局配置
- GlobalConfig gc = new GlobalConfig();
- String projectPath = System.getProperty("user.dir");
- gc.setOutputDir(projectPath + "/src/main/java");
- gc.setAuthor("wujun");
- gc.setOpen(false);
- gc.setBaseColumnList(true);
- gc.setBaseResultMap(true);
- gc.setDateType(DateType.ONLY_DATE);
- // gc.setSwagger2(true); 实体属性 Swagger2 注解
- mpg.setGlobalConfig(gc);
-
- // 数据源配置
- DataSourceConfig dsc = new DataSourceConfig();
- dsc.setUrl("jdbc:mysql://localhost:3307/db_test?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=UTC");
- // dsc.setSchemaName("public");
- dsc.setDriverName("com.mysql.cj.jdbc.Driver");
- dsc.setUsername("root");
- dsc.setPassword("mysqladmin");
- mpg.setDataSource(dsc);
-
- // 包配置
- PackageConfig pc = new PackageConfig();
- pc.setParent("com.company.project");
- pc.setEntity("model");
- pc.setMapper("dao");
- pc.setController("web");
- mpg.setPackageInfo(pc);
-
- // 自定义配置
- InjectionConfig cfg = new InjectionConfig() {
- @Override
- public void initMap() {
- // to do nothing
- }
- };
-
- // 如果模板引擎是 freemarker
- String templatePath = "/templates/mapper.xml.ftl";
- // 如果模板引擎是 velocity
- // String templatePath = "/templates/mapper.xml.vm";
-
- // 自定义输出配置
- List focList = new ArrayList<>();
- // 自定义配置会被优先输出
- focList.add(new FileOutConfig(templatePath) {
- @Override
- public String outputFile(TableInfo tableInfo) {
- // 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
- return projectPath + "/src/main/resources/mapper/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
- }
- });
- cfg.setFileOutConfigList(focList);
- mpg.setCfg(cfg);
-
- // 配置模板
- TemplateConfig templateConfig = new TemplateConfig();
-
- // 配置自定义输出模板
- //指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别
-// templateConfig.setEntity("templates/entity.java");
- // templateConfig.setService();
- templateConfig.setController("templates/controller.java");
-
- templateConfig.setXml(null);
- mpg.setTemplate(templateConfig);
-
- // 策略配置
- StrategyConfig strategy = new StrategyConfig();
- strategy.setNaming(NamingStrategy.underline_to_camel);
- strategy.setColumnNaming(NamingStrategy.underline_to_camel);
-// strategy.setSuperEntityClass("你自己的父类实体,没有就不用设置!");
- strategy.setEntityLombokModel(true);
- strategy.setRestControllerStyle(true);
- // 公共父类
-// strategy.setSuperControllerClass("你自己的父类控制器,没有就不用设置!");
- // 写于父类中的公共字段
-// strategy.setSuperEntityColumns("id");
- strategy.setInclude(tableName.split(","));
- strategy.setControllerMappingHyphenStyle(true);
- strategy.setLogicDeleteFieldName(logicDeleteFieldName); // 逻辑删除字段名称
- strategy.setTablePrefix(pc.getModuleName() + "_");
- mpg.setStrategy(strategy);
- mpg.setTemplateEngine(new FreemarkerTemplateEngine());
- mpg.execute();
- }
-
-}
\ No newline at end of file
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/test/java/com/company/project/Tester.java b/java_project_template/jun-mybatisplus-api-v2/src/test/java/com/company/project/Tester.java
deleted file mode 100644
index f513bc219d..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/test/java/com/company/project/Tester.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.company.project;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-/**
- * 单元测试
- */
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = Application.class)
-public class Tester {
-
- @Test
- public void test() {
-
- }
-}
-
-
-
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/test/resources/templates/controller.java.ftl b/java_project_template/jun-mybatisplus-api-v2/src/test/resources/templates/controller.java.ftl
deleted file mode 100644
index a62f181707..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/test/resources/templates/controller.java.ftl
+++ /dev/null
@@ -1,94 +0,0 @@
-package ${package.Controller};
-
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.company.project.core.Result;
-import com.company.project.core.ResultGenerator;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import org.springframework.web.bind.annotation.*;
-import ${package.Service}.${table.serviceName};
-import ${package.Entity}.${entity};
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-
-import javax.annotation.Resource;
-<#if restControllerStyle>
-import org.springframework.web.bind.annotation.RestController;
-<#else>
-import org.springframework.stereotype.Controller;
-#if>
-<#if superControllerClassPackage??>
-import ${superControllerClassPackage};
-#if>
-
-/**
- *
- * ${table.comment!} 前端控制器
- *
- *
- * @author ${author}
- * @since ${date}
- */
-<#if restControllerStyle>
-@Api(tags = {"${table.comment!}"})
-@Slf4j
-@RestController
-<#else>
-@Controller
-#if>
-@RequestMapping("<#if package.ModuleName??>/${package.ModuleName}#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}#if>")
-<#if kotlin>
-class ${table.controllerName}<#if superControllerClass??>:${superControllerClass}()#if>
-<#else>
-<#if superControllerClass??>public class ${table.controllerName} extends ${superControllerClass}{
-<#else>public class ${table.controllerName} {
-#if>
-
- @Resource
- private ${table.serviceName} ${(table.serviceName?substring(1))?uncap_first};
-
-
- @ApiOperation(value = "新增${table.comment!}")
- @PostMapping("add")
- public Result add(@RequestBody ${entity} ${entity?uncap_first}){
- ${(table.serviceName?substring(1))?uncap_first}.save(${entity?uncap_first});
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation(value = "删除${table.comment!}")
- @PostMapping("delete/{id}")
- public Result delete(@PathVariable("id") Long id){
- ${(table.serviceName?substring(1))?uncap_first}.removeById(id);
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation(value = "更新${table.comment!}")
- @PostMapping("update")
- public Result update(@RequestBody ${entity} ${entity?uncap_first}){
- ${(table.serviceName?substring(1))?uncap_first}.updateById(${entity?uncap_first});
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation(value = "查询${table.comment!}分页数据")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "currentPage", value = "页码"),
- @ApiImplicitParam(name = "pageCount", value = "每页条数")
- })
- @GetMapping("listByPage")
- public Result findListByPage(@RequestParam Integer currentPage,
- @RequestParam Integer pageCount){
- Page page = new Page(currentPage, pageCount);
- IPage<${entity}> iPage = ${(table.serviceName?substring(1))?uncap_first}.page(page);
- return ResultGenerator.genSuccessResult(iPage);
- }
-
- @ApiOperation(value = "id查询${table.comment!}")
- @GetMapping("getById/{id}")
- public Result findById(@PathVariable Long id){
- return ResultGenerator.genSuccessResult(${(table.serviceName?substring(1))?uncap_first}.getById(id));
- }
-
-}
-#if>
\ No newline at end of file
diff --git a/java_project_template/jun-mybatisplus-api-v2/src/test/resources/user.sql b/java_project_template/jun-mybatisplus-api-v2/src/test/resources/user.sql
deleted file mode 100644
index 51bd7db81e..0000000000
--- a/java_project_template/jun-mybatisplus-api-v2/src/test/resources/user.sql
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- Navicat Premium Data Transfer
-
- Source Server : localhost
- Source Server Type : MySQL
- Source Server Version : 50529
- Source Host : localhost:3306
- Source Schema : project
-
- Target Server Type : MySQL
- Target Server Version : 50529
- File Encoding : 65001
-
- Date: 08/01/2020 15:53:02
-*/
-
-SET NAMES utf8mb4;
-SET FOREIGN_KEY_CHECKS = 0;
-
--- ----------------------------
--- Table structure for user
--- ----------------------------
-DROP TABLE IF EXISTS `user`;
-CREATE TABLE `user` (
- `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
- `username` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户名',
- `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码',
- `nick_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '昵称',
- `sex` int(1) NULL DEFAULT NULL COMMENT '性别',
- `create_date` datetime NULL DEFAULT NULL COMMENT '创建时间',
- `create_user` int(11) NULL DEFAULT NULL COMMENT '创建人',
- `update_date` datetime NULL DEFAULT NULL COMMENT '修改时间',
- `update_user` int(11) NULL DEFAULT NULL COMMENT '修改人',
- `del_flag` int(1) NULL DEFAULT 0 COMMENT '删除标志0未删 1删除',
- PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
-
--- ----------------------------
--- Records of user
--- ----------------------------
-INSERT INTO `user` VALUES (1, 'admin', '9dc818b4bca3baa7d230fbf96c919638', '土豆', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `user` VALUES (2, '2@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '土豆-2', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `user` VALUES (3, '3@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '土豆-3', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `user` VALUES (4, '4@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '土豆-4', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `user` VALUES (5, '5@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '土豆-5', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `user` VALUES (6, '6@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '土豆-6', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `user` VALUES (7, '7@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '土豆-7', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `user` VALUES (8, '8@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '土豆-8', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `user` VALUES (9, '9@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '土豆-9', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `user` VALUES (10, '10@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '土豆-10', 1, NULL, NULL, NULL, NULL, 0);
-
-SET FOREIGN_KEY_CHECKS = 1;
diff --git a/java_project_template/jun_api_service_admin/Dockerfile b/java_project_template/jun_api_service_admin/Dockerfile
deleted file mode 100644
index 45ce8dba92..0000000000
--- a/java_project_template/jun_api_service_admin/Dockerfile
+++ /dev/null
@@ -1,13 +0,0 @@
-# 基础镜像
-FROM openjdk:8-jre
-# author
-MAINTAINER wenbin
-# 复制jar文件到路径
-ADD manager.jar manager.jar
-# 时间
-RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
-RUN echo 'Asia/Shanghai' >/etc/timezone
-# 启动服务
-ENTRYPOINT ["java","-jar","/manager.jar"]
-# 暴露端口
-EXPOSE 8080
diff --git a/java_project_template/jun_api_service_admin/dependencies.txt b/java_project_template/jun_api_service_admin/dependencies.txt
deleted file mode 100644
index 520c4cfefc..0000000000
Binary files a/java_project_template/jun_api_service_admin/dependencies.txt and /dev/null differ
diff --git a/java_project_template/jun_api_service_admin/pom.xml b/java_project_template/jun_api_service_admin/pom.xml
deleted file mode 100644
index 60d9dba329..0000000000
--- a/java_project_template/jun_api_service_admin/pom.xml
+++ /dev/null
@@ -1,344 +0,0 @@
-
-
- 4.0.0
-
- com.jun.plugin
- 1.0
- jun_api_service_admin
-
-
- 1.8
- 3.4.0
- 2.5.5
- 12.1.0.1-atlassian-hosted
- 4.0
- 2.6
- 2.5
- 1.10
- 1.7
- 2.3.2
- 1.4.0
- 1.1.10
- 1.2.74
- 2.0.0
- 2.0.2
- 1.6.2
-
-
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-starter-groovy-templates
-
-
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
- org.springframework.boot
- spring-boot-starter-aop
-
-
-
- org.springframework.boot
- spring-boot-starter-validation
- 2.5.14
-
-
-
-
- junit
- junit
- 4.13.2
- test
-
-
-
-
- com.alibaba
- druid-spring-boot-starter
- ${druid.version}
-
-
-
- org.springframework.boot
- spring-boot-starter-data-redis
-
-
-
-
-
- com.baomidou
- mybatis-plus
- ${mybatis-plus.version}
-
-
- com.baomidou
- mybatis-plus-boot-starter
- ${mybatis-plus.version}
-
-
- mysql
- mysql-connector-java
- runtime
-
-
- com.oracle
- ojdbc6
- ${ojdbc6.version}
-
-
- com.microsoft.sqlserver
- sqljdbc4
- ${sqlserver.version}
- runtime
-
-
-
-
-
-
-
-
-
- com.fasterxml.jackson.core
- jackson-core
- 2.13.3
-
-
-
- com.fasterxml.jackson.core
- jackson-annotations
- 2.13.3
-
-
-
- com.fasterxml.jackson.core
- jackson-databind
- 2.13.3
-
-
-
- com.fasterxml.jackson.dataformat
- jackson-dataformat-yaml
- 2.13.3
-
-
-
- com.fasterxml.jackson.dataformat
- jackson-dataformat-xml
- 2.13.3
-
-
-
- com.fasterxml.jackson.dataformat
- jackson-dataformat-properties
- 2.13.3
-
-
-
- org.dom4j
- dom4j
- 2.1.3
-
-
-
-
-
- com.google.code.gson
- gson
- 2.9.0
-
-
-
-
-
-
-
-
-
- org.apache.shiro
- shiro-spring
- ${shiro.version}
-
-
-
- org.projectlombok
- lombok
-
-
-
- com.alibaba
- fastjson
- ${fastjson.version}
-
-
-
-
- org.springframework.boot
- spring-boot-starter-thymeleaf
-
-
- com.github.theborakompanioni
- thymeleaf-extras-shiro
- ${thymeleaf-shiro.version}
-
-
-
-
-
- com.github.xiaoymin
- knife4j-spring-boot-starter
- ${knife4j.version}
-
-
- commons-lang
- commons-lang
- ${commons.lang.version}
-
-
- commons-io
- commons-io
- ${commons.io.version}
-
-
- commons-configuration
- commons-configuration
- ${commons.configuration.version}
-
-
- velocity
- org.apache.velocity
- ${velocity.version}
-
-
- org.quartz-scheduler
- quartz
- ${quartz.version}
-
-
- com.mchange
- c3p0
-
-
- com.zaxxer
- HikariCP-java6
-
-
-
-
- com.github.whvcse
- easy-captcha
- ${easy-captcha.version}
-
-
- commons-codec
- commons-codec
- 1.13
-
-
-
-
- com.auth0
- java-jwt
- 3.3.0
-
-
-
-
- redis.clients
- jedis
- 2.9.0
-
-
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-dependencies
-
-
-
- 2.5.14
- pom
- import
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.8.0
-
- 1.8
- 1.8
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
- 2.6.2
-
-
-
-
- repackage
-
-
-
-
-
-
-
-
-
- aliyun-repos
- http://maven.aliyun.com/nexus/content/groups/public/
-
- false
-
-
-
-
-
-
- aliyun-plugin
- http://maven.aliyun.com/nexus/content/groups/public/
-
- false
-
-
-
-
diff --git a/java_project_template/jun_api_service_admin/src/main/java/com/jun/plugin/ApiServiceApplication.java b/java_project_template/jun_api_service_admin/src/main/java/com/jun/plugin/ApiServiceApplication.java
deleted file mode 100644
index fac20938a2..0000000000
--- a/java_project_template/jun_api_service_admin/src/main/java/com/jun/plugin/ApiServiceApplication.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package com.jun.plugin;
-
-import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
-import lombok.extern.slf4j.Slf4j;
-import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.boot.CommandLineRunner;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.web.servlet.ServletComponentScan;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.annotation.Bean;
-import org.springframework.core.env.Environment;
-
-import java.net.InetAddress;
-@Slf4j
-@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)
-@MapperScan("com.jun.plugin.**.mapper")
-@ServletComponentScan(basePackages = {"com.jun.plugin.**.filter"})
-public class ApiServiceApplication {
-
- public static void main(String[] args) throws Exception {
- ConfigurableApplicationContext application = SpringApplication.run(ApiServiceApplication.class, args);
-
- Environment env = application.getEnvironment();
- log.info("\n----------------------------------------------------------\n\t" +
- "Application '{}' is running! Access URLs:\n\t" +
- "Api Test Json: \thttp://{}:{}/public/json\n\t" +
- "Api Code Generator: \thttp://{}:{}/generator/list.html\n\t" +
- "----------------------------------------------------------",
- env.getProperty("spring.application.name"),
- InetAddress.getLocalHost().getHostAddress(),
- env.getProperty("server.port"),
- InetAddress.getLocalHost().getHostAddress(),
- env.getProperty("server.port"));
- }
-
-
- @Bean
- public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
- return args -> {
- System.out.println("Let's inspect the beans provided by Spring Boot:");
- String[] beanNames = ctx.getBeanDefinitionNames();
- System.err.println("beanNames size = "+ beanNames.length);
- for (String beanName : beanNames) {
- //System.err.println(beanName);
- /*
- * Object bean = ctx.getBean(beanName); System.out.println(bean);
- * System.out.println();
- */
- }
-
- };
- }
-
-}
diff --git a/java_project_template/jun_api_service_admin/src/main/resources/application-dev.yml b/java_project_template/jun_api_service_admin/src/main/resources/application-dev.yml
deleted file mode 100644
index 26c25d2d8e..0000000000
--- a/java_project_template/jun_api_service_admin/src/main/resources/application-dev.yml
+++ /dev/null
@@ -1,72 +0,0 @@
-# 开发环境配置
-spring:
- thymeleaf:
- cache: false
- datasource:
- type: com.alibaba.druid.pool.DruidDataSource
- url: jdbc:mysql://localhost:3306/db_qixing?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2b8
- username: root
- password:
- driver-class-name: com.mysql.cj.jdbc.Driver
-# initialSize: 10
-# minIdle: 10
-# maxActive: 40
-# maxWait: 60000
-# test-on-borrow: true
-# test-while-idle: true
-# dynamic:
-# primary: master #设置默认的数据源或者数据源组,默认值即为master
-# datasource:
-# master:
-# username: root
-# password:
-# driver-class-name: com.mysql.cj.jdbc.Driver
-# url: jdbc:mysql://localhost:3306/test666?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2b8
-# oracle:
-# username: root
-# password:
-# driver-class-name: oracle.jdbc.driver.OracleDriver
-# url: jdbc:oracle:thin:@localhost:1521/company_project
-# sqlServer:
-# username: sa
-# password: 123456
-# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
-# url: jdbc:sqlserver://localhost:1433;databaseName=company_project
- redis:
- host: localhost # Redis服务器地址
- database: 0 # Redis数据库索引(默认为0)
- port: 6379 # Redis服务器连接端口
- password: # Redis服务器连接密码(默认为空)
- jedis:
- pool:
- max-active: 8 # 连接池最大连接数(使用负值表示没有限制)
- max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
- max-idle: 8 # 连接池中的最大空闲连接
- min-idle: 0 # 连接池中的最小空闲连接
- timeout: 13000 # 连接超时时间(毫秒
-
-filepath: "D:\\files\\"
-file:
- #文件上传目录 绝对路径 末尾请加 /
- path: D:/files/ #windows
- #path: /home/data/files/ #linux
- #文件预览、下载的url, 末尾请勿加 /
- url: http://qixing.vip321.vip/files
- qiniuAccessKey: ts0n9OF16ekFkDkZTTlpmyPI-tP3HKQDyw_GR4o2
- qiniuBucketName: qixing-files
- qiniuDomain: http://qiniu.vip321.vip
- qiniuPrefix: upload
- qiniuSecretKey: c-OjjwV3ZgzCQwxc6W_bsTFKuDg8qeyqohyJU0RL
- type: 1
-
-
-# AES密码加密私钥(Base64加密)
-encryptAESKey: V2FuZzkyNjQ1NGRTQkFQSUpXVA==
-# JWT认证加密私钥(Base64加密)
-encryptJWTKey: U0JBUElKV1RkV2FuZzkyNjQ1NA==
-# AccessToken过期时间-5分钟-5*60(秒为单位)
-accessTokenExpireTime: 300
-# RefreshToken过期时间-30分钟-30*60(秒为单位)
-refreshTokenExpireTime: 1800
-# Shiro缓存过期时间-5分钟-5*60(秒为单位)(一般设置与AccessToken过期时间一致)
-shiroCacheExpireTime: 300
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_admin/src/main/resources/application.yml b/java_project_template/jun_api_service_admin/src/main/resources/application.yml
deleted file mode 100644
index 219ae56fa5..0000000000
--- a/java_project_template/jun_api_service_admin/src/main/resources/application.yml
+++ /dev/null
@@ -1,50 +0,0 @@
-# 端口
-server:
- port: 8088
-
-spring:
- profiles:
- active: dev
- mvc:
- throw-exception-if-no-handler-found: true
- resources:
- add-mappings: false
- application:
- name: jun_springboot_api
- jackson:
- date-format: yyyy-MM-dd HH:mm:ss
- time-zone: GMT+8
- # 文件大小限制
- servlet:
- multipart:
- max-file-size: 10MB
- max-request-size: 100MB
- # redis token信息
- redis:
- key:
- prefix:
- userToken: "user:token:"
- passwordError: "user:password:error:"
- permissionRefresh: "user:token:permissionRefresh:"
- expire:
- userToken: 604800 # 7天 7*24*3600
- passwordError: 3600 # 一个小时
- permissionRefresh: 604800 # 7天 7*24*3600
- allowMultipleLogin: true # 允许多处登陆
-
-mybatis-plus:
- configuration:
- log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
- mapper-locations: classpath:mapper/${project.database}/**/*.xml,classpath:mapper/*.xml
- global-config:
- db-config:
- logic-delete-value: 0
- logic-not-delete-value: 1
- logic-delete-field: deleted
-
-#使用代码生成模块时 指定要生成的表存在于哪种数据库,可选值有【mysql、oracle、sqlServer】
-project:
- database: mysql
-
-shiro:
- enable: false
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_admin/src/main/resources/logback-spring.xml b/java_project_template/jun_api_service_admin/src/main/resources/logback-spring.xml
deleted file mode 100644
index e775a72900..0000000000
--- a/java_project_template/jun_api_service_admin/src/main/resources/logback-spring.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${CONSOLE_LOG_PATTERN}
-
-
-
-
-
-
- ${LOG_PATH}/${LOG_FILE}
-
- ${FILE_LOG_PATTERN}
-
-
- ${LOG_PATH}/${LOG_HISTORY}
- 30
-
-
-
-
-
-
-
- 0
- 500
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_admin/src/main/resources/templates/biztest/list.html b/java_project_template/jun_api_service_admin/src/main/resources/templates/biztest/list.html
deleted file mode 100644
index 128f8142a0..0000000000
--- a/java_project_template/jun_api_service_admin/src/main/resources/templates/biztest/list.html
+++ /dev/null
@@ -1,299 +0,0 @@
-
-
-
-
- Title
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_demo/.gitignore b/java_project_template/jun_api_service_demo/.gitignore
deleted file mode 100644
index 957445a861..0000000000
--- a/java_project_template/jun_api_service_demo/.gitignore
+++ /dev/null
@@ -1,23 +0,0 @@
-target/
-
-### STS ###
-.apt_generated
-.classpath
-.factorypath
-.project
-.settings
-.springBeans
-
-### IntelliJ IDEA ###
-.idea
-*.iws
-*.iml
-*.ipr
-
-### NetBeans ###
-nbproject/private/
-build/
-nbbuild/
-dist/
-nbdist/
-.nb-gradle/
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_demo/README.md b/java_project_template/jun_api_service_demo/README.md
deleted file mode 100644
index 2692deaf29..0000000000
--- a/java_project_template/jun_api_service_demo/README.md
+++ /dev/null
@@ -1,41 +0,0 @@
-## 简介
-Spring Boot API 是一个基于Spring Boot & MyBatis plus的种子项目,用于快速构建中小型API项目,特点稳定、简单、快速,摆脱那些重复劳动
-
-## 特征&提供
-- 统一响应结果封装及生成工具
-- 统一异常处理
-- 采用简单的jwt认证
-- 使用Druid Spring Boot Starter 集成Druid数据库连接池与监控
-- 集成MyBatis-Plus,实现单表业务零SQL
-- 支持多数据源,自由切换,只需方法或类上用 @DS 切换数据源
-- 集成国人风格的knife4j,自动生成接口文档
-- 提供代码生成器,生成controller,service,serviceImpl,dao,mapper.xml
-
-## 快速开始
-1. 克隆项目
-2. 导入```test```包里的mysql脚本user.sql
-3. 对```test```包内的代码生成器```CodeGenerator```进行配置,主要是JDBC,因为要根据表名来生成代码
-4. 输入表名,运行```CodeGenerator.main()```方法,生成基础代码(可能需要刷新项目目录才会出来)
-5. 根据业务在基础代码上进行扩展
-6. 对开发环境配置文件```application-dev.yml```进行配置,启动项目,Have Fun!
-
-## 开发建议
-- post调用接口ip:8080/api/user/login,参数json: {"username":"admin","password":"123456"},调用成功后, 返回token。以后调用api接口,header中传token
-- 正式环境已禁用接口文档的查看,配置文件添加knife4j:production: true 即可
-- Model内成员变量建议与表字段数量对应,如需扩展成员变量(比如连表查询)建议创建DTO,否则需在扩展的成员变量上加@TableField(exist = false),详见[MyBatis-Plus](https://mp.baomidou.com/guide/)文档说明
-- 建议业务失败直接使用ServiceException("ErrorMessage")抛出,由统一异常处理器来封装业务失败的响应结果,会直接被封装为{"code":400,"message":"ErrorMessage"}返回,尽情抛出;body方式传参,@Valid校验Model,更无需自己处理;
-
-## 接口文档效果图
-
-
-## 相关文档
-- Spring Boot([springboot官方](https://spring.io/projects/spring-boot/))
-- MyBatis-Plus ([查看官方中文文档](https://mp.baomidou.com/guide/))
-- MyBatis-Plus分页插件([查看官方中文文档](https://mp.baomidou.com/guide/page.html))
-- Druid Spring Boot Starter([查看官方中文文档](https://github.com/alibaba/druid/tree/master/druid-spring-boot-starter/))
-- Fastjson([查看官方中文文档](https://github.com/Alibaba/fastjson/wiki/%E9%A6%96%E9%A1%B5))
-- 阿里巴巴Java开发手册[最新版下载](https://github.com/alibaba/p3c)
-其他
-
-## License
-纯粹开源分享,感谢大家 [Star](https://github.com/aitangbao/springboot-api) 的支持。
diff --git a/java_project_template/jun_api_service_demo/pom.xml b/java_project_template/jun_api_service_demo/pom.xml
deleted file mode 100644
index 27274de1f0..0000000000
--- a/java_project_template/jun_api_service_demo/pom.xml
+++ /dev/null
@@ -1,156 +0,0 @@
-
-
- 4.0.0
-
- com.company.project
- jun_api_service_demo
- 1.0
- jar
-
-
- 1.8
- 3.3.0
-
-
-
-
- org.springframework.boot
- spring-boot-starter-parent
- 2.2.2.RELEASE
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-starter-jdbc
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
- com.baomidou
- dynamic-datasource-spring-boot-starter
- 2.5.5
-
-
- com.baomidou
- mybatis-plus
- ${mybatis-plus.version}
-
-
- com.baomidou
- mybatis-plus-boot-starter
- ${mybatis-plus.version}
-
-
- com.baomidou
- mybatis-plus-generator
- ${mybatis-plus.version}
-
-
- org.projectlombok
- lombok
- 1.18.36
-
-
-
-
-
- commons-codec
- commons-codec
-
-
- org.apache.commons
- commons-lang3
- 3.6
-
-
-
- mysql
- mysql-connector-java
- runtime
-
-
-
-
- com.alibaba
- fastjson
- 1.2.47
-
-
-
- com.alibaba
- druid-spring-boot-starter
- 1.1.10
-
-
-
- org.freemarker
- freemarker
- 2.3.30
- test
-
-
-
- com.github.xiaoymin
- knife4j-spring-boot-starter
- 2.0.2
-
-
-
- io.jsonwebtoken
- jjwt
- 0.9.0
-
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
- maven-compiler-plugin
-
- ${java.version}
- ${java.version}
- UTF-8
-
-
-
-
-
-
-
- aliyun-repos
- http://maven.aliyun.com/nexus/content/groups/public/
-
- false
-
-
-
-
-
-
- aliyun-plugin
- http://maven.aliyun.com/nexus/content/groups/public/
-
- false
-
-
-
-
-
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/Application.java b/java_project_template/jun_api_service_demo/src/main/java/com/company/project/Application.java
deleted file mode 100644
index 2d366a4211..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/Application.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.company.project;
-
-import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
-import org.mybatis.spring.annotation.MapperScan;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.core.env.Environment;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
-
-import java.net.InetAddress;
-
-@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)
-@MapperScan("com.company.project.dao")
-public class Application {
-
- private static Logger logger= LoggerFactory.getLogger(Application.class);
-
- public static void main(String[] args) throws Exception {
-
- ConfigurableApplicationContext application = SpringApplication.run(Application.class, args);
-
- Environment env = application.getEnvironment();
- logger.info("\n----------------------------------------------------------\n\t" +
- "Application '{}' is running! Access URLs:\n\t" +
- "Local: \t\thttp://localhost:{}\n\t" +
- "External: \thttp://{}:{}\n\t" +
- "Doc: \thttp://{}:{}/doc.html\n" +
- "----------------------------------------------------------",
- env.getProperty("spring.application.name"),
- env.getProperty("server.port"),
- InetAddress.getLocalHost().getHostAddress(),
- env.getProperty("server.port"),
- InetAddress.getLocalHost().getHostAddress(),
- env.getProperty("server.port"));
- }
-}
-
diff --git a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/configurer/LoginInterceptor.java b/java_project_template/jun_api_service_demo/src/main/java/com/company/project/configurer/LoginInterceptor.java
deleted file mode 100644
index 16e66ea0c8..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/configurer/LoginInterceptor.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package com.company.project.configurer;
-
-
-import com.alibaba.fastjson.JSON;
-import com.company.project.core.Result;
-import com.company.project.core.ResultCode;
-import com.company.project.utils.JwtUtils;
-import io.jsonwebtoken.Claims;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import java.io.IOException;
-
-import static com.company.project.utils.JwtUtils.USER_ACCOUNT_KEY;
-import static com.company.project.utils.JwtUtils.USER_ID_KEY;
-
-/**
- * 登陆拦截器
- */
-public class LoginInterceptor extends HandlerInterceptorAdapter {
-
- private final Logger logger = LoggerFactory.getLogger(WebMvcConfigurer.class);
- @Override
- public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
- //拦截接口
- //从header中获取token
- String token = request.getHeader("token");
- //如果header中不存在token,则从参数中获取token
- if(StringUtils.isBlank(token)){
- token = request.getParameter("token");
- }
- //token为空返回
- if(StringUtils.isBlank(token)){
- Result result = new Result();
- result.setCode(ResultCode.UNAUTHORIZED).setMessage("token不能为空").setSuccess(false);
- responseResult(response, result);
- return false;
- }// 校验并解析token,如果token过期或者篡改,则会返回null
- Claims claims = JwtUtils.checkJWT(token);
- if(null == claims){
- Result result = new Result();
- result.setCode(ResultCode.UNAUTHORIZED).setMessage("登陆失效, 请重新登陆").setSuccess(false);
- responseResult(response, result);
- return false;
- }
- // 校验通过后,设置用户信息到request里,在Controller中从Request域中获取用户信息
- request.setAttribute(USER_ID_KEY, claims.get("id"));
- request.setAttribute(USER_ACCOUNT_KEY, claims.get("account"));
- return true;
- }
-
-
-
- private void responseResult(HttpServletResponse response, Result result) {
- response.setCharacterEncoding("UTF-8");
- response.setHeader("Content-type", "application/json;charset=UTF-8");
- response.setStatus(200);
- try {
- response.getWriter().write(JSON.toJSONString(result));
- } catch (IOException ex) {
- logger.error(ex.getMessage());
- }
- }
-}
diff --git a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/configurer/MyBatisPlusConfig.java b/java_project_template/jun_api_service_demo/src/main/java/com/company/project/configurer/MyBatisPlusConfig.java
deleted file mode 100644
index f75a63819c..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/configurer/MyBatisPlusConfig.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.company.project.configurer;
-
-import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * @ClassName MyBatisPlusConfig
- * @Version 1.0
- **/
-@Configuration
-public class MyBatisPlusConfig {
- /**
- * 配置mybatis-plus 分页查件
- * @return
- */
- @Bean
- public PaginationInterceptor paginationInterceptor() {
- PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
- return paginationInterceptor;
- }
-}
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/configurer/SwaggerConfiguration.java b/java_project_template/jun_api_service_demo/src/main/java/com/company/project/configurer/SwaggerConfiguration.java
deleted file mode 100644
index d5bca5303f..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/configurer/SwaggerConfiguration.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.company.project.configurer;
-
-import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Import;
-import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
-import springfox.documentation.builders.ApiInfoBuilder;
-import springfox.documentation.builders.PathSelectors;
-import springfox.documentation.builders.RequestHandlerSelectors;
-import springfox.documentation.service.ApiInfo;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
-
-@Configuration
-@EnableSwagger2
-@EnableKnife4j
-@Import(BeanValidatorPluginsConfiguration.class)
-public class SwaggerConfiguration {
-
- @Bean
- public Docket createRestApi() {
- return new Docket(DocumentationType.SWAGGER_2)
- .apiInfo(apiInfo())
- .select()
- .apis(RequestHandlerSelectors.basePackage("com.company.project.web"))
- .paths(PathSelectors.any())
- .build();
- }
-
- private ApiInfo apiInfo() {
- return new ApiInfoBuilder()
- .title("Springboot-api APIs")
- .description("Springboot-api APIs")
- .termsOfServiceUrl("http://localhost:8080/")
- .contact("xxxxxxxxxx@163.com")
- .version("1.0")
- .build();
- }
-}
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/configurer/WebMvcConfigurer.java b/java_project_template/jun_api_service_demo/src/main/java/com/company/project/configurer/WebMvcConfigurer.java
deleted file mode 100644
index e790419d9b..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/configurer/WebMvcConfigurer.java
+++ /dev/null
@@ -1,178 +0,0 @@
-package com.company.project.configurer;
-
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.serializer.SerializerFeature;
-import com.alibaba.fastjson.support.config.FastJsonConfig;
-import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
-
-import com.company.project.core.Result;
-import com.company.project.core.ResultCode;
-import com.company.project.core.ResultGenerator;
-import com.company.project.core.ServiceException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.MediaType;
-import org.springframework.http.converter.HttpMessageConverter;
-import org.springframework.web.bind.MethodArgumentNotValidException;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.method.HandlerMethod;
-import org.springframework.web.servlet.HandlerExceptionResolver;
-import org.springframework.web.servlet.ModelAndView;
-import org.springframework.web.servlet.NoHandlerFoundException;
-import org.springframework.web.servlet.config.annotation.*;
-
-/**
- * Spring MVC 配置
- */
-@Configuration
-public class WebMvcConfigurer extends WebMvcConfigurerAdapter {
-
- private final Logger logger = LoggerFactory.getLogger(WebMvcConfigurer.class);
-
- @Bean
- LoginInterceptor loginInterceptor() {
-
- return new LoginInterceptor();
- }
-
- //使用阿里 FastJson 作为JSON MessageConverter
- @Override
- public void configureMessageConverters(List> converters) {
- FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
- FastJsonConfig config = new FastJsonConfig();
- config.setSerializerFeatures(SerializerFeature.WriteMapNullValue);//保留空的字段
- //SerializerFeature.WriteNullStringAsEmpty,//String null -> ""
- //SerializerFeature.WriteNullNumberAsZero//Number null -> 0
- // 按需配置,更多参考FastJson文档哈
-
- converter.setFastJsonConfig(config);
- converter.setDefaultCharset(Charset.forName("UTF-8"));
- converter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON_UTF8));
- converters.add(converter);
- }
-
-
- //统一异常处理
- @Override
- public void configureHandlerExceptionResolvers(List exceptionResolvers) {
- exceptionResolvers.add(new HandlerExceptionResolver() {
- public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception e) {
- Result result = new Result();
- if (e instanceof ServiceException) {//业务失败的异常,如“账号或密码错误”
- result.setCode(ResultCode.FAIL).setMessage(e.getMessage()).setSuccess(false);
- } else if (e instanceof MethodArgumentNotValidException) {//@valid注解验证参数
- MethodArgumentNotValidException m = (MethodArgumentNotValidException) e;
- m.getBindingResult().getFieldError().getDefaultMessage();
- result.setCode(ResultCode.PARAM_FAIL).setMessage(m.getBindingResult().getFieldError().getDefaultMessage()).setSuccess(false);
- } else if (e instanceof NoHandlerFoundException) {
- result.setCode(ResultCode.NOT_FOUND).setMessage("接口 [" + request.getRequestURI() + "] 不存在").setSuccess(false);
- } else if (e instanceof ServletException) {
- result.setCode(ResultCode.FAIL).setMessage(e.getMessage()).setSuccess(false);
- } else {
- result.setCode(ResultCode.INTERNAL_SERVER_ERROR).setMessage("接口 [" + request.getRequestURI() + "] 内部错误,请联系管理员").setSuccess(false);
- String message;
- if (handler instanceof HandlerMethod) {
- HandlerMethod handlerMethod = (HandlerMethod) handler;
- message = String.format("接口 [%s] 出现异常,方法:%s.%s,异常摘要:%s",
- request.getRequestURI(),
- handlerMethod.getBean().getClass().getName(),
- handlerMethod.getMethod().getName(),
- e.getMessage());
- } else {
- message = e.getMessage();
- }
- logger.error(message, e);
- }
- responseResult(response, result);
- return new ModelAndView();
- }
-
- });
- }
-
- @ExceptionHandler(MethodArgumentNotValidException.class)
- public Result handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
- return ResultGenerator.genFailResult(e.getBindingResult().getFieldError().getDefaultMessage());
- }
-
- /**
- * 页面跨域访问Controller过滤
- *
- * @return
- */
- @Override
- public void addCorsMappings(CorsRegistry registry) {
- WebMvcConfigurer.super.addCorsMappings(registry);
- registry.addMapping("/**")
- .allowedHeaders("*")
- .allowedMethods("POST","GET")
- .allowedOrigins("*");
- }
-
- //添加拦截器
- @Override
- public void addInterceptors(InterceptorRegistry registry) {
- registry.addInterceptor(loginInterceptor())
- .excludePathPatterns("/doc.html")
- .excludePathPatterns("/swagger-resources/**")
- .excludePathPatterns("/error")
- .excludePathPatterns("/webjars/**")
- .excludePathPatterns("/api/user/login")
- .excludePathPatterns("/api/user/register")
- .addPathPatterns("/**");
- }
-
-
- private void responseResult(HttpServletResponse response, Result result) {
- response.setCharacterEncoding("UTF-8");
- response.setHeader("Content-type", "application/json;charset=UTF-8");
- response.setStatus(200);
- try {
- response.getWriter().write(JSON.toJSONString(result));
- } catch (IOException ex) {
- logger.error(ex.getMessage());
- }
- }
-
- /**
- * 发现如果继承了WebMvcConfigurationSupport,则在yml中配置的相关内容会失效。 需要重新指定静态资源
- *
- * @param registry
- */
- @Override
- public void addResourceHandlers(ResourceHandlerRegistry registry) {
- registry.addResourceHandler("/**").addResourceLocations(
- "classpath:/static/");
- registry.addResourceHandler("doc.html").addResourceLocations(
- "classpath:/META-INF/resources/");
- registry.addResourceHandler("/webjars/**").addResourceLocations(
- "classpath:/META-INF/resources/webjars/");
- super.addResourceHandlers(registry);
- }
-
-
- /**
- * 配置servlet处理
- */
- @Override
- public void configureDefaultServletHandling(
- DefaultServletHandlerConfigurer configurer) {
- configurer.enable();
- }
-
-
-
-
-}
-
diff --git a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/core/ApplicationContextUtil.java b/java_project_template/jun_api_service_demo/src/main/java/com/company/project/core/ApplicationContextUtil.java
deleted file mode 100644
index 8121fb4b4b..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/core/ApplicationContextUtil.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.company.project.core;
-
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.stereotype.Component;
-
-/**
- * @className: ApplicationContextUtil
- * @Description: 解决定时任务获取不到service的问题
- * @Author moneylee
- * @Date 2019-05-11 14:28
- * @Version 1.0
- **/
-@Component
-public class ApplicationContextUtil implements ApplicationContextAware {
-
- private static ApplicationContext applicationContext;
-
- public static ApplicationContext getApplicationContext() {
- return applicationContext;
- }
-
-
- @Override
- public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
- ApplicationContextUtil.applicationContext = applicationContext;
-
- }
-
- public static Object getBean(String beanName) {
- return applicationContext.getBean(beanName);
- }
-
-}
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/core/Result.java b/java_project_template/jun_api_service_demo/src/main/java/com/company/project/core/Result.java
deleted file mode 100644
index b208a52ae2..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/core/Result.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package com.company.project.core;
-
-import com.alibaba.fastjson.JSON;
-
-/**
- * 统一API响应结果封装
- */
-public class Result {
- private int code;
- private String message;
- private T data;
- private Boolean success;
-
- public Result setCode(ResultCode resultCode) {
- this.code = resultCode.code();
- return this;
- }
-
- public int getCode() {
- return code;
- }
-
- public String getMessage() {
- return message;
- }
-
- public Result setMessage(String message) {
- this.message = message;
- return this;
- }
-
- public T getData() {
- return data;
- }
-
- public Result setData(T data) {
- this.data = data;
- return this;
- }
-
- public Boolean getSuccess() {
- return success;
- }
-
- public Result setSuccess(Boolean success) {
- this.success = success;
- return this;
- }
-
- @Override
- public String toString() {
- return JSON.toJSONString(this);
- }
-}
diff --git a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/core/ResultCode.java b/java_project_template/jun_api_service_demo/src/main/java/com/company/project/core/ResultCode.java
deleted file mode 100644
index 651c04d826..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/core/ResultCode.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.company.project.core;
-
-/**
- * 响应码枚举,参考HTTP状态码的语义
- */
-public enum ResultCode {
- SUCCESS(200),//成功
- FAIL(400),//失败
- UNAUTHORIZED(401),//未认证(签名错误)
- NOT_FOUND(404),//接口不存在
- INTERNAL_SERVER_ERROR(500),//服务器内部错误
- PARAM_FAIL(10001);//参数异常
-
- private final int code;
-
- ResultCode(int code) {
- this.code = code;
- }
-
- public int code() {
- return code;
- }
-}
diff --git a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/core/ResultGenerator.java b/java_project_template/jun_api_service_demo/src/main/java/com/company/project/core/ResultGenerator.java
deleted file mode 100644
index de79f955e9..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/core/ResultGenerator.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.company.project.core;
-
-/**
- * 响应结果生成工具
- */
-public class ResultGenerator {
- private static final String DEFAULT_SUCCESS_MESSAGE = "SUCCESS";
-
- public static Result genSuccessResult() {
- return new Result()
- .setSuccess(true)
- .setCode(ResultCode.SUCCESS)
- .setMessage(DEFAULT_SUCCESS_MESSAGE);
- }
-
- public static Result genSuccessResult(T data) {
- return new Result()
- .setSuccess(true)
- .setCode(ResultCode.SUCCESS)
- .setMessage(DEFAULT_SUCCESS_MESSAGE)
- .setData(data);
- }
-
- public static Result genFailResult(String message) {
- return new Result()
- .setSuccess(false)
- .setCode(ResultCode.FAIL)
- .setMessage(message);
- }
-}
diff --git a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/core/ServiceException.java b/java_project_template/jun_api_service_demo/src/main/java/com/company/project/core/ServiceException.java
deleted file mode 100644
index e698bce9da..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/core/ServiceException.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.company.project.core;
-
-/**
- * 服务(业务)异常如“ 账号或密码错误 ”,该异常只做INFO级别的日志记录 @see WebMvcConfigurer
- */
-public class ServiceException extends RuntimeException {
- public ServiceException() {
- }
-
- public ServiceException(String message) {
- super(message);
- }
-
- public ServiceException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/dao/UserMapper.java b/java_project_template/jun_api_service_demo/src/main/java/com/company/project/dao/UserMapper.java
deleted file mode 100644
index f731dd72d1..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/dao/UserMapper.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.company.project.dao;
-
-import com.company.project.model.User;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-
-/**
- *
- * Mapper 接口
- *
- *
- * @author project
- * @since 2020-01-08
- */
-public interface UserMapper extends BaseMapper {
-
-}
diff --git a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/model/User.java b/java_project_template/jun_api_service_demo/src/main/java/com/company/project/model/User.java
deleted file mode 100644
index ccb159e35c..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/model/User.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package com.company.project.model;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableLogic;
-import java.io.Serializable;
-import java.util.Date;
-
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-import javax.validation.constraints.NotEmpty;
-
-/**
- *
- *
- *
- *
- * @author project
- * @since 2020-01-08
- */
-@Data
-@EqualsAndHashCode(callSuper = false)
-@Accessors(chain = true)
-public class User implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * 主键
- */
- @TableId(value = "id", type = IdType.AUTO)
- private Integer id;
-
- /**
- * 用户名
- */
- @NotEmpty(message = "用户名不能为空!")
- private String username;
-
- /**
- * 密码
- */
- @NotEmpty(message = "密码不能为空!")
- private String password;
-
- /**
- * 昵称
- */
- private String nickName;
-
- /**
- * 性别
- */
- private Integer sex;
-
- /**
- * 创建时间
- */
- private Date createDate;
-
- /**
- * 创建人
- */
- private Integer createUser;
-
- /**
- * 修改时间
- */
- private Date updateDate;
-
- /**
- * 修改人
- */
- private Integer updateUser;
-
- /**
- * 删除标志0未删 1删除
- */
- @TableLogic
- private Integer delFlag;
-
- /**
- * 登陆返回token
- */
- @TableField(exist = false)
- private String token;
-
-}
diff --git a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/service/IUserService.java b/java_project_template/jun_api_service_demo/src/main/java/com/company/project/service/IUserService.java
deleted file mode 100644
index c6ea45ce7e..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/service/IUserService.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.company.project.service;
-
-import com.company.project.model.User;
-import com.baomidou.mybatisplus.extension.service.IService;
-
-/**
- *
- * 服务类
- *
- *
- * @author project
- * @since 2020-01-08
- */
-public interface IUserService extends IService {
-
-}
diff --git a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/service/impl/UserServiceImpl.java b/java_project_template/jun_api_service_demo/src/main/java/com/company/project/service/impl/UserServiceImpl.java
deleted file mode 100644
index 83f0a1a11d..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/service/impl/UserServiceImpl.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.company.project.service.impl;
-
-import com.company.project.model.User;
-import com.company.project.dao.UserMapper;
-import com.company.project.service.IUserService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.stereotype.Service;
-
-/**
- *
- * 服务实现类
- *
- *
- * @author project
- * @since 2020-01-08
- */
-@Service
-public class UserServiceImpl extends ServiceImpl implements IUserService {
-
-}
diff --git a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/utils/JwtUtils.java b/java_project_template/jun_api_service_demo/src/main/java/com/company/project/utils/JwtUtils.java
deleted file mode 100644
index 7cf948ef1b..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/utils/JwtUtils.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package com.company.project.utils;
-
-import com.company.project.model.User;
-import io.jsonwebtoken.Claims;
-import io.jsonwebtoken.Jwts;
-import io.jsonwebtoken.SignatureAlgorithm;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.Date;
-
-/**
- * jwt工具类
- */
-public class JwtUtils {
-
- public static final String USER_ID_KEY = "user_id_key";
-
- public static final String USER_ACCOUNT_KEY = "user_account_key";
-
-
- public static final String SUBJECT = "onehee";
-
- public static final long EXPIRE = 1000*60*60*24*7; //过期时间,毫秒,一周
-
- //秘钥
- public static final String APPSECRET = "onehee666";
-
- /**
- * 生成jwt
- * @param user
- * @return
- */
- public static String geneJsonWebToken(User user){
-
- String token = Jwts.builder().setSubject(SUBJECT)
- .claim("id",user.getId())
- .claim("userName",user.getUsername())
- .setIssuedAt(new Date())
- .setExpiration(new Date(System.currentTimeMillis()+EXPIRE))
- .signWith(SignatureAlgorithm.HS256,APPSECRET).compact();
-
- return token;
- }
-
-
- /**
- * 校验token
- * @param token
- * @return
- */
- public static Claims checkJWT(String token ){
-
- try{
- final Claims claims = Jwts.parser().setSigningKey(APPSECRET).
- parseClaimsJws(token).getBody();
- return claims;
-
- }catch (Exception e){ }
- return null;
-
- }
-
-
- /**
- * 判断当前登陆用户是不是admin
- * @param request
- * @return
- */
- public static boolean isAdmin(HttpServletRequest request) {
- if (request.getAttribute(USER_ACCOUNT_KEY) == null) {
- return false;
- }
- if ("admin".equals(request.getAttribute(USER_ACCOUNT_KEY).toString())){
- return true;
- } else {
- return false;
- }
- }
-
-
-
-}
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/utils/MD5Utils.java b/java_project_template/jun_api_service_demo/src/main/java/com/company/project/utils/MD5Utils.java
deleted file mode 100644
index c7a3dff75c..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/utils/MD5Utils.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package com.company.project.utils;
-
-import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
-
-public class MD5Utils {
-
- private static String salt = "springboot_api";
-
- /**
- * 加密字符串
- * @param password 要加密的明文
- * @param isAddSalt 是否加默认盐
- * @return 加密之后的结果
- */
- public static String Encrypt(String password, boolean isAddSalt){
- if (StringUtils.isNotEmpty(password)){
- if (isAddSalt){
- return DigestUtils.md5Hex(DigestUtils.md5(password + salt));
- } else {
- return DigestUtils.md5Hex(DigestUtils.md5(password));
- }
- }
- return null;
- }
-
- /**
- *
- * @param bytes
- * @return
- */
- public static String Encrypt(byte[] bytes){
- if (ArrayUtils.isNotEmpty(bytes)){
- return DigestUtils.md5Hex(DigestUtils.md5(bytes));
- }
- return null;
- }
-
- /**
- * MD5加盐加密
- * @param password 要加密的明文
- * @param salt 盐
- * @return 加密之后的结果
- */
- public static String Encrypt(String password, String salt){
- if (StringUtils.isNotEmpty(password)){
- return DigestUtils.md5Hex(DigestUtils.md5(password + salt));
- }
- return null;
- }
-
- public static void main(String[] args){
- System.out.println(MD5Utils.Encrypt("admin", true));
- }
-}
diff --git a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/web/UserController.java b/java_project_template/jun_api_service_demo/src/main/java/com/company/project/web/UserController.java
deleted file mode 100644
index 303acb3819..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/java/com/company/project/web/UserController.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package com.company.project.web;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.company.project.core.Result;
-import com.company.project.core.ResultGenerator;
-import com.company.project.utils.JwtUtils;
-import com.company.project.utils.MD5Utils;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import org.springframework.web.bind.annotation.*;
-import com.company.project.service.IUserService;
-import com.company.project.model.User;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- *
- * 前端控制器
- *
- *
- * @author project
- * @since 2020-01-08
- */
-@Slf4j
-@RestController
-@RequestMapping("/api/user")
-public class UserController {
-
- @Resource
- private IUserService userService;
-
- @ApiOperation("登陆")
- @PostMapping("/login")
- public Result login(@RequestBody @Valid User user) {
- QueryWrapper queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("username", user.getUsername());
- User userO = userService.getOne(queryWrapper);
- if (userO == null) {
- return ResultGenerator.genFailResult("账号未找到");
- }
- if (!MD5Utils.Encrypt(user.getPassword(),true).equals(userO.getPassword())) {
- return ResultGenerator.genFailResult("密码错误");
- }
- String token = JwtUtils.geneJsonWebToken(user);
- user.setToken(token);
- user.setPassword("");
- return ResultGenerator.genSuccessResult(user);
- }
-
- @ApiOperation("注册")
- @PostMapping("/register")
- public Result register(@RequestBody @Valid User user) {
- QueryWrapper queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("username", user.getUsername());
- User userO = userService.getOne(queryWrapper);
- if (userO != null) {
- return ResultGenerator.genFailResult("账号已存在");
- }
- user.setPassword(MD5Utils.Encrypt(user.getPassword(),true));
- userService.save(user);
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation(value = "删除")
- @PostMapping("delete/{id}")
- public Result delete(@PathVariable("id") Long id){
- userService.removeById(id);
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation(value = "更新")
- @PostMapping("update")
- public Result update(@RequestBody User user){
- //密码不更新
- user.setPassword(null);
- userService.updateById(user);
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation(value = "查询分页数据")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "currentPage", value = "页码"),
- @ApiImplicitParam(name = "pageCount", value = "每页条数")
- })
- @GetMapping("listByPage")
- public Result findListByPage(@RequestParam(defaultValue = "1") Integer currentPage,
- @RequestParam(defaultValue = "10") Integer pageCount){
- Page page = new Page(currentPage, pageCount);
- IPage iPage = userService.page(page);
- return ResultGenerator.genSuccessResult(iPage);
- }
-
- @ApiOperation(value = "id查询")
- @GetMapping("getById/{id}")
- public Result findById(@PathVariable Long id){
- return ResultGenerator.genSuccessResult(userService.getById(id));
- }
-
-}
diff --git a/java_project_template/jun_api_service_demo/src/main/resources/application-dev.yml b/java_project_template/jun_api_service_demo/src/main/resources/application-dev.yml
deleted file mode 100644
index bc1c96e6c7..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/resources/application-dev.yml
+++ /dev/null
@@ -1,31 +0,0 @@
-# 开发环境配置
-spring:
- datasource:
- dynamic:
- primary: master #设置默认的数据源或者数据源组,默认值即为master
- datasource:
- master:
- username: root
- password:
- driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://localhost:3306/test?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2b8
- slave_1:
- username: root
- password: 123456
- driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://xx.xx.xx.xx:3307/dynamic?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2b8
- slave_2:
- username: root
- password: 123456
- driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://xx.xx.xx.xx:3308/dynamic?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2b8
- #......省略
- #以上会配置一个默认库master,一个组slave下有两个子库slave_1,slave_2
-mybatis-plus:
- configuration:
- log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
- mapper-locations: classpath:mapper/*.xml
- global-config:
- db-config:
- logic-delete-value: 1
- logic-not-delete-value: 0
diff --git a/java_project_template/jun_api_service_demo/src/main/resources/application-prod.yml b/java_project_template/jun_api_service_demo/src/main/resources/application-prod.yml
deleted file mode 100644
index 50dcaed189..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/resources/application-prod.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-# 生产环境配置
-knife4j:
- production: true #生成环境禁用查看接口文档
diff --git a/java_project_template/jun_api_service_demo/src/main/resources/application-test.yml b/java_project_template/jun_api_service_demo/src/main/resources/application-test.yml
deleted file mode 100644
index 287da7b20e..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/resources/application-test.yml
+++ /dev/null
@@ -1 +0,0 @@
-# 测试环境配置
diff --git a/java_project_template/jun_api_service_demo/src/main/resources/application.yml b/java_project_template/jun_api_service_demo/src/main/resources/application.yml
deleted file mode 100644
index facce6d372..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/resources/application.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-spring:
- profiles:
- active: dev
- mvc:
- throw-exception-if-no-handler-found: true
- resources:
- add-mappings: false
- application:
- name: Springboot-api
- jackson:
- date-format: yyyy-MM-dd HH:mm:ss
- time-zone: GMT+8
-server:
- port: 8080
diff --git a/java_project_template/jun_api_service_demo/src/main/resources/banner.txt b/java_project_template/jun_api_service_demo/src/main/resources/banner.txt
deleted file mode 100644
index 152e179398..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/resources/banner.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-////////////////////////////////////////////////////////////////////
-// _ooOoo_ //
-// o8888888o //
-// 88" . "88 //
-// (| ^_^ |) //
-// O\ = /O //
-// ____/`---'\____ //
-// .' \\| |// `. //
-// / \\||| : |||// \ //
-// / _||||| -:- |||||- \ //
-// | | \\\ - /// | | //
-// | \_| ''\---/'' | | //
-// \ .-\__ `-` ___/-. / //
-// ___`. .' /--.--\ `. . ___ //
-// ."" '< `.___\_<|>_/___.' >'"". //
-// | | : `- \`.;`\ _ /`;.`/ - ` : | | //
-// \ \ `-. \_ __\ /__ _/ .-` / / //
-// ========`-.____`-.___\_____/___.-`____.-'======== //
-// `=---=' //
-// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
-// 佛祖保佑 永不宕机 永无BUG //
-////////////////////////////////////////////////////////////////////
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_demo/src/main/resources/mapper/UserMapper.xml b/java_project_template/jun_api_service_demo/src/main/resources/mapper/UserMapper.xml
deleted file mode 100644
index 87ab7e4161..0000000000
--- a/java_project_template/jun_api_service_demo/src/main/resources/mapper/UserMapper.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- id, username, password, nick_name, sex, create_date, create_user, update_date, update_user, del_flag
-
-
-
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_demo/src/test/java/CodeGenerator.java b/java_project_template/jun_api_service_demo/src/test/java/CodeGenerator.java
deleted file mode 100644
index 1c3b5f2dd8..0000000000
--- a/java_project_template/jun_api_service_demo/src/test/java/CodeGenerator.java
+++ /dev/null
@@ -1,113 +0,0 @@
-import com.baomidou.mybatisplus.core.toolkit.StringPool;
-import com.baomidou.mybatisplus.generator.AutoGenerator;
-import com.baomidou.mybatisplus.generator.InjectionConfig;
-import com.baomidou.mybatisplus.generator.config.*;
-import com.baomidou.mybatisplus.generator.config.po.TableInfo;
-import com.baomidou.mybatisplus.generator.config.rules.DateType;
-import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
-import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
-
-import java.util.ArrayList;
-import java.util.List;
-
-// 演示例子,执行 main 方法控制台输入模块表名回车自动生成对应项目目录中
-public class CodeGenerator {
-
-
- //多个表逗号分隔
- static String tableName = "user_copy";
- //逻辑删除字段名, 假如表没有逻辑删除字段,请忽视
- static String logicDeleteFieldName = "del_flag";
-
- public static void main(String[] args) {
- // 代码生成器
- AutoGenerator mpg = new AutoGenerator();
-
- // 全局配置
- GlobalConfig gc = new GlobalConfig();
- String projectPath = System.getProperty("user.dir");
- gc.setOutputDir(projectPath + "/src/main/java");
- gc.setAuthor("aitangbao");
- gc.setOpen(false);
- gc.setBaseColumnList(true);
- gc.setBaseResultMap(true);
- gc.setDateType(DateType.ONLY_DATE);
- // gc.setSwagger2(true); 实体属性 Swagger2 注解
- mpg.setGlobalConfig(gc);
-
- // 数据源配置
- DataSourceConfig dsc = new DataSourceConfig();
- dsc.setUrl("jdbc:mysql://localhost:3306/project?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=UTC");
- // dsc.setSchemaName("public");
- dsc.setDriverName("com.mysql.cj.jdbc.Driver");
- dsc.setUsername("root");
- dsc.setPassword("123456");
- mpg.setDataSource(dsc);
-
- // 包配置
- PackageConfig pc = new PackageConfig();
- pc.setParent("com.company.project");
- pc.setEntity("model");
- pc.setMapper("dao");
- pc.setController("web");
- mpg.setPackageInfo(pc);
-
- // 自定义配置
- InjectionConfig cfg = new InjectionConfig() {
- @Override
- public void initMap() {
- // to do nothing
- }
- };
-
- // 如果模板引擎是 freemarker
- String templatePath = "/templates/mapper.xml.ftl";
- // 如果模板引擎是 velocity
- // String templatePath = "/templates/mapper.xml.vm";
-
- // 自定义输出配置
- List focList = new ArrayList<>();
- // 自定义配置会被优先输出
- focList.add(new FileOutConfig(templatePath) {
- @Override
- public String outputFile(TableInfo tableInfo) {
- // 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
- return projectPath + "/src/main/resources/mapper/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
- }
- });
- cfg.setFileOutConfigList(focList);
- mpg.setCfg(cfg);
-
- // 配置模板
- TemplateConfig templateConfig = new TemplateConfig();
-
- // 配置自定义输出模板
- //指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别
-// templateConfig.setEntity("templates/entity.java");
- // templateConfig.setService();
- templateConfig.setController("templates/controller.java");
-
- templateConfig.setXml(null);
- mpg.setTemplate(templateConfig);
-
- // 策略配置
- StrategyConfig strategy = new StrategyConfig();
- strategy.setNaming(NamingStrategy.underline_to_camel);
- strategy.setColumnNaming(NamingStrategy.underline_to_camel);
-// strategy.setSuperEntityClass("你自己的父类实体,没有就不用设置!");
- strategy.setEntityLombokModel(true);
- strategy.setRestControllerStyle(true);
- // 公共父类
-// strategy.setSuperControllerClass("你自己的父类控制器,没有就不用设置!");
- // 写于父类中的公共字段
-// strategy.setSuperEntityColumns("id");
- strategy.setInclude(tableName.split(","));
- strategy.setControllerMappingHyphenStyle(true);
- strategy.setLogicDeleteFieldName(logicDeleteFieldName); // 逻辑删除字段名称
- strategy.setTablePrefix(pc.getModuleName() + "_");
- mpg.setStrategy(strategy);
- mpg.setTemplateEngine(new FreemarkerTemplateEngine());
- mpg.execute();
- }
-
-}
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_demo/src/test/java/com/company/project/Tester.java b/java_project_template/jun_api_service_demo/src/test/java/com/company/project/Tester.java
deleted file mode 100644
index f513bc219d..0000000000
--- a/java_project_template/jun_api_service_demo/src/test/java/com/company/project/Tester.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.company.project;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-/**
- * 单元测试
- */
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = Application.class)
-public class Tester {
-
- @Test
- public void test() {
-
- }
-}
-
-
-
diff --git a/java_project_template/jun_api_service_demo/src/test/resources/templates/controller.java.ftl b/java_project_template/jun_api_service_demo/src/test/resources/templates/controller.java.ftl
deleted file mode 100644
index a62f181707..0000000000
--- a/java_project_template/jun_api_service_demo/src/test/resources/templates/controller.java.ftl
+++ /dev/null
@@ -1,94 +0,0 @@
-package ${package.Controller};
-
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.company.project.core.Result;
-import com.company.project.core.ResultGenerator;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import org.springframework.web.bind.annotation.*;
-import ${package.Service}.${table.serviceName};
-import ${package.Entity}.${entity};
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-
-import javax.annotation.Resource;
-<#if restControllerStyle>
-import org.springframework.web.bind.annotation.RestController;
-<#else>
-import org.springframework.stereotype.Controller;
-#if>
-<#if superControllerClassPackage??>
-import ${superControllerClassPackage};
-#if>
-
-/**
- *
- * ${table.comment!} 前端控制器
- *
- *
- * @author ${author}
- * @since ${date}
- */
-<#if restControllerStyle>
-@Api(tags = {"${table.comment!}"})
-@Slf4j
-@RestController
-<#else>
-@Controller
-#if>
-@RequestMapping("<#if package.ModuleName??>/${package.ModuleName}#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}#if>")
-<#if kotlin>
-class ${table.controllerName}<#if superControllerClass??>:${superControllerClass}()#if>
-<#else>
-<#if superControllerClass??>public class ${table.controllerName} extends ${superControllerClass}{
-<#else>public class ${table.controllerName} {
-#if>
-
- @Resource
- private ${table.serviceName} ${(table.serviceName?substring(1))?uncap_first};
-
-
- @ApiOperation(value = "新增${table.comment!}")
- @PostMapping("add")
- public Result add(@RequestBody ${entity} ${entity?uncap_first}){
- ${(table.serviceName?substring(1))?uncap_first}.save(${entity?uncap_first});
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation(value = "删除${table.comment!}")
- @PostMapping("delete/{id}")
- public Result delete(@PathVariable("id") Long id){
- ${(table.serviceName?substring(1))?uncap_first}.removeById(id);
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation(value = "更新${table.comment!}")
- @PostMapping("update")
- public Result update(@RequestBody ${entity} ${entity?uncap_first}){
- ${(table.serviceName?substring(1))?uncap_first}.updateById(${entity?uncap_first});
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation(value = "查询${table.comment!}分页数据")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "currentPage", value = "页码"),
- @ApiImplicitParam(name = "pageCount", value = "每页条数")
- })
- @GetMapping("listByPage")
- public Result findListByPage(@RequestParam Integer currentPage,
- @RequestParam Integer pageCount){
- Page page = new Page(currentPage, pageCount);
- IPage<${entity}> iPage = ${(table.serviceName?substring(1))?uncap_first}.page(page);
- return ResultGenerator.genSuccessResult(iPage);
- }
-
- @ApiOperation(value = "id查询${table.comment!}")
- @GetMapping("getById/{id}")
- public Result findById(@PathVariable Long id){
- return ResultGenerator.genSuccessResult(${(table.serviceName?substring(1))?uncap_first}.getById(id));
- }
-
-}
-#if>
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_demo/src/test/resources/user.sql b/java_project_template/jun_api_service_demo/src/test/resources/user.sql
deleted file mode 100644
index 51bd7db81e..0000000000
--- a/java_project_template/jun_api_service_demo/src/test/resources/user.sql
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- Navicat Premium Data Transfer
-
- Source Server : localhost
- Source Server Type : MySQL
- Source Server Version : 50529
- Source Host : localhost:3306
- Source Schema : project
-
- Target Server Type : MySQL
- Target Server Version : 50529
- File Encoding : 65001
-
- Date: 08/01/2020 15:53:02
-*/
-
-SET NAMES utf8mb4;
-SET FOREIGN_KEY_CHECKS = 0;
-
--- ----------------------------
--- Table structure for user
--- ----------------------------
-DROP TABLE IF EXISTS `user`;
-CREATE TABLE `user` (
- `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
- `username` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户名',
- `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码',
- `nick_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '昵称',
- `sex` int(1) NULL DEFAULT NULL COMMENT '性别',
- `create_date` datetime NULL DEFAULT NULL COMMENT '创建时间',
- `create_user` int(11) NULL DEFAULT NULL COMMENT '创建人',
- `update_date` datetime NULL DEFAULT NULL COMMENT '修改时间',
- `update_user` int(11) NULL DEFAULT NULL COMMENT '修改人',
- `del_flag` int(1) NULL DEFAULT 0 COMMENT '删除标志0未删 1删除',
- PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
-
--- ----------------------------
--- Records of user
--- ----------------------------
-INSERT INTO `user` VALUES (1, 'admin', '9dc818b4bca3baa7d230fbf96c919638', '土豆', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `user` VALUES (2, '2@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '土豆-2', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `user` VALUES (3, '3@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '土豆-3', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `user` VALUES (4, '4@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '土豆-4', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `user` VALUES (5, '5@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '土豆-5', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `user` VALUES (6, '6@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '土豆-6', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `user` VALUES (7, '7@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '土豆-7', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `user` VALUES (8, '8@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '土豆-8', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `user` VALUES (9, '9@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '土豆-9', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `user` VALUES (10, '10@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '土豆-10', 1, NULL, NULL, NULL, NULL, 0);
-
-SET FOREIGN_KEY_CHECKS = 1;
diff --git a/java_project_template/jun_api_service_main/doc/user.sql b/java_project_template/jun_api_service_main/doc/user.sql
deleted file mode 100644
index 5503994482..0000000000
--- a/java_project_template/jun_api_service_main/doc/user.sql
+++ /dev/null
@@ -1,36 +0,0 @@
-SET NAMES utf8mb4;
-SET FOREIGN_KEY_CHECKS = 0;
-
--- ----------------------------
--- Table structure for user
--- ----------------------------
-DROP TABLE IF EXISTS `sys_user`;
-CREATE TABLE `sys_user` (
- `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
- `username` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户名',
- `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码',
- `nick_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '昵称',
- `sex` int(1) NULL DEFAULT NULL COMMENT '性别',
- `create_date` datetime NULL DEFAULT NULL COMMENT '创建时间',
- `create_user` int(11) NULL DEFAULT NULL COMMENT '创建人',
- `update_date` datetime NULL DEFAULT NULL COMMENT '修改时间',
- `update_user` int(11) NULL DEFAULT NULL COMMENT '修改人',
- `del_flag` int(1) NULL DEFAULT 0 COMMENT '删除标志0未删 1删除',
- PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
-
--- ----------------------------
--- Records of user
--- ----------------------------
-INSERT INTO `sys_user` VALUES (1, 'admin', '9dc818b4bca3baa7d230fbf96c919638', '用户', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `sys_user` VALUES (2, '2@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '用户-2', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `sys_user` VALUES (3, '3@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '用户-3', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `sys_user` VALUES (4, '4@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '用户-4', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `sys_user` VALUES (5, '5@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '用户-5', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `sys_user` VALUES (6, '6@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '用户-6', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `sys_user` VALUES (7, '7@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '用户-7', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `sys_user` VALUES (8, '8@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '用户-8', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `sys_user` VALUES (9, '9@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '用户-9', 1, NULL, NULL, NULL, NULL, 0);
-INSERT INTO `sys_user` VALUES (10, '10@qq.com', '9dc818b4bca3baa7d230fbf96c919638', '用户-10', 1, NULL, NULL, NULL, NULL, 0);
-
-SET FOREIGN_KEY_CHECKS = 1;
diff --git a/java_project_template/jun_api_service_main/pom.xml b/java_project_template/jun_api_service_main/pom.xml
deleted file mode 100644
index 3a405fe579..0000000000
--- a/java_project_template/jun_api_service_main/pom.xml
+++ /dev/null
@@ -1,155 +0,0 @@
-
-
- 4.0.0
-
- com.jun.plugin
- jun_api_service_main
- 1.0
- jar
-
-
- 1.8
- 3.3.0
-
-
-
-
- org.springframework.boot
- spring-boot-starter-parent
- 2.5.14
-
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-starter-jdbc
-
-
-
- org.springframework.boot
- spring-boot-starter-data-redis
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
- com.baomidou
- mybatis-plus
- ${mybatis-plus.version}
-
-
- com.baomidou
- mybatis-plus-boot-starter
- ${mybatis-plus.version}
-
-
- com.baomidou
- mybatis-plus-generator
- ${mybatis-plus.version}
-
-
- org.projectlombok
- lombok
- 1.18.26
- provided
-
-
-
-
-
- commons-codec
- commons-codec
-
-
- org.apache.commons
- commons-lang3
- 3.6
-
-
-
- mysql
- mysql-connector-java
- runtime
-
-
-
-
- com.alibaba
- fastjson
- 1.2.47
-
-
-
- com.alibaba
- druid-spring-boot-starter
- 1.1.10
-
-
-
- org.freemarker
- freemarker
- 2.3.30
- test
-
-
-
- com.github.xiaoymin
- knife4j-spring-boot-starter
- 2.0.2
-
-
- cn.hutool
- hutool-all
- 5.8.18
- compile
-
-
- junit
- junit
- test
-
-
- javax.validation
- validation-api
-
-
-
-
-
-
- aliyun-repos
- http://maven.aliyun.com/nexus/content/groups/public/
-
- false
-
-
-
-
-
-
- aliyun-plugin
- http://maven.aliyun.com/nexus/content/groups/public/
-
- false
-
-
-
-
-
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/ApiServiceApplication.java b/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/ApiServiceApplication.java
deleted file mode 100644
index c41f85cc60..0000000000
--- a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/ApiServiceApplication.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package com.jun.plugin.system;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.boot.CommandLineRunner;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.web.servlet.ServletComponentScan;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.core.env.Environment;
-
-import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
-
-import cn.hutool.core.lang.Console;
-import cn.hutool.extra.spring.SpringUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.scheduling.annotation.EnableScheduling;
-
-@Slf4j
-@EnableScheduling
-@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class) // 多数据源 (exclude = DruidDataSourceAutoConfigure.class)
-@MapperScan({"com.jun.plugin.**.mapper","com.bjc.lcp.**.mapper"})
-@ComponentScan(basePackages = {"com.bjc.lcp","com.jun.plugin"})
-@ServletComponentScan(basePackages = {"com.jun.plugin.**.filter"})
-public class ApiServiceApplication {
-
- public static void main(String[] args) throws UnknownHostException {
- SpringApplication app = new SpringApplication(ApiServiceApplication.class);
- Environment env = app.run(args).getEnvironment();
- log.info("\n----------------------------------------------------------\n\t" +
- "Application '{}' is running! Access URLs:\n\t" +
- "Local: \t\thttp://localhost:{}\n\t" +
- "External: \thttp://{}:{}\n\t" +
- "Knife4j: \thttp://localhost:{}/doc.html\n" +
- "SwaggerUI: \thttp://localhost:{}/swagger-ui.html\n" +
- "----------------------------------------------------------",
- env.getProperty("spring.application.name"),
- env.getProperty("server.port"),
- InetAddress.getLocalHost().getHostAddress(),
- env.getProperty("server.port"),
- env.getProperty("server.port"),
- env.getProperty("server.port"));
- Console.log(env.getProperty("server.port"));
- log.info("profiles = " + SpringUtil.getProperty("spring.profiles.active"));
- log.info("url = " + SpringUtil.getProperty("spring.datasource.url"));
- log.info("context = " + SpringUtil.getProperty("spring.groovy-api.context"));
- //SpringApplication.run(GroovyDemoApplication.class, args);
- }
-
- @Bean
- public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
- return args -> {
- System.out.println("Let's inspect the beans provided by Spring Boot:");
- String[] beanNames = ctx.getBeanDefinitionNames();
- System.err.println("beanNames size = "+ beanNames.length);
- for (String beanName : beanNames) {
- //System.err.println(beanName);
- /*
- * Object bean = ctx.getBean(beanName); System.out.println(bean);
- * System.out.println();
- */
- }
-
- };
- }
-
-
-
-
-}
diff --git a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/configurer/LoginInterceptor.java b/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/configurer/LoginInterceptor.java
deleted file mode 100644
index bc938a0f60..0000000000
--- a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/configurer/LoginInterceptor.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.jun.plugin.system.configurer;
-
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.jun.plugin.system.core.Result;
-import com.jun.plugin.system.core.ResultCode;
-import com.jun.plugin.system.service.HttpSessionService;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import java.io.IOException;
-
-/**
- * @author wenbin
- * @since 2019/10/30 15:29
- * 登陆拦截器
- */
-public class LoginInterceptor extends HandlerInterceptorAdapter {
-
- @Autowired
- private HttpSessionService httpSession;
-
- private final Logger logger = LoggerFactory.getLogger(WebMvcConfigurer.class);
-
- @Override
- public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
- //用户当前session信息
- JSONObject currentSession;
- //拦截接口
- //从header中获取token
- String token = request.getHeader("token");
- //如果header中不存在token,则从参数中获取token
- if (StringUtils.isBlank(token)) {
- token = request.getParameter("token");
- }
- //token为空返回
- if (StringUtils.isBlank(token)) {
- Result result = new Result();
- result.setCode(ResultCode.UNAUTHORIZED).setMessage("token不能为空").setSuccess(false);
- responseResult(response, result);
- return false;
- }// 校验并解析token,如果token过期或者篡改,则会返回null
- currentSession = httpSession.getCurrentSession();
- if (null != currentSession) {
- return true;
- } else {
- Result result = new Result();
- result.setCode(ResultCode.UNAUTHORIZED).setMessage("用户未登陆!").setSuccess(false);
- responseResult(response, result);
- return false;
- }
- }
-
-
- private void responseResult(HttpServletResponse response, Result result) {
- response.setCharacterEncoding("UTF-8");
- response.setHeader("Content-type", "application/json;charset=UTF-8");
- try {
- response.getWriter().write(JSON.toJSONString(result));
- } catch (IOException ex) {
- logger.error(ex.getMessage());
- }
- }
-}
diff --git a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/configurer/WebMvcConfigurer.java b/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/configurer/WebMvcConfigurer.java
deleted file mode 100644
index 0f2c8847f6..0000000000
--- a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/configurer/WebMvcConfigurer.java
+++ /dev/null
@@ -1,166 +0,0 @@
-package com.jun.plugin.system.configurer;
-
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.serializer.SerializerFeature;
-import com.alibaba.fastjson.support.config.FastJsonConfig;
-import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
-
-import com.jun.plugin.system.core.Result;
-import com.jun.plugin.system.core.ResultCode;
-import com.jun.plugin.system.core.ResultGenerator;
-import com.jun.plugin.system.core.ServiceException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.MediaType;
-import org.springframework.http.converter.HttpMessageConverter;
-import org.springframework.web.bind.MethodArgumentNotValidException;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.method.HandlerMethod;
-import org.springframework.web.servlet.HandlerExceptionResolver;
-import org.springframework.web.servlet.ModelAndView;
-import org.springframework.web.servlet.NoHandlerFoundException;
-import org.springframework.web.servlet.config.annotation.*;
-
-/**
- * Spring MVC 配置
- */
-@Configuration
-public class WebMvcConfigurer extends WebMvcConfigurerAdapter {
-
- private final Logger logger = LoggerFactory.getLogger(WebMvcConfigurer.class);
-
- @Bean
- LoginInterceptor loginInterceptor() {
-
- return new LoginInterceptor();
- }
-
-
- //使用阿里 FastJson 作为JSON MessageConverter
- @Override
- public void configureMessageConverters(List> converters) {
- FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
- FastJsonConfig config = new FastJsonConfig();
- config.setSerializerFeatures(SerializerFeature.WriteMapNullValue);//保留空的字段
- //SerializerFeature.WriteNullStringAsEmpty,//String null -> ""
- //SerializerFeature.WriteNullNumberAsZero//Number null -> 0
- // 按需配置,更多参考FastJson文档哈
-
- converter.setFastJsonConfig(config);
- converter.setDefaultCharset(Charset.forName("UTF-8"));
- converter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON_UTF8));
- converters.add(converter);
- }
-
-
- //统一异常处理
- @Override
- public void configureHandlerExceptionResolvers(List exceptionResolvers) {
- exceptionResolvers.add(new HandlerExceptionResolver() {
- public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception e) {
- Result result = new Result();
- if (e instanceof ServiceException) {//业务失败的异常,如“账号或密码错误”
- result.setCode(ResultCode.FAIL).setMessage(e.getMessage()).setSuccess(false);
- } else if (e instanceof MethodArgumentNotValidException) {//@valid注解验证参数
- MethodArgumentNotValidException m = (MethodArgumentNotValidException) e;
- m.getBindingResult().getFieldError().getDefaultMessage();
- result.setCode(ResultCode.PARAM_FAIL).setMessage(m.getBindingResult().getFieldError().getDefaultMessage()).setSuccess(false);
- } else if (e instanceof NoHandlerFoundException) {
- result.setCode(ResultCode.NOT_FOUND).setMessage("接口 [" + request.getRequestURI() + "] 不存在").setSuccess(false);
- } else if (e instanceof ServletException) {
- result.setCode(ResultCode.FAIL).setMessage(e.getMessage()).setSuccess(false);
- } else {
- result.setCode(ResultCode.INTERNAL_SERVER_ERROR).setMessage("接口 [" + request.getRequestURI() + "] 内部错误,请联系管理员").setSuccess(false);
- String message;
- if (handler instanceof HandlerMethod) {
- HandlerMethod handlerMethod = (HandlerMethod) handler;
- message = String.format("接口 [%s] 出现异常,方法:%s.%s,异常摘要:%s",
- request.getRequestURI(),
- handlerMethod.getBean().getClass().getName(),
- handlerMethod.getMethod().getName(),
- e.getMessage());
- } else {
- message = e.getMessage();
- }
- logger.error(message, e);
- }
- responseResult(response, result);
- return new ModelAndView();
- }
-
- });
- }
-
- @ExceptionHandler(MethodArgumentNotValidException.class)
- public Result handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
- return ResultGenerator.genFailResult(e.getBindingResult().getFieldError().getDefaultMessage());
- }
-
- /**
- * 页面跨域访问Controller过滤
- *
- * @return
- */
- @Override
- public void addCorsMappings(CorsRegistry registry) {
- WebMvcConfigurer.super.addCorsMappings(registry);
- registry.addMapping("/**")
- .allowedHeaders("*")
- .allowedMethods("POST", "GET")
- .allowedOrigins("*");
- }
-
- //添加拦截器
- @Override
- public void addInterceptors(InterceptorRegistry registry) {
- registry.addInterceptor(loginInterceptor())
- .excludePathPatterns("/doc.html")
- .excludePathPatterns("/swagger-resources/**")
- .excludePathPatterns("/error")
- .excludePathPatterns("/webjars/**")
- .excludePathPatterns("/api/user/login")
- .excludePathPatterns("/api/user/register")
- .addPathPatterns("/**");
- }
-
-
- private void responseResult(HttpServletResponse response, Result result) {
- response.setCharacterEncoding("UTF-8");
- response.setHeader("Content-type", "application/json;charset=UTF-8");
- try {
- response.getWriter().write(JSON.toJSONString(result));
- } catch (IOException ex) {
- logger.error(ex.getMessage());
- }
- }
-
- /**
- * 发现如果继承了WebMvcConfigurationSupport,则在yml中配置的相关内容会失效。 需要重新指定静态资源
- *
- * @param registry
- */
- @Override
- public void addResourceHandlers(ResourceHandlerRegistry registry) {
- registry.addResourceHandler("/**").addResourceLocations(
- "classpath:/static/");
- registry.addResourceHandler("doc.html").addResourceLocations(
- "classpath:/META-INF/resources/");
- registry.addResourceHandler("/webjars/**").addResourceLocations(
- "classpath:/META-INF/resources/webjars/");
- super.addResourceHandlers(registry);
- }
-
-
-}
-
diff --git a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/core/Result.java b/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/core/Result.java
deleted file mode 100644
index 9226990ccb..0000000000
--- a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/core/Result.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package com.jun.plugin.system.core;
-
-import com.alibaba.fastjson.JSON;
-
-/**
- * 统一API响应结果封装
- */
-public class Result {
- private int code;
- private String message;
- private T data;
- private Boolean success;
-
- public Result setCode(ResultCode resultCode) {
- this.code = resultCode.code();
- return this;
- }
-
- public int getCode() {
- return code;
- }
-
- public String getMessage() {
- return message;
- }
-
- public Result setMessage(String message) {
- this.message = message;
- return this;
- }
-
- public T getData() {
- return data;
- }
-
- public Result setData(T data) {
- this.data = data;
- return this;
- }
-
- public Boolean getSuccess() {
- return success;
- }
-
- public Result setSuccess(Boolean success) {
- this.success = success;
- return this;
- }
-
- @Override
- public String toString() {
- return JSON.toJSONString(this);
- }
-}
diff --git a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/core/ResultCode.java b/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/core/ResultCode.java
deleted file mode 100644
index ad96be137d..0000000000
--- a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/core/ResultCode.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.jun.plugin.system.core;
-
-/**
- * 响应码枚举,参考HTTP状态码的语义
- */
-public enum ResultCode {
- SUCCESS(200),//成功
- FAIL(400),//失败
- UNAUTHORIZED(401),//未认证(签名错误)
- NOT_FOUND(404),//接口不存在
- INTERNAL_SERVER_ERROR(500),//服务器内部错误
- PARAM_FAIL(10001);//参数异常
-
- private final int code;
-
- ResultCode(int code) {
- this.code = code;
- }
-
- public int code() {
- return code;
- }
-}
diff --git a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/core/ResultGenerator.java b/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/core/ResultGenerator.java
deleted file mode 100644
index 15a347e0d6..0000000000
--- a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/core/ResultGenerator.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.jun.plugin.system.core;
-
-/**
- * 响应结果生成工具
- */
-public class ResultGenerator {
- private static final String DEFAULT_SUCCESS_MESSAGE = "SUCCESS";
-
- public static Result genSuccessResult() {
- return new Result()
- .setSuccess(true)
- .setCode(ResultCode.SUCCESS)
- .setMessage(DEFAULT_SUCCESS_MESSAGE);
- }
-
- public static Result genSuccessResult(T data) {
- return new Result()
- .setSuccess(true)
- .setCode(ResultCode.SUCCESS)
- .setMessage(DEFAULT_SUCCESS_MESSAGE)
- .setData(data);
- }
-
- public static Result genFailResult(String message) {
- return new Result()
- .setSuccess(false)
- .setCode(ResultCode.FAIL)
- .setMessage(message);
- }
-}
diff --git a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/core/ServiceException.java b/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/core/ServiceException.java
deleted file mode 100644
index 47352a26f7..0000000000
--- a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/core/ServiceException.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.jun.plugin.system.core;
-
-/**
- * 服务(业务)异常如“ 账号或密码错误 ”,该异常只做INFO级别的日志记录 @see WebMvcConfigurer
- */
-public class ServiceException extends RuntimeException {
- public ServiceException() {
- }
-
- public ServiceException(String message) {
- super(message);
- }
-
- public ServiceException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/mapper/UserMapper.java b/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/mapper/UserMapper.java
deleted file mode 100644
index 15d4a4e183..0000000000
--- a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/mapper/UserMapper.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.jun.plugin.system.mapper;
-
-import com.jun.plugin.system.model.User;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-
-/**
- *
- * Mapper 接口
- *
- *
- * @author project
- * @since 2020-01-08
- */
-public interface UserMapper extends BaseMapper {
-
-}
diff --git a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/model/User.java b/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/model/User.java
deleted file mode 100644
index 19dfc1f8e9..0000000000
--- a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/model/User.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package com.jun.plugin.system.model;
-
-import com.baomidou.mybatisplus.annotation.*;
-
-import java.io.Serializable;
-import java.util.Date;
-
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-import javax.validation.constraints.NotEmpty;
-
-/**
- *
- *
- *
- *
- * @author project
- * @since 2020-01-08
- */
-@Data
-@EqualsAndHashCode(callSuper = false)
-@Accessors(chain = true)
-@TableName("user")
-public class User implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * 主键
- */
- @TableId(value = "id", type = IdType.AUTO)
- private Integer id;
-
- /**
- * 用户名
- */
- @NotEmpty(message = "用户名不能为空!")
- private String username;
-
- /**
- * 密码
- */
- @NotEmpty(message = "密码不能为空!")
- private String password;
-
- /**
- * 昵称
- */
- private String nickName;
-
- /**
- * 性别
- */
- private Integer sex;
-
- /**
- * 创建时间
- */
- private Date createDate;
-
- /**
- * 创建人
- */
- private Integer createUser;
-
- /**
- * 修改时间
- */
- private Date updateDate;
-
- /**
- * 修改人
- */
- private Integer updateUser;
-
- /**
- * 删除标志0未删 1删除
- */
- @TableLogic
- private Integer delFlag;
-
- /**
- * 登陆返回token
- */
- @TableField(exist = false)
- private String token;
-
-}
diff --git a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/service/HttpSessionService.java b/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/service/HttpSessionService.java
deleted file mode 100644
index c2d0bd3afc..0000000000
--- a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/service/HttpSessionService.java
+++ /dev/null
@@ -1,148 +0,0 @@
-package com.jun.plugin.system.service;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.jun.plugin.system.model.User;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.Random;
-
-/**
- * session管理器
- *
- * @author aitangbao
- */
-@Service
-public class HttpSessionService {
-
- @Autowired
- private RedisService redisDB;
-
- @Autowired
- private HttpServletRequest request;
-
- @Value("${spring.redis.key.prefix.userToken}")
- private String USER_TOKEN_PREFIX;
-
- @Value("${spring.redis.key.expire.userToken}")
- private int EXPIRE ;
-
- public String createTokenAndUser(User user) {
- //方便根据id找到redis的key, 修改密码/退出登陆 方便使用
- String token = getRandomToken(32) + "#" + user.getId();
- JSONObject sessionInfo = new JSONObject();
- sessionInfo.put("userId", user.getId());
- sessionInfo.put("username", user.getUsername());
- String key = USER_TOKEN_PREFIX + token;
- //设置该用户已登录的token
- redisDB.setAndExpire(key, sessionInfo.toJSONString(), EXPIRE);
- return token;
- }
-
- /**
- * 根据token获取userid
- *
- * @param token
- * @return
- */
- public static String getUserIdByToken(String token) {
- if (StringUtils.isBlank(token) || !token.contains("#")) {
- return "";
- } else {
- return token.substring(token.indexOf("#") + 1);
- }
- }
-
- /**
- * 获取参数中的token
- *
- * @return
- */
- public String getTokenFromHeader() {
- String token = request.getHeader("token");
- //如果header中不存在token,则从参数中获取token
- if (StringUtils.isBlank(token)) {
- token = request.getParameter("token");
- }
- return token;
- }
-
- /**
- * 获取当前session信息
- *
- * @return
- */
- public JSONObject getCurrentSession() {
- String token = getTokenFromHeader();
- if (null != token) {
- if (redisDB.exists(USER_TOKEN_PREFIX + token)) {
- String sessionInfoStr = redisDB.get(USER_TOKEN_PREFIX + token);
- JSONObject sessionInfo = JSON.parseObject(sessionInfoStr);
- return sessionInfo;
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
-
- /**
- * 使当前用户的token失效
- */
- public void abortUserByToken() {
- String token = getTokenFromHeader();
- redisDB.del(USER_TOKEN_PREFIX + token);
- }
-
- /**
- * 使所有用户的token失效
- */
- public void abortAllUserByToken() {
- String token = getTokenFromHeader();
- String userId = getUserIdByToken(token);
- redisDB.delKeys(USER_TOKEN_PREFIX+"*#" + userId);
- }
-
- /**
- * 使用户的token失效
- */
- public void abortUserByUserId(Integer userId) {
- redisDB.delKeys(USER_TOKEN_PREFIX+"*#" + userId);
- }
-
-
- /**
- * 生成随机的token
- *
- * @param length
- * @return
- */
- private String getRandomToken(int length) {
- Random random = new Random();
- StringBuilder randomStr = new StringBuilder();
-
- // 根据length生成相应长度的随机字符串
- for (int i = 0; i < length; i++) {
- String charOrNum = random.nextInt(2) % 2 == 0 ? "char" : "num";
-
- //输出字母还是数字
- if ("char".equalsIgnoreCase(charOrNum)) {
- //输出是大写字母还是小写字母
- int temp = random.nextInt(2) % 2 == 0 ? 65 : 97;
- randomStr.append((char) (random.nextInt(26) + temp));
- } else if ("num".equalsIgnoreCase(charOrNum)) {
- randomStr.append(String.valueOf(random.nextInt(10)));
- }
- }
-
- return randomStr.toString();
- }
-
-
-}
diff --git a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/service/IUserService.java b/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/service/IUserService.java
deleted file mode 100644
index abc230a605..0000000000
--- a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/service/IUserService.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.jun.plugin.system.service;
-
-import com.jun.plugin.system.core.Result;
-import com.jun.plugin.system.model.User;
-import com.baomidou.mybatisplus.extension.service.IService;
-
-/**
- *
- * 服务类
- *
- *
- * @author project
- * @since 2020-01-08
- */
-public interface IUserService extends IService {
-
- Result checkPassword(User userParam);
-}
diff --git a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/service/RedisService.java b/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/service/RedisService.java
deleted file mode 100644
index 4af29950af..0000000000
--- a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/service/RedisService.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package com.jun.plugin.system.service;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.StringRedisTemplate;
-import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
-
-import java.util.Date;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-
-/**
- * @author : aitangbao
- */
-
-@Service
-public class RedisService {
- @Autowired
- private StringRedisTemplate redisTemplate;
-
- public boolean exists(String key) {
- return this.redisTemplate.hasKey(key);
- }
-
- public String get(String key) {
- String value = this.redisTemplate.opsForValue().get(key);
- return value;
- }
-
-
- public void del(String key) {
- if (this.exists(key)) {
- this.redisTemplate.delete(key);
- }
-
- }
-
- public void setAndExpire(String key, String value, int seconds) {
- this.redisTemplate.opsForValue().set(key, value);
- this.redisTemplate.expire(key, (long) seconds, TimeUnit.SECONDS);
- }
-
-
- public void setExpire(String key, Date endTime) {
- long seconds = endTime.getTime() - (new Date()).getTime();
- this.redisTemplate.expire(key, (long) ((int) (seconds / 1000L)), TimeUnit.SECONDS);
- }
-
-
- public Set keys(String pattern) {
- return redisTemplate.keys("*" + pattern);
- }
-
- public void delKeys(String pattern) {
- Set keys = redisTemplate.keys(pattern);
- if (!CollectionUtils.isEmpty(keys)) {
- this.redisTemplate.delete(keys);
- }
- }
-}
diff --git a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/service/impl/UserServiceImpl.java b/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/service/impl/UserServiceImpl.java
deleted file mode 100644
index aef225cda7..0000000000
--- a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/service/impl/UserServiceImpl.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package com.jun.plugin.system.service.impl;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.jun.plugin.system.core.Result;
-import com.jun.plugin.system.core.ResultGenerator;
-import com.jun.plugin.system.model.User;
-import com.jun.plugin.system.mapper.UserMapper;
-import com.jun.plugin.system.service.IUserService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.jun.plugin.system.service.RedisService;
-import com.jun.plugin.system.utils.MD5Utils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
-
-/**
- *
- * 服务实现类
- *
- *
- * @author project
- * @since 2020-01-08
- */
-@Service
-public class UserServiceImpl extends ServiceImpl implements IUserService {
-
- @Autowired
- private UserMapper userMapper;
-
-
- @Autowired
- private RedisService redis;
- @Value("${spring.redis.key.prefix.passwordError}")
- private String PASSWORD_ERROR_PREFIX;
- @Value("${spring.redis.key.expire.passwordError}")
- private int PASSWORD_ERROR_EXPIRE;
-
- @Override
- public Result checkPassword(User userParam) {
-
- String username = userParam.getUsername();
- String password = userParam.getPassword();
- //redis key
- String redisPasswordErrorKey = PASSWORD_ERROR_PREFIX + username;
- //判断账户是否锁定
- String errorCount = redis.get(redisPasswordErrorKey);
- if (errorCount != null && Integer.parseInt(errorCount) == 5) {
- return ResultGenerator.genFailResult("密码连续错误5次,请1小时后重试");
- }
- //根据用户名获取用户信息
- QueryWrapper queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("username", username);
- User user = userMapper.selectOne(queryWrapper);
- if (user == null) {
- return ResultGenerator.genFailResult("账号未找到");
- }
-
- if (!MD5Utils.Encrypt(password, true).equals(user.getPassword())) {
- if (errorCount == null) {
- errorCount = "1";
- } else {
- errorCount = String.valueOf(Integer.parseInt(errorCount) + 1);
- }
- redis.setAndExpire(redisPasswordErrorKey, errorCount, PASSWORD_ERROR_EXPIRE);
- if ("5".equals(errorCount)) {
- return ResultGenerator.genFailResult("密码连续错误5次,请1小时后重试");
- } else {
- return ResultGenerator.genFailResult("密码错误,剩余次数" + (5 - Integer.parseInt(errorCount)));
- }
- } else {
- //登录成功删除错误登录次数
- redis.del(redisPasswordErrorKey);
- return ResultGenerator.genSuccessResult(user);
- }
- }
-}
diff --git a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/utils/ImageCodeUtil.java b/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/utils/ImageCodeUtil.java
deleted file mode 100644
index 44b4615a9e..0000000000
--- a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/utils/ImageCodeUtil.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package com.jun.plugin.system.utils;
-
-import lombok.extern.slf4j.Slf4j;
-
-import javax.imageio.ImageIO;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.util.Random;
-
-@Slf4j
-public class ImageCodeUtil {
-
-
- public static final String IMAGE_RANDOM_CODEKEY = "RANDOMVALIDATECODEKEY";//放到session中的key
- private String randString = "0123456789";//随机产生只有数字的字符串 private String
- //private String randString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";//随机产生只有字母的字符串
- //private String randString = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";//随机产生数字与字母组合的字符串
- private int width = 95;// 图片宽
- private int height = 25;// 图片高
- private int lineSize = 40;// 干扰线数量
- private int stringNum = 4;// 随机产生字符数量
-
-
- private Random random = new Random();
-
- /**
- * 获得字体
- */
- private Font getFont() {
- return new Font("Fixedsys", Font.CENTER_BASELINE, 18);
- }
-
- /**
- * 获得颜色
- */
- private Color getRandColor(int fc, int bc) {
- if (fc > 255)
- fc = 255;
- if (bc > 255)
- bc = 255;
- int r = fc + random.nextInt(bc - fc - 16);
- int g = fc + random.nextInt(bc - fc - 14);
- int b = fc + random.nextInt(bc - fc - 18);
- return new Color(r, g, b);
- }
-
- /**
- * 生成随机图片
- */
- public void getRandcode(HttpServletRequest request, HttpServletResponse response) {
- HttpSession session = request.getSession();
- // BufferedImage类是具有缓冲区的Image类,Image类是用于描述图像信息的类
- BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
- Graphics g = image.getGraphics();// 产生Image对象的Graphics对象,改对象可以在图像上进行各种绘制操作
- g.fillRect(0, 0, width, height);//图片大小
- g.setFont(new Font("Times New Roman", Font.ROMAN_BASELINE, 18));//字体大小
- g.setColor(getRandColor(110, 133));//字体颜色
- // 绘制干扰线
- for (int i = 0; i <= lineSize; i++) {
- drowLine(g);
- }
- // 绘制随机字符
- String randomString = "";
- for (int i = 1; i <= stringNum; i++) {
- randomString = drowString(g, randomString, i);
- }
- log.info(randomString);
- //将生成的随机字符串保存到session中
- session.removeAttribute(IMAGE_RANDOM_CODEKEY);
- session.setAttribute(IMAGE_RANDOM_CODEKEY, randomString);
- g.dispose();
- try {
- // 将内存中的图片通过流动形式输出到客户端
- ImageIO.write(image, "JPEG", response.getOutputStream());
- } catch (Exception e) {
- log.error("将内存中的图片通过流动形式输出到客户端失败>>>> ", e);
- }
-
- }
-
- /**
- * 绘制字符串
- */
- private String drowString(Graphics g, String randomString, int i) {
- g.setFont(getFont());
- g.setColor(new Color(random.nextInt(101), random.nextInt(111), random
- .nextInt(121)));
- String rand = String.valueOf(getRandomString(random.nextInt(randString
- .length())));
- randomString += rand;
- g.translate(random.nextInt(3), random.nextInt(3));
- g.drawString(rand, 13 * i, 16);
- return randomString;
- }
-
- /**
- * 绘制干扰线
- */
- private void drowLine(Graphics g) {
- int x = random.nextInt(width);
- int y = random.nextInt(height);
- int xl = random.nextInt(13);
- int yl = random.nextInt(15);
- g.drawLine(x, y, x + xl, y + yl);
- }
-
- /**
- * 获取随机的字符
- */
- public String getRandomString(int num) {
- return String.valueOf(randString.charAt(num));
- }
-}
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/utils/MD5Utils.java b/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/utils/MD5Utils.java
deleted file mode 100644
index 5d25618ede..0000000000
--- a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/utils/MD5Utils.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package com.jun.plugin.system.utils;
-
-import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
-
-public class MD5Utils {
-
- private static String salt = "springboot_api";
-
- /**
- * 加密字符串
- * @param password 要加密的明文
- * @param isAddSalt 是否加默认盐
- * @return 加密之后的结果
- */
- public static String Encrypt(String password, boolean isAddSalt){
- if (StringUtils.isNotEmpty(password)){
- if (isAddSalt){
- return DigestUtils.md5Hex(DigestUtils.md5(password + salt));
- } else {
- return DigestUtils.md5Hex(DigestUtils.md5(password));
- }
- }
- return null;
- }
-
- /**
- *
- * @param bytes
- * @return
- */
- public static String Encrypt(byte[] bytes){
- if (ArrayUtils.isNotEmpty(bytes)){
- return DigestUtils.md5Hex(DigestUtils.md5(bytes));
- }
- return null;
- }
-
- /**
- * MD5加盐加密
- * @param password 要加密的明文
- * @param salt 盐
- * @return 加密之后的结果
- */
- public static String Encrypt(String password, String salt){
- if (StringUtils.isNotEmpty(password)){
- return DigestUtils.md5Hex(DigestUtils.md5(password + salt));
- }
- return null;
- }
-
- public static void main(String[] args){
- System.out.println(MD5Utils.Encrypt("admin", true));
- }
-}
diff --git a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/web/UserController.java b/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/web/UserController.java
deleted file mode 100644
index c4c6bf4d3d..0000000000
--- a/java_project_template/jun_api_service_main/src/main/java/com/jun/plugin/system/web/UserController.java
+++ /dev/null
@@ -1,202 +0,0 @@
-package com.jun.plugin.system.web;
-
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.jun.plugin.system.core.Result;
-import com.jun.plugin.system.core.ResultGenerator;
-import com.jun.plugin.system.service.HttpSessionService;
-import com.jun.plugin.system.utils.MD5Utils;
-import com.jun.plugin.system.utils.ImageCodeUtil;
-import com.jun.plugin.system.service.IUserService;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.web.bind.annotation.*;
-import com.jun.plugin.system.model.User;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import javax.validation.Valid;
-
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- *
- * 前端控制器
- *
- *
- * @author project
- * @since 2020-01-08
- */
-@Slf4j
-@RestController
-@RequestMapping("/api/user")
-public class UserController {
-
- @Resource
- private IUserService userService;
- @Autowired
- private HttpSessionService httpSession;
-
- @Value("${spring.redis.allowMultipleLogin}")
- private Boolean allowMultipleLogin;
-
- @ApiOperation("登陆")
- @PostMapping("/login")
- public Result login(@RequestBody @Valid User userParam) {
-
- //校验密码,5次错误锁定账户
- Result result = userService.checkPassword(userParam);
- if (!result.getSuccess()) {
- return result;
- }
- //成功之后返回user
- User user = (User)result.getData();
-
- //是否删除之前token, 此处控制是否支持多登陆端;
- // true:允许多处登陆; false:只能单处登陆,顶掉之前登陆
- if (!allowMultipleLogin) {
- httpSession.abortUserByUserId(user.getId());
- }
-
- //生成token
- String token = httpSession.createTokenAndUser(user);
-
- Map resultMap = new HashMap<>(2);
- resultMap.put("token", token);
- resultMap.put("username", userParam.getUsername());
- return ResultGenerator.genSuccessResult(resultMap);
- }
-
- @ApiOperation("注册")
- @PostMapping("/register")
- public Result register(@RequestBody @Valid User user) {
- QueryWrapper queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("username", user.getUsername());
- User userO = userService.getOne(queryWrapper);
- if (userO != null) {
- return ResultGenerator.genFailResult("账号已存在");
- }
- user.setPassword(MD5Utils.Encrypt(user.getPassword(), true));
- userService.save(user);
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation("修改密码")
- @PostMapping("/updatePassword")
- public Result updatePassword(@RequestBody JSONObject param) {
- String oldPassword = param.getString("oldPassword");
- String newPassword = param.getString("newPassword");
- if (StringUtils.isBlank(oldPassword) || StringUtils.isBlank(newPassword)) {
- return ResultGenerator.genFailResult("密码不能为空");
- }
- //获取登陆信息
- JSONObject sessionInfo = httpSession.getCurrentSession();
- String userId = sessionInfo.getString("userId");
-
- User user = userService.getById(userId);
- if (user == null) {
- return ResultGenerator.genFailResult("账号未找到");
- }
- if (!MD5Utils.Encrypt(oldPassword, true).equals(user.getPassword())) {
- return ResultGenerator.genFailResult("旧密码错误");
- }
- User updateUser = new User();
- updateUser.setId(user.getId());
- updateUser.setPassword(MD5Utils.Encrypt(newPassword, true));
- userService.updateById(updateUser);
-
- //重置密码后删除原所有token
- httpSession.abortAllUserByToken();
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation("登出")
- @GetMapping("/logout")
- public Result logout() {
- //退出删除token
- httpSession.abortUserByToken();
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation("校验token是否有效")
- @GetMapping("/validateToken")
- public Result validateToken() {
- //拦截器拦截已判断,直接返回成功
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation(value = "删除")
- @PostMapping("delete/{id}")
- public Result delete(@PathVariable("id") Long id) {
- userService.removeById(id);
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation(value = "更新")
- @PostMapping("update")
- public Result update(@RequestBody User user) {
- //密码不更新
- user.setPassword(null);
- userService.updateById(user);
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation(value = "查询分页数据")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "currentPage", value = "页码"),
- @ApiImplicitParam(name = "pageCount", value = "每页条数")
- })
- @GetMapping("listByPage")
- public Result findListByPage(@RequestParam(defaultValue = "1") Integer currentPage,
- @RequestParam(defaultValue = "10") Integer pageCount) {
- Page page = new Page(currentPage, pageCount);
- IPage iPage = userService.page(page);
- return ResultGenerator.genSuccessResult(iPage);
- }
-
- @ApiOperation(value = "id查询")
- @GetMapping("getById/{id}")
- public Result findById(@PathVariable Long id) {
- return ResultGenerator.genSuccessResult(userService.getById(id));
- }
-
- @ApiOperation(value = "生成验证码")
- @GetMapping(value = "/getVerify")
- public void getVerify(HttpServletRequest request, HttpServletResponse response) {
- response.setContentType("image/jpeg");//设置相应类型,告诉浏览器输出的内容为图片
- response.setHeader("Pragma", "No-cache");//设置响应头信息,告诉浏览器不要缓存此内容
- response.setHeader("Cache-Control", "no-cache");
- response.setDateHeader("Expire", 0);
- try {
- ImageCodeUtil randomValidateCode = new ImageCodeUtil();
- randomValidateCode.getRandcode(request, response);//输出验证码图片方法
- } catch (Exception e) {
- log.error("生成验证码失败");
- }
- }
-
- @ApiOperation(value = "校验验证码")
- @PostMapping(value = "/checkVerify")
- public Result checkVerify(@RequestParam String imageCode, HttpSession session) {
- //从session中获取随机数
- Object random = session.getAttribute(ImageCodeUtil.IMAGE_RANDOM_CODEKEY);
- if (random != null && String.valueOf(random).equals(imageCode)) {
- return ResultGenerator.genSuccessResult();
- }
- return ResultGenerator.genFailResult("校验失败");
- }
-
-
-}
diff --git a/java_project_template/jun_api_service_main/src/main/resources/application-sqlite.yml b/java_project_template/jun_api_service_main/src/main/resources/application-sqlite.yml
deleted file mode 100644
index a43ec1e6f3..0000000000
--- a/java_project_template/jun_api_service_main/src/main/resources/application-sqlite.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-# 数据源配置
-spring:
- datasource:
- type: com.alibaba.druid.pool.DruidDataSource
- driverClassName: org.sqlite.JDBC
- druid:
- # 主库数据源
- master:
- # 发布后
- # url: jdbc:sqlite:./sqlite/code-generator.db
- # 开发时
- url: jdbc:sqlite::resource:static/sqlite/code-generator.db
- username: root
- password: password
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_main/src/main/resources/application-test.yml b/java_project_template/jun_api_service_main/src/main/resources/application-test.yml
deleted file mode 100644
index b9b3e21024..0000000000
--- a/java_project_template/jun_api_service_main/src/main/resources/application-test.yml
+++ /dev/null
@@ -1,88 +0,0 @@
-spring:
- redis:
- host: localhost # Redis服务器地址
- database: 0 # Redis数据库索引(默认为0)
- port: 6379 # Redis服务器连接端口
- password: # Redis服务器连接密码(默认为空)
- jedis:
- pool:
- max-active: 8 # 连接池最大连接数(使用负值表示没有限制)
- max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
- max-idle: 8 # 连接池中的最大空闲连接
- min-idle: 0 # 连接池中的最小空闲连接
- timeout: 3000 # 连接超时时间(毫秒
- # mysql
- datasource:
- type: com.alibaba.druid.pool.DruidDataSource
- #MySQL配置
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/db_qixing?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2b8
- username: root
- password:
-# username: ENC(i9EHZ6vsnfpTeKGvHmH+fA==)
-# password: ENC(KX2tfUq8cZG3IXeAwZgk5w==)
- #oracle配置
- # driverClassName: oracle.jdbc.OracleDriver
- # url: jdbc:oracle:thin:@47.100.206.162:1521:xe
- # username: renren
- # password: 123456
- #SQLServer配置
- # driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
- # url: jdbc:sqlserver://192.168.10.10:1433;DatabaseName=renren_fast
- # username: sa
- # password: 123456
- #PostgreSQL配置
- # driverClassName: org.postgresql.Driver
- # url: jdbc:postgresql://192.168.10.10:5432/renren_fast
- # username: postgres
- # password: 123456
-
- groovy-api:
-# servicename: jun-engine-api
-# enabled: true
-# context: /api
-# api_config: api_config
-# gateway: ~
-# config:
-# sql: sql.xml
-# datasource: datasource.xml
-# service-title: API平台
-# file-path: ~
-# datasource:
-# dbtype:
-# url:
-# username:
-# password:
-# class-model:
-# transcation: true
-# sql-model:
-# find-one-suffix: /first
-# pager-suffix: /page
-# count-suffix: /count
-
-
-filepath: "D:\\files\\"
-file:
- #文件上传目录 绝对路径 末尾请加 /
- path: D:/files/ #windows
- #path: /home/data/files/ #linux
- #文件预览、下载的url, 末尾请勿加 /
- url: http://qixing.vip321.vip/files
- qiniuAccessKey: ts0n9OF16ekFkDkZTTlpmyPI-tP3HKQDyw_GR4o2
- qiniuBucketName: qixing-files
- qiniuDomain: http://qiniu.vip321.vip
- qiniuPrefix: upload
- qiniuSecretKey: c-OjjwV3ZgzCQwxc6W_bsTFKuDg8qeyqohyJU0RL
- type: 1
-
-
-# AES密码加密私钥(Base64加密)
-encryptAESKey: V2FuZzkyNjQ1NGRTQkFQSUpXVA==
-# JWT认证加密私钥(Base64加密)
-encryptJWTKey: U0JBUElKV1RkV2FuZzkyNjQ1NA==
-# AccessToken过期时间-5分钟-5*60(秒为单位)
-accessTokenExpireTime: 300
-# RefreshToken过期时间-30分钟-30*60(秒为单位)
-refreshTokenExpireTime: 1800
-# Shiro缓存过期时间-5分钟-5*60(秒为单位)(一般设置与AccessToken过期时间一致)
-shiroCacheExpireTime: 300
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_main/src/main/resources/application.yml b/java_project_template/jun_api_service_main/src/main/resources/application.yml
deleted file mode 100644
index 1c9e9d4661..0000000000
--- a/java_project_template/jun_api_service_main/src/main/resources/application.yml
+++ /dev/null
@@ -1,59 +0,0 @@
-# 端口
-server:
- port: 9080
- http2:
- enabled: true
-
-spring:
- profiles:
- active: test
- mvc:
- throw-exception-if-no-handler-found: true
- resources:
- add-mappings: false
- application:
- name: groovy_api_service
- jackson:
- date-format: yyyy-MM-dd HH:mm:ss
- time-zone: GMT+8
- # 文件大小限制
- servlet:
- multipart:
- max-file-size: 10MB
- max-request-size: 100MB
- main:
- allow-bean-definition-overriding: true
- # redis token信息
- redis:
- key:
- prefix:
- userToken: "user:token:"
- passwordError: "user:password:error:"
- permissionRefresh: "user:token:permissionRefresh:"
- expire:
- userToken: 604800 # 7天 7*24*3600
- passwordError: 3600 # 一个小时
- permissionRefresh: 604800 # 7天 7*24*3600
- allowMultipleLogin: true # 允许多处登陆
-
-mybatis-plus:
- configuration:
- log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
- mapper-locations: classpath:mapper/${project.database}/**/*.xml,classpath:mapper/*.xml
- global-config:
- db-config:
- logic-delete-value: 0
- logic-not-delete-value: 1
- logic-delete-field: deleted
-
-#使用代码生成模块时 指定要生成的表存在于哪种数据库,可选值有【mysql、oracle、sqlServer】
-project:
- database: mysql
-
-jasypt:
- algorithm: PBEWithMD5AndDES
- encryptor:
- password: 123456@@
-
-shiro:
- enable: false
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_main/src/test/java/CodeGenerator.java b/java_project_template/jun_api_service_main/src/test/java/CodeGenerator.java
deleted file mode 100644
index b3c20b934e..0000000000
--- a/java_project_template/jun_api_service_main/src/test/java/CodeGenerator.java
+++ /dev/null
@@ -1,113 +0,0 @@
-import com.baomidou.mybatisplus.core.toolkit.StringPool;
-import com.baomidou.mybatisplus.generator.AutoGenerator;
-import com.baomidou.mybatisplus.generator.InjectionConfig;
-import com.baomidou.mybatisplus.generator.config.*;
-import com.baomidou.mybatisplus.generator.config.po.TableInfo;
-import com.baomidou.mybatisplus.generator.config.rules.DateType;
-import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
-import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
-
-import java.util.ArrayList;
-import java.util.List;
-
-// 演示例子,执行 main 方法控制台输入模块表名回车自动生成对应项目目录中
-public class CodeGenerator {
-
-
- //多个表逗号分隔
- static String tableName = "user";
- //逻辑删除字段名, 假如表没有逻辑删除字段,请忽视
- static String logicDeleteFieldName = "del_flag";
-
- public static void main(String[] args) {
- // 代码生成器
- AutoGenerator mpg = new AutoGenerator();
-
- // 全局配置
- GlobalConfig gc = new GlobalConfig();
- String projectPath = System.getProperty("user.dir");
- gc.setOutputDir(projectPath + "/src/main/java");
- gc.setAuthor("aitangbao");
- gc.setOpen(false);
- gc.setBaseColumnList(true);
- gc.setBaseResultMap(true);
- gc.setDateType(DateType.ONLY_DATE);
- // gc.setSwagger2(true); 实体属性 Swagger2 注解
- mpg.setGlobalConfig(gc);
-
- // 数据源配置
- DataSourceConfig dsc = new DataSourceConfig();
- dsc.setUrl("jdbc:mysql://localhost:3306/project?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=UTC");
- // dsc.setSchemaName("public");
- dsc.setDriverName("com.mysql.cj.jdbc.Driver");
- dsc.setUsername("root");
- dsc.setPassword("123456");
- mpg.setDataSource(dsc);
-
- // 包配置
- PackageConfig pc = new PackageConfig();
- pc.setParent("com.jun.plugin.system");
- pc.setEntity("model");
- pc.setMapper("dao");
- pc.setController("web");
- mpg.setPackageInfo(pc);
-
- // 自定义配置
- InjectionConfig cfg = new InjectionConfig() {
- @Override
- public void initMap() {
- // to do nothing
- }
- };
-
- // 如果模板引擎是 freemarker
- String templatePath = "/templates/mapper.xml.ftl";
- // 如果模板引擎是 velocity
- // String templatePath = "/templates/mapper.xml.vm";
-
- // 自定义输出配置
- List focList = new ArrayList<>();
- // 自定义配置会被优先输出
- focList.add(new FileOutConfig(templatePath) {
- @Override
- public String outputFile(TableInfo tableInfo) {
- // 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
- return projectPath + "/src/main/resources/mapper/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
- }
- });
- cfg.setFileOutConfigList(focList);
- mpg.setCfg(cfg);
-
- // 配置模板
- TemplateConfig templateConfig = new TemplateConfig();
-
- // 配置自定义输出模板
- //指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别
-// templateConfig.setEntity("templates/entity.java");
- // templateConfig.setService();
- templateConfig.setController("templates/controller.java");
-
- templateConfig.setXml(null);
- mpg.setTemplate(templateConfig);
-
- // 策略配置
- StrategyConfig strategy = new StrategyConfig();
- strategy.setNaming(NamingStrategy.underline_to_camel);
- strategy.setColumnNaming(NamingStrategy.underline_to_camel);
-// strategy.setSuperEntityClass("你自己的父类实体,没有就不用设置!");
- strategy.setEntityLombokModel(true);
- strategy.setRestControllerStyle(true);
- // 公共父类
-// strategy.setSuperControllerClass("你自己的父类控制器,没有就不用设置!");
- // 写于父类中的公共字段
-// strategy.setSuperEntityColumns("id");
- strategy.setInclude(tableName.split(","));
- strategy.setControllerMappingHyphenStyle(true);
- strategy.setLogicDeleteFieldName(logicDeleteFieldName); // 逻辑删除字段名称
- strategy.setTablePrefix(pc.getModuleName() + "_");
- mpg.setStrategy(strategy);
- mpg.setTemplateEngine(new FreemarkerTemplateEngine());
- mpg.execute();
- }
-
-}
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_main/src/test/java/com/jun/plugin/system/Tester.java b/java_project_template/jun_api_service_main/src/test/java/com/jun/plugin/system/Tester.java
deleted file mode 100644
index 73ec18fc47..0000000000
--- a/java_project_template/jun_api_service_main/src/test/java/com/jun/plugin/system/Tester.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.jun.plugin.system;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-/**
- * 单元测试
- */
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = ApiServiceApplication.class,webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class Tester {
-
- @Test
- public void test() {
-
- }
-}
-
-
-
diff --git a/java_project_template/jun_api_service_main/src/test/resources/templates/controller.java.ftl b/java_project_template/jun_api_service_main/src/test/resources/templates/controller.java.ftl
deleted file mode 100644
index 93f2bb3f44..0000000000
--- a/java_project_template/jun_api_service_main/src/test/resources/templates/controller.java.ftl
+++ /dev/null
@@ -1,94 +0,0 @@
-package ${package.Controller};
-
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import core.com.jun.plugin.system.Result;
-import core.com.jun.plugin.system.ResultGenerator;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import org.springframework.web.bind.annotation.*;
-import ${package.Service}.${table.serviceName};
-import ${package.Entity}.${entity};
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-
-import javax.annotation.Resource;
-<#if restControllerStyle>
-import org.springframework.web.bind.annotation.RestController;
-<#else>
-import org.springframework.stereotype.Controller;
-#if>
-<#if superControllerClassPackage??>
-import ${superControllerClassPackage};
-#if>
-
-/**
- *
- * ${table.comment!} 前端控制器
- *
- *
- * @author ${author}
- * @since ${date}
- */
-<#if restControllerStyle>
-@Api(tags = {"${table.comment!}"})
-@Slf4j
-@RestController
-<#else>
-@Controller
-#if>
-@RequestMapping("<#if package.ModuleName??>/${package.ModuleName}#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}#if>")
-<#if kotlin>
-class ${table.controllerName}<#if superControllerClass??>:${superControllerClass}()#if>
-<#else>
-<#if superControllerClass??>public class ${table.controllerName} extends ${superControllerClass}{
-<#else>public class ${table.controllerName} {
-#if>
-
- @Resource
- private ${table.serviceName} ${(table.serviceName?substring(1))?uncap_first};
-
-
- @ApiOperation(value = "新增${table.comment!}")
- @PostMapping("add")
- public Result add(@RequestBody ${entity} ${entity?uncap_first}){
- ${(table.serviceName?substring(1))?uncap_first}.save(${entity?uncap_first});
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation(value = "删除${table.comment!}")
- @PostMapping("delete/{id}")
- public Result delete(@PathVariable("id") Long id){
- ${(table.serviceName?substring(1))?uncap_first}.removeById(id);
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation(value = "更新${table.comment!}")
- @PostMapping("update")
- public Result update(@RequestBody ${entity} ${entity?uncap_first}){
- ${(table.serviceName?substring(1))?uncap_first}.updateById(${entity?uncap_first});
- return ResultGenerator.genSuccessResult();
- }
-
- @ApiOperation(value = "查询${table.comment!}分页数据")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "currentPage", value = "页码"),
- @ApiImplicitParam(name = "pageCount", value = "每页条数")
- })
- @GetMapping("listByPage")
- public Result findListByPage(@RequestParam Integer currentPage,
- @RequestParam Integer pageCount){
- Page page = new Page(currentPage, pageCount);
- IPage<${entity}> iPage = ${(table.serviceName?substring(1))?uncap_first}.page(page);
- return ResultGenerator.genSuccessResult(iPage);
- }
-
- @ApiOperation(value = "id查询${table.comment!}")
- @GetMapping("getById/{id}")
- public Result findById(@PathVariable Long id){
- return ResultGenerator.genSuccessResult(${(table.serviceName?substring(1))?uncap_first}.getById(id));
- }
-
-}
-#if>
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_simple/pom.xml b/java_project_template/jun_api_service_simple/pom.xml
deleted file mode 100644
index a7a4fe5b02..0000000000
--- a/java_project_template/jun_api_service_simple/pom.xml
+++ /dev/null
@@ -1,160 +0,0 @@
-
-
- 4.0.0
- com.jun.plugin
- jun_api_service_simple
- 1.0
- jun_api_service_simple
-
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
- io.github.wujun728
- jun-db-activerecord
- 1.0.25
-
-
-
- org.springframework.boot
- spring-boot-starter-freemarker
-
-
-
-
- org.springframework.boot
- spring-boot-starter-validation
-
-
- com.github.xiaoymin
- knife4j-spring-boot-starter
- 2.0.2
-
-
-
- org.springframework.boot
- spring-boot-starter-thymeleaf
-
-
-
- org.springframework.boot
- spring-boot-devtools
- runtime
- true
-
-
-
- org.springframework.boot
- spring-boot-starter-mail
-
-
- org.springframework.boot
- spring-boot-starter-websocket
-
-
- mysql
- mysql-connector-java
- runtime
-
-
-
- com.alibaba
- druid-spring-boot-starter
- 1.2.16
-
-
- com.baomidou
- mybatis-plus-boot-starter
- 3.5.3.2
-
-
- org.springframework.boot
- spring-boot-starter-data-redis
-
-
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-dependencies
-
-
-
- 2.5.14
- pom
- import
-
-
-
-
-
- manager
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.8.0
-
- 1.8
- 1.8
- UTF-8
-
-
-
-
-
-
-
-
-
-
- aliyun-repos
- http://maven.aliyun.com/nexus/content/groups/public/
-
- false
-
-
-
-
-
-
- aliyun-plugin
- http://maven.aliyun.com/nexus/content/groups/public/
-
- false
-
-
-
-
diff --git a/java_project_template/jun_api_service_simple/src/main/java/com/jun/plugin/project/QixingApplication.java b/java_project_template/jun_api_service_simple/src/main/java/com/jun/plugin/project/QixingApplication.java
deleted file mode 100644
index 7b71f4b9c0..0000000000
--- a/java_project_template/jun_api_service_simple/src/main/java/com/jun/plugin/project/QixingApplication.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package com.jun.plugin.project;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-
-import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
-import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.boot.CommandLineRunner;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.builder.SpringApplicationBuilder;
-import org.springframework.boot.web.servlet.ServletComponentScan;
-import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.annotation.Bean;
-import org.springframework.core.env.Environment;
-import org.springframework.scheduling.annotation.EnableScheduling;
-
-import lombok.extern.slf4j.Slf4j;
-
-@Slf4j
-@EnableScheduling
-@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class) // 多数据源 (exclude = DruidDataSourceAutoConfigure.class)
-@MapperScan("com.jun.plugin.**.mapper")
-//@ComponentScan(basePackages = "com.jun.plugin")
-@ServletComponentScan(basePackages = {"com.jun.plugin.**.filter"})
-public class QixingApplication extends SpringBootServletInitializer {
-
- public static void main(String[] args) throws Exception {
-// SpringApplication application = new SpringApplication(SpringbootApplication.class);
-// application.setBannerMode(Banner.Mode.OFF);
-// application.run(args);
- System.setProperty("spring.devtools.restart.enabled", "true");
- ConfigurableApplicationContext application = SpringApplication.run(QixingApplication.class, args);
- Environment env = application.getEnvironment();
- InetAddress inetAddress = Inet4Address.getLocalHost();
- String hostAddress = inetAddress.getHostAddress();
- String serverPort = env.getProperty("server.port");
- String serverPath = env.getProperty("spring.application.name");
- String url = env.getProperty("spring.datasource.url");
-
- log.info("项目启动成功!访问地址: http://{}:{}/{}", hostAddress, serverPort, serverPath);
- log.info("本机地址: http://localhost:{}", serverPort);
- }
-
- @Override // 为了打包springboot项目
- protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
- return builder.sources(this.getClass());
- }
-
- @Bean
- public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
- return args -> {
- System.out.println("Let's inspect the beans provided by Spring Boot:");
- String[] beanNames = ctx.getBeanDefinitionNames();
- System.err.println("beanNames size = "+ beanNames.length);
-
- for (String beanName : beanNames) {
- //System.err.println(beanName);
- }
-
- };
- }
-}
-
-
diff --git a/java_project_template/jun_api_service_simple/src/main/java/com/jun/plugin/project/config/GlobalRequestBodyAdvice2.java b/java_project_template/jun_api_service_simple/src/main/java/com/jun/plugin/project/config/GlobalRequestBodyAdvice2.java
deleted file mode 100644
index 827af89fa0..0000000000
--- a/java_project_template/jun_api_service_simple/src/main/java/com/jun/plugin/project/config/GlobalRequestBodyAdvice2.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package com.jun.plugin.project.config;
-
-import org.springframework.core.MethodParameter;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpInputMessage;
-import org.springframework.http.converter.HttpMessageConverter;
-import org.springframework.web.bind.annotation.ControllerAdvice;
-import org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Type;
-import java.util.Map;
-
-/**
- * @title 全局请求参数处理类
- */
-@ControllerAdvice(basePackages = "com.jun.plugin.*.controller")//此处设置需要当前Advice执行的域 , 省略默认全局生效
-public class GlobalRequestBodyAdvice2 implements RequestBodyAdvice {
-
-
- /** 此处如果返回false , 则不执行当前Advice的业务 */
- @Override
- public boolean supports(MethodParameter methodParameter, Type targetType, Class extends HttpMessageConverter>> converterType) {
-// return methodParameter.getMethod().isAnnotationPresent(XXApiReq.class);
- return false;
- }
-
- /**
- * @title 读取参数前执行
- * @description 在此做些编码 / 解密 / 封装参数为对象的操作
- *
- * */
- @Override
- public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class extends HttpMessageConverter>> converterType) throws IOException {
- // 提取数据
- InputStream is = inputMessage.getBody();
- byte[] data = new byte[is.available()];
- is.read(data);
- //转数据类型
- ObjectMapper mapper = new ObjectMapper();
- Map m = mapper.readValue(new String(data), Map.class);
- //m.forEach(null);
- return new XHttpInputMessage2(inputMessage, "UTF-8");
- }
-
- /**
- * @title 读取参数后执行
- */
- @Override
- public Object afterBodyRead(Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class extends HttpMessageConverter>> converterType) {
- return inputMessage;
- }
-
- /**
- * @title 无请求时的处理
- */
- @Override
- public Object handleEmptyBody(Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class extends HttpMessageConverter>> converterType) {
- return body;
- }
-}
-
-//这里实现了HttpInputMessage 封装一个自己的HttpInputMessage
-class XHttpInputMessage2 implements HttpInputMessage {
- private HttpHeaders headers;
- private InputStream body;
-
- public XHttpInputMessage2(HttpInputMessage httpInputMessage, String encode) throws IOException {
- this.headers = httpInputMessage.getHeaders();
- this.body = encode(httpInputMessage.getBody(), encode);
- }
-
- private InputStream encode(InputStream body, String encode) {
- //省略对流进行编码的操作
- return body;
- }
-
- @Override
- public InputStream getBody() {
- return body;
- }
-
- @Override
- public HttpHeaders getHeaders() {
- return null;
- }
-}
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_simple/src/main/java/com/jun/plugin/project/config/MetaObjectHandlerConfig2.java b/java_project_template/jun_api_service_simple/src/main/java/com/jun/plugin/project/config/MetaObjectHandlerConfig2.java
deleted file mode 100644
index 311e24554b..0000000000
--- a/java_project_template/jun_api_service_simple/src/main/java/com/jun/plugin/project/config/MetaObjectHandlerConfig2.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package com.jun.plugin.project.config;
-
-import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
-//import com.jun.plugin.project.service.HttpSessionService;
-import org.apache.ibatis.reflection.MetaObject;
-import org.springframework.stereotype.Component;
-
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashSet;
-
-
-/**
- * mybatis plus 默认值配置
- *
- * @author wujun
- * @version V1.0
- * @date 2020年3月18日
- */
-@Component
-public class MetaObjectHandlerConfig2 implements MetaObjectHandler {
-
-// @Lazy
-// @Resource
-// HttpSessionService httpSessionService;
-
- @Override
- public void insertFill(MetaObject metaObject) {
- Date currentDate = new Date();
- String[] setterNames = metaObject.getSetterNames();
- HashSet setterNameSet = new HashSet<>(Arrays.asList(setterNames));
- if (setterNameSet.contains("deleted")) {
- //默认未删除
- setFieldValByName("deleted", 0, metaObject);
- }
- if (setterNameSet.contains("createTime")) {
- //创建时间默认当前时间
- setFieldValByName("createTime", currentDate, metaObject);
- }
- if (setterNameSet.contains("createDate")) {
- //创建时间默认当前时间
- setFieldValByName("createDate", currentDate, metaObject);
- }
-// if (setterNameSet.contains("createId")) {
-// //创建时间默认当前时间
-// setFieldValByName("createId", httpSessionService.getCurrentUserId(), metaObject);
-// }
-// if (setterNameSet.contains("updateId")) {
-// //创建时间默认当前时间
-// setFieldValByName("updateId", httpSessionService.getCurrentUserId(), metaObject);
-// }
- if (setterNameSet.contains("updateTime")) {
- //创建时间默认当前时间
- setFieldValByName("updateTime", currentDate, metaObject);
- }
- if (setterNameSet.contains("updateDate")) {
- //创建时间默认当前时间
- setFieldValByName("updateDate", currentDate, metaObject);
- }
-
-
- }
-
- @Override
- public void updateFill(MetaObject metaObject) {
- Date currentDate = new Date();
- String[] setterNames = metaObject.getSetterNames();
- HashSet setterNameSet = new HashSet<>(Arrays.asList(setterNames));
- if (setterNameSet.contains("updateTime")) {
- //创建时间默认当前时间
- setFieldValByName("updateTime", currentDate, metaObject);
- }
- if (setterNameSet.contains("updateDate")) {
- //创建时间默认当前时间
- setFieldValByName("updateDate", currentDate, metaObject);
- }
-// if (setterNameSet.contains("updateId")) {
-// //创建时间默认当前时间
-// setFieldValByName("updateId", httpSessionService.getCurrentUserId(), metaObject);
-// }
- }
-}
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_simple/src/main/java/com/jun/plugin/project/config/MyBatisPlusConfig2.java b/java_project_template/jun_api_service_simple/src/main/java/com/jun/plugin/project/config/MyBatisPlusConfig2.java
deleted file mode 100644
index 2161759216..0000000000
--- a/java_project_template/jun_api_service_simple/src/main/java/com/jun/plugin/project/config/MyBatisPlusConfig2.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.jun.plugin.project.config;
-
-import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * mybatis plus config
- *
- * @author wujun
- * @version V1.0
- * @date 2020年3月18日
- */
-@Configuration
-public class MyBatisPlusConfig2 {
- /**
- * 配置mybatis-plus 分页查件
- */
- @Bean
- public PaginationInnerInterceptor paginationInterceptor() {
- return new PaginationInnerInterceptor();
- }
-}
\ No newline at end of file
diff --git a/java_project_template/jun_api_service_simple/src/main/java/com/jun/plugin/project/config/RedisCacheConfig2.java b/java_project_template/jun_api_service_simple/src/main/java/com/jun/plugin/project/config/RedisCacheConfig2.java
deleted file mode 100644
index 0eee4e8081..0000000000
--- a/java_project_template/jun_api_service_simple/src/main/java/com/jun/plugin/project/config/RedisCacheConfig2.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package com.jun.plugin.project.config;
-
-import java.time.Duration;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.annotation.EnableCaching;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.redis.cache.RedisCacheConfiguration;
-import org.springframework.data.redis.cache.RedisCacheManager;
-import org.springframework.data.redis.cache.RedisCacheWriter;
-import org.springframework.data.redis.connection.RedisConnectionFactory;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
-import org.springframework.data.redis.serializer.RedisSerializationContext;
-import org.springframework.data.redis.serializer.RedisSerializer;
-import org.springframework.data.redis.serializer.StringRedisSerializer;
-
-import javax.annotation.Resource;
-
-/**
- * Redis缓存配置。
- */
-@Configuration
-@EnableCaching
-public class RedisCacheConfig2 {
-
- @Autowired
- private RedisTemplate redisTemplate;
-
- @Resource
- private RedisConnectionFactory factory;
-
- @Bean
- public RedisTemplate redisTemplate() {
- RedisTemplate redisTemplate = new RedisTemplate<>();
- redisTemplate.setConnectionFactory(factory);
- // 字符串Key序列化
- StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
- redisTemplate.setKeySerializer(stringRedisSerializer);
- redisTemplate.setHashKeySerializer(stringRedisSerializer);
- // 对象值序列化
-// ObjectRedisSerializer objectRedisSerializer = new ObjectRedisSerializer();
- RedisSerializer