diff --git a/luigi-api/pom.xml b/luigi-api/pom.xml index 70b49b4..dc7b2c1 100644 --- a/luigi-api/pom.xml +++ b/luigi-api/pom.xml @@ -17,6 +17,11 @@ + + com.bzgame.server + luigi-service + 1.0-SNAPSHOT + org.springframework.boot spring-boot-starter-web @@ -71,6 +76,12 @@ redis.clients jedis + + + + io.springfox + springfox-boot-starter + diff --git a/luigi-api/src/main/java/com/bzgame/server/luigi/api/config/SwaggerConfig.java b/luigi-api/src/main/java/com/bzgame/server/luigi/api/config/SwaggerConfig.java new file mode 100644 index 0000000..c6fdb09 --- /dev/null +++ b/luigi-api/src/main/java/com/bzgame/server/luigi/api/config/SwaggerConfig.java @@ -0,0 +1,47 @@ +package com.bzgame.server.luigi.api.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; + +/** + * @author nidaren + */ +@Configuration +public class SwaggerConfig implements WebMvcConfigurer { + private final SwaggerProperties swaggerProperties; + + public SwaggerConfig(SwaggerProperties swaggerProperties) { + this.swaggerProperties = swaggerProperties; + } + + @Bean + public Docket createRestApi() { + return new Docket(DocumentationType.OAS_30) + .enable(swaggerProperties.getEnable()) + .useDefaultResponseMessages(false) + .apiInfo(apiInfo()) + .select() + .apis(RequestHandlerSelectors.basePackage("com.bzgame.server.luigi.api.rest")) + .paths(PathSelectors.any()) + .build(); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title(swaggerProperties.getApplicationName() + " Api Doc") + .description(swaggerProperties.getApplicationDescription()) + .contact(new Contact("bzc.app.server", "", "")) + .version(swaggerProperties.getApplicationVersion()) + .build(); + } + + +} diff --git a/luigi-api/src/main/java/com/bzgame/server/luigi/api/config/SwaggerProperties.java b/luigi-api/src/main/java/com/bzgame/server/luigi/api/config/SwaggerProperties.java new file mode 100644 index 0000000..048800b --- /dev/null +++ b/luigi-api/src/main/java/com/bzgame/server/luigi/api/config/SwaggerProperties.java @@ -0,0 +1,52 @@ +package com.bzgame.server.luigi.api.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * @author nidaren + */ +@Component +@ConfigurationProperties("swagger") +public class SwaggerProperties { + private Boolean enable; + + + private String applicationName; + + private String applicationVersion; + + private String applicationDescription; + + public Boolean getEnable() { + return enable; + } + + public void setEnable(Boolean enable) { + this.enable = enable; + } + + public String getApplicationName() { + return applicationName; + } + + public void setApplicationName(String applicationName) { + this.applicationName = applicationName; + } + + public String getApplicationVersion() { + return applicationVersion; + } + + public void setApplicationVersion(String applicationVersion) { + this.applicationVersion = applicationVersion; + } + + public String getApplicationDescription() { + return applicationDescription; + } + + public void setApplicationDescription(String applicationDescription) { + this.applicationDescription = applicationDescription; + } +} diff --git a/luigi-api/src/main/java/com/bzgame/server/luigi/api/rest/AuthorController.java b/luigi-api/src/main/java/com/bzgame/server/luigi/api/rest/AuthorController.java new file mode 100644 index 0000000..2ecccb0 --- /dev/null +++ b/luigi-api/src/main/java/com/bzgame/server/luigi/api/rest/AuthorController.java @@ -0,0 +1,39 @@ +package com.bzgame.server.luigi.api.rest; + +import com.bczgame.server.common.vo.Response; +import com.bzgame.server.luigi.api.aop.ApiFlag; +import com.bzgame.server.luigi.dao.domain.Author; +import com.bzgame.server.luigi.service.bo.AuthorService; +import com.bzgame.server.luigi.service.bo.response.CommonList; +import io.swagger.annotations.Api; +import org.apache.commons.lang3.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author nidaren + */ +@RestController +@RequestMapping("/api/luigi/author") +@Api(tags = "author") +public class AuthorController { + @Resource + private AuthorService authorService; + + @GetMapping("/seek") + @ApiFlag + public Response> seek(@RequestParam String name) { + if (StringUtils.isEmpty(name)) { + return new Response<>(new CommonList<>(), "ok", Response.CODE_SUCCESS); + } + return new Response<>(authorService.seek(name), "ok", Response.CODE_SUCCESS); + } +} diff --git a/luigi-api/src/main/java/com/bzgame/server/luigi/api/rest/PoemController.java b/luigi-api/src/main/java/com/bzgame/server/luigi/api/rest/PoemController.java new file mode 100644 index 0000000..96806f1 --- /dev/null +++ b/luigi-api/src/main/java/com/bzgame/server/luigi/api/rest/PoemController.java @@ -0,0 +1,35 @@ +package com.bzgame.server.luigi.api.rest; + +import com.bczgame.server.common.vo.Response; +import com.bzgame.server.luigi.api.aop.ApiFlag; +import com.bzgame.server.luigi.service.bo.PoemService; +import com.bzgame.server.luigi.service.bo.request.PoemQuery; +import com.bzgame.server.luigi.service.bo.response.CommonList; +import com.bzgame.server.luigi.service.bo.response.PoemBo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +/** + * poem + */ +@RestController +@RequestMapping("/api/luigi/poem") +@Api(tags = "poem") +public class PoemController { + @Resource + private PoemService poemService; + + @PostMapping("/list") + @ApiFlag + public Response> poemList(@RequestBody PoemQuery query) { + return new Response<>(poemService.query(query), "ok", Response.CODE_SUCCESS); + } + + @GetMapping("/detail") + public Response poemDetail(@RequestParam Integer id) { + return new Response<>(poemService.detail(id), "ok", Response.CODE_SUCCESS); + } +} diff --git a/luigi-api/src/main/java/com/bzgame/server/luigi/api/rest/UserController.java b/luigi-api/src/main/java/com/bzgame/server/luigi/api/rest/UserController.java new file mode 100644 index 0000000..09a6d09 --- /dev/null +++ b/luigi-api/src/main/java/com/bzgame/server/luigi/api/rest/UserController.java @@ -0,0 +1,28 @@ +package com.bzgame.server.luigi.api.rest; + +import com.bczgame.server.common.exception.BizException; +import com.bczgame.server.common.exception.ExceptionCode; +import com.bczgame.server.common.vo.Response; +import com.bzgame.server.luigi.api.aop.ApiFlag; +import com.bzgame.server.luigi.service.bo.response.UserBo; +import io.swagger.annotations.Api; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +/** + * @author nidaren + */ +@RestController +@RequestMapping("/api/luigi/user") +@Api(tags = "user") +public class UserController { + @GetMapping("/current") + @ApiFlag + public Response getCurrent() { + UserBo u = new UserBo(1, "test", "", "admin"); + return new Response<>(u, "ok", Response.CODE_SUCCESS); + } +} diff --git a/luigi-api/src/main/resources/application-default.yml b/luigi-api/src/main/resources/application-default.yml index d819500..ab7f6f9 100644 --- a/luigi-api/src/main/resources/application-default.yml +++ b/luigi-api/src/main/resources/application-default.yml @@ -21,10 +21,30 @@ spring: maxTotal: 128 poolMaxWaitMs: 50 timeOutMs: 100 + mvc: + pathmatch: + matching-strategy: ant_path_matcher logging: config: classpath:logback-spring.xml +springfox: + documentation: + swaggerUi: + baseUrl: /api/luigi + openApi: + v3: + path: /api/luigi/swagger/v3/api-docs + swagger: + v2: + path: /api/luigi/swagger/v2/api-docs + +swagger: + enable: true + applicationName: luigi + applicationDescription: support system for mario + applicationVersion: 1.0 + server: port: 8001 connection-timeout: 60000 #Time in milliseconds that connectors will wait for another HTTP request before closing the connection. diff --git a/luigi-api/src/main/resources/application-prod.yml b/luigi-api/src/main/resources/application-prod.yml index 7027527..1a2ee06 100644 --- a/luigi-api/src/main/resources/application-prod.yml +++ b/luigi-api/src/main/resources/application-prod.yml @@ -14,6 +14,23 @@ spring: logging: config: classpath:logback-spring.xml +springfox: + documentation: + swaggerUi: + baseUrl: /api/luigi + openApi: + v3: + path: /api/luigi/swagger/v3/api-docs + swagger: + v2: + path: /api/luigi/swagger/v2/api-docs + +swagger: + enable: false + applicationName: luigi + applicationDescription: support system for mario + applicationVersion: 1.0 + server: port: 8001 connection-timeout: 60000 #Time in milliseconds that connectors will wait for another HTTP request before closing the connection. diff --git a/luigi-api/src/main/resources/application-test.yml b/luigi-api/src/main/resources/application-test.yml index c779b66..7a53811 100644 --- a/luigi-api/src/main/resources/application-test.yml +++ b/luigi-api/src/main/resources/application-test.yml @@ -25,6 +25,23 @@ spring: logging: config: classpath:logback-spring.xml +springfox: + documentation: + swaggerUi: + baseUrl: /api/luigi + openApi: + v3: + path: /api/luigi/swagger/v3/api-docs + swagger: + v2: + path: /api/luigi/swagger/v2/api-docs + +swagger: + enable: false + applicationName: luigi + applicationDescription: support system for mario + applicationVersion: 1.0 + server: port: 8001 connection-timeout: 60000 #Time in milliseconds that connectors will wait for another HTTP request before closing the connection. diff --git a/luigi-dao/pom.xml b/luigi-dao/pom.xml index a8c968e..fc74474 100644 --- a/luigi-dao/pom.xml +++ b/luigi-dao/pom.xml @@ -36,11 +36,6 @@ org.mybatis.spring.boot mybatis-spring-boot-starter - - junit - junit - test - diff --git a/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/config/TopicDataSourceConfig.java b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/config/MarioDataSourceConfig.java similarity index 67% rename from luigi-dao/src/main/java/com/bzgame/server/luigi/dao/config/TopicDataSourceConfig.java rename to luigi-dao/src/main/java/com/bzgame/server/luigi/dao/config/MarioDataSourceConfig.java index 8da3a78..5288af6 100644 --- a/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/config/TopicDataSourceConfig.java +++ b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/config/MarioDataSourceConfig.java @@ -10,31 +10,26 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import javax.sql.DataSource; -/** - * Created by cba/kit-backend on 2022-03-18 15:25:35 - */ @Configuration -@MapperScan(basePackages = TopicDataSourceConfig.BASE_PACKAGE,sqlSessionFactoryRef = TopicDataSourceConfig.SSF_NAME,sqlSessionTemplateRef = TopicDataSourceConfig.SST_NAME) -public class TopicDataSourceConfig { +@MapperScan(basePackages = MarioDataSourceConfig.BASE_PACKAGE,sqlSessionFactoryRef = MarioDataSourceConfig.SSF_NAME,sqlSessionTemplateRef = MarioDataSourceConfig.SST_NAME) +public class MarioDataSourceConfig { + public static final String DS_NAME = "marioDataSource"; - //TODO 修改配置常量名 + public static final String TM_NAME = "marioTransactionManager"; - public static final String DS_NAME = "topicDataSource"; + public static final String SSF_NAME = "marioSqlSessionFactory"; - public static final String TM_NAME = "topicTransactionManager"; + public static final String SST_NAME = "marioSqlSessionTemplate"; - public static final String SSF_NAME = "topicSqlSessionFactory"; + public static final String DS_CFG_PREFIX = "datasource.mario"; - public static final String SST_NAME = "topicSqlSessionTemplate"; - - public static final String DS_CFG_PREFIX = "datasource.topic"; - - public static final String BASE_PACKAGE = "bcz.app.server.luigi.dao.mapper"; + public static final String BASE_PACKAGE = "com.bzgame.server.luigi.dao.mapper"; @Bean(name = DS_NAME) @ConfigurationProperties(DS_CFG_PREFIX) @@ -47,10 +42,11 @@ public class TopicDataSourceConfig { return new DataSourceTransactionManager(dataSource); } - @Bean(name = SSF_NAME) public SqlSessionFactory sqlSessionFactory(@Qualifier(DS_NAME) DataSource dataSource, @Qualifier(MybatisGeneralConfig.MBTS_CFG_NAME) org.apache.ibatis.session.Configuration configuration) throws Exception { SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); + PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); + factoryBean.setMapperLocations(resolver.getResources("classpath*:/mapper/*.xml")); factoryBean.setConfiguration(configuration); factoryBean.setDataSource(dataSource); return factoryBean.getObject(); diff --git a/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/config/MybatisGeneralConfig.java b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/config/MybatisGeneralConfig.java index fccbbaa..870d60c 100644 --- a/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/config/MybatisGeneralConfig.java +++ b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/config/MybatisGeneralConfig.java @@ -6,9 +6,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Scope; -/** - * Created by cba/kit-backend on 2022-03-18 15:25:35 - */ @Configuration public class MybatisGeneralConfig { diff --git a/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/domain/Author.java b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/domain/Author.java new file mode 100644 index 0000000..86273b6 --- /dev/null +++ b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/domain/Author.java @@ -0,0 +1,234 @@ +package com.bzgame.server.luigi.dao.domain; + +import java.io.Serializable; + +public class Author implements Serializable { + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column author.id + * + * @mbg.generated + */ + private Integer id; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column author.name + * + * @mbg.generated + */ + private String name; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column author.dynasty + * + * @mbg.generated + */ + private String dynasty; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column author.poem_cnt + * + * @mbg.generated + */ + private Integer poemCnt; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column author.status + * + * @mbg.generated + */ + private Integer status; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column author.introduction + * + * @mbg.generated + */ + private String introduction; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table author + * + * @mbg.generated + */ + private static final long serialVersionUID = 1L; + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column author.id + * + * @return the value of author.id + * + * @mbg.generated + */ + public Integer getId() { + return id; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column author.id + * + * @param id the value for author.id + * + * @mbg.generated + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column author.name + * + * @return the value of author.name + * + * @mbg.generated + */ + public String getName() { + return name; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column author.name + * + * @param name the value for author.name + * + * @mbg.generated + */ + public void setName(String name) { + this.name = name == null ? null : name.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column author.dynasty + * + * @return the value of author.dynasty + * + * @mbg.generated + */ + public String getDynasty() { + return dynasty; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column author.dynasty + * + * @param dynasty the value for author.dynasty + * + * @mbg.generated + */ + public void setDynasty(String dynasty) { + this.dynasty = dynasty == null ? null : dynasty.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column author.poem_cnt + * + * @return the value of author.poem_cnt + * + * @mbg.generated + */ + public Integer getPoemCnt() { + return poemCnt; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column author.poem_cnt + * + * @param poemCnt the value for author.poem_cnt + * + * @mbg.generated + */ + public void setPoemCnt(Integer poemCnt) { + this.poemCnt = poemCnt; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column author.status + * + * @return the value of author.status + * + * @mbg.generated + */ + public Integer getStatus() { + return status; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column author.status + * + * @param status the value for author.status + * + * @mbg.generated + */ + public void setStatus(Integer status) { + this.status = status; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column author.introduction + * + * @return the value of author.introduction + * + * @mbg.generated + */ + public String getIntroduction() { + return introduction; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column author.introduction + * + * @param introduction the value for author.introduction + * + * @mbg.generated + */ + public void setIntroduction(String introduction) { + this.introduction = introduction == null ? null : introduction.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", name=").append(name); + sb.append(", dynasty=").append(dynasty); + sb.append(", poemCnt=").append(poemCnt); + sb.append(", status=").append(status); + sb.append(", introduction=").append(introduction); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/domain/AuthorExample.java b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/domain/AuthorExample.java new file mode 100644 index 0000000..5d08695 --- /dev/null +++ b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/domain/AuthorExample.java @@ -0,0 +1,642 @@ +package com.bzgame.server.luigi.dao.domain; + +import java.util.ArrayList; +import java.util.List; + +public class AuthorExample { + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table author + * + * @mbg.generated + */ + protected String orderByClause; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table author + * + * @mbg.generated + */ + protected boolean distinct; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table author + * + * @mbg.generated + */ + protected List oredCriteria; + + private Integer limit; + + private Integer offset; + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + public AuthorExample() { + oredCriteria = new ArrayList(); + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + public String getOrderByClause() { + return orderByClause; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + public boolean isDistinct() { + return distinct; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + public List getOredCriteria() { + return oredCriteria; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public Integer getLimit() { + return limit; + } + + public void setOffset(Integer offset) { + this.offset = offset; + } + + public Integer getOffset() { + return offset; + } + + /** + * This class was generated by MyBatis Generator. + * This class corresponds to the database table author + * + * @mbg.generated + */ + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Integer value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Integer value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Integer value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Integer value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Integer value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Integer value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Integer value1, Integer value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Integer value1, Integer value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andNameIsNull() { + addCriterion("`name` is null"); + return (Criteria) this; + } + + public Criteria andNameIsNotNull() { + addCriterion("`name` is not null"); + return (Criteria) this; + } + + public Criteria andNameEqualTo(String value) { + addCriterion("`name` =", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotEqualTo(String value) { + addCriterion("`name` <>", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThan(String value) { + addCriterion("`name` >", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThanOrEqualTo(String value) { + addCriterion("`name` >=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThan(String value) { + addCriterion("`name` <", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThanOrEqualTo(String value) { + addCriterion("`name` <=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLike(String value) { + addCriterion("`name` like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotLike(String value) { + addCriterion("`name` not like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameIn(List values) { + addCriterion("`name` in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameNotIn(List values) { + addCriterion("`name` not in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameBetween(String value1, String value2) { + addCriterion("`name` between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andNameNotBetween(String value1, String value2) { + addCriterion("`name` not between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andDynastyIsNull() { + addCriterion("dynasty is null"); + return (Criteria) this; + } + + public Criteria andDynastyIsNotNull() { + addCriterion("dynasty is not null"); + return (Criteria) this; + } + + public Criteria andDynastyEqualTo(String value) { + addCriterion("dynasty =", value, "dynasty"); + return (Criteria) this; + } + + public Criteria andDynastyNotEqualTo(String value) { + addCriterion("dynasty <>", value, "dynasty"); + return (Criteria) this; + } + + public Criteria andDynastyGreaterThan(String value) { + addCriterion("dynasty >", value, "dynasty"); + return (Criteria) this; + } + + public Criteria andDynastyGreaterThanOrEqualTo(String value) { + addCriterion("dynasty >=", value, "dynasty"); + return (Criteria) this; + } + + public Criteria andDynastyLessThan(String value) { + addCriterion("dynasty <", value, "dynasty"); + return (Criteria) this; + } + + public Criteria andDynastyLessThanOrEqualTo(String value) { + addCriterion("dynasty <=", value, "dynasty"); + return (Criteria) this; + } + + public Criteria andDynastyLike(String value) { + addCriterion("dynasty like", value, "dynasty"); + return (Criteria) this; + } + + public Criteria andDynastyNotLike(String value) { + addCriterion("dynasty not like", value, "dynasty"); + return (Criteria) this; + } + + public Criteria andDynastyIn(List values) { + addCriterion("dynasty in", values, "dynasty"); + return (Criteria) this; + } + + public Criteria andDynastyNotIn(List values) { + addCriterion("dynasty not in", values, "dynasty"); + return (Criteria) this; + } + + public Criteria andDynastyBetween(String value1, String value2) { + addCriterion("dynasty between", value1, value2, "dynasty"); + return (Criteria) this; + } + + public Criteria andDynastyNotBetween(String value1, String value2) { + addCriterion("dynasty not between", value1, value2, "dynasty"); + return (Criteria) this; + } + + public Criteria andPoemCntIsNull() { + addCriterion("poem_cnt is null"); + return (Criteria) this; + } + + public Criteria andPoemCntIsNotNull() { + addCriterion("poem_cnt is not null"); + return (Criteria) this; + } + + public Criteria andPoemCntEqualTo(Integer value) { + addCriterion("poem_cnt =", value, "poemCnt"); + return (Criteria) this; + } + + public Criteria andPoemCntNotEqualTo(Integer value) { + addCriterion("poem_cnt <>", value, "poemCnt"); + return (Criteria) this; + } + + public Criteria andPoemCntGreaterThan(Integer value) { + addCriterion("poem_cnt >", value, "poemCnt"); + return (Criteria) this; + } + + public Criteria andPoemCntGreaterThanOrEqualTo(Integer value) { + addCriterion("poem_cnt >=", value, "poemCnt"); + return (Criteria) this; + } + + public Criteria andPoemCntLessThan(Integer value) { + addCriterion("poem_cnt <", value, "poemCnt"); + return (Criteria) this; + } + + public Criteria andPoemCntLessThanOrEqualTo(Integer value) { + addCriterion("poem_cnt <=", value, "poemCnt"); + return (Criteria) this; + } + + public Criteria andPoemCntIn(List values) { + addCriterion("poem_cnt in", values, "poemCnt"); + return (Criteria) this; + } + + public Criteria andPoemCntNotIn(List values) { + addCriterion("poem_cnt not in", values, "poemCnt"); + return (Criteria) this; + } + + public Criteria andPoemCntBetween(Integer value1, Integer value2) { + addCriterion("poem_cnt between", value1, value2, "poemCnt"); + return (Criteria) this; + } + + public Criteria andPoemCntNotBetween(Integer value1, Integer value2) { + addCriterion("poem_cnt not between", value1, value2, "poemCnt"); + return (Criteria) this; + } + + public Criteria andStatusIsNull() { + addCriterion("`status` is null"); + return (Criteria) this; + } + + public Criteria andStatusIsNotNull() { + addCriterion("`status` is not null"); + return (Criteria) this; + } + + public Criteria andStatusEqualTo(Integer value) { + addCriterion("`status` =", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotEqualTo(Integer value) { + addCriterion("`status` <>", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThan(Integer value) { + addCriterion("`status` >", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThanOrEqualTo(Integer value) { + addCriterion("`status` >=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThan(Integer value) { + addCriterion("`status` <", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThanOrEqualTo(Integer value) { + addCriterion("`status` <=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusIn(List values) { + addCriterion("`status` in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotIn(List values) { + addCriterion("`status` not in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusBetween(Integer value1, Integer value2) { + addCriterion("`status` between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotBetween(Integer value1, Integer value2) { + addCriterion("`status` not between", value1, value2, "status"); + return (Criteria) this; + } + } + + /** + * This class was generated by MyBatis Generator. + * This class corresponds to the database table author + * + * @mbg.generated do_not_delete_during_merge + */ + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + /** + * This class was generated by MyBatis Generator. + * This class corresponds to the database table author + * + * @mbg.generated + */ + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/domain/DroolRules.java b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/domain/DroolRules.java deleted file mode 100644 index 9b42d4b..0000000 --- a/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/domain/DroolRules.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.bzgame.server.luigi.dao.domain; - -/** - * @author chenyang@baicizhan.com - * @date 2020/3/9 6:31 PM - */ -public class DroolRules { - private long id; - private String rules; - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getRules() { - return rules; - } - - public void setRules(String rules) { - this.rules = rules; - } -} diff --git a/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/domain/Poem.java b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/domain/Poem.java new file mode 100644 index 0000000..a29df4e --- /dev/null +++ b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/domain/Poem.java @@ -0,0 +1,302 @@ +package com.bzgame.server.luigi.dao.domain; + +import java.io.Serializable; + +public class Poem implements Serializable { + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column poem.id + * + * @mbg.generated + */ + private Integer id; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column poem.author_id + * + * @mbg.generated + */ + private Integer authorId; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column poem.title + * + * @mbg.generated + */ + private String title; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column poem.line + * + * @mbg.generated + */ + private String line; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column poem.status + * + * @mbg.generated + */ + private Integer status; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column poem.content + * + * @mbg.generated + */ + private String content; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column poem.note + * + * @mbg.generated + */ + private String note; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column poem.translation + * + * @mbg.generated + */ + private String translation; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table poem + * + * @mbg.generated + */ + private static final long serialVersionUID = 1L; + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column poem.id + * + * @return the value of poem.id + * + * @mbg.generated + */ + public Integer getId() { + return id; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column poem.id + * + * @param id the value for poem.id + * + * @mbg.generated + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column poem.author_id + * + * @return the value of poem.author_id + * + * @mbg.generated + */ + public Integer getAuthorId() { + return authorId; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column poem.author_id + * + * @param authorId the value for poem.author_id + * + * @mbg.generated + */ + public void setAuthorId(Integer authorId) { + this.authorId = authorId; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column poem.title + * + * @return the value of poem.title + * + * @mbg.generated + */ + public String getTitle() { + return title; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column poem.title + * + * @param title the value for poem.title + * + * @mbg.generated + */ + public void setTitle(String title) { + this.title = title == null ? null : title.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column poem.line + * + * @return the value of poem.line + * + * @mbg.generated + */ + public String getLine() { + return line; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column poem.line + * + * @param line the value for poem.line + * + * @mbg.generated + */ + public void setLine(String line) { + this.line = line == null ? null : line.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column poem.status + * + * @return the value of poem.status + * + * @mbg.generated + */ + public Integer getStatus() { + return status; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column poem.status + * + * @param status the value for poem.status + * + * @mbg.generated + */ + public void setStatus(Integer status) { + this.status = status; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column poem.content + * + * @return the value of poem.content + * + * @mbg.generated + */ + public String getContent() { + return content; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column poem.content + * + * @param content the value for poem.content + * + * @mbg.generated + */ + public void setContent(String content) { + this.content = content == null ? null : content.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column poem.note + * + * @return the value of poem.note + * + * @mbg.generated + */ + public String getNote() { + return note; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column poem.note + * + * @param note the value for poem.note + * + * @mbg.generated + */ + public void setNote(String note) { + this.note = note == null ? null : note.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column poem.translation + * + * @return the value of poem.translation + * + * @mbg.generated + */ + public String getTranslation() { + return translation; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column poem.translation + * + * @param translation the value for poem.translation + * + * @mbg.generated + */ + public void setTranslation(String translation) { + this.translation = translation == null ? null : translation.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", authorId=").append(authorId); + sb.append(", title=").append(title); + sb.append(", line=").append(line); + sb.append(", status=").append(status); + sb.append(", content=").append(content); + sb.append(", note=").append(note); + sb.append(", translation=").append(translation); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/domain/PoemExample.java b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/domain/PoemExample.java new file mode 100644 index 0000000..4931763 --- /dev/null +++ b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/domain/PoemExample.java @@ -0,0 +1,642 @@ +package com.bzgame.server.luigi.dao.domain; + +import java.util.ArrayList; +import java.util.List; + +public class PoemExample { + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table poem + * + * @mbg.generated + */ + protected String orderByClause; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table poem + * + * @mbg.generated + */ + protected boolean distinct; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table poem + * + * @mbg.generated + */ + protected List oredCriteria; + + private Integer limit; + + private Integer offset; + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + public PoemExample() { + oredCriteria = new ArrayList(); + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + public String getOrderByClause() { + return orderByClause; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + public boolean isDistinct() { + return distinct; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + public List getOredCriteria() { + return oredCriteria; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public Integer getLimit() { + return limit; + } + + public void setOffset(Integer offset) { + this.offset = offset; + } + + public Integer getOffset() { + return offset; + } + + /** + * This class was generated by MyBatis Generator. + * This class corresponds to the database table poem + * + * @mbg.generated + */ + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Integer value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Integer value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Integer value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Integer value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Integer value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Integer value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Integer value1, Integer value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Integer value1, Integer value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andAuthorIdIsNull() { + addCriterion("author_id is null"); + return (Criteria) this; + } + + public Criteria andAuthorIdIsNotNull() { + addCriterion("author_id is not null"); + return (Criteria) this; + } + + public Criteria andAuthorIdEqualTo(Integer value) { + addCriterion("author_id =", value, "authorId"); + return (Criteria) this; + } + + public Criteria andAuthorIdNotEqualTo(Integer value) { + addCriterion("author_id <>", value, "authorId"); + return (Criteria) this; + } + + public Criteria andAuthorIdGreaterThan(Integer value) { + addCriterion("author_id >", value, "authorId"); + return (Criteria) this; + } + + public Criteria andAuthorIdGreaterThanOrEqualTo(Integer value) { + addCriterion("author_id >=", value, "authorId"); + return (Criteria) this; + } + + public Criteria andAuthorIdLessThan(Integer value) { + addCriterion("author_id <", value, "authorId"); + return (Criteria) this; + } + + public Criteria andAuthorIdLessThanOrEqualTo(Integer value) { + addCriterion("author_id <=", value, "authorId"); + return (Criteria) this; + } + + public Criteria andAuthorIdIn(List values) { + addCriterion("author_id in", values, "authorId"); + return (Criteria) this; + } + + public Criteria andAuthorIdNotIn(List values) { + addCriterion("author_id not in", values, "authorId"); + return (Criteria) this; + } + + public Criteria andAuthorIdBetween(Integer value1, Integer value2) { + addCriterion("author_id between", value1, value2, "authorId"); + return (Criteria) this; + } + + public Criteria andAuthorIdNotBetween(Integer value1, Integer value2) { + addCriterion("author_id not between", value1, value2, "authorId"); + return (Criteria) this; + } + + public Criteria andTitleIsNull() { + addCriterion("title is null"); + return (Criteria) this; + } + + public Criteria andTitleIsNotNull() { + addCriterion("title is not null"); + return (Criteria) this; + } + + public Criteria andTitleEqualTo(String value) { + addCriterion("title =", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleNotEqualTo(String value) { + addCriterion("title <>", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleGreaterThan(String value) { + addCriterion("title >", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleGreaterThanOrEqualTo(String value) { + addCriterion("title >=", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleLessThan(String value) { + addCriterion("title <", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleLessThanOrEqualTo(String value) { + addCriterion("title <=", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleLike(String value) { + addCriterion("title like", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleNotLike(String value) { + addCriterion("title not like", value, "title"); + return (Criteria) this; + } + + public Criteria andTitleIn(List values) { + addCriterion("title in", values, "title"); + return (Criteria) this; + } + + public Criteria andTitleNotIn(List values) { + addCriterion("title not in", values, "title"); + return (Criteria) this; + } + + public Criteria andTitleBetween(String value1, String value2) { + addCriterion("title between", value1, value2, "title"); + return (Criteria) this; + } + + public Criteria andTitleNotBetween(String value1, String value2) { + addCriterion("title not between", value1, value2, "title"); + return (Criteria) this; + } + + public Criteria andLineIsNull() { + addCriterion("line is null"); + return (Criteria) this; + } + + public Criteria andLineIsNotNull() { + addCriterion("line is not null"); + return (Criteria) this; + } + + public Criteria andLineEqualTo(String value) { + addCriterion("line =", value, "line"); + return (Criteria) this; + } + + public Criteria andLineNotEqualTo(String value) { + addCriterion("line <>", value, "line"); + return (Criteria) this; + } + + public Criteria andLineGreaterThan(String value) { + addCriterion("line >", value, "line"); + return (Criteria) this; + } + + public Criteria andLineGreaterThanOrEqualTo(String value) { + addCriterion("line >=", value, "line"); + return (Criteria) this; + } + + public Criteria andLineLessThan(String value) { + addCriterion("line <", value, "line"); + return (Criteria) this; + } + + public Criteria andLineLessThanOrEqualTo(String value) { + addCriterion("line <=", value, "line"); + return (Criteria) this; + } + + public Criteria andLineLike(String value) { + addCriterion("line like", value, "line"); + return (Criteria) this; + } + + public Criteria andLineNotLike(String value) { + addCriterion("line not like", value, "line"); + return (Criteria) this; + } + + public Criteria andLineIn(List values) { + addCriterion("line in", values, "line"); + return (Criteria) this; + } + + public Criteria andLineNotIn(List values) { + addCriterion("line not in", values, "line"); + return (Criteria) this; + } + + public Criteria andLineBetween(String value1, String value2) { + addCriterion("line between", value1, value2, "line"); + return (Criteria) this; + } + + public Criteria andLineNotBetween(String value1, String value2) { + addCriterion("line not between", value1, value2, "line"); + return (Criteria) this; + } + + public Criteria andStatusIsNull() { + addCriterion("`status` is null"); + return (Criteria) this; + } + + public Criteria andStatusIsNotNull() { + addCriterion("`status` is not null"); + return (Criteria) this; + } + + public Criteria andStatusEqualTo(Integer value) { + addCriterion("`status` =", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotEqualTo(Integer value) { + addCriterion("`status` <>", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThan(Integer value) { + addCriterion("`status` >", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThanOrEqualTo(Integer value) { + addCriterion("`status` >=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThan(Integer value) { + addCriterion("`status` <", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThanOrEqualTo(Integer value) { + addCriterion("`status` <=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusIn(List values) { + addCriterion("`status` in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotIn(List values) { + addCriterion("`status` not in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusBetween(Integer value1, Integer value2) { + addCriterion("`status` between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotBetween(Integer value1, Integer value2) { + addCriterion("`status` not between", value1, value2, "status"); + return (Criteria) this; + } + } + + /** + * This class was generated by MyBatis Generator. + * This class corresponds to the database table poem + * + * @mbg.generated do_not_delete_during_merge + */ + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + /** + * This class was generated by MyBatis Generator. + * This class corresponds to the database table poem + * + * @mbg.generated + */ + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/mapper/AuthorMapper.java b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/mapper/AuthorMapper.java new file mode 100644 index 0000000..1638f4c --- /dev/null +++ b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/mapper/AuthorMapper.java @@ -0,0 +1,120 @@ +package com.bzgame.server.luigi.dao.mapper; + +import com.bzgame.server.luigi.dao.domain.Author; +import com.bzgame.server.luigi.dao.domain.AuthorExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface AuthorMapper { + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + long countByExample(AuthorExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + int deleteByExample(AuthorExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + int deleteByPrimaryKey(Integer id); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + int insert(Author record); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + int insertSelective(Author record); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + List selectByExampleWithBLOBs(AuthorExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + List selectByExample(AuthorExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + Author selectByPrimaryKey(Integer id); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + int updateByExampleSelective(@Param("record") Author record, @Param("example") AuthorExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + int updateByExampleWithBLOBs(@Param("record") Author record, @Param("example") AuthorExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + int updateByExample(@Param("record") Author record, @Param("example") AuthorExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + int updateByPrimaryKeySelective(Author record); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + int updateByPrimaryKeyWithBLOBs(Author record); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table author + * + * @mbg.generated + */ + int updateByPrimaryKey(Author record); +} \ No newline at end of file diff --git a/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/mapper/DroolRulesMapper.java b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/mapper/DroolRulesMapper.java deleted file mode 100644 index 69569fe..0000000 --- a/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/mapper/DroolRulesMapper.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.bzgame.server.luigi.dao.mapper; - -import com.bzgame.server.luigi.dao.domain.DroolRules; -import org.apache.ibatis.annotations.Select; - -/** - * @author chenyang@baicizhan.com - * @date 2020/3/9 6:32 PM - */ -public interface DroolRulesMapper { - @Select("SELECT *FROM drool_rules WHERE id=1") - DroolRules query(); -} diff --git a/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/mapper/PoemMapper.java b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/mapper/PoemMapper.java new file mode 100644 index 0000000..f1630f4 --- /dev/null +++ b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/mapper/PoemMapper.java @@ -0,0 +1,120 @@ +package com.bzgame.server.luigi.dao.mapper; + +import com.bzgame.server.luigi.dao.domain.Poem; +import com.bzgame.server.luigi.dao.domain.PoemExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface PoemMapper { + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + long countByExample(PoemExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + int deleteByExample(PoemExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + int deleteByPrimaryKey(Integer id); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + int insert(Poem record); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + int insertSelective(Poem record); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + List selectByExampleWithBLOBs(PoemExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + List selectByExample(PoemExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + Poem selectByPrimaryKey(Integer id); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + int updateByExampleSelective(@Param("record") Poem record, @Param("example") PoemExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + int updateByExampleWithBLOBs(@Param("record") Poem record, @Param("example") PoemExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + int updateByExample(@Param("record") Poem record, @Param("example") PoemExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + int updateByPrimaryKeySelective(Poem record); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + int updateByPrimaryKeyWithBLOBs(Poem record); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table poem + * + * @mbg.generated + */ + int updateByPrimaryKey(Poem record); +} \ No newline at end of file diff --git a/luigi-dao/src/main/resources/mapper/AuthorMapper.xml b/luigi-dao/src/main/resources/mapper/AuthorMapper.xml new file mode 100644 index 0000000..b41f22f --- /dev/null +++ b/luigi-dao/src/main/resources/mapper/AuthorMapper.xml @@ -0,0 +1,366 @@ + + + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + id, `name`, dynasty, poem_cnt, `status` + + + + introduction + + + + + + + delete from author + where id = #{id,jdbcType=INTEGER} + + + + delete from author + + + + + + + + SELECT LAST_INSERT_ID() + + insert into author (`name`, dynasty, poem_cnt, + `status`, introduction) + values (#{name,jdbcType=VARCHAR}, #{dynasty,jdbcType=VARCHAR}, #{poemCnt,jdbcType=INTEGER}, + #{status,jdbcType=INTEGER}, #{introduction,jdbcType=LONGVARCHAR}) + + + + + SELECT LAST_INSERT_ID() + + insert into author + + + `name`, + + + dynasty, + + + poem_cnt, + + + `status`, + + + introduction, + + + + + #{name,jdbcType=VARCHAR}, + + + #{dynasty,jdbcType=VARCHAR}, + + + #{poemCnt,jdbcType=INTEGER}, + + + #{status,jdbcType=INTEGER}, + + + #{introduction,jdbcType=LONGVARCHAR}, + + + + + + + update author + + + id = #{record.id,jdbcType=INTEGER}, + + + `name` = #{record.name,jdbcType=VARCHAR}, + + + dynasty = #{record.dynasty,jdbcType=VARCHAR}, + + + poem_cnt = #{record.poemCnt,jdbcType=INTEGER}, + + + `status` = #{record.status,jdbcType=INTEGER}, + + + introduction = #{record.introduction,jdbcType=LONGVARCHAR}, + + + + + + + + + update author + set id = #{record.id,jdbcType=INTEGER}, + `name` = #{record.name,jdbcType=VARCHAR}, + dynasty = #{record.dynasty,jdbcType=VARCHAR}, + poem_cnt = #{record.poemCnt,jdbcType=INTEGER}, + `status` = #{record.status,jdbcType=INTEGER}, + introduction = #{record.introduction,jdbcType=LONGVARCHAR} + + + + + + + update author + set id = #{record.id,jdbcType=INTEGER}, + `name` = #{record.name,jdbcType=VARCHAR}, + dynasty = #{record.dynasty,jdbcType=VARCHAR}, + poem_cnt = #{record.poemCnt,jdbcType=INTEGER}, + `status` = #{record.status,jdbcType=INTEGER} + + + + + + + update author + + + `name` = #{name,jdbcType=VARCHAR}, + + + dynasty = #{dynasty,jdbcType=VARCHAR}, + + + poem_cnt = #{poemCnt,jdbcType=INTEGER}, + + + `status` = #{status,jdbcType=INTEGER}, + + + introduction = #{introduction,jdbcType=LONGVARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + + update author + set `name` = #{name,jdbcType=VARCHAR}, + dynasty = #{dynasty,jdbcType=VARCHAR}, + poem_cnt = #{poemCnt,jdbcType=INTEGER}, + `status` = #{status,jdbcType=INTEGER}, + introduction = #{introduction,jdbcType=LONGVARCHAR} + where id = #{id,jdbcType=INTEGER} + + + + update author + set `name` = #{name,jdbcType=VARCHAR}, + dynasty = #{dynasty,jdbcType=VARCHAR}, + poem_cnt = #{poemCnt,jdbcType=INTEGER}, + `status` = #{status,jdbcType=INTEGER} + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/luigi-dao/src/main/resources/mapper/PoemMapper.xml b/luigi-dao/src/main/resources/mapper/PoemMapper.xml new file mode 100644 index 0000000..2f74bc9 --- /dev/null +++ b/luigi-dao/src/main/resources/mapper/PoemMapper.xml @@ -0,0 +1,398 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + id, author_id, title, line, `status` + + + + content, note, `translation` + + + + + + + delete from poem + where id = #{id,jdbcType=INTEGER} + + + + delete from poem + + + + + + + + SELECT LAST_INSERT_ID() + + insert into poem (author_id, title, line, + `status`, content, note, + `translation`) + values (#{authorId,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, #{line,jdbcType=VARCHAR}, + #{status,jdbcType=INTEGER}, #{content,jdbcType=LONGVARCHAR}, #{note,jdbcType=LONGVARCHAR}, + #{translation,jdbcType=LONGVARCHAR}) + + + + + SELECT LAST_INSERT_ID() + + insert into poem + + + author_id, + + + title, + + + line, + + + `status`, + + + content, + + + note, + + + `translation`, + + + + + #{authorId,jdbcType=INTEGER}, + + + #{title,jdbcType=VARCHAR}, + + + #{line,jdbcType=VARCHAR}, + + + #{status,jdbcType=INTEGER}, + + + #{content,jdbcType=LONGVARCHAR}, + + + #{note,jdbcType=LONGVARCHAR}, + + + #{translation,jdbcType=LONGVARCHAR}, + + + + + + + update poem + + + id = #{record.id,jdbcType=INTEGER}, + + + author_id = #{record.authorId,jdbcType=INTEGER}, + + + title = #{record.title,jdbcType=VARCHAR}, + + + line = #{record.line,jdbcType=VARCHAR}, + + + `status` = #{record.status,jdbcType=INTEGER}, + + + content = #{record.content,jdbcType=LONGVARCHAR}, + + + note = #{record.note,jdbcType=LONGVARCHAR}, + + + `translation` = #{record.translation,jdbcType=LONGVARCHAR}, + + + + + + + + + update poem + set id = #{record.id,jdbcType=INTEGER}, + author_id = #{record.authorId,jdbcType=INTEGER}, + title = #{record.title,jdbcType=VARCHAR}, + line = #{record.line,jdbcType=VARCHAR}, + `status` = #{record.status,jdbcType=INTEGER}, + content = #{record.content,jdbcType=LONGVARCHAR}, + note = #{record.note,jdbcType=LONGVARCHAR}, + `translation` = #{record.translation,jdbcType=LONGVARCHAR} + + + + + + + update poem + set id = #{record.id,jdbcType=INTEGER}, + author_id = #{record.authorId,jdbcType=INTEGER}, + title = #{record.title,jdbcType=VARCHAR}, + line = #{record.line,jdbcType=VARCHAR}, + `status` = #{record.status,jdbcType=INTEGER} + + + + + + + update poem + + + author_id = #{authorId,jdbcType=INTEGER}, + + + title = #{title,jdbcType=VARCHAR}, + + + line = #{line,jdbcType=VARCHAR}, + + + `status` = #{status,jdbcType=INTEGER}, + + + content = #{content,jdbcType=LONGVARCHAR}, + + + note = #{note,jdbcType=LONGVARCHAR}, + + + `translation` = #{translation,jdbcType=LONGVARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + + update poem + set author_id = #{authorId,jdbcType=INTEGER}, + title = #{title,jdbcType=VARCHAR}, + line = #{line,jdbcType=VARCHAR}, + `status` = #{status,jdbcType=INTEGER}, + content = #{content,jdbcType=LONGVARCHAR}, + note = #{note,jdbcType=LONGVARCHAR}, + `translation` = #{translation,jdbcType=LONGVARCHAR} + where id = #{id,jdbcType=INTEGER} + + + + update poem + set author_id = #{authorId,jdbcType=INTEGER}, + title = #{title,jdbcType=VARCHAR}, + line = #{line,jdbcType=VARCHAR}, + `status` = #{status,jdbcType=INTEGER} + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/luigi-service/pom.xml b/luigi-service/pom.xml index 9c6404a..4b93cd3 100644 --- a/luigi-service/pom.xml +++ b/luigi-service/pom.xml @@ -11,6 +11,15 @@ luigi-service + + com.bzgame.server + luigi-dao + 1.0-SNAPSHOT + + + com.bzgame.server + common + org.springframework.boot spring-boot-starter-web diff --git a/luigi-service/src/main/java/com/bzgame/server/luigi/service/bo/AuthorService.java b/luigi-service/src/main/java/com/bzgame/server/luigi/service/bo/AuthorService.java new file mode 100644 index 0000000..e57fdd1 --- /dev/null +++ b/luigi-service/src/main/java/com/bzgame/server/luigi/service/bo/AuthorService.java @@ -0,0 +1,42 @@ +package com.bzgame.server.luigi.service.bo; + +import com.bzgame.server.luigi.dao.domain.Author; +import com.bzgame.server.luigi.dao.domain.AuthorExample; +import com.bzgame.server.luigi.dao.mapper.AuthorMapper; +import com.bzgame.server.luigi.service.bo.response.CommonList; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author nidaren + */ +@Service +public class AuthorService { + @Resource + private AuthorMapper authorMapper; + + public Map getByIds(List ids) { + AuthorExample example = new AuthorExample(); + example.createCriteria().andIdIn(ids); + List list = authorMapper.selectByExample(example); + return list.stream().collect(Collectors.toMap(Author::getId, x -> x)); + } + + public Author getById(Integer id) { + return authorMapper.selectByPrimaryKey(id); + } + + public CommonList seek(String authorName) { + AuthorExample example = new AuthorExample(); + example.createCriteria().andNameLike(authorName + "%"); + List authors = authorMapper.selectByExample(example); + CommonList res = new CommonList<>(); + res.setTotal(authors.size()); + res.setList(authors); + return res; + } +} diff --git a/luigi-service/src/main/java/com/bzgame/server/luigi/service/bo/PoemService.java b/luigi-service/src/main/java/com/bzgame/server/luigi/service/bo/PoemService.java new file mode 100644 index 0000000..af619c2 --- /dev/null +++ b/luigi-service/src/main/java/com/bzgame/server/luigi/service/bo/PoemService.java @@ -0,0 +1,83 @@ +package com.bzgame.server.luigi.service.bo; + +import com.bczgame.server.common.exception.BizException; +import com.bczgame.server.common.exception.ExceptionCode; +import com.bzgame.server.luigi.dao.domain.Author; +import com.bzgame.server.luigi.dao.domain.Poem; +import com.bzgame.server.luigi.dao.domain.PoemExample; +import com.bzgame.server.luigi.dao.mapper.PoemMapper; +import com.bzgame.server.luigi.service.bo.request.PoemQuery; +import com.bzgame.server.luigi.service.bo.response.CommonList; +import com.bzgame.server.luigi.service.bo.response.PoemBo; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author nidaren + */ +@Service +public class PoemService { + @Resource + private PoemMapper poemMapper; + + @Resource + private AuthorService authorService; + + public CommonList query(PoemQuery query) { + PoemExample example = new PoemExample(); + PoemExample.Criteria criteria = example.createCriteria(); + setQuery(query, criteria); + example.setOffset((query.getCurrent() - 1) * query.getPageSize()); + example.setLimit(query.getPageSize()); + List poems = poemMapper.selectByExampleWithBLOBs(example); + long total = poemMapper.countByExample(example); + CommonList res = new CommonList<>(); + res.setTotal((int) total); + res.setList(convert(poems)); + return res; + } + + public PoemBo detail(Integer id) { + Poem p = poemMapper.selectByPrimaryKey(id); + Author a = authorService.getById(p.getAuthorId()); + PoemBo bo = new PoemBo(p); + bo.setAuthorName(a.getName()); + return bo; + } + + private List convert(List poems) { + List authorIds = poems.stream().map(Poem::getAuthorId).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(authorIds)) { + return poems.stream().map(PoemBo::new).collect(Collectors.toList()); + } + Map aMap = authorService.getByIds(authorIds); + return poems.stream().map(x -> { + PoemBo bo = new PoemBo(x); + bo.setAuthorName(aMap.get(x.getAuthorId()).getName()); + return bo; + }).collect(Collectors.toList()); + } + + private void setQuery(PoemQuery query, PoemExample.Criteria criteria) { + if (CollectionUtils.isEmpty(query.getQuery())) { + return; + } + query.getQuery().forEach(x -> { + switch (x.getKey()) { + case "authorId": + criteria.andAuthorIdEqualTo(Integer.valueOf(x.getVal())); + break; + case "status": + criteria.andStatusEqualTo(Integer.valueOf(x.getVal())); + break; + default: + throw new BizException(ExceptionCode.PARAM_ILLEGAL_WARN, "参数非法"); + } + }); + } +} diff --git a/luigi-service/src/main/java/com/bzgame/server/luigi/service/bo/request/PoemQuery.java b/luigi-service/src/main/java/com/bzgame/server/luigi/service/bo/request/PoemQuery.java new file mode 100644 index 0000000..d012848 --- /dev/null +++ b/luigi-service/src/main/java/com/bzgame/server/luigi/service/bo/request/PoemQuery.java @@ -0,0 +1,57 @@ +package com.bzgame.server.luigi.service.bo.request; + +import java.util.List; + +/** + * @author nidaren + */ +public class PoemQuery { + private List query; + private int pageSize; + private int current; + + public static class QueryParam { + private String key; + private String val; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getVal() { + return val; + } + + public void setVal(String val) { + this.val = val; + } + } + + public List getQuery() { + return query; + } + + public void setQuery(List query) { + this.query = query; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getCurrent() { + return current; + } + + public void setCurrent(int current) { + this.current = current; + } +} diff --git a/luigi-service/src/main/java/com/bzgame/server/luigi/service/bo/response/CommonList.java b/luigi-service/src/main/java/com/bzgame/server/luigi/service/bo/response/CommonList.java new file mode 100644 index 0000000..3d2384a --- /dev/null +++ b/luigi-service/src/main/java/com/bzgame/server/luigi/service/bo/response/CommonList.java @@ -0,0 +1,45 @@ +package com.bzgame.server.luigi.service.bo.response; + +import java.util.List; + +/** + * @author nidaren + */ +public class CommonList { + private List list; + private Integer total; + private Integer pageSize; + private Integer current; + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + public Integer getTotal() { + return total; + } + + public void setTotal(Integer total) { + this.total = total; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public Integer getCurrent() { + return current; + } + + public void setCurrent(Integer current) { + this.current = current; + } +} diff --git a/luigi-service/src/main/java/com/bzgame/server/luigi/service/bo/response/PoemBo.java b/luigi-service/src/main/java/com/bzgame/server/luigi/service/bo/response/PoemBo.java new file mode 100644 index 0000000..148979f --- /dev/null +++ b/luigi-service/src/main/java/com/bzgame/server/luigi/service/bo/response/PoemBo.java @@ -0,0 +1,26 @@ +package com.bzgame.server.luigi.service.bo.response; + +import com.bzgame.server.luigi.dao.domain.Poem; +import org.springframework.beans.BeanUtils; + +/** + * @author nidaren + */ +public class PoemBo extends Poem { + private String authorName; + + public PoemBo() { + } + + public PoemBo(Poem p) { + BeanUtils.copyProperties(p, this); + } + + public String getAuthorName() { + return authorName; + } + + public void setAuthorName(String authorName) { + this.authorName = authorName; + } +} diff --git a/luigi-service/src/main/java/com/bzgame/server/luigi/service/bo/response/UserBo.java b/luigi-service/src/main/java/com/bzgame/server/luigi/service/bo/response/UserBo.java new file mode 100644 index 0000000..b6f7393 --- /dev/null +++ b/luigi-service/src/main/java/com/bzgame/server/luigi/service/bo/response/UserBo.java @@ -0,0 +1,53 @@ +package com.bzgame.server.luigi.service.bo.response; + +/** + * @author nidaren + */ +public class UserBo { + private Integer id; + private String name; + private String avatar; + private String role; + + public UserBo() { + } + + public UserBo(Integer id, String name, String avatar, String role) { + this.id = id; + this.name = name; + this.avatar = avatar; + this.role = role; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAvatar() { + return avatar; + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } +} diff --git a/pom.xml b/pom.xml index 86394b6..52b725d 100644 --- a/pom.xml +++ b/pom.xml @@ -84,6 +84,13 @@ jedis 2.9.0 + + + + io.springfox + springfox-boot-starter + 3.0.0 +