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 index e96b5f8..2f91fda 100644 --- 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 @@ -3,19 +3,14 @@ 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.AuthorService; import com.bzgame.server.luigi.service.bo.request.PaginationQuery; import com.bzgame.server.luigi.service.bo.response.CommonList; -import com.bzgame.server.luigi.service.bo.response.PoemBo; import io.swagger.annotations.Api; import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; /** * @author nidaren @@ -29,7 +24,7 @@ public class AuthorController { @GetMapping("/seek") @ApiFlag - public Response> seek(@RequestParam String name) { + public Response> seekAuthor(@RequestParam String name) { if (StringUtils.isEmpty(name)) { return new Response<>(new CommonList<>(), "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 index a5abddc..eb361f2 100644 --- 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 @@ -2,11 +2,12 @@ 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.PoemService; import com.bzgame.server.luigi.service.bo.request.PaginationQuery; import com.bzgame.server.luigi.service.bo.response.CommonList; import com.bzgame.server.luigi.service.bo.response.PoemBo; import io.swagger.annotations.Api; +import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -27,6 +28,15 @@ public class PoemController { return new Response<>(poemService.query(query), "ok", Response.CODE_SUCCESS); } + @GetMapping("/seek") + @ApiFlag + public Response> seekPoem(@RequestParam String title) { + if (StringUtils.isEmpty(title)) { + return new Response<>(new CommonList<>(), "ok", Response.CODE_SUCCESS); + } + return new Response<>(poemService.seek(title), "ok", Response.CODE_SUCCESS); + } + @GetMapping("/detail") @ApiFlag public Response poemDetail(@RequestParam Integer id) { diff --git a/luigi-api/src/main/java/com/bzgame/server/luigi/api/rest/VerseController.java b/luigi-api/src/main/java/com/bzgame/server/luigi/api/rest/VerseController.java new file mode 100644 index 0000000..a3308e6 --- /dev/null +++ b/luigi-api/src/main/java/com/bzgame/server/luigi/api/rest/VerseController.java @@ -0,0 +1,42 @@ +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.Verse; +import com.bzgame.server.luigi.service.VerseService; +import com.bzgame.server.luigi.service.bo.request.PaginationQuery; +import com.bzgame.server.luigi.service.bo.response.CommonList; +import io.swagger.annotations.Api; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +/** + * @author nidaren + */ +@RestController +@RequestMapping("/api/luigi/verse") +@Api(tags = "verse") +public class VerseController { + @Resource + private VerseService verseService; + + @GetMapping("/get") + @ApiFlag + public Response getVerseById(@RequestParam Integer id) { + return new Response<>(verseService.detail(id), "ok", Response.CODE_SUCCESS); + } + + @PostMapping("/list") + @ApiFlag + public Response> verseList(@RequestBody PaginationQuery query) { + return new Response<>(verseService.list(query), "ok", Response.CODE_SUCCESS); + } + + @PostMapping("/save") + @ApiFlag + public Response saveVerse(@RequestBody Verse verse) { + return new Response<>(verseService.save(verse), "ok", 1); + } + +} diff --git a/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/domain/Verse.java b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/domain/Verse.java new file mode 100644 index 0000000..2a0fcaa --- /dev/null +++ b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/domain/Verse.java @@ -0,0 +1,336 @@ +package com.bzgame.server.luigi.dao.domain; + +import java.io.Serializable; + +public class Verse implements Serializable { + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column verse.id + * + * @mbg.generated + */ + private Integer id; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column verse.title + * + * @mbg.generated + */ + private String title; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column verse.content + * + * @mbg.generated + */ + private String content; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column verse.author_id + * + * @mbg.generated + */ + private Integer authorId; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column verse.author_name + * + * @mbg.generated + */ + private String authorName; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column verse.type + * + * @mbg.generated + */ + private Byte type; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column verse.origin_id + * + * @mbg.generated + */ + private Integer originId; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column verse.chapter_id + * + * @mbg.generated + */ + private Integer chapterId; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column verse.status + * + * @mbg.generated + */ + private Integer status; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table verse + * + * @mbg.generated + */ + private static final long serialVersionUID = 1L; + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column verse.id + * + * @return the value of verse.id + * + * @mbg.generated + */ + public Integer getId() { + return id; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column verse.id + * + * @param id the value for verse.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 verse.title + * + * @return the value of verse.title + * + * @mbg.generated + */ + public String getTitle() { + return title; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column verse.title + * + * @param title the value for verse.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 verse.content + * + * @return the value of verse.content + * + * @mbg.generated + */ + public String getContent() { + return content; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column verse.content + * + * @param content the value for verse.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 verse.author_id + * + * @return the value of verse.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 verse.author_id + * + * @param authorId the value for verse.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 verse.author_name + * + * @return the value of verse.author_name + * + * @mbg.generated + */ + public String getAuthorName() { + return authorName; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column verse.author_name + * + * @param authorName the value for verse.author_name + * + * @mbg.generated + */ + public void setAuthorName(String authorName) { + this.authorName = authorName == null ? null : authorName.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column verse.type + * + * @return the value of verse.type + * + * @mbg.generated + */ + public Byte getType() { + return type; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column verse.type + * + * @param type the value for verse.type + * + * @mbg.generated + */ + public void setType(Byte type) { + this.type = type; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column verse.origin_id + * + * @return the value of verse.origin_id + * + * @mbg.generated + */ + public Integer getOriginId() { + return originId; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column verse.origin_id + * + * @param originId the value for verse.origin_id + * + * @mbg.generated + */ + public void setOriginId(Integer originId) { + this.originId = originId; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column verse.chapter_id + * + * @return the value of verse.chapter_id + * + * @mbg.generated + */ + public Integer getChapterId() { + return chapterId; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column verse.chapter_id + * + * @param chapterId the value for verse.chapter_id + * + * @mbg.generated + */ + public void setChapterId(Integer chapterId) { + this.chapterId = chapterId; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column verse.status + * + * @return the value of verse.status + * + * @mbg.generated + */ + public Integer getStatus() { + return status; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column verse.status + * + * @param status the value for verse.status + * + * @mbg.generated + */ + public void setStatus(Integer status) { + this.status = status; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table verse + * + * @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(", title=").append(title); + sb.append(", content=").append(content); + sb.append(", authorId=").append(authorId); + sb.append(", authorName=").append(authorName); + sb.append(", type=").append(type); + sb.append(", originId=").append(originId); + sb.append(", chapterId=").append(chapterId); + sb.append(", status=").append(status); + 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/VerseExample.java b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/domain/VerseExample.java new file mode 100644 index 0000000..a0e1cc3 --- /dev/null +++ b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/domain/VerseExample.java @@ -0,0 +1,892 @@ +package com.bzgame.server.luigi.dao.domain; + +import java.util.ArrayList; +import java.util.List; + +public class VerseExample { + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table verse + * + * @mbg.generated + */ + protected String orderByClause; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table verse + * + * @mbg.generated + */ + protected boolean distinct; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table verse + * + * @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 verse + * + * @mbg.generated + */ + public VerseExample() { + oredCriteria = new ArrayList(); + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table verse + * + * @mbg.generated + */ + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table verse + * + * @mbg.generated + */ + public String getOrderByClause() { + return orderByClause; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table verse + * + * @mbg.generated + */ + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table verse + * + * @mbg.generated + */ + public boolean isDistinct() { + return distinct; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table verse + * + * @mbg.generated + */ + public List getOredCriteria() { + return oredCriteria; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table verse + * + * @mbg.generated + */ + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table verse + * + * @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 verse + * + * @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 verse + * + * @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 verse + * + * @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 verse + * + * @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 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 andContentIsNull() { + addCriterion("content is null"); + return (Criteria) this; + } + + public Criteria andContentIsNotNull() { + addCriterion("content is not null"); + return (Criteria) this; + } + + public Criteria andContentEqualTo(String value) { + addCriterion("content =", value, "content"); + return (Criteria) this; + } + + public Criteria andContentNotEqualTo(String value) { + addCriterion("content <>", value, "content"); + return (Criteria) this; + } + + public Criteria andContentGreaterThan(String value) { + addCriterion("content >", value, "content"); + return (Criteria) this; + } + + public Criteria andContentGreaterThanOrEqualTo(String value) { + addCriterion("content >=", value, "content"); + return (Criteria) this; + } + + public Criteria andContentLessThan(String value) { + addCriterion("content <", value, "content"); + return (Criteria) this; + } + + public Criteria andContentLessThanOrEqualTo(String value) { + addCriterion("content <=", value, "content"); + return (Criteria) this; + } + + public Criteria andContentLike(String value) { + addCriterion("content like", value, "content"); + return (Criteria) this; + } + + public Criteria andContentNotLike(String value) { + addCriterion("content not like", value, "content"); + return (Criteria) this; + } + + public Criteria andContentIn(List values) { + addCriterion("content in", values, "content"); + return (Criteria) this; + } + + public Criteria andContentNotIn(List values) { + addCriterion("content not in", values, "content"); + return (Criteria) this; + } + + public Criteria andContentBetween(String value1, String value2) { + addCriterion("content between", value1, value2, "content"); + return (Criteria) this; + } + + public Criteria andContentNotBetween(String value1, String value2) { + addCriterion("content not between", value1, value2, "content"); + 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 andAuthorNameIsNull() { + addCriterion("author_name is null"); + return (Criteria) this; + } + + public Criteria andAuthorNameIsNotNull() { + addCriterion("author_name is not null"); + return (Criteria) this; + } + + public Criteria andAuthorNameEqualTo(String value) { + addCriterion("author_name =", value, "authorName"); + return (Criteria) this; + } + + public Criteria andAuthorNameNotEqualTo(String value) { + addCriterion("author_name <>", value, "authorName"); + return (Criteria) this; + } + + public Criteria andAuthorNameGreaterThan(String value) { + addCriterion("author_name >", value, "authorName"); + return (Criteria) this; + } + + public Criteria andAuthorNameGreaterThanOrEqualTo(String value) { + addCriterion("author_name >=", value, "authorName"); + return (Criteria) this; + } + + public Criteria andAuthorNameLessThan(String value) { + addCriterion("author_name <", value, "authorName"); + return (Criteria) this; + } + + public Criteria andAuthorNameLessThanOrEqualTo(String value) { + addCriterion("author_name <=", value, "authorName"); + return (Criteria) this; + } + + public Criteria andAuthorNameLike(String value) { + addCriterion("author_name like", value, "authorName"); + return (Criteria) this; + } + + public Criteria andAuthorNameNotLike(String value) { + addCriterion("author_name not like", value, "authorName"); + return (Criteria) this; + } + + public Criteria andAuthorNameIn(List values) { + addCriterion("author_name in", values, "authorName"); + return (Criteria) this; + } + + public Criteria andAuthorNameNotIn(List values) { + addCriterion("author_name not in", values, "authorName"); + return (Criteria) this; + } + + public Criteria andAuthorNameBetween(String value1, String value2) { + addCriterion("author_name between", value1, value2, "authorName"); + return (Criteria) this; + } + + public Criteria andAuthorNameNotBetween(String value1, String value2) { + addCriterion("author_name not between", value1, value2, "authorName"); + return (Criteria) this; + } + + public Criteria andTypeIsNull() { + addCriterion("`type` is null"); + return (Criteria) this; + } + + public Criteria andTypeIsNotNull() { + addCriterion("`type` is not null"); + return (Criteria) this; + } + + public Criteria andTypeEqualTo(Byte value) { + addCriterion("`type` =", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotEqualTo(Byte value) { + addCriterion("`type` <>", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThan(Byte value) { + addCriterion("`type` >", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThanOrEqualTo(Byte value) { + addCriterion("`type` >=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThan(Byte value) { + addCriterion("`type` <", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThanOrEqualTo(Byte value) { + addCriterion("`type` <=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeIn(List values) { + addCriterion("`type` in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotIn(List values) { + addCriterion("`type` not in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeBetween(Byte value1, Byte value2) { + addCriterion("`type` between", value1, value2, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotBetween(Byte value1, Byte value2) { + addCriterion("`type` not between", value1, value2, "type"); + return (Criteria) this; + } + + public Criteria andOriginIdIsNull() { + addCriterion("origin_id is null"); + return (Criteria) this; + } + + public Criteria andOriginIdIsNotNull() { + addCriterion("origin_id is not null"); + return (Criteria) this; + } + + public Criteria andOriginIdEqualTo(Integer value) { + addCriterion("origin_id =", value, "originId"); + return (Criteria) this; + } + + public Criteria andOriginIdNotEqualTo(Integer value) { + addCriterion("origin_id <>", value, "originId"); + return (Criteria) this; + } + + public Criteria andOriginIdGreaterThan(Integer value) { + addCriterion("origin_id >", value, "originId"); + return (Criteria) this; + } + + public Criteria andOriginIdGreaterThanOrEqualTo(Integer value) { + addCriterion("origin_id >=", value, "originId"); + return (Criteria) this; + } + + public Criteria andOriginIdLessThan(Integer value) { + addCriterion("origin_id <", value, "originId"); + return (Criteria) this; + } + + public Criteria andOriginIdLessThanOrEqualTo(Integer value) { + addCriterion("origin_id <=", value, "originId"); + return (Criteria) this; + } + + public Criteria andOriginIdIn(List values) { + addCriterion("origin_id in", values, "originId"); + return (Criteria) this; + } + + public Criteria andOriginIdNotIn(List values) { + addCriterion("origin_id not in", values, "originId"); + return (Criteria) this; + } + + public Criteria andOriginIdBetween(Integer value1, Integer value2) { + addCriterion("origin_id between", value1, value2, "originId"); + return (Criteria) this; + } + + public Criteria andOriginIdNotBetween(Integer value1, Integer value2) { + addCriterion("origin_id not between", value1, value2, "originId"); + return (Criteria) this; + } + + public Criteria andChapterIdIsNull() { + addCriterion("chapter_id is null"); + return (Criteria) this; + } + + public Criteria andChapterIdIsNotNull() { + addCriterion("chapter_id is not null"); + return (Criteria) this; + } + + public Criteria andChapterIdEqualTo(Integer value) { + addCriterion("chapter_id =", value, "chapterId"); + return (Criteria) this; + } + + public Criteria andChapterIdNotEqualTo(Integer value) { + addCriterion("chapter_id <>", value, "chapterId"); + return (Criteria) this; + } + + public Criteria andChapterIdGreaterThan(Integer value) { + addCriterion("chapter_id >", value, "chapterId"); + return (Criteria) this; + } + + public Criteria andChapterIdGreaterThanOrEqualTo(Integer value) { + addCriterion("chapter_id >=", value, "chapterId"); + return (Criteria) this; + } + + public Criteria andChapterIdLessThan(Integer value) { + addCriterion("chapter_id <", value, "chapterId"); + return (Criteria) this; + } + + public Criteria andChapterIdLessThanOrEqualTo(Integer value) { + addCriterion("chapter_id <=", value, "chapterId"); + return (Criteria) this; + } + + public Criteria andChapterIdIn(List values) { + addCriterion("chapter_id in", values, "chapterId"); + return (Criteria) this; + } + + public Criteria andChapterIdNotIn(List values) { + addCriterion("chapter_id not in", values, "chapterId"); + return (Criteria) this; + } + + public Criteria andChapterIdBetween(Integer value1, Integer value2) { + addCriterion("chapter_id between", value1, value2, "chapterId"); + return (Criteria) this; + } + + public Criteria andChapterIdNotBetween(Integer value1, Integer value2) { + addCriterion("chapter_id not between", value1, value2, "chapterId"); + 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 verse + * + * @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 verse + * + * @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/VerseMapper.java b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/mapper/VerseMapper.java new file mode 100644 index 0000000..d4f98b6 --- /dev/null +++ b/luigi-dao/src/main/java/com/bzgame/server/luigi/dao/mapper/VerseMapper.java @@ -0,0 +1,96 @@ +package com.bzgame.server.luigi.dao.mapper; + +import com.bzgame.server.luigi.dao.domain.Verse; +import com.bzgame.server.luigi.dao.domain.VerseExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface VerseMapper { + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table verse + * + * @mbg.generated + */ + long countByExample(VerseExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table verse + * + * @mbg.generated + */ + int deleteByExample(VerseExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table verse + * + * @mbg.generated + */ + int deleteByPrimaryKey(Integer id); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table verse + * + * @mbg.generated + */ + int insert(Verse record); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table verse + * + * @mbg.generated + */ + int insertSelective(Verse record); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table verse + * + * @mbg.generated + */ + List selectByExample(VerseExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table verse + * + * @mbg.generated + */ + Verse selectByPrimaryKey(Integer id); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table verse + * + * @mbg.generated + */ + int updateByExampleSelective(@Param("record") Verse record, @Param("example") VerseExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table verse + * + * @mbg.generated + */ + int updateByExample(@Param("record") Verse record, @Param("example") VerseExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table verse + * + * @mbg.generated + */ + int updateByPrimaryKeySelective(Verse record); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table verse + * + * @mbg.generated + */ + int updateByPrimaryKey(Verse record); +} \ No newline at end of file diff --git a/luigi-dao/src/main/resources/mapper/VerseMapper.xml b/luigi-dao/src/main/resources/mapper/VerseMapper.xml new file mode 100644 index 0000000..c956761 --- /dev/null +++ b/luigi-dao/src/main/resources/mapper/VerseMapper.xml @@ -0,0 +1,342 @@ + + + + + + + + + + + + + + + + + + + + + + + + + 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, title, content, author_id, author_name, `type`, origin_id, chapter_id, `status` + + + + + + delete from verse + where id = #{id,jdbcType=INTEGER} + + + + delete from verse + + + + + + + + SELECT LAST_INSERT_ID() + + insert into verse (title, content, author_id, + author_name, `type`, origin_id, + chapter_id, `status`) + values (#{title,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, #{authorId,jdbcType=INTEGER}, + #{authorName,jdbcType=VARCHAR}, #{type,jdbcType=TINYINT}, #{originId,jdbcType=INTEGER}, + #{chapterId,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}) + + + + + SELECT LAST_INSERT_ID() + + insert into verse + + + title, + + + content, + + + author_id, + + + author_name, + + + `type`, + + + origin_id, + + + chapter_id, + + + `status`, + + + + + #{title,jdbcType=VARCHAR}, + + + #{content,jdbcType=VARCHAR}, + + + #{authorId,jdbcType=INTEGER}, + + + #{authorName,jdbcType=VARCHAR}, + + + #{type,jdbcType=TINYINT}, + + + #{originId,jdbcType=INTEGER}, + + + #{chapterId,jdbcType=INTEGER}, + + + #{status,jdbcType=INTEGER}, + + + + + + + update verse + + + id = #{record.id,jdbcType=INTEGER}, + + + title = #{record.title,jdbcType=VARCHAR}, + + + content = #{record.content,jdbcType=VARCHAR}, + + + author_id = #{record.authorId,jdbcType=INTEGER}, + + + author_name = #{record.authorName,jdbcType=VARCHAR}, + + + `type` = #{record.type,jdbcType=TINYINT}, + + + origin_id = #{record.originId,jdbcType=INTEGER}, + + + chapter_id = #{record.chapterId,jdbcType=INTEGER}, + + + `status` = #{record.status,jdbcType=INTEGER}, + + + + + + + + + update verse + set id = #{record.id,jdbcType=INTEGER}, + title = #{record.title,jdbcType=VARCHAR}, + content = #{record.content,jdbcType=VARCHAR}, + author_id = #{record.authorId,jdbcType=INTEGER}, + author_name = #{record.authorName,jdbcType=VARCHAR}, + `type` = #{record.type,jdbcType=TINYINT}, + origin_id = #{record.originId,jdbcType=INTEGER}, + chapter_id = #{record.chapterId,jdbcType=INTEGER}, + `status` = #{record.status,jdbcType=INTEGER} + + + + + + + update verse + + + title = #{title,jdbcType=VARCHAR}, + + + content = #{content,jdbcType=VARCHAR}, + + + author_id = #{authorId,jdbcType=INTEGER}, + + + author_name = #{authorName,jdbcType=VARCHAR}, + + + `type` = #{type,jdbcType=TINYINT}, + + + origin_id = #{originId,jdbcType=INTEGER}, + + + chapter_id = #{chapterId,jdbcType=INTEGER}, + + + `status` = #{status,jdbcType=INTEGER}, + + + where id = #{id,jdbcType=INTEGER} + + + + update verse + set title = #{title,jdbcType=VARCHAR}, + content = #{content,jdbcType=VARCHAR}, + author_id = #{authorId,jdbcType=INTEGER}, + author_name = #{authorName,jdbcType=VARCHAR}, + `type` = #{type,jdbcType=TINYINT}, + origin_id = #{originId,jdbcType=INTEGER}, + chapter_id = #{chapterId,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/mybatis-generator/generatorConfig.xml b/luigi-dao/src/main/resources/mybatis-generator/generatorConfig.xml index 55b1486..008a2bc 100644 --- a/luigi-dao/src/main/resources/mybatis-generator/generatorConfig.xml +++ b/luigi-dao/src/main/resources/mybatis-generator/generatorConfig.xml @@ -45,7 +45,7 @@ - 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/AuthorService.java similarity index 98% rename from luigi-service/src/main/java/com/bzgame/server/luigi/service/bo/AuthorService.java rename to luigi-service/src/main/java/com/bzgame/server/luigi/service/AuthorService.java index 5fa21ca..6d981dc 100644 --- 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/AuthorService.java @@ -1,4 +1,4 @@ -package com.bzgame.server.luigi.service.bo; +package com.bzgame.server.luigi.service; import com.bczgame.server.common.exception.BizException; import com.bczgame.server.common.exception.ExceptionCode; 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/PoemService.java similarity index 91% rename from luigi-service/src/main/java/com/bzgame/server/luigi/service/bo/PoemService.java rename to luigi-service/src/main/java/com/bzgame/server/luigi/service/PoemService.java index 6e12aef..d334f46 100644 --- 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/PoemService.java @@ -1,4 +1,4 @@ -package com.bzgame.server.luigi.service.bo; +package com.bzgame.server.luigi.service; import com.bczgame.server.common.exception.BizException; import com.bczgame.server.common.exception.ExceptionCode; @@ -49,6 +49,17 @@ public class PoemService { return res; } + + public CommonList seek(String title) { + PoemExample example = new PoemExample(); + example.createCriteria().andTitleLike(title + "%"); + List poems = poemMapper.selectByExample(example); + CommonList res = new CommonList<>(); + res.setTotal(poems.size()); + res.setList(convert(poems)); + return res; + } + public PoemBo detail(Integer id) { Poem p = poemMapper.selectByPrimaryKey(id); Author a = authorService.getById(p.getAuthorId()); diff --git a/luigi-service/src/main/java/com/bzgame/server/luigi/service/VerseService.java b/luigi-service/src/main/java/com/bzgame/server/luigi/service/VerseService.java new file mode 100644 index 0000000..fa640c4 --- /dev/null +++ b/luigi-service/src/main/java/com/bzgame/server/luigi/service/VerseService.java @@ -0,0 +1,88 @@ +package com.bzgame.server.luigi.service; + +import com.bczgame.server.common.exception.BizException; +import com.bczgame.server.common.exception.ExceptionCode; +import com.bzgame.server.luigi.dao.domain.*; +import com.bzgame.server.luigi.dao.mapper.VerseMapper; +import com.bzgame.server.luigi.service.bo.request.PaginationQuery; +import com.bzgame.server.luigi.service.bo.response.CommonList; +import com.bzgame.server.luigi.service.bo.response.PoemBo; +import com.bzgame.server.luigi.service.constant.DetailTypeEnum; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @author nidaren + */ +@Service +public class VerseService { + + @Resource + private VerseMapper verseMapper; + + @Resource + private PoemService poemService; + + public CommonList list(PaginationQuery query) { + VerseExample example = new VerseExample(); + VerseExample.Criteria criteria = example.createCriteria(); + setQuery(query, criteria); + example.setOffset((query.getCurrent() - 1) * query.getPageSize()); + example.setLimit(query.getPageSize()); + List verses = verseMapper.selectByExample(example); + long total = verseMapper.countByExample(example); + CommonList res = new CommonList<>(); + res.setTotal((int) total); + res.setList(verses); + return res; + } + + public Verse detail(Integer id) { + return verseMapper.selectByPrimaryKey(id); + } + + public Integer save(Verse v) { + if (v.getOriginId() != null) { + PoemBo poemBo = poemService.detail(v.getOriginId()); + v.setAuthorName(poemBo.getAuthorName()); + v.setAuthorId(poemBo.getAuthorId()); + v.setTitle(poemBo.getTitle()); + v.setType(DetailTypeEnum.POEM.getType().byteValue()); + } + if (v.getId() != null) { + verseMapper.updateByPrimaryKeySelective(v); + } else { + verseMapper.insertSelective(v); + } + return v.getId(); + } + + private void setQuery(PaginationQuery query, VerseExample.Criteria criteria) { + criteria.andStatusGreaterThanOrEqualTo(0); + + 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; + case "id": + criteria.andIdEqualTo(Integer.valueOf(x.getVal())); + break; + case "originId": + criteria.andOriginIdEqualTo(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/constant/DetailTypeEnum.java b/luigi-service/src/main/java/com/bzgame/server/luigi/service/constant/DetailTypeEnum.java new file mode 100644 index 0000000..6181a49 --- /dev/null +++ b/luigi-service/src/main/java/com/bzgame/server/luigi/service/constant/DetailTypeEnum.java @@ -0,0 +1,32 @@ +package com.bzgame.server.luigi.service.constant; + +import com.bczgame.server.common.exception.BizException; +import com.bczgame.server.common.exception.ExceptionCode; + +public enum DetailTypeEnum { + CREATION(1), + DIARY(2), + DISCUSS(3), + POEM(4), + BOOK(5); + + + private final Integer type; + + DetailTypeEnum(Integer type) { + this.type = type; + } + + public static DetailTypeEnum getByType(Integer type) { + for (DetailTypeEnum c : DetailTypeEnum.values()) { + if (c.type.equals(type)) { + return c; + } + } + throw new BizException(ExceptionCode.PARAM_ILLEGAL_WARN, "illegal type"); + } + + public Integer getType() { + return type; + } +}