mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-22 12:48:59 +08:00
feat:添加商品类目级联列表接口
This commit is contained in:
parent
abe0201905
commit
32e4e3d60c
@ -24,7 +24,7 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-core</artifactId>
|
||||
<artifactId>common-core</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -24,7 +24,7 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-core</artifactId>
|
||||
<artifactId>common-core</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -24,7 +24,7 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-core</artifactId>
|
||||
<artifactId>common-core</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -24,7 +24,7 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-core</artifactId>
|
||||
<artifactId>common-core</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
4
pom.xml
4
pom.xml
@ -14,11 +14,11 @@
|
||||
<module>youlai-admin</module>
|
||||
<module>youlai-auth</module>
|
||||
<module>youlai-gateway</module>
|
||||
<module>youlai-registry</module>
|
||||
<module>mall-sms</module>
|
||||
<module>mall-ums</module>
|
||||
<module>mall-pms</module>
|
||||
<module>mall-oms</module>
|
||||
<module>youlai-registry</module>
|
||||
</modules>
|
||||
|
||||
<parent>
|
||||
@ -109,6 +109,4 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
</project>
|
||||
|
@ -31,19 +31,19 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-web</artifactId>
|
||||
<artifactId>common-web</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-db</artifactId>
|
||||
<artifactId>common-db</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-knife4j</artifactId>
|
||||
<artifactId>common-knife4j</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -24,7 +24,7 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-core</artifactId>
|
||||
<artifactId>common-core</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -30,37 +30,37 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-db</artifactId>
|
||||
<artifactId>common-db</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-web</artifactId>
|
||||
<artifactId>common-web</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-knife4j</artifactId>
|
||||
<artifactId>common-knife4j</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-core</artifactId>
|
||||
<artifactId>common-core</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-redis</artifactId>
|
||||
<artifactId>common-redis</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-web</artifactId>
|
||||
<artifactId>common-web</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
36
youlai-common/common-core/pom.xml
Normal file
36
youlai-common/common-core/pom.xml
Normal file
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>youlai-common</artifactId>
|
||||
<groupId>com.youlai</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>common-core</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- swagger2-annotations -->
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- spring boot web -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- mybatis-plus -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,5 @@
|
||||
package com.youlai.common.core.base;
|
||||
|
||||
public class BaseController<T> {
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.youlai.common.core.base;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
@ApiModel
|
||||
public class BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@ApiModelProperty(value = "创建时间", example = "2020-01-01 00:00:00")
|
||||
private Date gmtCreate;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@ApiModelProperty(value = "创建时间", example = "2020-01-01 00:00:00")
|
||||
private Date gmtModified;
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package com.youlai.common.core.constant;
|
||||
|
||||
public interface AuthConstants {
|
||||
|
||||
/**
|
||||
* JWT存储权限前缀
|
||||
*/
|
||||
String AUTHORITY_PREFIX = "ROLE_";
|
||||
|
||||
/**
|
||||
* JWT存储权限属性
|
||||
*/
|
||||
String AUTHORITY_CLAIM_NAME = "authorities";
|
||||
|
||||
/**
|
||||
* 认证信息Http请求头
|
||||
*/
|
||||
String JWT_TOKEN_HEADER = "Authorization";
|
||||
|
||||
/**
|
||||
* JWT令牌前缀
|
||||
*/
|
||||
String JWT_TOKEN_PREFIX = "Bearer ";
|
||||
|
||||
/**
|
||||
* JWT载体key
|
||||
*/
|
||||
String JWT_PAYLOAD_KEY = "payload";
|
||||
|
||||
/**
|
||||
* Redis缓存权限规则key
|
||||
*/
|
||||
String RESOURCE_ROLES_KEY = "auth:resourceRoles";
|
||||
|
||||
/**
|
||||
* 黑名单token前缀
|
||||
*/
|
||||
String TOKEN_BLACKLIST_PREFIX = "auth:token:blacklist:";
|
||||
|
||||
String CLIENT_DETAILS_FIELDS = "client_id, CONCAT('{noop}',client_secret) as client_secret, resource_ids, scope, "
|
||||
+ "authorized_grant_types, web_server_redirect_uri, authorities, access_token_validity, "
|
||||
+ "refresh_token_validity, additional_information, autoapprove";
|
||||
|
||||
String BASE_CLIENT_DETAILS_SQL = "select " + CLIENT_DETAILS_FIELDS + " from oauth_client_details";
|
||||
|
||||
String FIND_CLIENT_DETAILS_SQL = BASE_CLIENT_DETAILS_SQL + " order by client_id";
|
||||
|
||||
String SELECT_CLIENT_DETAILS_SQL = BASE_CLIENT_DETAILS_SQL + " where client_id = ?";
|
||||
|
||||
/**
|
||||
* 密码加密方式
|
||||
*/
|
||||
String BCRYPT = "{bcrypt}";
|
||||
|
||||
String JWT_USER_ID_KEY = "id";
|
||||
|
||||
String JWT_CLIENT_ID_KEY = "client_id";
|
||||
|
||||
/**
|
||||
* 有来商城后台管理客户端ID
|
||||
*/
|
||||
String ADMIN_CLIENT_ID="youlai-mall-admin";
|
||||
|
||||
|
||||
/**
|
||||
* 有来商城微信小程序客户端ID
|
||||
*/
|
||||
String WEAPP_CLIENT_ID="youlai-mall-weapp";
|
||||
|
||||
/**
|
||||
* 后台管理接口路径匹配
|
||||
*/
|
||||
String ADMIN_URL_PATTERN ="/youlai-admin/**" ;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.youlai.common.core.constant;
|
||||
|
||||
public interface Constants {
|
||||
|
||||
/**
|
||||
* 正常状态值
|
||||
*/
|
||||
Integer STATUS_NORMAL_VALUE = 1;
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.youlai.common.core.result;
|
||||
|
||||
/**
|
||||
* @author haoxr
|
||||
* @date 2020-06-23
|
||||
**/
|
||||
public interface IResultCode {
|
||||
|
||||
String getCode();
|
||||
|
||||
String getMsg();
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.youlai.common.core.result;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author haoxr
|
||||
* @date 2020-06-24
|
||||
**/
|
||||
@Data
|
||||
public class PageResult<T> extends Result {
|
||||
|
||||
private long total;
|
||||
|
||||
public static <T> PageResult<T> success(T data, Long total) {
|
||||
PageResult<T> pageResult = new PageResult();
|
||||
pageResult.setCode(ResultCode.SUCCESS.getCode());
|
||||
pageResult.setMsg(ResultCode.SUCCESS.getMsg());
|
||||
pageResult.setData(data);
|
||||
pageResult.setTotal(total);
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.youlai.common.core.result;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author haoxr
|
||||
* @date 2020-06-23
|
||||
**/
|
||||
@Data
|
||||
public class Result<T> implements Serializable {
|
||||
|
||||
private String code;
|
||||
|
||||
private T data;
|
||||
|
||||
private String msg;
|
||||
|
||||
|
||||
public static <T> Result<T> success() {
|
||||
return success(null);
|
||||
}
|
||||
|
||||
public static <T> Result<T> success(T data) {
|
||||
ResultCode rce = ResultCode.SUCCESS;
|
||||
if (data instanceof Boolean && Boolean.FALSE.equals(data)) {
|
||||
rce = ResultCode.SYSTEM_EXECUTION_ERROR;
|
||||
}
|
||||
return result(rce, data);
|
||||
}
|
||||
|
||||
|
||||
public static <T> Result<T> error() {
|
||||
return result(ResultCode.SYSTEM_EXECUTION_ERROR.getCode(), ResultCode.SYSTEM_EXECUTION_ERROR.getMsg(), null);
|
||||
}
|
||||
|
||||
public static <T> Result<T> error(String msg) {
|
||||
return result(ResultCode.SYSTEM_EXECUTION_ERROR.getCode(), msg, null);
|
||||
}
|
||||
|
||||
public static <T> Result<T> status(boolean status) {
|
||||
if (status) {
|
||||
return success();
|
||||
} else {
|
||||
return error();
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> Result<T> custom(IResultCode resultCode) {
|
||||
return result(resultCode.getCode(), resultCode.getMsg(), null);
|
||||
}
|
||||
|
||||
|
||||
private static <T> Result<T> result(IResultCode resultCode, T data) {
|
||||
return result(resultCode.getCode(), resultCode.getMsg(), data);
|
||||
}
|
||||
|
||||
private static <T> Result<T> result(String code, String msg, T data) {
|
||||
Result<T> result = new Result<T>();
|
||||
result.setCode(code);
|
||||
result.setData(data);
|
||||
result.setMsg(msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package com.youlai.common.core.result;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author haoxr
|
||||
* @date 2020-06-23
|
||||
**/
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public enum ResultCode implements IResultCode, Serializable {
|
||||
|
||||
SUCCESS("00000","一切ok"),
|
||||
|
||||
USER_ERROR("A0001","用户端错误"),
|
||||
USER_LOGIN_ERROR("A0200","用户登录异常"),
|
||||
|
||||
USER_ACCOUNT_NOT_EXIST("A0201","用户账户不存在"),
|
||||
USER_ACCOUNT_LOCKED("A0202","用户账户被冻结"),
|
||||
USER_ACCOUNT_INVALID("A0203","用户账户已作废"),
|
||||
|
||||
USERNAME_OR_PASSWORD_ERROR("A0210","用户名或密码错误"),
|
||||
INPUT_PASSWORD_EXCEED_LIMIT("A0211","用户输入密码次数超限"),
|
||||
TOKEN_INVALID_OR_EXPIRED("A0230","token无效或已过期"),
|
||||
|
||||
USER_AUTHORIZED_ERROR ("A0300","访问权限异常"),
|
||||
USER_ACCESS_UNAUTHORIZED ("A0301","访问未授权"),
|
||||
|
||||
USER_REQUEST_PARAM_ERROR("A0400","用户请求参数错误"),
|
||||
USER_REQUEST_PARAM_IS_BLANK("A0410","请求必填参数为空"),
|
||||
|
||||
USER_UPLOAD_FILE_ERROR("A0700","用户上传文件异常"),
|
||||
USER_UPLOAD_FILE_TYPE_NOT_MATCH("A0701","用户上传文件类型不匹配"),
|
||||
USER_UPLOAD_FILE_SIZE_EXCEEDS("A0702","用户上传文件太大"),
|
||||
USER_UPLOAD_IMAGE_SIZE_EXCEEDS("A0703","用户上传图片太大"),
|
||||
|
||||
SYSTEM_EXECUTION_ERROR("B0001","系统执行出错"),
|
||||
SYSTEM_EXECUTION_TIMEOUT("B0100","系统执行超时"),
|
||||
SYSTEM_ORDER_PROCESSING_TIMEOUT("B0100","系统订单处理超时"),
|
||||
|
||||
SYSTEM_DISASTER_RECOVERY_TRIGGER("B0200","系统容灾功能被出发"),
|
||||
SYSTEM_LIMITING("B0210","系统限流"),
|
||||
SYSTEM_FUNCTION_DEGRADATION("B0220","系统功能降级"),
|
||||
|
||||
SYSTEM_RESOURCE_ERROR("B0300","系统资源异常"),
|
||||
SYSTEM_RESOURCE_EXHAUSTION("B0310","系统资源耗尽"),
|
||||
SYSTEM_RESOURCE_ACCESS_ERROR("B0320","系统资源访问异常"),
|
||||
SYSTEM_READ_DISK_FILE_ERROR("B0321","系统读取磁盘文件失败"),
|
||||
|
||||
CALL_THIRD_PARTY_SERVICE_ERROR("C0001","调用第三方服务出错"),
|
||||
MIDDLEWARE_SERVICE_ERROR("C0100","中间件服务出错"),
|
||||
INTERFACE_NOT_EXIST("C0113","接口不存在"),
|
||||
|
||||
MESSAGE_SERVICE_ERROR("C0120","消息服务出错"),
|
||||
MESSAGE_DELIVERY_ERROR("C0121","消息投递出错"),
|
||||
MESSAGE_CONSUMPTION_ERROR("C0122","消息消费出错"),
|
||||
MESSAGE_SUBSCRIPTION_ERROR("C0123","消息订阅出错"),
|
||||
MESSAGE_GROUP_NOT_FOUND("C0124","消息分组未查到"),
|
||||
|
||||
DATABASE_ERROR("C0300","数据库服务出错"),
|
||||
DATABASE_TABLE_NOT_EXIST("C0311","表不存在"),
|
||||
DATABASE_COLUMN_NOT_EXIST("C0312","列不存在"),
|
||||
DATABASE_DUPLICATE_COLUMN_NAME("C0321","多表关联中存在多个相同名称的列"),
|
||||
DATABASE_DEADLOCK("C0331","数据库死锁"),
|
||||
DATABASE_PRIMARY_KEY_CONFLICT("C0341","主键冲突") ;
|
||||
|
||||
@Override
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
private String code;
|
||||
|
||||
private String msg;
|
||||
}
|
30
youlai-common/common-db/pom.xml
Normal file
30
youlai-common/common-db/pom.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>youlai-common</artifactId>
|
||||
<groupId>com.youlai</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>common-db</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,32 @@
|
||||
package com.youlai.common.db.config;
|
||||
|
||||
import com.baomidou.mybatisplus.core.config.GlobalConfig;
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import com.youlai.common.db.handler.MetaHandler;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
@Configuration
|
||||
@EnableTransactionManagement
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
/**
|
||||
* 分页插件,自动识别数据库类型 多租户,请参考官网【插件扩展】
|
||||
*/
|
||||
@Bean
|
||||
public PaginationInterceptor paginationInterceptor() {
|
||||
return new PaginationInterceptor();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 自动填充数据库创建人、创建时间、更新人、更新时间
|
||||
*/
|
||||
@Bean
|
||||
public GlobalConfig globalConfig() {
|
||||
GlobalConfig globalConfig = new GlobalConfig();
|
||||
globalConfig.setMetaObjectHandler(new MetaHandler());
|
||||
return globalConfig;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.youlai.common.db.handler;
|
||||
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author haoxr
|
||||
**/
|
||||
@Component
|
||||
public class MetaHandler implements MetaObjectHandler {
|
||||
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
this.setFieldValByName("gmtCreate", new Date(), metaObject);
|
||||
this.setFieldValByName("gmtModified", new Date(), metaObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
this.setFieldValByName("gmtCreate", new Date(), metaObject);
|
||||
}
|
||||
}
|
20
youlai-common/common-knife4j/pom.xml
Normal file
20
youlai-common/common-knife4j/pom.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>youlai-common</artifactId>
|
||||
<groupId>com.youlai</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>common-knife4j</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,66 @@
|
||||
package com.youlai.common.knife4j;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.*;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
@Slf4j
|
||||
public class Knife4jConfig {
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
//.securitySchemes(Collections.singletonList(securityScheme()))
|
||||
.securityContexts(Collections.singletonList(securityContext()))
|
||||
.useDefaultResponseMessages(false);
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("有来科技API")
|
||||
.contact(new Contact("youlai", "https://www.youlai.store", "youlaistore@163.com"))
|
||||
.version("1.0.0")
|
||||
.build();
|
||||
}
|
||||
|
||||
private SecurityScheme securityScheme() {
|
||||
/* GrantType grantType = new ResourceOwnerPasswordCredentialsGrant(AUTH_TOKEN_ENDPOINT);
|
||||
|
||||
return new OAuthBuilder()
|
||||
.name("OAuth2")
|
||||
.grantTypes(Collections.singletonList(grantType))
|
||||
.scopes(Arrays.asList(scopes()))
|
||||
.build();*/
|
||||
return null;
|
||||
}
|
||||
|
||||
private AuthorizationScope[] scopes() {
|
||||
AuthorizationScope[] scopes = {};
|
||||
return scopes;
|
||||
}
|
||||
|
||||
private SecurityContext securityContext() {
|
||||
return SecurityContext.builder()
|
||||
.securityReferences(Collections.singletonList(new SecurityReference("OAuth2", scopes())))
|
||||
.forPaths(PathSelectors.any())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
20
youlai-common/common-redis/pom.xml
Normal file
20
youlai-common/common-redis/pom.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>youlai-common</artifactId>
|
||||
<groupId>com.youlai</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>common-redis</artifactId>
|
||||
<dependencies>
|
||||
<!-- spring boot redis -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,23 @@
|
||||
package com.youlai.common.redis;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
|
||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
|
||||
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setHashValueSerializer(new JdkSerializationRedisSerializer());
|
||||
redisTemplate.setConnectionFactory(factory);
|
||||
redisTemplate.afterPropertiesSet();
|
||||
return redisTemplate;
|
||||
}
|
||||
}
|
32
youlai-common/common-web/pom.xml
Normal file
32
youlai-common/common-web/pom.xml
Normal file
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>youlai-common</artifactId>
|
||||
<groupId>com.youlai</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>common-web</artifactId>
|
||||
|
||||
<properties>
|
||||
<youlai.version>1.0.0-SNAPSHOT</youlai.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>common-core</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- spring boot web -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,39 @@
|
||||
package com.youlai.common.web.config;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||
MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
|
||||
ObjectMapper objectMapper = jackson2HttpMessageConverter.getObjectMapper();
|
||||
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
||||
objectMapper.setTimeZone(TimeZone.getTimeZone("GMT+8"));
|
||||
objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
|
||||
|
||||
// 后台Long值传递给前端精度丢失问题(JS最大精度整数是Math.pow(2,53))
|
||||
SimpleModule simpleModule = new SimpleModule();
|
||||
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
|
||||
// simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
|
||||
// simpleModule.addSerializer(BigInteger.class, ToStringSerializer.instance);
|
||||
objectMapper.registerModule(simpleModule);
|
||||
|
||||
jackson2HttpMessageConverter.setObjectMapper(objectMapper);
|
||||
converters.add(0, jackson2HttpMessageConverter);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.youlai.common.web.exception;
|
||||
|
||||
import com.youlai.common.core.result.IResultCode;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class BizException extends RuntimeException {
|
||||
|
||||
public IResultCode resultCode;
|
||||
|
||||
public BizException(IResultCode errorCode) {
|
||||
super(errorCode.getMsg());
|
||||
this.resultCode = errorCode;
|
||||
}
|
||||
|
||||
public BizException(String message){
|
||||
super(message);
|
||||
}
|
||||
|
||||
public BizException(String message, Throwable cause){
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public BizException(Throwable cause){
|
||||
super(cause);
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.youlai.common.web.exception;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.youlai.common.core.result.Result;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
/**
|
||||
* 全局系统异常处理
|
||||
*
|
||||
* @author hxrui
|
||||
* @date 2020-02-25 13:54
|
||||
**/
|
||||
@RestControllerAdvice
|
||||
@Slf4j
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
@ExceptionHandler(IllegalArgumentException.class)
|
||||
public Result handleIllegalArgumentException(IllegalArgumentException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
@ExceptionHandler(JsonProcessingException.class)
|
||||
public Result handleJsonProcessingException(JsonProcessingException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(BizException.class)
|
||||
public Result handleBizException(BizException e) {
|
||||
if (e.getResultCode() != null) {
|
||||
return Result.custom(e.getResultCode());
|
||||
}
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.youlai.common.web.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel
|
||||
public class CascaderVO {
|
||||
|
||||
@ApiModelProperty(name="节点value")
|
||||
private String value;
|
||||
|
||||
@ApiModelProperty(name="节点label")
|
||||
private String label;
|
||||
|
||||
@ApiModelProperty(name="子节点")
|
||||
private List<CascaderVO> children;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.youlai.common.web.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class TreeSelectVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String label;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private List<TreeSelectVO> children;
|
||||
}
|
@ -14,11 +14,11 @@
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>youlai-common-core</module>
|
||||
<module>youlai-common-knife4j</module>
|
||||
<module>youlai-common-redis</module>
|
||||
<module>youlai-common-web</module>
|
||||
<module>youlai-common-db</module>
|
||||
<module>common-core</module>
|
||||
<module>common-knife4j</module>
|
||||
<module>common-redis</module>
|
||||
<module>common-web</module>
|
||||
<module>common-db</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
@ -94,37 +94,31 @@
|
||||
<!-- common -->
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-core</artifactId>
|
||||
<artifactId>common-core</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-knife4j</artifactId>
|
||||
<artifactId>common-knife4j</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-redis</artifactId>
|
||||
<artifactId>common-redis</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-web</artifactId>
|
||||
<artifactId>common-web</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-db</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-auth</artifactId>
|
||||
<artifactId>common-db</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
@ -21,13 +21,13 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-core</artifactId>
|
||||
<artifactId>common-core</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-common-redis</artifactId>
|
||||
<artifactId>common-redis</artifactId>
|
||||
<version>${youlai.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user