mirror of
https://github.com/201206030/novel-cloud.git
synced 2025-06-24 22:16:39 +00:00
refactor: 基于 novel 项目 & Spring Cloud 2022 & Spring Cloud Alibaba 2022 重构
This commit is contained in:
@ -1,34 +0,0 @@
|
||||
<?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>novel-author</artifactId>
|
||||
<groupId>com.java2nb.novel</groupId>
|
||||
<version>1.3.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>author-api</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.java2nb.novel</groupId>
|
||||
<artifactId>novel-common</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-cache</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-redis</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
@ -1,148 +0,0 @@
|
||||
package com.java2nb.novel.author.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.annotation.Generated;
|
||||
import java.util.Date;
|
||||
|
||||
public class Author {
|
||||
@ApiModelProperty(value = "主键")
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty(value = "邀请码")
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private String inviteCode;
|
||||
|
||||
@ApiModelProperty(value = "笔名")
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private String penName;
|
||||
|
||||
@ApiModelProperty(value = "手机号码")
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private String telPhone;
|
||||
|
||||
@ApiModelProperty(value = "QQ或微信账号")
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private String chatAccount;
|
||||
|
||||
@ApiModelProperty(value = "电子邮箱")
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty(value = "作品方向,0:男频,1:女频")
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Byte workDirection;
|
||||
|
||||
@ApiModelProperty(value = "0:正常,1:封禁")
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Byte status;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Date createTime;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public String getInviteCode() {
|
||||
return inviteCode;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setInviteCode(String inviteCode) {
|
||||
this.inviteCode = inviteCode == null ? null : inviteCode.trim();
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public String getPenName() {
|
||||
return penName;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setPenName(String penName) {
|
||||
this.penName = penName == null ? null : penName.trim();
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public String getTelPhone() {
|
||||
return telPhone;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setTelPhone(String telPhone) {
|
||||
this.telPhone = telPhone == null ? null : telPhone.trim();
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public String getChatAccount() {
|
||||
return chatAccount;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setChatAccount(String chatAccount) {
|
||||
this.chatAccount = chatAccount == null ? null : chatAccount.trim();
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setEmail(String email) {
|
||||
this.email = email == null ? null : email.trim();
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public Byte getWorkDirection() {
|
||||
return workDirection;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setWorkDirection(Byte workDirection) {
|
||||
this.workDirection = workDirection;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public Byte getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setStatus(Byte status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
package com.java2nb.novel.author.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.annotation.Generated;
|
||||
import java.util.Date;
|
||||
|
||||
public class AuthorCode {
|
||||
@ApiModelProperty(value = "主键")
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "邀请码")
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private String inviteCode;
|
||||
|
||||
@ApiModelProperty(value = "有效时间")
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Date validityTime;
|
||||
|
||||
@ApiModelProperty(value = "是否使用过,0:未使用,1:使用过")
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Byte isUse;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "创建人ID")
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Long createUserId;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public String getInviteCode() {
|
||||
return inviteCode;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setInviteCode(String inviteCode) {
|
||||
this.inviteCode = inviteCode == null ? null : inviteCode.trim();
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public Date getValidityTime() {
|
||||
return validityTime;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setValidityTime(Date validityTime) {
|
||||
this.validityTime = validityTime;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public Byte getIsUse() {
|
||||
return isUse;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setIsUse(Byte isUse) {
|
||||
this.isUse = isUse;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public Long getCreateUserId() {
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setCreateUserId(Long createUserId) {
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
<?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>novel-author</artifactId>
|
||||
<groupId>com.java2nb.novel</groupId>
|
||||
<version>1.3.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>author-service</artifactId>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.java2nb.novel</groupId>
|
||||
<artifactId>author-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-netflix-hystrix</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<!--<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>${docker.maven.plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<imageName>201206030/${project.artifactId}:${project.version}</imageName>
|
||||
<dockerHost>${docker.host}</dockerHost>
|
||||
<baseImage>java:8</baseImage>
|
||||
<entryPoint>["java", "-jar","/${project.build.finalName}.jar"]</entryPoint>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>/</targetPath>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<include>${project.build.finalName}.jar</include>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</plugin>-->
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
@ -1,24 +0,0 @@
|
||||
package com.java2nb.novel;
|
||||
|
||||
import com.java2nb.novel.common.cache.CacheService;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
|
||||
/**
|
||||
* 作家微服务启动器
|
||||
* @author xiongxiaoyang
|
||||
* @version 1.0
|
||||
* @since 2020/5/27
|
||||
*/
|
||||
@SpringBootApplication
|
||||
//@ComponentScan(excludeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {CacheService.class})})
|
||||
@EnableFeignClients
|
||||
public class AuthorApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AuthorApplication.class);
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package com.java2nb.novel.author.mapper;
|
||||
|
||||
import org.mybatis.dynamic.sql.SqlColumn;
|
||||
import org.mybatis.dynamic.sql.SqlTable;
|
||||
|
||||
import javax.annotation.Generated;
|
||||
import java.sql.JDBCType;
|
||||
import java.util.Date;
|
||||
|
||||
public final class AuthorCodeDynamicSqlSupport {
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final AuthorCode authorCode = new AuthorCode();
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Long> id = authorCode.id;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<String> inviteCode = authorCode.inviteCode;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Date> validityTime = authorCode.validityTime;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Byte> isUse = authorCode.isUse;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Date> createTime = authorCode.createTime;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Long> createUserId = authorCode.createUserId;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final class AuthorCode extends SqlTable {
|
||||
public final SqlColumn<Long> id = column("id", JDBCType.BIGINT);
|
||||
|
||||
public final SqlColumn<String> inviteCode = column("invite_code", JDBCType.VARCHAR);
|
||||
|
||||
public final SqlColumn<Date> validityTime = column("validity_time", JDBCType.TIMESTAMP);
|
||||
|
||||
public final SqlColumn<Byte> isUse = column("is_use", JDBCType.TINYINT);
|
||||
|
||||
public final SqlColumn<Date> createTime = column("create_time", JDBCType.TIMESTAMP);
|
||||
|
||||
public final SqlColumn<Long> createUserId = column("create_user_id", JDBCType.BIGINT);
|
||||
|
||||
public AuthorCode() {
|
||||
super("author_code");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,177 +0,0 @@
|
||||
package com.java2nb.novel.author.mapper;
|
||||
|
||||
import com.java2nb.novel.author.entity.AuthorCode;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.mybatis.dynamic.sql.SqlBuilder;
|
||||
import org.mybatis.dynamic.sql.delete.DeleteDSL;
|
||||
import org.mybatis.dynamic.sql.delete.MyBatis3DeleteModelAdapter;
|
||||
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
|
||||
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
|
||||
import org.mybatis.dynamic.sql.render.RenderingStrategy;
|
||||
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
|
||||
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
|
||||
import org.mybatis.dynamic.sql.select.SelectDSL;
|
||||
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
|
||||
import org.mybatis.dynamic.sql.update.MyBatis3UpdateModelAdapter;
|
||||
import org.mybatis.dynamic.sql.update.UpdateDSL;
|
||||
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
|
||||
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
|
||||
|
||||
import javax.annotation.Generated;
|
||||
import java.util.List;
|
||||
|
||||
import static com.java2nb.novel.author.mapper.AuthorCodeDynamicSqlSupport.*;
|
||||
import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo;
|
||||
|
||||
@Mapper
|
||||
public interface AuthorCodeMapper {
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||
long count(SelectStatementProvider selectStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@DeleteProvider(type=SqlProviderAdapter.class, method="delete")
|
||||
int delete(DeleteStatementProvider deleteStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@InsertProvider(type=SqlProviderAdapter.class, method="insert")
|
||||
int insert(InsertStatementProvider<AuthorCode> insertStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||
@ResultMap("AuthorCodeResult")
|
||||
AuthorCode selectOne(SelectStatementProvider selectStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||
@Results(id="AuthorCodeResult", value = {
|
||||
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
|
||||
@Result(column="invite_code", property="inviteCode", jdbcType=JdbcType.VARCHAR),
|
||||
@Result(column="validity_time", property="validityTime", jdbcType=JdbcType.TIMESTAMP),
|
||||
@Result(column="is_use", property="isUse", jdbcType=JdbcType.TINYINT),
|
||||
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
|
||||
@Result(column="create_user_id", property="createUserId", jdbcType=JdbcType.BIGINT)
|
||||
})
|
||||
List<AuthorCode> selectMany(SelectStatementProvider selectStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@UpdateProvider(type=SqlProviderAdapter.class, method="update")
|
||||
int update(UpdateStatementProvider updateStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default QueryExpressionDSL<MyBatis3SelectModelAdapter<Long>> countByExample() {
|
||||
return SelectDSL.selectWithMapper(this::count, SqlBuilder.count())
|
||||
.from(authorCode);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default DeleteDSL<MyBatis3DeleteModelAdapter<Integer>> deleteByExample() {
|
||||
return DeleteDSL.deleteFromWithMapper(this::delete, authorCode);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int deleteByPrimaryKey(Long id_) {
|
||||
return DeleteDSL.deleteFromWithMapper(this::delete, authorCode)
|
||||
.where(id, isEqualTo(id_))
|
||||
.build()
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int insert(AuthorCode record) {
|
||||
return insert(SqlBuilder.insert(record)
|
||||
.into(authorCode)
|
||||
.map(id).toProperty("id")
|
||||
.map(inviteCode).toProperty("inviteCode")
|
||||
.map(validityTime).toProperty("validityTime")
|
||||
.map(isUse).toProperty("isUse")
|
||||
.map(createTime).toProperty("createTime")
|
||||
.map(createUserId).toProperty("createUserId")
|
||||
.build()
|
||||
.render(RenderingStrategy.MYBATIS3));
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int insertSelective(AuthorCode record) {
|
||||
return insert(SqlBuilder.insert(record)
|
||||
.into(authorCode)
|
||||
.map(id).toPropertyWhenPresent("id", record::getId)
|
||||
.map(inviteCode).toPropertyWhenPresent("inviteCode", record::getInviteCode)
|
||||
.map(validityTime).toPropertyWhenPresent("validityTime", record::getValidityTime)
|
||||
.map(isUse).toPropertyWhenPresent("isUse", record::getIsUse)
|
||||
.map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
|
||||
.map(createUserId).toPropertyWhenPresent("createUserId", record::getCreateUserId)
|
||||
.build()
|
||||
.render(RenderingStrategy.MYBATIS3));
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<AuthorCode>>> selectByExample() {
|
||||
return SelectDSL.selectWithMapper(this::selectMany, id, inviteCode, validityTime, isUse, createTime, createUserId)
|
||||
.from(authorCode);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<AuthorCode>>> selectDistinctByExample() {
|
||||
return SelectDSL.selectDistinctWithMapper(this::selectMany, id, inviteCode, validityTime, isUse, createTime, createUserId)
|
||||
.from(authorCode);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default AuthorCode selectByPrimaryKey(Long id_) {
|
||||
return SelectDSL.selectWithMapper(this::selectOne, id, inviteCode, validityTime, isUse, createTime, createUserId)
|
||||
.from(authorCode)
|
||||
.where(id, isEqualTo(id_))
|
||||
.build()
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExample(AuthorCode record) {
|
||||
return UpdateDSL.updateWithMapper(this::update, authorCode)
|
||||
.set(id).equalTo(record::getId)
|
||||
.set(inviteCode).equalTo(record::getInviteCode)
|
||||
.set(validityTime).equalTo(record::getValidityTime)
|
||||
.set(isUse).equalTo(record::getIsUse)
|
||||
.set(createTime).equalTo(record::getCreateTime)
|
||||
.set(createUserId).equalTo(record::getCreateUserId);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExampleSelective(AuthorCode record) {
|
||||
return UpdateDSL.updateWithMapper(this::update, authorCode)
|
||||
.set(id).equalToWhenPresent(record::getId)
|
||||
.set(inviteCode).equalToWhenPresent(record::getInviteCode)
|
||||
.set(validityTime).equalToWhenPresent(record::getValidityTime)
|
||||
.set(isUse).equalToWhenPresent(record::getIsUse)
|
||||
.set(createTime).equalToWhenPresent(record::getCreateTime)
|
||||
.set(createUserId).equalToWhenPresent(record::getCreateUserId);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int updateByPrimaryKey(AuthorCode record) {
|
||||
return UpdateDSL.updateWithMapper(this::update, authorCode)
|
||||
.set(inviteCode).equalTo(record::getInviteCode)
|
||||
.set(validityTime).equalTo(record::getValidityTime)
|
||||
.set(isUse).equalTo(record::getIsUse)
|
||||
.set(createTime).equalTo(record::getCreateTime)
|
||||
.set(createUserId).equalTo(record::getCreateUserId)
|
||||
.where(id, isEqualTo(record::getId))
|
||||
.build()
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int updateByPrimaryKeySelective(AuthorCode record) {
|
||||
return UpdateDSL.updateWithMapper(this::update, authorCode)
|
||||
.set(inviteCode).equalToWhenPresent(record::getInviteCode)
|
||||
.set(validityTime).equalToWhenPresent(record::getValidityTime)
|
||||
.set(isUse).equalToWhenPresent(record::getIsUse)
|
||||
.set(createTime).equalToWhenPresent(record::getCreateTime)
|
||||
.set(createUserId).equalToWhenPresent(record::getCreateUserId)
|
||||
.where(id, isEqualTo(record::getId))
|
||||
.build()
|
||||
.execute();
|
||||
}
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
package com.java2nb.novel.author.mapper;
|
||||
|
||||
import org.mybatis.dynamic.sql.SqlColumn;
|
||||
import org.mybatis.dynamic.sql.SqlTable;
|
||||
|
||||
import javax.annotation.Generated;
|
||||
import java.sql.JDBCType;
|
||||
import java.util.Date;
|
||||
|
||||
public final class AuthorDynamicSqlSupport {
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final Author author = new Author();
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Long> id = author.id;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Long> userId = author.userId;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<String> inviteCode = author.inviteCode;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<String> penName = author.penName;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<String> telPhone = author.telPhone;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<String> chatAccount = author.chatAccount;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<String> email = author.email;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Byte> workDirection = author.workDirection;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Byte> status = author.status;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Date> createTime = author.createTime;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final class Author extends SqlTable {
|
||||
public final SqlColumn<Long> id = column("id", JDBCType.BIGINT);
|
||||
|
||||
public final SqlColumn<Long> userId = column("user_id", JDBCType.BIGINT);
|
||||
|
||||
public final SqlColumn<String> inviteCode = column("invite_code", JDBCType.VARCHAR);
|
||||
|
||||
public final SqlColumn<String> penName = column("pen_name", JDBCType.VARCHAR);
|
||||
|
||||
public final SqlColumn<String> telPhone = column("tel_phone", JDBCType.VARCHAR);
|
||||
|
||||
public final SqlColumn<String> chatAccount = column("chat_account", JDBCType.VARCHAR);
|
||||
|
||||
public final SqlColumn<String> email = column("email", JDBCType.VARCHAR);
|
||||
|
||||
public final SqlColumn<Byte> workDirection = column("work_direction", JDBCType.TINYINT);
|
||||
|
||||
public final SqlColumn<Byte> status = column("status", JDBCType.TINYINT);
|
||||
|
||||
public final SqlColumn<Date> createTime = column("create_time", JDBCType.TIMESTAMP);
|
||||
|
||||
public Author() {
|
||||
super("author");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,205 +0,0 @@
|
||||
package com.java2nb.novel.author.mapper;
|
||||
|
||||
import com.java2nb.novel.author.entity.Author;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.mybatis.dynamic.sql.SqlBuilder;
|
||||
import org.mybatis.dynamic.sql.delete.DeleteDSL;
|
||||
import org.mybatis.dynamic.sql.delete.MyBatis3DeleteModelAdapter;
|
||||
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
|
||||
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
|
||||
import org.mybatis.dynamic.sql.render.RenderingStrategy;
|
||||
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
|
||||
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
|
||||
import org.mybatis.dynamic.sql.select.SelectDSL;
|
||||
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
|
||||
import org.mybatis.dynamic.sql.update.MyBatis3UpdateModelAdapter;
|
||||
import org.mybatis.dynamic.sql.update.UpdateDSL;
|
||||
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
|
||||
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
|
||||
|
||||
import javax.annotation.Generated;
|
||||
import java.util.List;
|
||||
|
||||
import static com.java2nb.novel.author.mapper.AuthorDynamicSqlSupport.*;
|
||||
import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo;
|
||||
|
||||
@Mapper
|
||||
public interface AuthorMapper {
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||
long count(SelectStatementProvider selectStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@DeleteProvider(type=SqlProviderAdapter.class, method="delete")
|
||||
int delete(DeleteStatementProvider deleteStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@InsertProvider(type=SqlProviderAdapter.class, method="insert")
|
||||
int insert(InsertStatementProvider<Author> insertStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||
@ResultMap("AuthorResult")
|
||||
Author selectOne(SelectStatementProvider selectStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||
@Results(id="AuthorResult", value = {
|
||||
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
|
||||
@Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
|
||||
@Result(column="invite_code", property="inviteCode", jdbcType=JdbcType.VARCHAR),
|
||||
@Result(column="pen_name", property="penName", jdbcType=JdbcType.VARCHAR),
|
||||
@Result(column="tel_phone", property="telPhone", jdbcType=JdbcType.VARCHAR),
|
||||
@Result(column="chat_account", property="chatAccount", jdbcType=JdbcType.VARCHAR),
|
||||
@Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
|
||||
@Result(column="work_direction", property="workDirection", jdbcType=JdbcType.TINYINT),
|
||||
@Result(column="status", property="status", jdbcType=JdbcType.TINYINT),
|
||||
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
|
||||
})
|
||||
List<Author> selectMany(SelectStatementProvider selectStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@UpdateProvider(type=SqlProviderAdapter.class, method="update")
|
||||
int update(UpdateStatementProvider updateStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default QueryExpressionDSL<MyBatis3SelectModelAdapter<Long>> countByExample() {
|
||||
return SelectDSL.selectWithMapper(this::count, SqlBuilder.count())
|
||||
.from(author);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default DeleteDSL<MyBatis3DeleteModelAdapter<Integer>> deleteByExample() {
|
||||
return DeleteDSL.deleteFromWithMapper(this::delete, author);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int deleteByPrimaryKey(Long id_) {
|
||||
return DeleteDSL.deleteFromWithMapper(this::delete, author)
|
||||
.where(id, isEqualTo(id_))
|
||||
.build()
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int insert(Author record) {
|
||||
return insert(SqlBuilder.insert(record)
|
||||
.into(author)
|
||||
.map(id).toProperty("id")
|
||||
.map(userId).toProperty("userId")
|
||||
.map(inviteCode).toProperty("inviteCode")
|
||||
.map(penName).toProperty("penName")
|
||||
.map(telPhone).toProperty("telPhone")
|
||||
.map(chatAccount).toProperty("chatAccount")
|
||||
.map(email).toProperty("email")
|
||||
.map(workDirection).toProperty("workDirection")
|
||||
.map(status).toProperty("status")
|
||||
.map(createTime).toProperty("createTime")
|
||||
.build()
|
||||
.render(RenderingStrategy.MYBATIS3));
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int insertSelective(Author record) {
|
||||
return insert(SqlBuilder.insert(record)
|
||||
.into(author)
|
||||
.map(id).toPropertyWhenPresent("id", record::getId)
|
||||
.map(userId).toPropertyWhenPresent("userId", record::getUserId)
|
||||
.map(inviteCode).toPropertyWhenPresent("inviteCode", record::getInviteCode)
|
||||
.map(penName).toPropertyWhenPresent("penName", record::getPenName)
|
||||
.map(telPhone).toPropertyWhenPresent("telPhone", record::getTelPhone)
|
||||
.map(chatAccount).toPropertyWhenPresent("chatAccount", record::getChatAccount)
|
||||
.map(email).toPropertyWhenPresent("email", record::getEmail)
|
||||
.map(workDirection).toPropertyWhenPresent("workDirection", record::getWorkDirection)
|
||||
.map(status).toPropertyWhenPresent("status", record::getStatus)
|
||||
.map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
|
||||
.build()
|
||||
.render(RenderingStrategy.MYBATIS3));
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<Author>>> selectByExample() {
|
||||
return SelectDSL.selectWithMapper(this::selectMany, id, userId, inviteCode, penName, telPhone, chatAccount, email, workDirection, status, createTime)
|
||||
.from(author);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<Author>>> selectDistinctByExample() {
|
||||
return SelectDSL.selectDistinctWithMapper(this::selectMany, id, userId, inviteCode, penName, telPhone, chatAccount, email, workDirection, status, createTime)
|
||||
.from(author);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default Author selectByPrimaryKey(Long id_) {
|
||||
return SelectDSL.selectWithMapper(this::selectOne, id, userId, inviteCode, penName, telPhone, chatAccount, email, workDirection, status, createTime)
|
||||
.from(author)
|
||||
.where(id, isEqualTo(id_))
|
||||
.build()
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExample(Author record) {
|
||||
return UpdateDSL.updateWithMapper(this::update, author)
|
||||
.set(id).equalTo(record::getId)
|
||||
.set(userId).equalTo(record::getUserId)
|
||||
.set(inviteCode).equalTo(record::getInviteCode)
|
||||
.set(penName).equalTo(record::getPenName)
|
||||
.set(telPhone).equalTo(record::getTelPhone)
|
||||
.set(chatAccount).equalTo(record::getChatAccount)
|
||||
.set(email).equalTo(record::getEmail)
|
||||
.set(workDirection).equalTo(record::getWorkDirection)
|
||||
.set(status).equalTo(record::getStatus)
|
||||
.set(createTime).equalTo(record::getCreateTime);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExampleSelective(Author record) {
|
||||
return UpdateDSL.updateWithMapper(this::update, author)
|
||||
.set(id).equalToWhenPresent(record::getId)
|
||||
.set(userId).equalToWhenPresent(record::getUserId)
|
||||
.set(inviteCode).equalToWhenPresent(record::getInviteCode)
|
||||
.set(penName).equalToWhenPresent(record::getPenName)
|
||||
.set(telPhone).equalToWhenPresent(record::getTelPhone)
|
||||
.set(chatAccount).equalToWhenPresent(record::getChatAccount)
|
||||
.set(email).equalToWhenPresent(record::getEmail)
|
||||
.set(workDirection).equalToWhenPresent(record::getWorkDirection)
|
||||
.set(status).equalToWhenPresent(record::getStatus)
|
||||
.set(createTime).equalToWhenPresent(record::getCreateTime);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int updateByPrimaryKey(Author record) {
|
||||
return UpdateDSL.updateWithMapper(this::update, author)
|
||||
.set(userId).equalTo(record::getUserId)
|
||||
.set(inviteCode).equalTo(record::getInviteCode)
|
||||
.set(penName).equalTo(record::getPenName)
|
||||
.set(telPhone).equalTo(record::getTelPhone)
|
||||
.set(chatAccount).equalTo(record::getChatAccount)
|
||||
.set(email).equalTo(record::getEmail)
|
||||
.set(workDirection).equalTo(record::getWorkDirection)
|
||||
.set(status).equalTo(record::getStatus)
|
||||
.set(createTime).equalTo(record::getCreateTime)
|
||||
.where(id, isEqualTo(record::getId))
|
||||
.build()
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int updateByPrimaryKeySelective(Author record) {
|
||||
return UpdateDSL.updateWithMapper(this::update, author)
|
||||
.set(userId).equalToWhenPresent(record::getUserId)
|
||||
.set(inviteCode).equalToWhenPresent(record::getInviteCode)
|
||||
.set(penName).equalToWhenPresent(record::getPenName)
|
||||
.set(telPhone).equalToWhenPresent(record::getTelPhone)
|
||||
.set(chatAccount).equalToWhenPresent(record::getChatAccount)
|
||||
.set(email).equalToWhenPresent(record::getEmail)
|
||||
.set(workDirection).equalToWhenPresent(record::getWorkDirection)
|
||||
.set(status).equalToWhenPresent(record::getStatus)
|
||||
.set(createTime).equalToWhenPresent(record::getCreateTime)
|
||||
.where(id, isEqualTo(record::getId))
|
||||
.build()
|
||||
.execute();
|
||||
}
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
spring:
|
||||
profiles:
|
||||
include: [common]
|
||||
|
@ -1,13 +0,0 @@
|
||||
spring:
|
||||
application:
|
||||
name: author-service
|
||||
cloud:
|
||||
nacos:
|
||||
config:
|
||||
ext‐config[0]:
|
||||
data‐id: novel-jwt.yml
|
||||
group: novel-common
|
||||
refresh: true
|
||||
profiles:
|
||||
active: dev
|
||||
|
30
novel-author/novel-author-api/pom.xml
Normal file
30
novel-author/novel-author-api/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>novel-author</artifactId>
|
||||
<groupId>io.github.xxyopen</groupId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>novel-author-api</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.xxyopen</groupId>
|
||||
<artifactId>novel-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,28 @@
|
||||
package io.github.xxyopen.novel.author.dto;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 作家信息 DTO
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/5/18
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class AuthorInfoDto implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
private String penName;
|
||||
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package io.github.xxyopen.novel.author.dto.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.*;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 作家注册 请求DTO
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/5/23
|
||||
*/
|
||||
@Data
|
||||
public class AuthorRegisterReqDto {
|
||||
|
||||
@Schema(hidden = true)
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 笔名
|
||||
*/
|
||||
@Schema(description = "笔名", required = true)
|
||||
@NotBlank(message = "笔名不能为空!")
|
||||
private String penName;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
@Schema(description = "手机号码", required = true)
|
||||
@NotBlank(message = "手机号不能为空!")
|
||||
@Pattern(regexp = "^1[3|4|5|6|7|8|9][0-9]{9}$", message = "手机号格式不正确!")
|
||||
private String telPhone;
|
||||
|
||||
/**
|
||||
* QQ或微信账号
|
||||
*/
|
||||
@Schema(description = "QQ或微信账号", required = true)
|
||||
@NotBlank(message = "QQ或微信账号不能为空!")
|
||||
private String chatAccount;
|
||||
|
||||
/**
|
||||
* 电子邮箱
|
||||
*/
|
||||
@Schema(description = "电子邮箱", required = true)
|
||||
@NotBlank(message = "电子邮箱不能为空!")
|
||||
@Email(message = "邮箱格式不正确!")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 作品方向;0-男频 1-女频
|
||||
*/
|
||||
@Schema(description = "作品方向;0-男频 1-女频", required = true)
|
||||
@NotNull(message = "作品方向不能为空!")
|
||||
@Min(0)
|
||||
@Max(1)
|
||||
private Integer workDirection;
|
||||
|
||||
}
|
36
novel-author/novel-author-service/pom.xml
Normal file
36
novel-author/novel-author-service/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>novel-author</artifactId>
|
||||
<groupId>io.github.xxyopen</groupId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>novel-author-service</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.github.xxyopen</groupId>
|
||||
<artifactId>novel-author-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.xxyopen</groupId>
|
||||
<artifactId>novel-book-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.xxyopen</groupId>
|
||||
<artifactId>novel-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,21 @@
|
||||
package io.github.xxyopen.novel.author;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
@SpringBootApplication(scanBasePackages = {"io.github.xxyopen.novel"})
|
||||
@MapperScan("io.github.xxyopen.novel.author.dao.mapper")
|
||||
@EnableCaching
|
||||
@EnableDiscoveryClient
|
||||
@EnableFeignClients(basePackages = {"io.github.xxyopen.novel.book.feign"})
|
||||
public class NovelAuthorApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(NovelAuthorApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package io.github.xxyopen.novel.author.config;
|
||||
|
||||
import io.github.xxyopen.novel.author.dto.AuthorInfoDto;
|
||||
import io.github.xxyopen.novel.author.manager.cache.AuthorInfoCacheManager;
|
||||
import io.github.xxyopen.novel.common.auth.JwtUtils;
|
||||
import io.github.xxyopen.novel.common.auth.UserHolder;
|
||||
import io.github.xxyopen.novel.common.constant.ErrorCodeEnum;
|
||||
import io.github.xxyopen.novel.common.constant.SystemConfigConsts;
|
||||
import io.github.xxyopen.novel.config.exception.BusinessException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 认证授权 拦截器:为了注入其它的 Spring beans,需要通过 @Component 注解将该拦截器注册到 Spring 上下文
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/5/18
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class AuthInterceptor implements HandlerInterceptor {
|
||||
|
||||
private final AuthorInfoCacheManager authorInfoCacheManager;
|
||||
|
||||
/**
|
||||
* handle 执行前调用
|
||||
*/
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
|
||||
Object handler) throws Exception {
|
||||
// 获取登录 JWT
|
||||
String token = request.getHeader(SystemConfigConsts.HTTP_AUTH_HEADER_NAME);
|
||||
|
||||
// 开始认证
|
||||
if (!StringUtils.hasText(token)) {
|
||||
// token 为空
|
||||
throw new BusinessException(ErrorCodeEnum.USER_LOGIN_EXPIRED);
|
||||
}
|
||||
Long userId = JwtUtils.parseToken(token, SystemConfigConsts.NOVEL_FRONT_KEY);
|
||||
if (Objects.isNull(userId)) {
|
||||
// token 解析失败
|
||||
throw new BusinessException(ErrorCodeEnum.USER_LOGIN_EXPIRED);
|
||||
}
|
||||
// 作家权限认证
|
||||
AuthorInfoDto authorInfo = authorInfoCacheManager.getAuthor(userId);
|
||||
if (Objects.isNull(authorInfo)) {
|
||||
// 作家账号不存在,无权访问作家专区
|
||||
throw new BusinessException(ErrorCodeEnum.USER_UN_AUTH);
|
||||
}
|
||||
|
||||
// 设置作家ID到当前线程
|
||||
UserHolder.setAuthorId(authorInfo.getId());
|
||||
// 设置 userId 到当前线程
|
||||
UserHolder.setUserId(userId);
|
||||
return HandlerInterceptor.super.preHandle(request, response, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* handler 执行后调用,出现异常不调用
|
||||
*/
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
|
||||
ModelAndView modelAndView) throws Exception {
|
||||
HandlerInterceptor.super.postHandle(request, response, handler, modelAndView);
|
||||
}
|
||||
|
||||
/**
|
||||
* DispatcherServlet 完全处理完请求后调用,出现异常照常调用
|
||||
*/
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
|
||||
throws Exception {
|
||||
// 清理当前线程保存的用户数据
|
||||
UserHolder.clear();
|
||||
HandlerInterceptor.super.afterCompletion(request, response, handler, ex);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package io.github.xxyopen.novel.author.config;
|
||||
|
||||
import io.github.xxyopen.novel.common.constant.ApiRouterConsts;
|
||||
import io.github.xxyopen.novel.config.interceptor.TokenParseInterceptor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* Spring Web Mvc 相关配置不要加 @EnableWebMvc 注解,否则会导致 jackson 的全局配置失效。因为 @EnableWebMvc 注解会导致 WebMvcAutoConfiguration 自动配置失效
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/5/18
|
||||
*/
|
||||
@Configuration
|
||||
@RequiredArgsConstructor
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
|
||||
private final AuthInterceptor authInterceptor;
|
||||
|
||||
private final TokenParseInterceptor tokenParseInterceptor;
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
|
||||
// 权限认证拦截
|
||||
registry.addInterceptor(authInterceptor)
|
||||
// 拦截作家后台相关请求接口
|
||||
.addPathPatterns(
|
||||
ApiRouterConsts.API_AUTHOR_URL_PREFIX + "/**")
|
||||
// 放行注册相关请求接口
|
||||
.excludePathPatterns(ApiRouterConsts.API_AUTHOR_URL_PREFIX + "/register",
|
||||
ApiRouterConsts.API_AUTHOR_URL_PREFIX + "/status")
|
||||
.order(2);
|
||||
|
||||
// Token 解析
|
||||
registry.addInterceptor(tokenParseInterceptor)
|
||||
.addPathPatterns(
|
||||
ApiRouterConsts.API_AUTHOR_URL_PREFIX + "/register", ApiRouterConsts.API_AUTHOR_URL_PREFIX + "/status")
|
||||
.order(3);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
package io.github.xxyopen.novel.author.controller.author;
|
||||
|
||||
import io.github.xxyopen.novel.author.dto.req.AuthorRegisterReqDto;
|
||||
import io.github.xxyopen.novel.author.manager.feign.BookFeignManager;
|
||||
import io.github.xxyopen.novel.author.service.AuthorService;
|
||||
import io.github.xxyopen.novel.book.dto.req.BookAddReqDto;
|
||||
import io.github.xxyopen.novel.book.dto.req.BookPageReqDto;
|
||||
import io.github.xxyopen.novel.book.dto.req.ChapterAddReqDto;
|
||||
import io.github.xxyopen.novel.book.dto.req.ChapterPageReqDto;
|
||||
import io.github.xxyopen.novel.book.dto.resp.BookChapterRespDto;
|
||||
import io.github.xxyopen.novel.book.dto.resp.BookInfoRespDto;
|
||||
import io.github.xxyopen.novel.common.auth.UserHolder;
|
||||
import io.github.xxyopen.novel.common.constant.ApiRouterConsts;
|
||||
import io.github.xxyopen.novel.common.constant.SystemConfigConsts;
|
||||
import io.github.xxyopen.novel.common.req.PageReqDto;
|
||||
import io.github.xxyopen.novel.common.resp.PageRespDto;
|
||||
import io.github.xxyopen.novel.common.resp.RestResp;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 作家后台-作家模块 API 控制器
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/5/23
|
||||
*/
|
||||
@Tag(name = "AuthorController", description = "作家后台-作者模块")
|
||||
@SecurityRequirement(name = SystemConfigConsts.HTTP_AUTH_HEADER_NAME)
|
||||
@RestController
|
||||
@RequestMapping(ApiRouterConsts.API_AUTHOR_URL_PREFIX)
|
||||
@RequiredArgsConstructor
|
||||
public class AuthorController {
|
||||
|
||||
private final AuthorService authorService;
|
||||
|
||||
private final BookFeignManager bookFeignManager;
|
||||
|
||||
/**
|
||||
* 作家注册接口
|
||||
*/
|
||||
@Operation(summary = "作家注册接口")
|
||||
@PostMapping("register")
|
||||
public RestResp<Void> register(@Valid @RequestBody AuthorRegisterReqDto dto) {
|
||||
dto.setUserId(UserHolder.getUserId());
|
||||
return authorService.register(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询作家状态接口
|
||||
*/
|
||||
@Operation(summary = "作家状态查询接口")
|
||||
@GetMapping("status")
|
||||
public RestResp<Integer> getStatus() {
|
||||
return authorService.getStatus(UserHolder.getUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 小说发布接口
|
||||
*/
|
||||
@Operation(summary = "小说发布接口")
|
||||
@PostMapping("book")
|
||||
public RestResp<Void> publishBook(@Valid @RequestBody BookAddReqDto dto) {
|
||||
return bookFeignManager.publishBook(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 小说发布列表查询接口
|
||||
*/
|
||||
@Operation(summary = "小说发布列表查询接口")
|
||||
@GetMapping("books")
|
||||
public RestResp<PageRespDto<BookInfoRespDto>> listBooks(@ParameterObject BookPageReqDto dto) {
|
||||
dto.setAuthorId(UserHolder.getAuthorId());
|
||||
return bookFeignManager.listPublishBooks(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 小说章节发布接口
|
||||
*/
|
||||
@Operation(summary = "小说章节发布接口")
|
||||
@PostMapping("book/chapter/{bookId}")
|
||||
public RestResp<Void> publishBookChapter(
|
||||
@Parameter(description = "小说ID") @PathVariable("bookId") Long bookId,
|
||||
@Valid @RequestBody ChapterAddReqDto dto) {
|
||||
dto.setAuthorId(UserHolder.getAuthorId());
|
||||
dto.setBookId(bookId);
|
||||
return bookFeignManager.publishBookChapter(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 小说章节发布列表查询接口
|
||||
*/
|
||||
@Operation(summary = "小说章节发布列表查询接口")
|
||||
@GetMapping("book/chapters/{bookId}")
|
||||
public RestResp<PageRespDto<BookChapterRespDto>> listBookChapters(
|
||||
@Parameter(description = "小说ID") @PathVariable("bookId") Long bookId,
|
||||
@ParameterObject PageReqDto dto) {
|
||||
ChapterPageReqDto chapterPageReqReqDto = new ChapterPageReqDto();
|
||||
chapterPageReqReqDto.setBookId(bookId);
|
||||
chapterPageReqReqDto.setPageNum(dto.getPageNum());
|
||||
chapterPageReqReqDto.setPageSize(dto.getPageSize());
|
||||
return bookFeignManager.listPublishBookChapters(chapterPageReqReqDto);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package io.github.xxyopen.novel.author.dao.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 作家邀请码
|
||||
* </p>
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/05/11
|
||||
*/
|
||||
@TableName("author_code")
|
||||
public class AuthorCode implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 邀请码
|
||||
*/
|
||||
private String inviteCode;
|
||||
|
||||
/**
|
||||
* 有效时间
|
||||
*/
|
||||
private LocalDateTime validityTime;
|
||||
|
||||
/**
|
||||
* 是否使用过;0-未使用 1-使用过
|
||||
*/
|
||||
private Integer isUsed;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getInviteCode() {
|
||||
return inviteCode;
|
||||
}
|
||||
|
||||
public void setInviteCode(String inviteCode) {
|
||||
this.inviteCode = inviteCode;
|
||||
}
|
||||
|
||||
public LocalDateTime getValidityTime() {
|
||||
return validityTime;
|
||||
}
|
||||
|
||||
public void setValidityTime(LocalDateTime validityTime) {
|
||||
this.validityTime = validityTime;
|
||||
}
|
||||
|
||||
public Integer getIsUsed() {
|
||||
return isUsed;
|
||||
}
|
||||
|
||||
public void setIsUsed(Integer isUsed) {
|
||||
this.isUsed = isUsed;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(LocalDateTime createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(LocalDateTime updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AuthorCode{" +
|
||||
"id=" + id +
|
||||
", inviteCode=" + inviteCode +
|
||||
", validityTime=" + validityTime +
|
||||
", isUsed=" + isUsed +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
"}";
|
||||
}
|
||||
}
|
@ -0,0 +1,185 @@
|
||||
package io.github.xxyopen.novel.author.dao.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 稿费收入统计
|
||||
* </p>
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/05/11
|
||||
*/
|
||||
@TableName("author_income")
|
||||
public class AuthorIncome implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 作家ID
|
||||
*/
|
||||
private Long authorId;
|
||||
|
||||
/**
|
||||
* 小说ID
|
||||
*/
|
||||
private Long bookId;
|
||||
|
||||
/**
|
||||
* 收入月份
|
||||
*/
|
||||
private LocalDate incomeMonth;
|
||||
|
||||
/**
|
||||
* 税前收入;单位:分
|
||||
*/
|
||||
private Integer preTaxIncome;
|
||||
|
||||
/**
|
||||
* 税后收入;单位:分
|
||||
*/
|
||||
private Integer afterTaxIncome;
|
||||
|
||||
/**
|
||||
* 支付状态;0-待支付 1-已支付
|
||||
*/
|
||||
private Integer payStatus;
|
||||
|
||||
/**
|
||||
* 稿费确认状态;0-待确认 1-已确认
|
||||
*/
|
||||
private Integer confirmStatus;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
private String detail;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getAuthorId() {
|
||||
return authorId;
|
||||
}
|
||||
|
||||
public void setAuthorId(Long authorId) {
|
||||
this.authorId = authorId;
|
||||
}
|
||||
|
||||
public Long getBookId() {
|
||||
return bookId;
|
||||
}
|
||||
|
||||
public void setBookId(Long bookId) {
|
||||
this.bookId = bookId;
|
||||
}
|
||||
|
||||
public LocalDate getIncomeMonth() {
|
||||
return incomeMonth;
|
||||
}
|
||||
|
||||
public void setIncomeMonth(LocalDate incomeMonth) {
|
||||
this.incomeMonth = incomeMonth;
|
||||
}
|
||||
|
||||
public Integer getPreTaxIncome() {
|
||||
return preTaxIncome;
|
||||
}
|
||||
|
||||
public void setPreTaxIncome(Integer preTaxIncome) {
|
||||
this.preTaxIncome = preTaxIncome;
|
||||
}
|
||||
|
||||
public Integer getAfterTaxIncome() {
|
||||
return afterTaxIncome;
|
||||
}
|
||||
|
||||
public void setAfterTaxIncome(Integer afterTaxIncome) {
|
||||
this.afterTaxIncome = afterTaxIncome;
|
||||
}
|
||||
|
||||
public Integer getPayStatus() {
|
||||
return payStatus;
|
||||
}
|
||||
|
||||
public void setPayStatus(Integer payStatus) {
|
||||
this.payStatus = payStatus;
|
||||
}
|
||||
|
||||
public Integer getConfirmStatus() {
|
||||
return confirmStatus;
|
||||
}
|
||||
|
||||
public void setConfirmStatus(Integer confirmStatus) {
|
||||
this.confirmStatus = confirmStatus;
|
||||
}
|
||||
|
||||
public String getDetail() {
|
||||
return detail;
|
||||
}
|
||||
|
||||
public void setDetail(String detail) {
|
||||
this.detail = detail;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(LocalDateTime createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(LocalDateTime updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AuthorIncome{" +
|
||||
"id=" + id +
|
||||
", authorId=" + authorId +
|
||||
", bookId=" + bookId +
|
||||
", incomeMonth=" + incomeMonth +
|
||||
", preTaxIncome=" + preTaxIncome +
|
||||
", afterTaxIncome=" + afterTaxIncome +
|
||||
", payStatus=" + payStatus +
|
||||
", confirmStatus=" + confirmStatus +
|
||||
", detail=" + detail +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
"}";
|
||||
}
|
||||
}
|
@ -0,0 +1,157 @@
|
||||
package io.github.xxyopen.novel.author.dao.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 稿费收入明细统计
|
||||
* </p>
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/05/11
|
||||
*/
|
||||
@TableName("author_income_detail")
|
||||
public class AuthorIncomeDetail implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 作家ID
|
||||
*/
|
||||
private Long authorId;
|
||||
|
||||
/**
|
||||
* 小说ID;0表示全部作品
|
||||
*/
|
||||
private Long bookId;
|
||||
|
||||
/**
|
||||
* 收入日期
|
||||
*/
|
||||
private LocalDate incomeDate;
|
||||
|
||||
/**
|
||||
* 订阅总额
|
||||
*/
|
||||
private Integer incomeAccount;
|
||||
|
||||
/**
|
||||
* 订阅次数
|
||||
*/
|
||||
private Integer incomeCount;
|
||||
|
||||
/**
|
||||
* 订阅人数
|
||||
*/
|
||||
private Integer incomeNumber;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getAuthorId() {
|
||||
return authorId;
|
||||
}
|
||||
|
||||
public void setAuthorId(Long authorId) {
|
||||
this.authorId = authorId;
|
||||
}
|
||||
|
||||
public Long getBookId() {
|
||||
return bookId;
|
||||
}
|
||||
|
||||
public void setBookId(Long bookId) {
|
||||
this.bookId = bookId;
|
||||
}
|
||||
|
||||
public LocalDate getIncomeDate() {
|
||||
return incomeDate;
|
||||
}
|
||||
|
||||
public void setIncomeDate(LocalDate incomeDate) {
|
||||
this.incomeDate = incomeDate;
|
||||
}
|
||||
|
||||
public Integer getIncomeAccount() {
|
||||
return incomeAccount;
|
||||
}
|
||||
|
||||
public void setIncomeAccount(Integer incomeAccount) {
|
||||
this.incomeAccount = incomeAccount;
|
||||
}
|
||||
|
||||
public Integer getIncomeCount() {
|
||||
return incomeCount;
|
||||
}
|
||||
|
||||
public void setIncomeCount(Integer incomeCount) {
|
||||
this.incomeCount = incomeCount;
|
||||
}
|
||||
|
||||
public Integer getIncomeNumber() {
|
||||
return incomeNumber;
|
||||
}
|
||||
|
||||
public void setIncomeNumber(Integer incomeNumber) {
|
||||
this.incomeNumber = incomeNumber;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(LocalDateTime createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(LocalDateTime updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AuthorIncomeDetail{" +
|
||||
"id=" + id +
|
||||
", authorId=" + authorId +
|
||||
", bookId=" + bookId +
|
||||
", incomeDate=" + incomeDate +
|
||||
", incomeAccount=" + incomeAccount +
|
||||
", incomeCount=" + incomeCount +
|
||||
", incomeNumber=" + incomeNumber +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
"}";
|
||||
}
|
||||
}
|
@ -0,0 +1,184 @@
|
||||
package io.github.xxyopen.novel.author.dao.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 作者信息
|
||||
* </p>
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/05/11
|
||||
*/
|
||||
@TableName("author_info")
|
||||
public class AuthorInfo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 邀请码
|
||||
*/
|
||||
private String inviteCode;
|
||||
|
||||
/**
|
||||
* 笔名
|
||||
*/
|
||||
private String penName;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
private String telPhone;
|
||||
|
||||
/**
|
||||
* QQ或微信账号
|
||||
*/
|
||||
private String chatAccount;
|
||||
|
||||
/**
|
||||
* 电子邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 作品方向;0-男频 1-女频
|
||||
*/
|
||||
private Integer workDirection;
|
||||
|
||||
/**
|
||||
* 0:正常;1-封禁
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getInviteCode() {
|
||||
return inviteCode;
|
||||
}
|
||||
|
||||
public void setInviteCode(String inviteCode) {
|
||||
this.inviteCode = inviteCode;
|
||||
}
|
||||
|
||||
public String getPenName() {
|
||||
return penName;
|
||||
}
|
||||
|
||||
public void setPenName(String penName) {
|
||||
this.penName = penName;
|
||||
}
|
||||
|
||||
public String getTelPhone() {
|
||||
return telPhone;
|
||||
}
|
||||
|
||||
public void setTelPhone(String telPhone) {
|
||||
this.telPhone = telPhone;
|
||||
}
|
||||
|
||||
public String getChatAccount() {
|
||||
return chatAccount;
|
||||
}
|
||||
|
||||
public void setChatAccount(String chatAccount) {
|
||||
this.chatAccount = chatAccount;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public Integer getWorkDirection() {
|
||||
return workDirection;
|
||||
}
|
||||
|
||||
public void setWorkDirection(Integer workDirection) {
|
||||
this.workDirection = workDirection;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(LocalDateTime createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(LocalDateTime updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AuthorInfo{" +
|
||||
"id=" + id +
|
||||
", userId=" + userId +
|
||||
", inviteCode=" + inviteCode +
|
||||
", penName=" + penName +
|
||||
", telPhone=" + telPhone +
|
||||
", chatAccount=" + chatAccount +
|
||||
", email=" + email +
|
||||
", workDirection=" + workDirection +
|
||||
", status=" + status +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
"}";
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package io.github.xxyopen.novel.author.dao.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import io.github.xxyopen.novel.author.dao.entity.AuthorCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 作家邀请码 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/05/11
|
||||
*/
|
||||
public interface AuthorCodeMapper extends BaseMapper<AuthorCode> {
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package io.github.xxyopen.novel.author.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import io.github.xxyopen.novel.author.dao.entity.AuthorIncomeDetail;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 稿费收入明细统计 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/05/11
|
||||
*/
|
||||
public interface AuthorIncomeDetailMapper extends BaseMapper<AuthorIncomeDetail> {
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package io.github.xxyopen.novel.author.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import io.github.xxyopen.novel.author.dao.entity.AuthorIncome;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 稿费收入统计 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/05/11
|
||||
*/
|
||||
public interface AuthorIncomeMapper extends BaseMapper<AuthorIncome> {
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package io.github.xxyopen.novel.author.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import io.github.xxyopen.novel.author.dao.entity.AuthorInfo;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 作者信息 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/05/11
|
||||
*/
|
||||
public interface AuthorInfoMapper extends BaseMapper<AuthorInfo> {
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package io.github.xxyopen.novel.author.manager.cache;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.github.xxyopen.novel.author.dao.entity.AuthorInfo;
|
||||
import io.github.xxyopen.novel.author.dao.mapper.AuthorInfoMapper;
|
||||
import io.github.xxyopen.novel.author.dto.AuthorInfoDto;
|
||||
import io.github.xxyopen.novel.common.constant.CacheConsts;
|
||||
import io.github.xxyopen.novel.common.constant.DatabaseConsts;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 作家信息 缓存管理类
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/5/12
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class AuthorInfoCacheManager {
|
||||
|
||||
private final AuthorInfoMapper authorInfoMapper;
|
||||
|
||||
/**
|
||||
* 查询作家信息,并放入缓存中
|
||||
*/
|
||||
@Cacheable(cacheManager = CacheConsts.REDIS_CACHE_MANAGER,
|
||||
value = CacheConsts.AUTHOR_INFO_CACHE_NAME, unless = "#result == null")
|
||||
public AuthorInfoDto getAuthor(Long userId) {
|
||||
QueryWrapper<AuthorInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper
|
||||
.eq(DatabaseConsts.AuthorInfoTable.COLUMN_USER_ID, userId)
|
||||
.last(DatabaseConsts.SqlEnum.LIMIT_1.getSql());
|
||||
AuthorInfo authorInfo = authorInfoMapper.selectOne(queryWrapper);
|
||||
if (Objects.isNull(authorInfo)) {
|
||||
return null;
|
||||
}
|
||||
return AuthorInfoDto.builder()
|
||||
.id(authorInfo.getId())
|
||||
.penName(authorInfo.getPenName())
|
||||
.status(authorInfo.getStatus()).build();
|
||||
}
|
||||
|
||||
@CacheEvict(cacheManager = CacheConsts.REDIS_CACHE_MANAGER,
|
||||
value = CacheConsts.AUTHOR_INFO_CACHE_NAME)
|
||||
public void evictAuthorCache() {
|
||||
// 调用此方法自动清除作家信息的缓存
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package io.github.xxyopen.novel.author.manager.feign;
|
||||
|
||||
import io.github.xxyopen.novel.author.dto.AuthorInfoDto;
|
||||
import io.github.xxyopen.novel.author.manager.cache.AuthorInfoCacheManager;
|
||||
import io.github.xxyopen.novel.book.dto.req.BookAddReqDto;
|
||||
import io.github.xxyopen.novel.book.dto.req.BookPageReqDto;
|
||||
import io.github.xxyopen.novel.book.dto.req.ChapterAddReqDto;
|
||||
import io.github.xxyopen.novel.book.dto.req.ChapterPageReqDto;
|
||||
import io.github.xxyopen.novel.book.dto.resp.BookChapterRespDto;
|
||||
import io.github.xxyopen.novel.book.dto.resp.BookEsRespDto;
|
||||
import io.github.xxyopen.novel.book.dto.resp.BookInfoRespDto;
|
||||
import io.github.xxyopen.novel.book.feign.BookFeign;
|
||||
import io.github.xxyopen.novel.common.auth.UserHolder;
|
||||
import io.github.xxyopen.novel.common.constant.ErrorCodeEnum;
|
||||
import io.github.xxyopen.novel.common.req.PageReqDto;
|
||||
import io.github.xxyopen.novel.common.resp.PageRespDto;
|
||||
import io.github.xxyopen.novel.common.resp.RestResp;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 小说微服务调用 Feign 客户端管理
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2023/3/29
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class BookFeignManager {
|
||||
|
||||
private final BookFeign bookFeign;
|
||||
|
||||
private final AuthorInfoCacheManager authorInfoCacheManager;
|
||||
|
||||
public RestResp<Void> publishBook(BookAddReqDto dto) {
|
||||
AuthorInfoDto author = authorInfoCacheManager.getAuthor(UserHolder.getUserId());
|
||||
dto.setAuthorId(author.getId());
|
||||
dto.setPenName(author.getPenName());
|
||||
return bookFeign.publishBook(dto);
|
||||
}
|
||||
|
||||
public RestResp<PageRespDto<BookInfoRespDto>> listPublishBooks(BookPageReqDto dto) {
|
||||
authorInfoCacheManager.getAuthor(UserHolder.getUserId());
|
||||
return bookFeign.listPublishBooks(dto);
|
||||
}
|
||||
|
||||
public RestResp<Void> publishBookChapter(ChapterAddReqDto dto) {
|
||||
return bookFeign.publishBookChapter(dto);
|
||||
}
|
||||
|
||||
public RestResp<PageRespDto<BookChapterRespDto>> listPublishBookChapters(ChapterPageReqDto dto) {
|
||||
return bookFeign.listPublishBookChapters(dto);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package io.github.xxyopen.novel.author.service;
|
||||
|
||||
|
||||
import io.github.xxyopen.novel.author.dto.req.AuthorRegisterReqDto;
|
||||
import io.github.xxyopen.novel.common.resp.RestResp;
|
||||
|
||||
/**
|
||||
* 作家模块 业务服务类
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/5/23
|
||||
*/
|
||||
public interface AuthorService {
|
||||
|
||||
/**
|
||||
* 作家注册
|
||||
*
|
||||
* @param dto 注册参数
|
||||
* @return void
|
||||
*/
|
||||
RestResp<Void> register(AuthorRegisterReqDto dto);
|
||||
|
||||
/**
|
||||
* 查询作家状态
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 作家状态
|
||||
*/
|
||||
RestResp<Integer> getStatus(Long userId);
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package io.github.xxyopen.novel.author.service.impl;
|
||||
|
||||
import io.github.xxyopen.novel.author.dao.entity.AuthorInfo;
|
||||
import io.github.xxyopen.novel.author.dao.mapper.AuthorInfoMapper;
|
||||
import io.github.xxyopen.novel.author.dto.AuthorInfoDto;
|
||||
import io.github.xxyopen.novel.author.dto.req.AuthorRegisterReqDto;
|
||||
import io.github.xxyopen.novel.author.manager.cache.AuthorInfoCacheManager;
|
||||
import io.github.xxyopen.novel.author.service.AuthorService;
|
||||
import io.github.xxyopen.novel.common.resp.RestResp;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 作家模块 服务实现类
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @date 2022/5/23
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class AuthorServiceImpl implements AuthorService {
|
||||
|
||||
private final AuthorInfoCacheManager authorInfoCacheManager;
|
||||
|
||||
private final AuthorInfoMapper authorInfoMapper;
|
||||
|
||||
@Override
|
||||
public RestResp<Void> register(AuthorRegisterReqDto dto) {
|
||||
// 校验该用户是否已注册为作家
|
||||
AuthorInfoDto author = authorInfoCacheManager.getAuthor(dto.getUserId());
|
||||
if (Objects.nonNull(author)) {
|
||||
// 该用户已经是作家,直接返回
|
||||
return RestResp.ok();
|
||||
}
|
||||
// 保存作家注册信息
|
||||
AuthorInfo authorInfo = new AuthorInfo();
|
||||
authorInfo.setUserId(dto.getUserId());
|
||||
authorInfo.setChatAccount(dto.getChatAccount());
|
||||
authorInfo.setEmail(dto.getEmail());
|
||||
authorInfo.setInviteCode("0");
|
||||
authorInfo.setTelPhone(dto.getTelPhone());
|
||||
authorInfo.setPenName(dto.getPenName());
|
||||
authorInfo.setWorkDirection(dto.getWorkDirection());
|
||||
authorInfo.setCreateTime(LocalDateTime.now());
|
||||
authorInfo.setUpdateTime(LocalDateTime.now());
|
||||
authorInfoMapper.insert(authorInfo);
|
||||
// 清除作家缓存
|
||||
authorInfoCacheManager.evictAuthorCache();
|
||||
return RestResp.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestResp<Integer> getStatus(Long userId) {
|
||||
AuthorInfoDto author = authorInfoCacheManager.getAuthor(userId);
|
||||
return Objects.isNull(author) ? RestResp.ok(null) : RestResp.ok(author.getStatus());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
server:
|
||||
port: 9010
|
||||
spring:
|
||||
profiles:
|
||||
include: common
|
||||
active: dev
|
||||
|
||||
management:
|
||||
# 端点启用配置
|
||||
endpoint:
|
||||
logfile:
|
||||
# 启用返回日志文件内容的端点
|
||||
enabled: true
|
||||
# 外部日志文件路径
|
||||
external-file: logs/novel-author-service.log
|
@ -0,0 +1,6 @@
|
||||
spring:
|
||||
application:
|
||||
name: novel-author-service
|
||||
profiles:
|
||||
include: common
|
||||
|
@ -1,20 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<!-- 彩色日志依赖的渲染类 -->
|
||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
|
||||
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
|
||||
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
|
||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
|
||||
<conversionRule conversionWord="wex"
|
||||
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
|
||||
<conversionRule conversionWord="wEx"
|
||||
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
|
||||
<!-- 彩色日志格式 -->
|
||||
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}" />
|
||||
<property name="CONSOLE_LOG_PATTERN"
|
||||
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||
|
||||
<!-- %m输出的信息,%p日志级别,%t线程名,%d日期,%c类的全名,%i索引【从数字0开始递增】,,, -->
|
||||
<!-- appender是configuration的子节点,是负责写日志的组件。 -->
|
||||
<!-- ConsoleAppender:把日志输出到控制台 -->
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<!--
|
||||
<pattern>%d %p (%file:%line\)- %m%n</pattern>
|
||||
-->
|
||||
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||
<!-- 控制台也要使用UTF-8,不要使用GBK,否则会中文乱码 -->
|
||||
<charset>UTF-8</charset>
|
||||
@ -26,7 +26,7 @@
|
||||
<!-- 2.如果日期没有发生变化,但是当前日志的文件大小超过1KB时,对当前日志进行分割 重命名 -->
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
|
||||
<File>logs/author-service.log</File>
|
||||
<File>logs/novel-author-service.log</File>
|
||||
<!-- rollingPolicy:当发生滚动时,决定 RollingFileAppender 的行为,涉及文件移动和重命名。 -->
|
||||
<!-- TimeBasedRollingPolicy: 最常用的滚动策略,它根据时间来制定滚动策略,既负责滚动也负责出发滚动 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
@ -49,24 +49,31 @@
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
<!--输出到logstash的appender-->
|
||||
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
|
||||
<!--可以访问的logstash日志收集端口-->
|
||||
<destination>198.245.61.51:4560</destination>
|
||||
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder"/>
|
||||
</appender>
|
||||
<!-- 控制台输出日志级别 -->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
<appender-ref ref="FILE" />
|
||||
<appender-ref ref="LOGSTASH"/>
|
||||
</root>
|
||||
<!-- 指定项目中某个包,当有日志操作行为时的日志记录级别 -->
|
||||
<!-- com.maijinjie.springboot 为根包,也就是只要是发生在这个根包下面的所有日志操作行为的权限都是DEBUG -->
|
||||
<!-- 级别依次为【从高到低】:FATAL > ERROR > WARN > INFO > DEBUG > TRACE -->
|
||||
<logger name="com.java2nb" level="DEBUG">
|
||||
<appender-ref ref="STDOUT" />
|
||||
<appender-ref ref="FILE" />
|
||||
<appender-ref ref="LOGSTASH"/>
|
||||
</logger>
|
||||
<springProfile name="dev">
|
||||
<!-- ROOT 日志级别 -->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
<appender-ref ref="FILE"/>
|
||||
</root>
|
||||
<!-- 指定项目中某个包,当有日志操作行为时的日志记录级别 -->
|
||||
<!-- com.maijinjie.springboot 为根包,也就是只要是发生在这个根包下面的所有日志操作行为的权限都是DEBUG -->
|
||||
<!-- 级别依次为【从高到低】:FATAL > ERROR > WARN > INFO > DEBUG > TRACE -->
|
||||
<logger name="io.github.xxyopen" level="DEBUG" additivity="false">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
<appender-ref ref="FILE"/>
|
||||
</logger>
|
||||
</springProfile>
|
||||
|
||||
<springProfile name="prod">
|
||||
<!-- ROOT 日志级别 -->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="FILE"/>
|
||||
</root>
|
||||
<!-- 指定项目中某个包,当有日志操作行为时的日志记录级别 -->
|
||||
<!-- com.maijinjie.springboot 为根包,也就是只要是发生在这个根包下面的所有日志操作行为的权限都是DEBUG -->
|
||||
<!-- 级别依次为【从高到低】:FATAL > ERROR > WARN > INFO > DEBUG > TRACE -->
|
||||
<logger name="io.github.xxyopen" level="ERROR" additivity="false">
|
||||
<appender-ref ref="FILE"/>
|
||||
</logger>
|
||||
</springProfile>
|
||||
</configuration>
|
@ -4,19 +4,32 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>novel-cloud</artifactId>
|
||||
<groupId>com.java2nb.novel</groupId>
|
||||
<version>1.3.0</version>
|
||||
<groupId>io.github.xxyopen</groupId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>novel-author</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>author-api</module>
|
||||
<module>author-service</module>
|
||||
<module>novel-author-api</module>
|
||||
<module>novel-author-service</module>
|
||||
</modules>
|
||||
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.github.xxyopen</groupId>
|
||||
<artifactId>novel-common</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.xxyopen</groupId>
|
||||
<artifactId>novel-config</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
</project>
|
Reference in New Issue
Block a user