diff --git a/.gitignore b/.gitignore index 7768ab4..a67cc18 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ target/ *.iws *.iml *.ipr +/.mvn/ ### NetBeans ### /nbproject/private/ @@ -29,4 +30,3 @@ build/ ### VS Code ### .vscode/ -/.mvn/ diff --git a/README.md b/README.md index f1d2b83..810561c 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,6 @@ forest 在很多方面受到了 [Symphony](https://github.com/88250/symphony) 注册 用户名 Email - 邀请链接 验证码 邮件验证 新手向导 @@ -74,9 +73,7 @@ forest 在很多方面受到了 [Symphony](https://github.com/88250/symphony) 默认“待分类” 发布后 可更新 - 历史版本 可删除 - Sandbox 机制 回帖 内容编辑器 本地存储 @@ -91,8 +88,6 @@ forest 在很多方面受到了 [Symphony](https://github.com/88250/symphony) 分享 微信 QQ - 微博 - Twitter 分享链接(带用户标识) 相关帖子 缩略摘要 @@ -107,7 +102,7 @@ forest 在很多方面受到了 [Symphony](https://github.com/88250/symphony) 创建者 贡献者 关注/引用/回帖数 - 所属领域 + 所属专题 关注 排序 默认(按发布时间降序) @@ -118,7 +113,6 @@ forest 在很多方面受到了 [Symphony](https://github.com/88250/symphony) 实时热度 最新回复 回帖数 - 是否查浏览过该帖(前端样式) 创建时间 后台管理 后台首页 @@ -128,10 +122,9 @@ forest 在很多方面受到了 [Symphony](https://github.com/88250/symphony) 最高在线 会员 帖子 - 领域 + 专题 标签 回帖 - 版本检查 用户管理 按用户名/邮件搜索 添加新用户 @@ -145,11 +138,6 @@ forest 在很多方面受到了 [Symphony](https://github.com/88250/symphony) 高级更新 用户名 邮箱地址 - 积分充值 - 积分提现 - 活动积分奖励 - 违规积分扣除 - 补偿初始化积分 帖子管理 按 id 搜索帖子 重建所有帖子搜索索引 @@ -157,10 +145,10 @@ forest 在很多方面受到了 [Symphony](https://github.com/88250/symphony) 帖子数据维护 锁定帖子 删除帖子 - 领域管理 - 按名称搜索领域 - 添加领域 - 领域数据维护 + 专题管理 + 按名称搜索专题 + 添加专题 + 专题数据维护 添加/移除相关标签 名称 URI @@ -173,7 +161,7 @@ forest 在很多方面受到了 [Symphony](https://github.com/88250/symphony) title keywords description - 删除领域 + 删除专题 标签管理 按名称搜索标签 添加标签 @@ -231,13 +219,9 @@ forest 在很多方面受到了 [Symphony](https://github.com/88250/symphony) 专题、发帖、通知、个人等入口 专题导航列表 对搜索引擎爬虫友好 -邮件 - 邮件服务 - 本地 JavaMail 用户设置 基本信息 昵称 - 自我标签 URL 个性签名 个人主页背景图 @@ -253,11 +237,8 @@ forest 在很多方面受到了 [Symphony](https://github.com/88250/symphony) 更新密码 更新用户名 永久停用账号 - 邀请 - 邀请链接 - 兑换邀请码 钱包 - 转账记录 + 交易记录 帮助 使用入门 基础知识 diff --git a/src/main/java/com/rymcu/forest/answer/AnswerController.java b/src/main/java/com/rymcu/forest/answer/AnswerController.java new file mode 100644 index 0000000..0ebfd5c --- /dev/null +++ b/src/main/java/com/rymcu/forest/answer/AnswerController.java @@ -0,0 +1,48 @@ +package com.rymcu.forest.answer; + +import com.alibaba.fastjson.JSONObject; +import com.rymcu.forest.core.result.GlobalResult; +import com.rymcu.forest.core.result.GlobalResultGenerator; +import com.rymcu.forest.dto.AnswerDTO; +import com.rymcu.forest.entity.User; +import com.rymcu.forest.util.HttpUtils; +import com.rymcu.forest.util.UserUtils; +import com.rymcu.forest.web.api.exception.BaseApiException; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author ronger + */ +@RestController +@RequestMapping("/api/v1/answer") +public class AnswerController { + + private final static String ANSWER_API_URL = "http://101.132.237.86:8089/question"; + + @GetMapping("/today") + public GlobalResult today() throws BaseApiException { + User user = UserUtils.getCurrentUserByToken(); + String result = HttpUtils.sendGet(ANSWER_API_URL + "/record/" + user.getIdUser() ); + return JSONObject.parseObject(result, GlobalResult.class); + } + + @PostMapping("/answer") + public GlobalResult answer(@RequestBody AnswerDTO answerDTO) throws BaseApiException { + User user = UserUtils.getCurrentUserByToken(); + Map params = new HashMap<>(3); + params.put("userId", user.getIdUser()); + params.put("answer", answerDTO.getAnswer()); + params.put("subjectQuestionId", answerDTO.getIdSubjectQuestion()); + String result = HttpUtils.sendPost(ANSWER_API_URL + "/answer/everyday", params); + return JSONObject.parseObject(result, GlobalResult.class); + } + + @GetMapping("/get-answer") + public GlobalResult getAnswer(Integer idSubjectQuestion) { + String result = HttpUtils.sendGet(ANSWER_API_URL + "/show-answer/" + idSubjectQuestion ); + return JSONObject.parseObject(result, GlobalResult.class); + } +} diff --git a/src/main/java/com/rymcu/forest/config/WebMvcConfigurer.java b/src/main/java/com/rymcu/forest/config/WebMvcConfigurer.java index f671a9a..d4a46c4 100644 --- a/src/main/java/com/rymcu/forest/config/WebMvcConfigurer.java +++ b/src/main/java/com/rymcu/forest/config/WebMvcConfigurer.java @@ -71,7 +71,7 @@ public class WebMvcConfigurer extends WebMvcConfigurationSupport { public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(restAuthTokenInterceptor()).addPathPatterns("/api/**") .excludePathPatterns("/api/v1/console/**", "/api/v1/article/articles/**", "/api/v1/article/detail/**" - , "/api/v1/topic/**", "/api/v1/user/**", "/api/v1/article/*/comments"); + , "/api/v1/topic/**", "/api/v1/user/**", "/api/v1/article/*/comments", "/api/v1/rule/currency/**"); } diff --git a/src/main/java/com/rymcu/forest/dto/AnswerDTO.java b/src/main/java/com/rymcu/forest/dto/AnswerDTO.java new file mode 100644 index 0000000..7c9a208 --- /dev/null +++ b/src/main/java/com/rymcu/forest/dto/AnswerDTO.java @@ -0,0 +1,17 @@ +package com.rymcu.forest.dto; + +import lombok.Data; + +/** + * @author ronger + */ +@Data +public class AnswerDTO { + + private Integer idSubjectQuestion; + + private String answer; + + private Integer idUser; + +} diff --git a/src/main/java/com/rymcu/forest/dto/ArticleDTO.java b/src/main/java/com/rymcu/forest/dto/ArticleDTO.java index 0950118..43a84b4 100644 --- a/src/main/java/com/rymcu/forest/dto/ArticleDTO.java +++ b/src/main/java/com/rymcu/forest/dto/ArticleDTO.java @@ -53,4 +53,10 @@ public class ArticleDTO { private List portfolios; private Integer sortNo; + /** 0:非优选1:优选;0 */ + private String articlePerfect; + /** 点赞总数 */ + private Integer articleThumbsUpCount; + /** 赞赏总数 */ + private Integer articleSponsorCount; } diff --git a/src/main/java/com/rymcu/forest/dto/BankAccountDTO.java b/src/main/java/com/rymcu/forest/dto/BankAccountDTO.java new file mode 100644 index 0000000..6707d5e --- /dev/null +++ b/src/main/java/com/rymcu/forest/dto/BankAccountDTO.java @@ -0,0 +1,35 @@ +package com.rymcu.forest.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * @author ronger + */ +@Data +public class BankAccountDTO { + + private Integer idBankAccount; + /** 所属银行 */ + private Integer idBank; + /** 所属银行名称 */ + private String bankName; + /** 银行账户 */ + private String bankAccount; + /** 账户余额 */ + private BigDecimal accountBalance; + /** 账户所有者 */ + private Integer accountOwner; + /** 账户所有者姓名 */ + private String accountOwnerName; + /** 创建时间 */ + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + private Date createdTime; + + private List transactionRecords; + +} diff --git a/src/main/java/com/rymcu/forest/dto/BankAccountSearchDTO.java b/src/main/java/com/rymcu/forest/dto/BankAccountSearchDTO.java new file mode 100644 index 0000000..7cbd91d --- /dev/null +++ b/src/main/java/com/rymcu/forest/dto/BankAccountSearchDTO.java @@ -0,0 +1,17 @@ +package com.rymcu.forest.dto; + +import lombok.Data; + +/** + * @author ronger + */ +@Data +public class BankAccountSearchDTO { + /** 所属银行名称 */ + private String bankName; + /** 银行账户 */ + private String bankAccount; + /** 账户所有者姓名 */ + private String accountOwnerName; + +} diff --git a/src/main/java/com/rymcu/forest/dto/BankDTO.java b/src/main/java/com/rymcu/forest/dto/BankDTO.java new file mode 100644 index 0000000..166288c --- /dev/null +++ b/src/main/java/com/rymcu/forest/dto/BankDTO.java @@ -0,0 +1,33 @@ +package com.rymcu.forest.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author ronger + */ +@Data +public class BankDTO { + + private Integer idBank; + /** 银行名称 */ + private String bankName; + /** 银行负责人 */ + private Integer bankOwner; + /** 银行负责人 */ + private String bankOwnerName; + /** 银行账户 */ + private String bankAccount; + /** 账户余额 */ + private BigDecimal accountBalance; + /** 银行描述 */ + private String bankDescription; + /** 创建人 */ + private Integer createdBy; + /** 创建时间 */ + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + private Date createdTime; +} diff --git a/src/main/java/com/rymcu/forest/dto/SearchModel.java b/src/main/java/com/rymcu/forest/dto/SearchModel.java new file mode 100644 index 0000000..5a44e51 --- /dev/null +++ b/src/main/java/com/rymcu/forest/dto/SearchModel.java @@ -0,0 +1,17 @@ +package com.rymcu.forest.dto; + +import lombok.Data; + +/** + * @author ronger + */ +@Data +public class SearchModel { + + private String label; + + private String value; + + private String type; + +} diff --git a/src/main/java/com/rymcu/forest/dto/TransactionRecordDTO.java b/src/main/java/com/rymcu/forest/dto/TransactionRecordDTO.java new file mode 100644 index 0000000..14148d8 --- /dev/null +++ b/src/main/java/com/rymcu/forest/dto/TransactionRecordDTO.java @@ -0,0 +1,32 @@ +package com.rymcu.forest.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author ronger + */ +@Data +public class TransactionRecordDTO { + + private Integer idTransactionRecord; + /** 交易流水号 */ + private String transactionNo; + /** 款项 */ + private String funds; + /** 交易发起方 */ + private String formBankAccount; + /** 交易收款方 */ + private String toBankAccount; + /** 交易金额 */ + private BigDecimal money; + /** 交易类型 */ + private String transactionType; + /** 交易时间 */ + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + private Date transactionTime; + +} diff --git a/src/main/java/com/rymcu/forest/entity/Article.java b/src/main/java/com/rymcu/forest/entity/Article.java index 3fded31..a929ee3 100644 --- a/src/main/java/com/rymcu/forest/entity/Article.java +++ b/src/main/java/com/rymcu/forest/entity/Article.java @@ -13,7 +13,7 @@ import java.util.Date; * @author ronger */ @Data -@Table(name = "vertical_article") +@Table(name = "forest_article") public class Article implements Serializable,Cloneable { /** 主键 */ @Id @@ -36,7 +36,7 @@ public class Article implements Serializable,Cloneable { private String articlePreviewContent; /** 评论总数 */ private Integer articleCommentCount; - /** 0:非优选1:优选;0 */ + /** 0:非优选1:优选; */ private String articlePerfect; /** 文章永久链接 */ private String articlePermalink; @@ -48,4 +48,8 @@ public class Article implements Serializable,Cloneable { private Date updatedTime; /** 文章状态 */ private String articleStatus; + /** 点赞总数 */ + private Integer articleThumbsUpCount; + /** 赞赏总数 */ + private Integer articleSponsorCount; } diff --git a/src/main/java/com/rymcu/forest/entity/ArticleContent.java b/src/main/java/com/rymcu/forest/entity/ArticleContent.java index 26bf9d9..846b477 100644 --- a/src/main/java/com/rymcu/forest/entity/ArticleContent.java +++ b/src/main/java/com/rymcu/forest/entity/ArticleContent.java @@ -12,7 +12,7 @@ import java.util.Date; * @author ronger */ @Data -@Table(name = "vertical_article_content") +@Table(name = "forest_article_content") public class ArticleContent { @Id diff --git a/src/main/java/com/rymcu/forest/entity/ArticleThumbsUp.java b/src/main/java/com/rymcu/forest/entity/ArticleThumbsUp.java new file mode 100644 index 0000000..b7729dd --- /dev/null +++ b/src/main/java/com/rymcu/forest/entity/ArticleThumbsUp.java @@ -0,0 +1,37 @@ +package com.rymcu.forest.entity; + +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import java.io.Serializable; +import java.util.Date; + +/** + * @author ronger + */ +@Data +@Table(name="forest_article_thumbs_up") +public class ArticleThumbsUp implements Serializable, Cloneable { + /** + * 主键 + */ + @Id + @Column(name = "id") + @GeneratedValue(generator = "JDBC") + private Integer idArticleThumbsUp; + /** + * 文章表主键 + */ + private Integer idArticle; + /** + * 用户表主键 + */ + private Integer idUser; + /** + * 点赞时间 + */ + private Date thumbsUpTime; +} diff --git a/src/main/java/com/rymcu/forest/entity/Bank.java b/src/main/java/com/rymcu/forest/entity/Bank.java new file mode 100644 index 0000000..97405fb --- /dev/null +++ b/src/main/java/com/rymcu/forest/entity/Bank.java @@ -0,0 +1,37 @@ +package com.rymcu.forest.entity; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import java.util.Date; + +/** + * 银行 + * @author ronger + */ +@Table(name = "forest_bank") +@Data +public class Bank { + + /** 主键 */ + @Id + @Column(name = "id") + @GeneratedValue(generator = "JDBC") + private Integer idBank; + /** 银行名称 */ + private String bankName; + /** 银行负责人 */ + private Integer bankOwner; + /** 银行描述 */ + private String bankDescription; + /** 创建人 */ + private Integer createdBy; + /** 创建时间 */ + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + private Date createdTime; + +} diff --git a/src/main/java/com/rymcu/forest/entity/BankAccount.java b/src/main/java/com/rymcu/forest/entity/BankAccount.java new file mode 100644 index 0000000..3c3374a --- /dev/null +++ b/src/main/java/com/rymcu/forest/entity/BankAccount.java @@ -0,0 +1,38 @@ +package com.rymcu.forest.entity; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 银行账户 + * @author ronger + */ +@Table(name = "forest_bank_account") +@Data +public class BankAccount { + /** 主键 */ + @Id + @Column(name = "id") + @GeneratedValue(generator = "JDBC") + private Integer idBankAccount; + /** 所属银行 */ + private Integer idBank; + /** 银行账户 */ + private String bankAccount; + /** 账户余额 */ + private BigDecimal accountBalance; + /** 账户所有者 */ + private Integer accountOwner; + /** 创建时间 */ + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + private Date createdTime; + /** 账户类型 */ + private String accountType; +} diff --git a/src/main/java/com/rymcu/forest/entity/Comment.java b/src/main/java/com/rymcu/forest/entity/Comment.java index 6f59d9b..3431f74 100644 --- a/src/main/java/com/rymcu/forest/entity/Comment.java +++ b/src/main/java/com/rymcu/forest/entity/Comment.java @@ -13,7 +13,7 @@ import java.util.Date; * @author ronger */ @Data -@Table(name="vertical_comment") +@Table(name="forest_comment") public class Comment implements Serializable,Cloneable { /** 主键 */ @Id diff --git a/src/main/java/com/rymcu/forest/entity/CurrencyIssue.java b/src/main/java/com/rymcu/forest/entity/CurrencyIssue.java new file mode 100644 index 0000000..4ab315c --- /dev/null +++ b/src/main/java/com/rymcu/forest/entity/CurrencyIssue.java @@ -0,0 +1,29 @@ +package com.rymcu.forest.entity; + +import lombok.Data; + +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 货币发行记录 + * @author ronger + */ +@Table(name = "forest_currency_issue") +@Data +public class CurrencyIssue { + /** 主键 */ + @Id + @GeneratedValue(generator = "JDBC") + private Integer id; + /** 发行数额 */ + private BigDecimal issueValue; + /** 发行人 */ + private Integer createdBy; + /** 发行时间 */ + private Date createdTime; + +} diff --git a/src/main/java/com/rymcu/forest/entity/CurrencyRule.java b/src/main/java/com/rymcu/forest/entity/CurrencyRule.java new file mode 100644 index 0000000..243a5cc --- /dev/null +++ b/src/main/java/com/rymcu/forest/entity/CurrencyRule.java @@ -0,0 +1,57 @@ +package com.rymcu.forest.entity; + +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @author ronger + */ +@Table(name="forest_currency_rule") +@Data +public class CurrencyRule implements Serializable, Cloneable { + /** + * 主键 + */ + @Id + @GeneratedValue(generator = "JDBC") + @Column(name = "id") + private Integer idCurrencyRule; + /** + * 规则名称 + */ + private String ruleName; + /** + * 规则标志(与枚举变量对应) + */ + private String ruleSign; + /** + * 规则描述 + */ + private String ruleDescription; + /** + * 金额 + */ + private BigDecimal money; + /** + * 奖励(0)/消耗(1)状态 + */ + private String awardStatus; + /** + * 上限金额 + */ + private BigDecimal maximumMoney; + /** + * 重复(0: 不重复,单位:天) + */ + private Integer repeatDays; + /** + * 状态 + */ + private String status; +} diff --git a/src/main/java/com/rymcu/forest/entity/Follow.java b/src/main/java/com/rymcu/forest/entity/Follow.java index b87855c..471fe44 100644 --- a/src/main/java/com/rymcu/forest/entity/Follow.java +++ b/src/main/java/com/rymcu/forest/entity/Follow.java @@ -12,7 +12,7 @@ import java.io.Serializable; * @author ronger */ @Data -@Table(name="vertical_follow") +@Table(name="forest_follow") public class Follow implements Serializable,Cloneable { /** 主键 */ @Id diff --git a/src/main/java/com/rymcu/forest/entity/Notification.java b/src/main/java/com/rymcu/forest/entity/Notification.java index ceb4b6c..809f070 100644 --- a/src/main/java/com/rymcu/forest/entity/Notification.java +++ b/src/main/java/com/rymcu/forest/entity/Notification.java @@ -15,7 +15,7 @@ import java.util.Date; * @author ronger */ @Data -@Table(name="vertical_notification") +@Table(name="forest_notification") public class Notification implements Serializable,Cloneable { /** * 主键 diff --git a/src/main/java/com/rymcu/forest/entity/Permission.java b/src/main/java/com/rymcu/forest/entity/Permission.java index e24ce23..d5b0bb8 100644 --- a/src/main/java/com/rymcu/forest/entity/Permission.java +++ b/src/main/java/com/rymcu/forest/entity/Permission.java @@ -13,7 +13,7 @@ import java.io.Serializable; * @author ronger */ @Data -@Table(name = "vertical_permission") +@Table(name = "forest_permission") public class Permission implements Serializable,Cloneable { @Id diff --git a/src/main/java/com/rymcu/forest/entity/Portfolio.java b/src/main/java/com/rymcu/forest/entity/Portfolio.java index c0ad005..8165a4f 100644 --- a/src/main/java/com/rymcu/forest/entity/Portfolio.java +++ b/src/main/java/com/rymcu/forest/entity/Portfolio.java @@ -2,17 +2,14 @@ package com.rymcu.forest.entity; import lombok.Data; -import javax.persistence.Column; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; +import javax.persistence.*; import java.util.Date; /** * @author ronger */ @Data -@Table(name = "vertical_portfolio") +@Table(name = "forest_portfolio") public class Portfolio { /** 主键 */ @Id @@ -34,4 +31,6 @@ public class Portfolio { private Date createdTime; /** 更新时间 */ private Date updatedTime; + @Transient + private String headImgType; } diff --git a/src/main/java/com/rymcu/forest/entity/Role.java b/src/main/java/com/rymcu/forest/entity/Role.java index ec8ce28..99c2511 100644 --- a/src/main/java/com/rymcu/forest/entity/Role.java +++ b/src/main/java/com/rymcu/forest/entity/Role.java @@ -14,7 +14,7 @@ import java.util.Date; * @author ronger */ @Data -@Table(name = "vertical_role") +@Table(name = "forest_role") public class Role implements Serializable,Cloneable { @Id @Column(name = "id") diff --git a/src/main/java/com/rymcu/forest/entity/SpecialDay.java b/src/main/java/com/rymcu/forest/entity/SpecialDay.java index e221995..5455d6a 100644 --- a/src/main/java/com/rymcu/forest/entity/SpecialDay.java +++ b/src/main/java/com/rymcu/forest/entity/SpecialDay.java @@ -13,7 +13,7 @@ import java.util.Date; * @author ronger */ @Data -@Table(name="vertical_special_day") +@Table(name="forest_special_day") public class SpecialDay implements Serializable,Cloneable{ /** */ @Id diff --git a/src/main/java/com/rymcu/forest/entity/Sponsor.java b/src/main/java/com/rymcu/forest/entity/Sponsor.java new file mode 100644 index 0000000..46ad4b3 --- /dev/null +++ b/src/main/java/com/rymcu/forest/entity/Sponsor.java @@ -0,0 +1,44 @@ +package com.rymcu.forest.entity; + +import lombok.Data; + +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author ronger + */ +@Data +@Table(name="forest_sponsor") +public class Sponsor implements Serializable, Cloneable { + /** + * 主键 + */ + @Id + @GeneratedValue(generator = "JDBC") + private Integer id; + /** + * 数据类型 + */ + private String dataType; + /** + * 数据主键 + */ + private Integer dataId; + /** + * 赞赏人 + */ + private Integer sponsor; + /** + * 赞赏日期 + */ + private Date sponsorshipTime; + /** + * 赞赏金额 + */ + private BigDecimal sponsorshipMoney; +} diff --git a/src/main/java/com/rymcu/forest/entity/Tag.java b/src/main/java/com/rymcu/forest/entity/Tag.java index 42119ec..8a2e5f2 100644 --- a/src/main/java/com/rymcu/forest/entity/Tag.java +++ b/src/main/java/com/rymcu/forest/entity/Tag.java @@ -13,7 +13,7 @@ import java.util.Date; * @author ronger */ @Data -@Table(name = "vertical_tag") +@Table(name = "forest_tag") public class Tag implements Serializable,Cloneable { /** 主键 */ @Id diff --git a/src/main/java/com/rymcu/forest/entity/Topic.java b/src/main/java/com/rymcu/forest/entity/Topic.java index 49bc120..cab07de 100644 --- a/src/main/java/com/rymcu/forest/entity/Topic.java +++ b/src/main/java/com/rymcu/forest/entity/Topic.java @@ -12,7 +12,7 @@ import java.util.Date; * @author ronger */ @Data -@Table(name = "vertical_topic") +@Table(name = "forest_topic") public class Topic { /** 主键 */ diff --git a/src/main/java/com/rymcu/forest/entity/TransactionRecord.java b/src/main/java/com/rymcu/forest/entity/TransactionRecord.java new file mode 100644 index 0000000..c7e34c8 --- /dev/null +++ b/src/main/java/com/rymcu/forest/entity/TransactionRecord.java @@ -0,0 +1,38 @@ +package com.rymcu.forest.entity; + +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 交易记录 + * @author ronger + */ +@Table(name = "forest_transaction_record") +@Data +public class TransactionRecord { + /** 主键 */ + @Id + @Column(name = "id") + @GeneratedValue(generator = "JDBC") + private Integer idTransactionRecord; + /** 交易流水号 */ + private String transactionNo; + /** 款项 */ + private String funds; + /** 交易发起方 */ + private String formBankAccount; + /** 交易收款方 */ + private String toBankAccount; + /** 交易金额 */ + private BigDecimal money; + /** 交易类型 */ + private String transactionType; + /** 交易时间 */ + private Date transactionTime; +} diff --git a/src/main/java/com/rymcu/forest/entity/User.java b/src/main/java/com/rymcu/forest/entity/User.java index a5ef26a..b13a264 100644 --- a/src/main/java/com/rymcu/forest/entity/User.java +++ b/src/main/java/com/rymcu/forest/entity/User.java @@ -15,7 +15,7 @@ import java.util.Date; /** * @author ronger */ -@Table(name = "vertical_user") +@Table(name = "forest_user") @Data public class User implements Serializable,Cloneable { @Id diff --git a/src/main/java/com/rymcu/forest/entity/UserExtend.java b/src/main/java/com/rymcu/forest/entity/UserExtend.java index a45962f..b4e339a 100644 --- a/src/main/java/com/rymcu/forest/entity/UserExtend.java +++ b/src/main/java/com/rymcu/forest/entity/UserExtend.java @@ -9,7 +9,7 @@ import javax.persistence.Table; * @author ronger */ @Data -@Table(name = "vertical_user_extend") +@Table(name = "forest_user_extend") public class UserExtend { @Id diff --git a/src/main/java/com/rymcu/forest/entity/Visit.java b/src/main/java/com/rymcu/forest/entity/Visit.java index 94e251a..f1f2aa1 100644 --- a/src/main/java/com/rymcu/forest/entity/Visit.java +++ b/src/main/java/com/rymcu/forest/entity/Visit.java @@ -15,7 +15,7 @@ import java.util.Date; * @author ronger */ @Data -@Table(name="vertical_visit") +@Table(name="forest_visit") public class Visit implements Serializable,Cloneable { /** 主键 */ diff --git a/src/main/java/com/rymcu/forest/entity/WxUser.java b/src/main/java/com/rymcu/forest/entity/WxUser.java index 2748754..81fdce4 100644 --- a/src/main/java/com/rymcu/forest/entity/WxUser.java +++ b/src/main/java/com/rymcu/forest/entity/WxUser.java @@ -11,7 +11,7 @@ import javax.persistence.Table; * @author ronger */ @Data -@Table(name = "vertical_wx_user") +@Table(name = "forest_wx_user") public class WxUser { @Id diff --git a/src/main/java/com/rymcu/forest/enumerate/SponsorEnum.java b/src/main/java/com/rymcu/forest/enumerate/SponsorEnum.java new file mode 100644 index 0000000..7efc1e7 --- /dev/null +++ b/src/main/java/com/rymcu/forest/enumerate/SponsorEnum.java @@ -0,0 +1,30 @@ +package com.rymcu.forest.enumerate; + +/** + * @author ronger + */ + +public enum SponsorEnum { + Article("0", 20); + + private String dataType; + + private Integer money; + + SponsorEnum(String dataType, Integer money) { + this.dataType = dataType; + this.money = money; + } + + public String getDataType() { + return this.dataType; + } + + public Integer getMoney() { + return this.money; + } + + public boolean isArticle() { + return Article.equals(this); + } +} diff --git a/src/main/java/com/rymcu/forest/jwt/aop/RestAuthTokenInterceptor.java b/src/main/java/com/rymcu/forest/jwt/aop/RestAuthTokenInterceptor.java index b3ee752..37928cc 100644 --- a/src/main/java/com/rymcu/forest/jwt/aop/RestAuthTokenInterceptor.java +++ b/src/main/java/com/rymcu/forest/jwt/aop/RestAuthTokenInterceptor.java @@ -1,13 +1,11 @@ package com.rymcu.forest.jwt.aop; - import com.rymcu.forest.jwt.def.JwtConstants; import com.rymcu.forest.jwt.model.TokenModel; import com.rymcu.forest.jwt.service.TokenManager; -import com.rymcu.forest.jwt.util.oConvertUtils; -import com.rymcu.forest.web.api.exception.ErrorCode; import com.rymcu.forest.web.api.exception.BaseApiException; +import com.rymcu.forest.web.api.exception.ErrorCode; import io.jsonwebtoken.Claims; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureException; @@ -18,6 +16,7 @@ import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.util.Objects; /** * Restful请求, Token校验规则拦截器(JWT) @@ -55,7 +54,7 @@ public class RestAuthTokenInterceptor implements HandlerInterceptor { } Object username = claims.getId(); - if (oConvertUtils.isEmpty(username)) { + if (Objects.isNull(username)) { throw new BaseApiException(ErrorCode.INVALID_TOKEN); } TokenModel model = manager.getToken(authHeader,username.toString()); diff --git a/src/main/java/com/rymcu/forest/jwt/util/oConvertUtils.java b/src/main/java/com/rymcu/forest/jwt/util/oConvertUtils.java deleted file mode 100644 index 0d3a5c8..0000000 --- a/src/main/java/com/rymcu/forest/jwt/util/oConvertUtils.java +++ /dev/null @@ -1,499 +0,0 @@ -package com.rymcu.forest.jwt.util; - -import org.apache.commons.lang.StringEscapeUtils; -import org.apache.commons.lang.StringUtils; - -import javax.servlet.http.HttpServletRequest; -import java.io.UnsupportedEncodingException; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.net.SocketException; -import java.net.UnknownHostException; -import java.sql.Date; -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * - * @author 张代浩 - * - */ -public class oConvertUtils { - public static boolean isEmpty(Object object) { - if (object == null) { - return (true); - } - if (object.equals("")) { - return (true); - } - if (object.equals("null")) { - return (true); - } - return (false); - } - - public static boolean isNotEmpty(Object object) { - if (object != null && !object.equals("") && !object.equals("null")) { - return (true); - } - return (false); - } - - public static String decode(String strIn, String sourceCode, String targetCode) { - String temp = code2code(strIn, sourceCode, targetCode); - return temp; - } - - public static String StrToUTF(String strIn, String sourceCode, String targetCode) { - strIn = ""; - try { - strIn = new String(strIn.getBytes("ISO-8859-1"), "GBK"); - } catch (UnsupportedEncodingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return strIn; - - } - - private static String code2code(String strIn, String sourceCode, String targetCode) { - String strOut = null; - if (strIn == null || (strIn.trim()).equals("")) { - return strIn; - } - try { - byte[] b = strIn.getBytes(sourceCode); - for (int i = 0; i < b.length; i++) { - System.out.print(b[i] + " "); - } - strOut = new String(b, targetCode); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - return strOut; - } - - public static int getInt(String s, int defval) { - if (s == null || s == "") { - return (defval); - } - try { - return (Integer.parseInt(s)); - } catch (NumberFormatException e) { - return (defval); - } - } - - public static int getInt(String s) { - if (s == null || s == "") { - return 0; - } - try { - return (Integer.parseInt(s)); - } catch (NumberFormatException e) { - return 0; - } - } - - public static int getInt(String s, Integer df) { - if (s == null || s == "") { - return df; - } - try { - return (Integer.parseInt(s)); - } catch (NumberFormatException e) { - return 0; - } - } - - public static Integer[] getInts(String[] s) { - Integer[] integer = new Integer[s.length]; - if (s == null) { - return null; - } - for (int i = 0; i < s.length; i++) { - integer[i] = Integer.parseInt(s[i]); - } - return integer; - - } - - public static double getDouble(String s, double defval) { - if (s == null || s == "") { - return (defval); - } - try { - return (Double.parseDouble(s)); - } catch (NumberFormatException e) { - return (defval); - } - } - - public static double getDou(Double s, double defval) { - if (s == null) { - return (defval); - } - return s; - } - - public static Short getShort(String s) { - if (StringUtils.isNotEmpty(s)) { - return (Short.parseShort(s)); - } else { - return null; - } - } - - public static int getInt(Object object, int defval) { - if (isEmpty(object)) { - return (defval); - } - try { - return (Integer.parseInt(object.toString())); - } catch (NumberFormatException e) { - return (defval); - } - } - - public static int getInt(BigDecimal s, int defval) { - if (s == null) { - return (defval); - } - return s.intValue(); - } - - public static Integer[] getIntegerArry(String[] object) { - int len = object.length; - Integer[] result = new Integer[len]; - try { - for (int i = 0; i < len; i++) { - result[i] = new Integer(object[i].trim()); - } - return result; - } catch (NumberFormatException e) { - return null; - } - } - - public static String getString(String s) { - return (getString(s, "")); - } - - /** - * 转义成Unicode编码 - * @param s - * @return - */ - public static String escapeJava(Object s) { - return StringEscapeUtils.escapeJava(getString(s)); - } - - public static String getString(Object object) { - if (isEmpty(object)) { - return ""; - } - return (object.toString().trim()); - } - - public static String getString(int i) { - return (String.valueOf(i)); - } - - public static String getString(float i) { - return (String.valueOf(i)); - } - - public static String getString(String s, String defval) { - if (isEmpty(s)) { - return (defval); - } - return (s.trim()); - } - - public static String getString(Object s, String defval) { - if (isEmpty(s)) { - return (defval); - } - return (s.toString().trim()); - } - - public static long stringToLong(String str) { - Long test = new Long(0); - try { - test = Long.valueOf(str); - } catch (Exception e) { - } - return test.longValue(); - } - - /** - * 获取本机IP - */ - public static String getIp() { - String ip = null; - try { - InetAddress address = InetAddress.getLocalHost(); - ip = address.getHostAddress(); - - } catch (UnknownHostException e) { - e.printStackTrace(); - } - return ip; - } - - /** - * 判断一个类是否为基本数据类型。 - * - * @param clazz - * 要判断的类。 - * @return true 表示为基本数据类型。 - */ - private static boolean isBaseDataType(Class clazz) throws Exception { - return (clazz.equals(String.class) || clazz.equals(Integer.class) || clazz.equals(Byte.class) || clazz.equals(Long.class) || clazz.equals(Double.class) || clazz.equals(Float.class) || clazz.equals(Character.class) || clazz.equals(Short.class) || clazz.equals(BigDecimal.class) || clazz.equals(BigInteger.class) || clazz.equals(Boolean.class) || clazz.equals(Date.class) || clazz.isPrimitive()); - } - - /** - * @param request - * IP - * @return IP Address - */ - public static String getIpAddrByRequest(HttpServletRequest request) { - String ip = request.getHeader("x-forwarded-for"); - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { - ip = request.getHeader("Proxy-Client-IP"); - } - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { - ip = request.getHeader("WL-Proxy-Client-IP"); - } - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { - ip = request.getRemoteAddr(); - } - return ip; - } - - /** - * @return 本机IP - * @throws SocketException - */ - public static String getRealIp() throws SocketException { - String localip = null;// 本地IP,如果没有配置外网IP则返回它 - String netip = null;// 外网IP - - Enumeration netInterfaces = NetworkInterface.getNetworkInterfaces(); - InetAddress ip = null; - boolean finded = false;// 是否找到外网IP - while (netInterfaces.hasMoreElements() && !finded) { - NetworkInterface ni = netInterfaces.nextElement(); - Enumeration address = ni.getInetAddresses(); - while (address.hasMoreElements()) { - ip = address.nextElement(); - if (!ip.isSiteLocalAddress() && !ip.isLoopbackAddress() && ip.getHostAddress().indexOf(":") == -1) {// 外网IP - netip = ip.getHostAddress(); - finded = true; - break; - } else if (ip.isSiteLocalAddress() && !ip.isLoopbackAddress() && ip.getHostAddress().indexOf(":") == -1) {// 内网IP - localip = ip.getHostAddress(); - } - } - } - - if (netip != null && !"".equals(netip)) { - return netip; - } else { - return localip; - } - } - - /** - * java去除字符串中的空格、回车、换行符、制表符 - * - * @param str - * @return - */ - public static String replaceBlank(String str) { - String dest = ""; - if (str != null) { - Pattern p = Pattern.compile("\\s*|\t|\r|\n"); - Matcher m = p.matcher(str); - dest = m.replaceAll(""); - } - return dest; - - } - - /** - * 判断元素是否在数组内 - * - * @param substring - * @param source - * @return - */ - public static boolean isIn(String substring, String[] source) { - if (source == null || source.length == 0) { - return false; - } - for (int i = 0; i < source.length; i++) { - String aSource = source[i]; - if (aSource.equals(substring)) { - return true; - } - } - return false; - } - - /** - * 获取Map对象 - */ - public static Map getHashMap() { - return new HashMap(); - } - - /** - * SET转换MAP - * - * @param str - * @return - */ - public static Map SetToMap(Set setobj) { - Map map = getHashMap(); - for (Iterator iterator = setobj.iterator(); iterator.hasNext();) { - Map.Entry entry = (Map.Entry) iterator.next(); - map.put(entry.getKey().toString(), entry.getValue() == null ? "" : entry.getValue().toString().trim()); - } - return map; - - } - - public static boolean isInnerIP(String ipAddress) { - boolean isInnerIp = false; - long ipNum = getIpNum(ipAddress); - /** - * 私有IP:A类 10.0.0.0-10.255.255.255 B类 172.16.0.0-172.31.255.255 C类 192.168.0.0-192.168.255.255 当然,还有127这个网段是环回地址 - **/ - long aBegin = getIpNum("10.0.0.0"); - long aEnd = getIpNum("10.255.255.255"); - long bBegin = getIpNum("172.16.0.0"); - long bEnd = getIpNum("172.31.255.255"); - long cBegin = getIpNum("192.168.0.0"); - long cEnd = getIpNum("192.168.255.255"); - isInnerIp = isInner(ipNum, aBegin, aEnd) || isInner(ipNum, bBegin, bEnd) || isInner(ipNum, cBegin, cEnd) || ipAddress.equals("127.0.0.1"); - return isInnerIp; - } - - private static long getIpNum(String ipAddress) { - String[] ip = ipAddress.split("\\."); - long a = Integer.parseInt(ip[0]); - long b = Integer.parseInt(ip[1]); - long c = Integer.parseInt(ip[2]); - long d = Integer.parseInt(ip[3]); - - long ipNum = a * 256 * 256 * 256 + b * 256 * 256 + c * 256 + d; - return ipNum; - } - - private static boolean isInner(long userIp, long begin, long end) { - return (userIp >= begin) && (userIp <= end); - } - - /** - * 将下划线大写方式命名的字符串转换为驼峰式。 - * 如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。
- * 例如:hello_world->helloWorld - * - * @param name - * 转换前的下划线大写方式命名的字符串 - * @return 转换后的驼峰式命名的字符串 - */ - public static String camelName(String name) { - StringBuilder result = new StringBuilder(); - // 快速检查 - if (name == null || name.isEmpty()) { - // 没必要转换 - return ""; - } else if (!name.contains("_")) { - // 不含下划线,仅将首字母小写 - - return name.substring(0, 1).toLowerCase() + name.substring(1).toLowerCase(); - - } - // 用下划线将原始字符串分割 - String camels[] = name.split("_"); - for (String camel : camels) { - // 跳过原始字符串中开头、结尾的下换线或双重下划线 - if (camel.isEmpty()) { - continue; - } - // 处理真正的驼峰片段 - if (result.length() == 0) { - // 第一个驼峰片段,全部字母都小写 - result.append(camel.toLowerCase()); - } else { - // 其他的驼峰片段,首字母大写 - result.append(camel.substring(0, 1).toUpperCase()); - result.append(camel.substring(1).toLowerCase()); - } - } - return result.toString(); - } - - /** - * 将下划线大写方式命名的字符串转换为驼峰式。 - * 如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。
- * 例如:hello_world,test_id->helloWorld,testId - * - * @param name - * 转换前的下划线大写方式命名的字符串 - * @return 转换后的驼峰式命名的字符串 - */ - public static String camelNames(String names) { - if(names==null||names.equals("")){ - return null; - } - StringBuffer sf = new StringBuffer(); - String[] fs = names.split(","); - for (String field : fs) { - field = camelName(field); - sf.append(field + ","); - } - String result = sf.toString(); - return result.substring(0, result.length() - 1); - } - - /** - * 将下划线大写方式命名的字符串转换为驼峰式。(首字母写) - * 如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。
- * 例如:hello_world->HelloWorld - * - * @param name - * 转换前的下划线大写方式命名的字符串 - * @return 转换后的驼峰式命名的字符串 - */ - public static String camelNameCapFirst(String name) { - StringBuilder result = new StringBuilder(); - // 快速检查 - if (name == null || name.isEmpty()) { - // 没必要转换 - return ""; - } else if (!name.contains("_")) { - // 不含下划线,仅将首字母小写 - return name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase(); - } - // 用下划线将原始字符串分割 - String camels[] = name.split("_"); - for (String camel : camels) { - // 跳过原始字符串中开头、结尾的下换线或双重下划线 - if (camel.isEmpty()) { - continue; - } - // 其他的驼峰片段,首字母大写 - result.append(camel.substring(0, 1).toUpperCase()); - result.append(camel.substring(1).toLowerCase()); - } - return result.toString(); - } - -} diff --git a/src/main/java/com/rymcu/forest/mapper/ArticleMapper.java b/src/main/java/com/rymcu/forest/mapper/ArticleMapper.java index bb54796..4f9d5ca 100644 --- a/src/main/java/com/rymcu/forest/mapper/ArticleMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/ArticleMapper.java @@ -176,4 +176,12 @@ public interface ArticleMapper extends Mapper
{ * @return */ List selectPortfolioArticlesByIdPortfolioAndSortNo(@Param("idPortfolio") Integer idPortfolio, @Param("sortNo") Integer sortNo); + + /** + * 更新文章优选状态 + * @param idArticle + * @param articlePerfect + * @return + */ + int updatePerfect(@Param("idArticle") Integer idArticle, @Param("articlePerfect") String articlePerfect); } diff --git a/src/main/java/com/rymcu/forest/mapper/ArticleThumbsUpMapper.java b/src/main/java/com/rymcu/forest/mapper/ArticleThumbsUpMapper.java new file mode 100644 index 0000000..7a192f5 --- /dev/null +++ b/src/main/java/com/rymcu/forest/mapper/ArticleThumbsUpMapper.java @@ -0,0 +1,18 @@ +package com.rymcu.forest.mapper; + +import com.rymcu.forest.core.mapper.Mapper; +import com.rymcu.forest.entity.ArticleThumbsUp; +import org.apache.ibatis.annotations.Param; + +/** + * @author ronger + */ +public interface ArticleThumbsUpMapper extends Mapper { + /** + * 更新文章点赞数 + * @param idArticle + * @param thumbsUpNumber + * @return + */ + Integer updateArticleThumbsUpNumber(@Param("idArticle") Integer idArticle, @Param("thumbsUpNumber") Integer thumbsUpNumber); +} diff --git a/src/main/java/com/rymcu/forest/mapper/BankAccountMapper.java b/src/main/java/com/rymcu/forest/mapper/BankAccountMapper.java new file mode 100644 index 0000000..a71f580 --- /dev/null +++ b/src/main/java/com/rymcu/forest/mapper/BankAccountMapper.java @@ -0,0 +1,35 @@ +package com.rymcu.forest.mapper; + +import com.rymcu.forest.core.mapper.Mapper; +import com.rymcu.forest.dto.BankAccountDTO; +import com.rymcu.forest.entity.BankAccount; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author ronger + */ +public interface BankAccountMapper extends Mapper { + /** + * 查询银行账户 + * @param bankName + * @param accountOwnerName + * @param bankAccount + * @return + */ + List selectBankAccounts(@Param("bankName") String bankName, @Param("accountOwnerName") String accountOwnerName, @Param("bankAccount") String bankAccount); + + /** + * 获取银行账户信息 + * @param idBank + * @return + */ + BankAccountDTO selectBankAccount(@Param("idBank") Integer idBank); + + /** + * 获取当前最大卡号 + * @return + */ + String selectMaxBankAccount(); +} diff --git a/src/main/java/com/rymcu/forest/mapper/BankMapper.java b/src/main/java/com/rymcu/forest/mapper/BankMapper.java new file mode 100644 index 0000000..d330d8c --- /dev/null +++ b/src/main/java/com/rymcu/forest/mapper/BankMapper.java @@ -0,0 +1,18 @@ +package com.rymcu.forest.mapper; + +import com.rymcu.forest.core.mapper.Mapper; +import com.rymcu.forest.dto.BankDTO; +import com.rymcu.forest.entity.Bank; + +import java.util.List; + +/** + * @author ronger + */ +public interface BankMapper extends Mapper { + /** + * 查询银行列表数据 + * @return + */ + List selectBanks(); +} diff --git a/src/main/java/com/rymcu/forest/mapper/CurrencyRuleMapper.java b/src/main/java/com/rymcu/forest/mapper/CurrencyRuleMapper.java new file mode 100644 index 0000000..8e26f4e --- /dev/null +++ b/src/main/java/com/rymcu/forest/mapper/CurrencyRuleMapper.java @@ -0,0 +1,10 @@ +package com.rymcu.forest.mapper; + +import com.rymcu.forest.core.mapper.Mapper; +import com.rymcu.forest.entity.CurrencyRule; + +/** + * @author ronger + */ +public interface CurrencyRuleMapper extends Mapper { +} diff --git a/src/main/java/com/rymcu/forest/mapper/SearchMapper.java b/src/main/java/com/rymcu/forest/mapper/SearchMapper.java new file mode 100644 index 0000000..b6a8a3f --- /dev/null +++ b/src/main/java/com/rymcu/forest/mapper/SearchMapper.java @@ -0,0 +1,28 @@ +package com.rymcu.forest.mapper; + +import com.rymcu.forest.dto.SearchModel; + +import java.util.List; + +/** + * @author ronger + */ +public interface SearchMapper { + /** + * 初始化文章搜索数据 + * @return + */ + List searchInitialArticleSearch(); + + /** + * 初始化作品集搜索数据 + * @return + */ + List searchInitialPortfolioSearch(); + + /** + * 初始化用户搜索数据 + * @return + */ + List searchInitialUserSearch(); +} diff --git a/src/main/java/com/rymcu/forest/mapper/SponsorMapper.java b/src/main/java/com/rymcu/forest/mapper/SponsorMapper.java new file mode 100644 index 0000000..7f36c26 --- /dev/null +++ b/src/main/java/com/rymcu/forest/mapper/SponsorMapper.java @@ -0,0 +1,17 @@ +package com.rymcu.forest.mapper; + +import com.rymcu.forest.core.mapper.Mapper; +import com.rymcu.forest.entity.Sponsor; +import org.apache.ibatis.annotations.Param; + +/** + * @author ronger + */ +public interface SponsorMapper extends Mapper { + /** + * 更新文章赞赏数 + * @param idArticle + * @return + */ + Integer updateArticleSponsorCount(@Param("idArticle") Integer idArticle); +} diff --git a/src/main/java/com/rymcu/forest/mapper/TagMapper.java b/src/main/java/com/rymcu/forest/mapper/TagMapper.java index bc53ff5..b4b1138 100644 --- a/src/main/java/com/rymcu/forest/mapper/TagMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/TagMapper.java @@ -13,7 +13,7 @@ import java.util.List; public interface TagMapper extends Mapper { /** - * 插入标签文章表(vertical_tag_article)相关信息 + * 插入标签文章表(forest_tag_article)相关信息 * @param idTag * @param idArticle * @return diff --git a/src/main/java/com/rymcu/forest/mapper/TransactionRecordMapper.java b/src/main/java/com/rymcu/forest/mapper/TransactionRecordMapper.java new file mode 100644 index 0000000..e181c85 --- /dev/null +++ b/src/main/java/com/rymcu/forest/mapper/TransactionRecordMapper.java @@ -0,0 +1,30 @@ +package com.rymcu.forest.mapper; + +import com.rymcu.forest.core.mapper.Mapper; +import com.rymcu.forest.dto.TransactionRecordDTO; +import com.rymcu.forest.entity.TransactionRecord; +import org.apache.ibatis.annotations.Param; + +import java.math.BigDecimal; +import java.util.List; + +/** + * @author ronger + */ +public interface TransactionRecordMapper extends Mapper { + /** + * 交易 + * @param formBankAccount + * @param toBankAccount + * @param money + * @return + */ + Integer transfer(@Param("formBankAccount") String formBankAccount, @Param("toBankAccount") String toBankAccount, @Param("money") BigDecimal money); + + /** + * 查询指定账户的交易记录 + * @param bankAccount + * @return + */ + List selectTransactionRecords(@Param("bankAccount") String bankAccount); +} diff --git a/src/main/java/com/rymcu/forest/service/ArticleService.java b/src/main/java/com/rymcu/forest/service/ArticleService.java index 9454bad..f839ed5 100644 --- a/src/main/java/com/rymcu/forest/service/ArticleService.java +++ b/src/main/java/com/rymcu/forest/service/ArticleService.java @@ -111,6 +111,16 @@ public interface ArticleService extends Service
{ * @param idArticle * @param tags * @return + * @throws UnsupportedEncodingException + * @throws BaseApiException */ Map updateTags(Integer idArticle, String tags) throws UnsupportedEncodingException, BaseApiException; + + /** + * 更新文章优选状态 + * @param idArticle + * @param articlePerfect + * @return + */ + Map updatePerfect(Integer idArticle, String articlePerfect); } diff --git a/src/main/java/com/rymcu/forest/service/ArticleThumbsUpService.java b/src/main/java/com/rymcu/forest/service/ArticleThumbsUpService.java new file mode 100644 index 0000000..d565c29 --- /dev/null +++ b/src/main/java/com/rymcu/forest/service/ArticleThumbsUpService.java @@ -0,0 +1,20 @@ +package com.rymcu.forest.service; + +import com.rymcu.forest.core.service.Service; +import com.rymcu.forest.entity.ArticleThumbsUp; +import com.rymcu.forest.web.api.exception.BaseApiException; + +import java.util.Map; + +/** + * @author ronger + */ +public interface ArticleThumbsUpService extends Service { + /** + * 点赞 + * @param articleThumbsUp + * @throws BaseApiException + * @return + */ + Map thumbsUp(ArticleThumbsUp articleThumbsUp) throws BaseApiException; +} diff --git a/src/main/java/com/rymcu/forest/service/BankAccountService.java b/src/main/java/com/rymcu/forest/service/BankAccountService.java new file mode 100644 index 0000000..a764f7b --- /dev/null +++ b/src/main/java/com/rymcu/forest/service/BankAccountService.java @@ -0,0 +1,35 @@ +package com.rymcu.forest.service; + +import com.rymcu.forest.core.service.Service; +import com.rymcu.forest.dto.BankAccountDTO; +import com.rymcu.forest.dto.BankAccountSearchDTO; +import com.rymcu.forest.entity.BankAccount; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author ronger + */ +public interface BankAccountService extends Service { + /** + * 查询银行账户列表 + * @param bankAccountSearchDTO + * @return + */ + List findBankAccounts(BankAccountSearchDTO bankAccountSearchDTO); + + /** + * 查询用户银行账户 + * @param idUser + * @return + */ + BankAccountDTO findBankAccountByIdUser(Integer idUser); + + /** + * 根据账户查询银行账户信息 + * @param bankAccount + * @return + */ + BankAccount findByBankAccount(String bankAccount); +} diff --git a/src/main/java/com/rymcu/forest/service/BankService.java b/src/main/java/com/rymcu/forest/service/BankService.java new file mode 100644 index 0000000..59fd8bb --- /dev/null +++ b/src/main/java/com/rymcu/forest/service/BankService.java @@ -0,0 +1,14 @@ +package com.rymcu.forest.service; + +import com.rymcu.forest.core.service.Service; +import com.rymcu.forest.dto.BankDTO; +import com.rymcu.forest.entity.Bank; + +import java.util.List; + +/** + * @author ronger + */ +public interface BankService extends Service { + List findBanks(); +} diff --git a/src/main/java/com/rymcu/forest/service/CurrencyRuleService.java b/src/main/java/com/rymcu/forest/service/CurrencyRuleService.java new file mode 100644 index 0000000..45bdf3b --- /dev/null +++ b/src/main/java/com/rymcu/forest/service/CurrencyRuleService.java @@ -0,0 +1,10 @@ +package com.rymcu.forest.service; + +import com.rymcu.forest.core.service.Service; +import com.rymcu.forest.entity.CurrencyRule; + +/** + * @author ronger + */ +public interface CurrencyRuleService extends Service { +} diff --git a/src/main/java/com/rymcu/forest/service/SearchService.java b/src/main/java/com/rymcu/forest/service/SearchService.java new file mode 100644 index 0000000..7485bf0 --- /dev/null +++ b/src/main/java/com/rymcu/forest/service/SearchService.java @@ -0,0 +1,16 @@ +package com.rymcu.forest.service; + +import com.rymcu.forest.dto.SearchModel; + +import java.util.List; + +/** + * @author ronger + */ +public interface SearchService { + /** + * 初始化搜索数据 + * @return + */ + List initialSearch(); +} diff --git a/src/main/java/com/rymcu/forest/service/SponsorService.java b/src/main/java/com/rymcu/forest/service/SponsorService.java new file mode 100644 index 0000000..3adf035 --- /dev/null +++ b/src/main/java/com/rymcu/forest/service/SponsorService.java @@ -0,0 +1,19 @@ +package com.rymcu.forest.service; + +import com.rymcu.forest.core.service.Service; +import com.rymcu.forest.entity.Sponsor; + +import java.util.Map; + +/** + * @author ronger + */ +public interface SponsorService extends Service { + /** + * 赞赏 + * @param sponsor + * @return + * @throws Exception + */ + Map sponsorship(Sponsor sponsor) throws Exception; +} diff --git a/src/main/java/com/rymcu/forest/service/TransactionRecordService.java b/src/main/java/com/rymcu/forest/service/TransactionRecordService.java new file mode 100644 index 0000000..feb08ed --- /dev/null +++ b/src/main/java/com/rymcu/forest/service/TransactionRecordService.java @@ -0,0 +1,38 @@ +package com.rymcu.forest.service; + +import com.rymcu.forest.core.service.Service; +import com.rymcu.forest.dto.TransactionRecordDTO; +import com.rymcu.forest.entity.TransactionRecord; + +import java.math.BigDecimal; +import java.util.List; + +/** + * @author ronger + */ +public interface TransactionRecordService extends Service { + /** + * 交易 + * @param transactionRecord + * @return + * @throws Exception + */ + TransactionRecord transfer(TransactionRecord transactionRecord) throws Exception; + + /** + * 查询指定账户的交易记录 + * @param bankAccount + * @return + */ + List findTransactionRecords(String bankAccount); + + /** + * 根据用户主键进行交易 + * @param toUserId + * @param formUserId + * @param money + * @return + * @throws Exception + */ + TransactionRecord transferByUserId(Integer toUserId, Integer formUserId, BigDecimal money) throws Exception; +} diff --git a/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java index a9ba491..faaa500 100644 --- a/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/ArticleServiceImpl.java @@ -334,24 +334,37 @@ public class ArticleServiceImpl extends AbstractService
implements Arti return map; } + @Override + public Map updatePerfect(Integer idArticle, String articlePerfect) { + Map map = new HashMap(2); + int result = articleMapper.updatePerfect(idArticle, articlePerfect); + if (result == 0) { + map.put("success", false); + map.put("message", "设置优选文章失败!"); + } else { + map.put("success", true); + } + return map; + } + private ArticleDTO genArticle(ArticleDTO article, Integer type) { - Integer ARTICLE_LIST = 0; - Integer ARTICLE_VIEW = 1; - Integer ARTICLE_EDIT = 2; + Integer articleList = 0; + Integer articleView = 1; + Integer articleEdit = 2; Author author = genAuthor(article); article.setArticleAuthor(author); article.setTimeAgo(Utils.getTimeAgo(article.getUpdatedTime())); List tags = articleMapper.selectTags(article.getIdArticle()); article.setTags(tags); - if (!type.equals(ARTICLE_LIST)) { + if (!type.equals(articleList)) { ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle()); - if (type.equals(ARTICLE_VIEW)) { + if (type.equals(articleView)) { article.setArticleContent(articleContent.getArticleContentHtml()); // 获取所属作品集列表数据 List portfolioArticleDTOList = articleMapper.selectPortfolioArticles(article.getIdArticle()); portfolioArticleDTOList.forEach(portfolioArticleDTO -> genPortfolioArticles(portfolioArticleDTO)); article.setPortfolios(portfolioArticleDTOList); - } else if (type.equals(ARTICLE_EDIT)) { + } else if (type.equals(articleEdit)) { article.setArticleContent(articleContent.getArticleContent()); } else { article.setArticleContent(articleContent.getArticleContentHtml()); diff --git a/src/main/java/com/rymcu/forest/service/impl/ArticleThumbsUpServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/ArticleThumbsUpServiceImpl.java new file mode 100644 index 0000000..4dcf87a --- /dev/null +++ b/src/main/java/com/rymcu/forest/service/impl/ArticleThumbsUpServiceImpl.java @@ -0,0 +1,70 @@ +package com.rymcu.forest.service.impl; + +import com.rymcu.forest.core.service.AbstractService; +import com.rymcu.forest.entity.Article; +import com.rymcu.forest.entity.ArticleThumbsUp; +import com.rymcu.forest.entity.User; +import com.rymcu.forest.mapper.ArticleThumbsUpMapper; +import com.rymcu.forest.service.ArticleService; +import com.rymcu.forest.service.ArticleThumbsUpService; +import com.rymcu.forest.util.UserUtils; +import com.rymcu.forest.web.api.exception.BaseApiException; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * @author ronger + */ +@Service +public class ArticleThumbsUpServiceImpl extends AbstractService implements ArticleThumbsUpService { + + @Resource + private ArticleThumbsUpMapper articleThumbsUpMapper; + @Resource + private ArticleService articleService; + + @Override + @Transactional(rollbackFor = Exception.class) + public Map thumbsUp(ArticleThumbsUp articleThumbsUp) throws BaseApiException { + Map map = new HashMap(3); + if (Objects.isNull(articleThumbsUp) || Objects.isNull(articleThumbsUp.getIdArticle())) { + map.put("message", "数据异常,文章不存在!"); + map.put("success", false); + } else { + Integer thumbsUpNumber = 1; + Article article = articleService.findById(String.valueOf(articleThumbsUp.getIdArticle())); + if (Objects.isNull(article)) { + map.put("message", "数据异常,文章不存在!"); + map.put("success", false); + } else { + User user = UserUtils.getCurrentUserByToken(); + articleThumbsUp.setIdUser(user.getIdUser()); + ArticleThumbsUp thumbsUp = articleThumbsUpMapper.selectOne(articleThumbsUp); + if (Objects.isNull(thumbsUp)) { + articleThumbsUp.setThumbsUpTime(new Date()); + articleThumbsUpMapper.insertSelective(articleThumbsUp); + // 更新文章点赞数 + } else { + articleThumbsUpMapper.deleteByPrimaryKey(thumbsUp.getIdArticleThumbsUp()); + // 更新文章点赞数 + thumbsUpNumber = -1; + } + articleThumbsUpMapper.updateArticleThumbsUpNumber(articleThumbsUp.getIdArticle(), thumbsUpNumber); + map.put("success", true); + map.put("thumbsUpNumber", thumbsUpNumber); + if (thumbsUpNumber > 0) { + map.put("message", "点赞成功"); + } else { + map.put("message", "已取消点赞"); + } + } + } + return map; + } +} diff --git a/src/main/java/com/rymcu/forest/service/impl/BankAccountServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/BankAccountServiceImpl.java new file mode 100644 index 0000000..714f372 --- /dev/null +++ b/src/main/java/com/rymcu/forest/service/impl/BankAccountServiceImpl.java @@ -0,0 +1,79 @@ +package com.rymcu.forest.service.impl; + +import com.rymcu.forest.core.service.AbstractService; +import com.rymcu.forest.dto.BankAccountDTO; +import com.rymcu.forest.dto.BankAccountSearchDTO; +import com.rymcu.forest.dto.TransactionRecordDTO; +import com.rymcu.forest.entity.BankAccount; +import com.rymcu.forest.mapper.BankAccountMapper; +import com.rymcu.forest.service.BankAccountService; +import com.rymcu.forest.service.TransactionRecordService; +import org.apache.commons.lang.StringUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +import java.util.Objects; + +/** + * @author ronger + */ +@Service +public class BankAccountServiceImpl extends AbstractService implements BankAccountService { + + private static String DEFAULT_ACCOUNT_TYPE = "0"; + + @Resource + BankAccountMapper bankAccountMapper; + @Resource + TransactionRecordService transactionRecordService; + + @Override + public List findBankAccounts(BankAccountSearchDTO bankAccountSearchDTO) { + List bankAccounts = bankAccountMapper.selectBankAccounts(bankAccountSearchDTO.getBankName(), bankAccountSearchDTO.getAccountOwnerName(), bankAccountSearchDTO.getBankAccount()); + return bankAccounts; + } + + @Override + public BankAccountDTO findBankAccountByIdUser(Integer idUser) { + BankAccount bankAccount = new BankAccount(); + bankAccount.setAccountOwner(idUser); + bankAccount.setAccountType(DEFAULT_ACCOUNT_TYPE); + List bankAccounts = bankAccountMapper.select(bankAccount); + BankAccountDTO bankAccountDTO; + if (Objects.nonNull(bankAccounts) && bankAccounts.size() > 0) { + bankAccountDTO = bankAccountMapper.selectBankAccount(bankAccounts.get(0).getIdBankAccount()); + } else { + bankAccount.setAccountBalance(new BigDecimal("0")); + // 默认为社区发展与改革银行 + bankAccount.setIdBank(2); + bankAccount.setBankAccount(nextBankAccount()); + bankAccount.setCreatedTime(new Date()); + bankAccountMapper.insertSelective(bankAccount); + bankAccountDTO = bankAccountMapper.selectBankAccount(bankAccount.getIdBankAccount()); + } + // 查询交易记录 + List records = transactionRecordService.findTransactionRecords(bankAccountDTO.getBankAccount()); + bankAccountDTO.setTransactionRecords(records); + return bankAccountDTO; + } + + @Override + public BankAccount findByBankAccount(String bankAccount) { + BankAccount searchBankAccount = new BankAccount(); + searchBankAccount.setBankAccount(bankAccount); + return bankAccountMapper.selectOne(searchBankAccount); + } + + private String nextBankAccount() { + String bankAccount = "600000001"; + String maxBankAccount = bankAccountMapper.selectMaxBankAccount(); + if (StringUtils.isNotBlank(maxBankAccount)) { + BigDecimal bigDecimal = new BigDecimal(maxBankAccount).add(new BigDecimal("1")); + return bigDecimal.toString(); + } + return bankAccount; + } +} diff --git a/src/main/java/com/rymcu/forest/service/impl/BankServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/BankServiceImpl.java new file mode 100644 index 0000000..431a506 --- /dev/null +++ b/src/main/java/com/rymcu/forest/service/impl/BankServiceImpl.java @@ -0,0 +1,27 @@ +package com.rymcu.forest.service.impl; + +import com.rymcu.forest.core.service.AbstractService; +import com.rymcu.forest.dto.BankDTO; +import com.rymcu.forest.entity.Bank; +import com.rymcu.forest.mapper.BankMapper; +import com.rymcu.forest.service.BankService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @author ronger + */ +@Service +public class BankServiceImpl extends AbstractService implements BankService { + + @Resource + private BankMapper bankMapper; + + @Override + public List findBanks() { + List banks = bankMapper.selectBanks(); + return banks; + } +} diff --git a/src/main/java/com/rymcu/forest/service/impl/CurrencyRuleServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/CurrencyRuleServiceImpl.java new file mode 100644 index 0000000..ff472ec --- /dev/null +++ b/src/main/java/com/rymcu/forest/service/impl/CurrencyRuleServiceImpl.java @@ -0,0 +1,20 @@ +package com.rymcu.forest.service.impl; + +import com.rymcu.forest.core.service.AbstractService; +import com.rymcu.forest.entity.CurrencyRule; +import com.rymcu.forest.mapper.CurrencyRuleMapper; +import com.rymcu.forest.service.CurrencyRuleService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** + * @author ronger + */ +@Service +public class CurrencyRuleServiceImpl extends AbstractService implements CurrencyRuleService { + + @Resource + private CurrencyRuleMapper currencyRuleMapper; + +} diff --git a/src/main/java/com/rymcu/forest/service/impl/PortfolioServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/PortfolioServiceImpl.java index 6172e14..b6aa53c 100644 --- a/src/main/java/com/rymcu/forest/service/impl/PortfolioServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/PortfolioServiceImpl.java @@ -12,7 +12,9 @@ import com.rymcu.forest.service.PortfolioService; import com.rymcu.forest.service.UserService; import com.rymcu.forest.util.UserUtils; import com.rymcu.forest.util.Utils; +import com.rymcu.forest.web.api.common.UploadController; import com.rymcu.forest.web.api.exception.BaseApiException; +import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -63,6 +65,10 @@ public class PortfolioServiceImpl extends AbstractService implements @Override public Portfolio postPortfolio(Portfolio portfolio) throws BaseApiException { User user = UserUtils.getCurrentUserByToken(); + if (StringUtils.isNotBlank(portfolio.getHeadImgType())) { + String headImgUrl = UploadController.uploadBase64File(portfolio.getHeadImgUrl(), 0); + portfolio.setHeadImgUrl(headImgUrl); + } if (portfolio.getIdPortfolio() == null || portfolio.getIdPortfolio() == 0) { portfolio.setPortfolioAuthorId(user.getIdUser()); portfolio.setCreatedTime(new Date()); diff --git a/src/main/java/com/rymcu/forest/service/impl/SearchServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/SearchServiceImpl.java new file mode 100644 index 0000000..2f583b0 --- /dev/null +++ b/src/main/java/com/rymcu/forest/service/impl/SearchServiceImpl.java @@ -0,0 +1,43 @@ +package com.rymcu.forest.service.impl; + +import com.rymcu.forest.core.service.redis.RedisResult; +import com.rymcu.forest.core.service.redis.RedisService; +import com.rymcu.forest.dto.SearchModel; +import com.rymcu.forest.mapper.SearchMapper; +import com.rymcu.forest.service.SearchService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * @author ronger + */ +@Service +public class SearchServiceImpl implements SearchService { + + @Resource + private SearchMapper searchMapper; + @Resource + private RedisService redisService; + + @Override + public List initialSearch() { + String searchKey = "initialSearch"; + RedisResult result = redisService.getListResult(searchKey, SearchModel.class); + if (Objects.nonNull(result.getListResult())) { + return result.getListResult(); + } + List list = new ArrayList<>(); + List articleSearchModels = searchMapper.searchInitialArticleSearch(); + List portfolioSearchModels = searchMapper.searchInitialPortfolioSearch(); + List userSearchModels = searchMapper.searchInitialUserSearch(); + list.addAll(articleSearchModels); + list.addAll(portfolioSearchModels); + list.addAll(userSearchModels); + redisService.set(searchKey, list, 24 * 60 * 60); + return list; + } +} diff --git a/src/main/java/com/rymcu/forest/service/impl/SponsorServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/SponsorServiceImpl.java new file mode 100644 index 0000000..8b1e589 --- /dev/null +++ b/src/main/java/com/rymcu/forest/service/impl/SponsorServiceImpl.java @@ -0,0 +1,64 @@ +package com.rymcu.forest.service.impl; + +import com.rymcu.forest.core.service.AbstractService; +import com.rymcu.forest.dto.ArticleDTO; +import com.rymcu.forest.entity.Sponsor; +import com.rymcu.forest.entity.TransactionRecord; +import com.rymcu.forest.entity.User; +import com.rymcu.forest.enumerate.SponsorEnum; +import com.rymcu.forest.mapper.SponsorMapper; +import com.rymcu.forest.service.ArticleService; +import com.rymcu.forest.service.SponsorService; +import com.rymcu.forest.service.TransactionRecordService; +import com.rymcu.forest.util.UserUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.*; + +/** + * @author ronger + */ +@Service +public class SponsorServiceImpl extends AbstractService implements SponsorService { + + @Resource + private SponsorMapper sponsorMapper; + @Resource + private ArticleService articleService; + @Resource + private TransactionRecordService transactionRecordService; + + @Override + @Transactional(rollbackFor = Exception.class) + public Map sponsorship(Sponsor sponsor) throws Exception { + Map map = new HashMap(2); + if (Objects.isNull(sponsor) || Objects.isNull(sponsor.getDataId()) || Objects.isNull(sponsor.getDataType())) { + map.put("success", false); + map.put("message", "数据异常"); + } else { + SponsorEnum result = Arrays.stream(SponsorEnum.values()).filter(sponsorEnum -> sponsorEnum.getDataType().equals(sponsor.getDataType())).findFirst().orElse(SponsorEnum.Article); + BigDecimal money = BigDecimal.valueOf(result.getMoney()); + sponsor.setSponsorshipMoney(money); + User user = UserUtils.getCurrentUserByToken(); + sponsor.setSponsor(user.getIdUser()); + sponsor.setSponsorshipTime(new Date()); + sponsorMapper.insertSelective(sponsor); + // 赞赏金额划转 + if (result.isArticle()) { + ArticleDTO articleDTO = articleService.findArticleDTOById(sponsor.getDataId(), 1); + TransactionRecord transactionRecord = transactionRecordService.transferByUserId(articleDTO.getArticleAuthorId(), user.getIdUser(), money); + if (Objects.isNull(transactionRecord.getIdTransactionRecord())) { + throw new Exception("余额不足"); + } + // 更新文章赞赏数 + sponsorMapper.updateArticleSponsorCount(articleDTO.getIdArticle()); + } + map.put("success", true); + map.put("message", "赞赏成功"); + } + return map; + } +} diff --git a/src/main/java/com/rymcu/forest/service/impl/TagServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/TagServiceImpl.java index 2a0c314..54a18ff 100644 --- a/src/main/java/com/rymcu/forest/service/impl/TagServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/TagServiceImpl.java @@ -103,8 +103,10 @@ public class TagServiceImpl extends AbstractService implements TagService { tags.append(tagNlpDTO.getTag()).append(","); } article.setArticleTags(tags.toString()); - saveTagArticle(article, articleContentHtml); + } else { + article.setArticleTags("待分类"); } + saveTagArticle(article, articleContentHtml); } } return 0; diff --git a/src/main/java/com/rymcu/forest/service/impl/TransactionRecordServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/TransactionRecordServiceImpl.java new file mode 100644 index 0000000..7925da4 --- /dev/null +++ b/src/main/java/com/rymcu/forest/service/impl/TransactionRecordServiceImpl.java @@ -0,0 +1,106 @@ +package com.rymcu.forest.service.impl; + +import com.rymcu.forest.core.exception.ServiceException; +import com.rymcu.forest.core.service.AbstractService; +import com.rymcu.forest.core.service.redis.RedisService; +import com.rymcu.forest.dto.BankAccountDTO; +import com.rymcu.forest.dto.TransactionRecordDTO; +import com.rymcu.forest.entity.BankAccount; +import com.rymcu.forest.entity.TransactionRecord; +import com.rymcu.forest.mapper.TransactionRecordMapper; +import com.rymcu.forest.service.BankAccountService; +import com.rymcu.forest.service.TransactionRecordService; +import com.rymcu.forest.util.DateUtil; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.Objects; + +/** + * @author ronger + */ +@Service +public class TransactionRecordServiceImpl extends AbstractService implements TransactionRecordService { + + @Resource + private TransactionRecordMapper transactionRecordMapper; + @Resource + private BankAccountService bankAccountService; + @Resource + private RedisService redisService; + + @Override + @Transactional(rollbackFor = Exception.class) + public TransactionRecord transfer(TransactionRecord transactionRecord) throws Exception { + // 判断发起者账户状态 + boolean formAccountStatus = checkFormAccountStatus(transactionRecord.getFormBankAccount(), transactionRecord.getMoney()); + if (formAccountStatus) { + Integer result = transactionRecordMapper.transfer(transactionRecord.getFormBankAccount(), transactionRecord.getToBankAccount(), transactionRecord.getMoney()); + if (result > 0) { + transactionRecord.setTransactionNo(nextTransactionNo()); + transactionRecord.setTransactionTime(new Date()); + transactionRecordMapper.insertSelective(transactionRecord); + } + } else { + throw new Exception("余额不足"); + } + return transactionRecord; + } + + @Override + public List findTransactionRecords(String bankAccount) { + return transactionRecordMapper.selectTransactionRecords(bankAccount); + } + + @Override + public TransactionRecord transferByUserId(Integer toUserId, Integer formUserId, BigDecimal money) throws Exception { + BankAccountDTO toBankAccount = bankAccountService.findBankAccountByIdUser(toUserId); + BankAccountDTO formBankAccount = bankAccountService.findBankAccountByIdUser(formUserId); + TransactionRecord transactionRecord = new TransactionRecord(); + transactionRecord.setToBankAccount(toBankAccount.getBankAccount()); + transactionRecord.setFormBankAccount(formBankAccount.getBankAccount()); + transactionRecord.setMoney(money); + transactionRecord.setFunds("赞赏"); + return transfer(transactionRecord); + } + + private String nextTransactionNo() { + String orderNo = "E"; + String key = "orderId"; + int timeout = 60; + //根据时间获取前缀 + String prefix = getPrefix(new Date()); + //使用redis获取自增ID + long id = redisService.incrBy(key, timeout); + return orderNo + prefix + DateUtil.getNowDateNum() + String.format("%1$05d", id); + } + + private static String getPrefix(Date date) { + Calendar c = Calendar.getInstance(); + c.setTime(date); + int year = c.get(Calendar.YEAR); + int day = c.get(Calendar.DAY_OF_YEAR); + int hour = c.get(Calendar.HOUR_OF_DAY); + //天数转为3位字符串,不满3位用0补齐 + String dayFmt = String.format("%1$03d", day); + //小时转为2位字符串,不满2位用0补齐 + String hourFmt = String.format("%1$02d", hour); + //2位年份+3位天数+2位小时 + return (year - 2000) + dayFmt + hourFmt; + } + + private boolean checkFormAccountStatus(String formBankAccount, BigDecimal money) { + BankAccount bankAccount = bankAccountService.findByBankAccount(formBankAccount); + if (Objects.nonNull(bankAccount)) { + if (bankAccount.getAccountBalance().compareTo(money) > 0) { + return true; + } + } + return false; + } +} diff --git a/src/main/java/com/rymcu/forest/util/DateUtil.java b/src/main/java/com/rymcu/forest/util/DateUtil.java new file mode 100644 index 0000000..3da5633 --- /dev/null +++ b/src/main/java/com/rymcu/forest/util/DateUtil.java @@ -0,0 +1,38 @@ +package com.rymcu.forest.util; + +import org.apache.commons.lang.StringUtils; + +import java.util.Calendar; + +/** + * @author ronger + */ +public class DateUtil { + + public static String strLen(String s, int len) { + if (StringUtils.isBlank(s)) { + s = ""; + } + for (int i = 0; i < len - s.length(); ++i) { + s = "0" + s; + } + return s; + } + + public static String getYear(Calendar cal) { + return String.valueOf(cal.get(1)); + } + + public static String getMonth(Calendar cal) { + return strLen(String.valueOf(cal.get(2) + 1), 2); + } + + public static String getDay(Calendar cal) { + return strLen(String.valueOf(cal.get(5)), 2); + } + + public static String getNowDateNum() { + Calendar cal = Calendar.getInstance(); + return getYear(cal) + getMonth(cal) + getDay(cal); + } +} diff --git a/src/main/java/com/rymcu/forest/util/FileUtils.java b/src/main/java/com/rymcu/forest/util/FileUtils.java index 7d87994..c0ed2b7 100644 --- a/src/main/java/com/rymcu/forest/util/FileUtils.java +++ b/src/main/java/com/rymcu/forest/util/FileUtils.java @@ -7,180 +7,178 @@ import org.springframework.web.multipart.MultipartFile; import java.io.*; import java.net.URLEncoder; +import java.util.Arrays; /** * 文件操作工具类 - * @author 张代浩 * + * @author 张代浩 */ public class FileUtils { - private static final Logger logger = LoggerFactory.getLogger(FileUtils.class); - /** - * 获取文件扩展名 - * - * @param filename - * @return - */ - public static String getExtend(String filename) { - return getExtend(filename, ""); - } + private static final Logger logger = LoggerFactory.getLogger(FileUtils.class); - /** - * 获取文件扩展名 - * - * @param filename - * @return - */ - public static String getExtend(String filename, String defExt) { - if ((filename != null) && (filename.length() > 0)) { - int i = filename.lastIndexOf('.'); + /** + * 获取文件扩展名 + * + * @param filename + * @return + */ + public static String getExtend(String filename) { + return getExtend(filename, ""); + } - if ((i > 0) && (i < (filename.length() - 1))) { - return (filename.substring(i+1)).toLowerCase(); - } - } - return defExt.toLowerCase(); - } + /** + * 获取文件扩展名 + * + * @param filename + * @return + */ + public static String getExtend(String filename, String defExt) { + if ((filename != null) && (filename.length() > 0)) { + int i = filename.lastIndexOf('.'); - /** - * 获取文件名称[不含后缀名] - * - * @param - * @return String - */ - public static String getFilePrefix(String fileName) { - int splitIndex = fileName.lastIndexOf("."); - return fileName.substring(0, splitIndex).replaceAll("\\s*", ""); - } - - /** - * 获取文件名称[不含后缀名] - * 不去掉文件目录的空格 - * @param - * @return String - */ - public static String getFilePrefix2(String fileName) { - int splitIndex = fileName.lastIndexOf("."); - return fileName.substring(0, splitIndex); - } - - /** - * 文件复制 - *方法摘要:这里一句话描述方法的用途 - *@param - *@return void - */ - public static void copyFile(String inputFile,String outputFile) throws FileNotFoundException{ - File sFile = new File(inputFile); - File tFile = new File(outputFile); - FileInputStream fis = new FileInputStream(sFile); - FileOutputStream fos = new FileOutputStream(tFile); - int temp = 0; - byte[] buf = new byte[10240]; - try { - while((temp = fis.read(buf))!=-1){ - fos.write(buf, 0, temp); - } - } catch (IOException e) { - e.printStackTrace(); - } finally{ + if ((i > 0) && (i < (filename.length() - 1))) { + return (filename.substring(i + 1)).toLowerCase(); + } + } + return defExt.toLowerCase(); + } + + /** + * 获取文件名称[不含后缀名] + * + * @param + * @return String + */ + public static String getFilePrefix(String fileName) { + int splitIndex = fileName.lastIndexOf("."); + return fileName.substring(0, splitIndex).replaceAll("\\s*", ""); + } + + /** + * 获取文件名称[不含后缀名] + * 不去掉文件目录的空格 + * + * @param + * @return String + */ + public static String getFilePrefix2(String fileName) { + int splitIndex = fileName.lastIndexOf("."); + return fileName.substring(0, splitIndex); + } + + /** + * 文件复制 + * 方法摘要:这里一句话描述方法的用途 + * + * @param + * @return void + */ + public static void copyFile(String inputFile, String outputFile) throws FileNotFoundException { + File sFile = new File(inputFile); + File tFile = new File(outputFile); + FileInputStream fis = new FileInputStream(sFile); + FileOutputStream fos = new FileOutputStream(tFile); + int temp = 0; + byte[] buf = new byte[10240]; + try { + while ((temp = fis.read(buf)) != -1) { + fos.write(buf, 0, temp); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { try { - fis.close(); - fos.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - /** - * 判断文件是否为图片
- *
- * - * @param filename - * 文件名
- * 判断具体文件类型
- * @return 检查后的结果
- * @throws Exception - */ - public static boolean isPicture(String filename) { - // 文件名称为空的场合 - if (StringUtils.isBlank(filename)) { - // 返回不和合法 - return false; - } - // 获得文件后缀名 - //String tmpName = getExtend(filename); - String tmpName = filename; - // 声明图片后缀名数组 - String imgeArray[][] = { { "bmp", "0" }, { "dib", "1" }, - { "gif", "2" }, { "jfif", "3" }, { "jpe", "4" }, - { "jpeg", "5" }, { "jpg", "6" }, { "png", "7" }, - { "tif", "8" }, { "tiff", "9" }, { "ico", "10" } }; - // 遍历名称数组 - for (int i = 0; i < imgeArray.length; i++) { - // 判断单个类型文件的场合 - if (imgeArray[i][0].equals(tmpName.toLowerCase())) { - return true; - } - } - return false; - } + fis.close(); + fos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } - /** - * 判断文件是否为DWG
- *
- * - * @param filename - * 文件名
- * 判断具体文件类型
- * @return 检查后的结果
- * @throws Exception - */ - public static boolean isDwg(String filename) { - // 文件名称为空的场合 - if (oConvertUtils.isEmpty(filename)) { - // 返回不和合法 - return false; - } - // 获得文件后缀名 - String tmpName = getExtend(filename); - // 声明图片后缀名数组 - if (tmpName.equals("dwg")) { - return true; - } - return false; - } - - /** - * 删除指定的文件 - * - * @param strFileName - * 指定绝对路径的文件名 - * @return 如果删除成功true否则false - */ - public static boolean delete(String strFileName) { - File fileDelete = new File(strFileName); + /** + * 判断文件是否为图片
+ *
+ * + * @param filename 文件名
+ * 判断具体文件类型
+ * @return 检查后的结果
+ * @throws Exception + */ + public static boolean isPicture(String filename) { + // 文件名称为空的场合 + if (StringUtils.isBlank(filename)) { + // 返回不和合法 + return false; + } + // 获得文件后缀名 + //String tmpName = getExtend(filename); + String tmpName = filename; + // 声明图片后缀名数组 + String[] imageArray = {"bmp", "dib", "gif", "jfif", "jpe", + "jpeg", "jpg", "png", "tif", "tiff", "ico"}; + // 遍历名称数组 + for (String s : imageArray) { + if (s.equals(tmpName)) { + return true; + } + } + return false; + } - if (!fileDelete.exists() || !fileDelete.isFile()) { - logger.info("错误: " + strFileName + "不存在!"); - return false; - } + /** + * 判断文件是否为DWG
+ *
+ * + * @param filename 文件名
+ * 判断具体文件类型
+ * @return 检查后的结果
+ * @throws Exception + */ + public static boolean isDwg(String filename) { + // 文件名称为空的场合 + if (StringUtils.isEmpty(filename)) { + // 返回不和合法 + return false; + } + // 获得文件后缀名 + String tmpName = getExtend(filename); + // 声明图片后缀名数组 + if ("dwg".equals(tmpName)) { + return true; + } + return false; + } - //LogUtil.info("--------成功删除文件---------"+strFileName); - return fileDelete.delete(); - } - - /** - * - * @Title: encodingFileName 2015-11-26 huangzq add - * @Description: 防止文件名中文乱码含有空格时%20 - * @param @param fileName - * @param @return 设定文件 - * @return String 返回类型 - * @throws - */ - public static String encodingFileName(String fileName) { + /** + * 删除指定的文件 + * + * @param strFileName 指定绝对路径的文件名 + * @return 如果删除成功true否则false + */ + public static boolean delete(String strFileName) { + File fileDelete = new File(strFileName); + + if (!fileDelete.exists() || !fileDelete.isFile()) { + logger.info("错误: " + strFileName + "不存在!"); + return false; + } + + //LogUtil.info("--------成功删除文件---------"+strFileName); + return fileDelete.delete(); + } + + /** + * @param @param fileName + * @param @return 设定文件 + * @return String 返回类型 + * @throws + * @Title: encodingFileName 2015-11-26 huangzq add + * @Description: 防止文件名中文乱码含有空格时%20 + */ + public static String encodingFileName(String fileName) { String returnFileName = ""; try { returnFileName = URLEncoder.encode(fileName, "UTF-8"); @@ -198,67 +196,69 @@ public class FileUtils { /** * 根据现有路径获取SWF文件名称 + * * @author taoYan * @since 2018年7月26日 */ - public static String getSwfPath(String path){ - String leftSlash = "/"; - if(!File.separator.equals(leftSlash)){ - path = path.replace(File.separator,leftSlash); - } - String fileDir = path.substring(0,path.lastIndexOf(leftSlash)+1);//文件目录带/ - int pointPosition = path.lastIndexOf("."); - String fileName = path.substring(path.lastIndexOf(leftSlash)+1,pointPosition);//文件名不带后缀 - String swfName = "";//PinyinUtil.getPinYinHeadChar(fileName);// 取文件名首字母作为SWF文件名 - return fileDir+swfName+".swf"; + public static String getSwfPath(String path) { + String leftSlash = "/"; + if (!File.separator.equals(leftSlash)) { + path = path.replace(File.separator, leftSlash); + } + String fileDir = path.substring(0, path.lastIndexOf(leftSlash) + 1);//文件目录带/ + int pointPosition = path.lastIndexOf("."); + String fileName = path.substring(path.lastIndexOf(leftSlash) + 1, pointPosition);//文件名不带后缀 + String swfName = "";//PinyinUtil.getPinYinHeadChar(fileName);// 取文件名首字母作为SWF文件名 + return fileDir + swfName + ".swf"; } - + /** * 上传txt文件,防止乱码 + * * @author taoYan * @since 2018年7月26日 */ - public static void uploadTxtFile(MultipartFile mf, String savePath) throws IOException{ - //利用utf-8字符集的固定首行隐藏编码原理 - //Unicode:FF FE UTF-8:EF BB - byte[] allbytes = mf.getBytes(); - try{ - String head1 = toHexString(allbytes[0]); - //System.out.println(head1); - String head2 = toHexString(allbytes[1]); - //System.out.println(head2); - if("ef".equals(head1) && "bb".equals(head2)){ - //UTF-8 - String contents = new String(mf.getBytes(),"UTF-8"); - if(StringUtils.isNotBlank(contents)){ - OutputStream out = new FileOutputStream(savePath); - out.write(contents.getBytes()); - out.close(); - } - } else { + public static void uploadTxtFile(MultipartFile mf, String savePath) throws IOException { + //利用utf-8字符集的固定首行隐藏编码原理 + //Unicode:FF FE UTF-8:EF BB + byte[] allbytes = mf.getBytes(); + try { + String head1 = toHexString(allbytes[0]); + //System.out.println(head1); + String head2 = toHexString(allbytes[1]); + //System.out.println(head2); + if ("ef".equals(head1) && "bb".equals(head2)) { + //UTF-8 + String contents = new String(mf.getBytes(), "UTF-8"); + if (StringUtils.isNotBlank(contents)) { + OutputStream out = new FileOutputStream(savePath); + out.write(contents.getBytes()); + out.close(); + } + } else { - //GBK - String contents = new String(mf.getBytes(),"GBK"); - OutputStream out = new FileOutputStream(savePath); - out.write(contents.getBytes()); - out.close(); + //GBK + String contents = new String(mf.getBytes(), "GBK"); + OutputStream out = new FileOutputStream(savePath); + out.write(contents.getBytes()); + out.close(); - } - } catch(Exception e){ - String contents = new String(mf.getBytes(),"UTF-8"); - if(StringUtils.isNotBlank(contents)){ - OutputStream out = new FileOutputStream(savePath); - out.write(contents.getBytes()); - out.close(); - } - } + } + } catch (Exception e) { + String contents = new String(mf.getBytes(), "UTF-8"); + if (StringUtils.isNotBlank(contents)) { + OutputStream out = new FileOutputStream(savePath); + out.write(contents.getBytes()); + out.close(); + } + } } - - public static String toHexString(int index){ - String hexString = Integer.toHexString(index); + + public static String toHexString(int index) { + String hexString = Integer.toHexString(index); // 1个byte变成16进制的,只需要2位就可以表示了,取后面两位,去掉前面的符号填充 - hexString = hexString.substring(hexString.length() -2); + hexString = hexString.substring(hexString.length() - 2); return hexString; - } + } } diff --git a/src/main/java/com/rymcu/forest/util/HttpUtils.java b/src/main/java/com/rymcu/forest/util/HttpUtils.java new file mode 100644 index 0000000..7425c32 --- /dev/null +++ b/src/main/java/com/rymcu/forest/util/HttpUtils.java @@ -0,0 +1,34 @@ +package com.rymcu.forest.util; + +import com.alibaba.fastjson.JSON; +import jodd.http.HttpRequest; +import jodd.http.HttpResponse; + +import java.util.Map; + +/** + * @author ronger + */ +public class HttpUtils { + + public static String sendGet(String url) { + HttpRequest request = HttpRequest.get(url); + HttpResponse response = request.send(); + return response.bodyText(); + } + + public static String sendPost(String url, Map params) { + HttpRequest request = HttpRequest.post(url); + request.contentType("application/json"); + request.charset("utf-8"); + + //参数详情 + if (params != null) { + request.body(JSON.toJSONString(params)); + } + + HttpResponse response = request.send(); + String respJson = response.bodyText(); + return respJson; + } +} diff --git a/src/main/java/com/rymcu/forest/util/UserUtils.java b/src/main/java/com/rymcu/forest/util/UserUtils.java index 9441268..6899270 100644 --- a/src/main/java/com/rymcu/forest/util/UserUtils.java +++ b/src/main/java/com/rymcu/forest/util/UserUtils.java @@ -6,13 +6,15 @@ import com.rymcu.forest.jwt.def.JwtConstants; import com.rymcu.forest.jwt.model.TokenModel; import com.rymcu.forest.jwt.service.TokenManager; import com.rymcu.forest.mapper.UserMapper; -import com.rymcu.forest.web.api.exception.ErrorCode; import com.rymcu.forest.web.api.exception.BaseApiException; +import com.rymcu.forest.web.api.exception.ErrorCode; import io.jsonwebtoken.Claims; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureException; import org.apache.commons.lang.StringUtils; +import java.util.Objects; + /** * @author ronger */ @@ -31,14 +33,14 @@ public class UserUtils { return null; } // 验证token - Claims claims = null; + Claims claims; try { claims = Jwts.parser().setSigningKey(JwtConstants.JWT_SECRET).parseClaimsJws(authHeader).getBody(); } catch (final SignatureException e) { throw new BaseApiException(ErrorCode.UNAUTHORIZED); } Object account = claims.getId(); - if (!oConvertUtils.isEmpty(account)) { + if (StringUtils.isNotBlank(Objects.toString(account, ""))) { TokenModel model = tokenManager.getToken(authHeader, account.toString()); if (tokenManager.checkToken(model)) { return userMapper.findByAccount(account.toString()); @@ -52,14 +54,14 @@ public class UserUtils { public static TokenUser getTokenUser(String token) { if(StringUtils.isNotBlank(token)){ // 验证token - Claims claims = null; + Claims claims; try { claims = Jwts.parser().setSigningKey(JwtConstants.JWT_SECRET).parseClaimsJws(token).getBody(); } catch (final SignatureException e) { return null; } Object account = claims.getId(); - if (!oConvertUtils.isEmpty(account)) { + if (StringUtils.isNotBlank(Objects.toString(account, ""))) { TokenModel model = tokenManager.getToken(token, account.toString()); if (tokenManager.checkToken(model)) { User user = userMapper.findByAccount(account.toString()); diff --git a/src/main/java/com/rymcu/forest/util/Utils.java b/src/main/java/com/rymcu/forest/util/Utils.java index 2cd80da..99db051 100644 --- a/src/main/java/com/rymcu/forest/util/Utils.java +++ b/src/main/java/com/rymcu/forest/util/Utils.java @@ -130,10 +130,7 @@ public class Utils { } public static void main(String[] args){ - LocalDate localDate = LocalDate.parse("2019-11-15"); - ZoneId zone = ZoneId.systemDefault(); - Instant instant = localDate.atStartOfDay().atZone(zone).toInstant(); - String s = getTimeAgo(Date.from(instant)); + String s = entryptPassword("admin"); System.out.println(s); } diff --git a/src/main/java/com/rymcu/forest/util/oConvertUtils.java b/src/main/java/com/rymcu/forest/util/oConvertUtils.java deleted file mode 100644 index 782922b..0000000 --- a/src/main/java/com/rymcu/forest/util/oConvertUtils.java +++ /dev/null @@ -1,499 +0,0 @@ -package com.rymcu.forest.util; - -import org.apache.commons.lang.StringEscapeUtils; -import org.apache.commons.lang.StringUtils; - -import javax.servlet.http.HttpServletRequest; -import java.io.UnsupportedEncodingException; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.net.SocketException; -import java.net.UnknownHostException; -import java.sql.Date; -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * - * @author 张代浩 - * - */ -public class oConvertUtils { - public static boolean isEmpty(Object object) { - if (object == null) { - return (true); - } - if (object.equals("")) { - return (true); - } - if (object.equals("null")) { - return (true); - } - return (false); - } - - public static boolean isNotEmpty(Object object) { - if (object != null && !object.equals("") && !object.equals("null")) { - return (true); - } - return (false); - } - - public static String decode(String strIn, String sourceCode, String targetCode) { - String temp = code2code(strIn, sourceCode, targetCode); - return temp; - } - - public static String StrToUTF(String strIn, String sourceCode, String targetCode) { - strIn = ""; - try { - strIn = new String(strIn.getBytes("ISO-8859-1"), "GBK"); - } catch (UnsupportedEncodingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return strIn; - - } - - private static String code2code(String strIn, String sourceCode, String targetCode) { - String strOut = null; - if (strIn == null || (strIn.trim()).equals("")) { - return strIn; - } - try { - byte[] b = strIn.getBytes(sourceCode); - for (int i = 0; i < b.length; i++) { - System.out.print(b[i] + " "); - } - strOut = new String(b, targetCode); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - return strOut; - } - - public static int getInt(String s, int defval) { - if (s == null || s == "") { - return (defval); - } - try { - return (Integer.parseInt(s)); - } catch (NumberFormatException e) { - return (defval); - } - } - - public static int getInt(String s) { - if (s == null || s == "") { - return 0; - } - try { - return (Integer.parseInt(s)); - } catch (NumberFormatException e) { - return 0; - } - } - - public static int getInt(String s, Integer df) { - if (s == null || s == "") { - return df; - } - try { - return (Integer.parseInt(s)); - } catch (NumberFormatException e) { - return 0; - } - } - - public static Integer[] getInts(String[] s) { - Integer[] integer = new Integer[s.length]; - if (s == null) { - return null; - } - for (int i = 0; i < s.length; i++) { - integer[i] = Integer.parseInt(s[i]); - } - return integer; - - } - - public static double getDouble(String s, double defval) { - if (s == null || s == "") { - return (defval); - } - try { - return (Double.parseDouble(s)); - } catch (NumberFormatException e) { - return (defval); - } - } - - public static double getDou(Double s, double defval) { - if (s == null) { - return (defval); - } - return s; - } - - public static Short getShort(String s) { - if (StringUtils.isNotEmpty(s)) { - return (Short.parseShort(s)); - } else { - return null; - } - } - - public static int getInt(Object object, int defval) { - if (isEmpty(object)) { - return (defval); - } - try { - return (Integer.parseInt(object.toString())); - } catch (NumberFormatException e) { - return (defval); - } - } - - public static int getInt(BigDecimal s, int defval) { - if (s == null) { - return (defval); - } - return s.intValue(); - } - - public static Integer[] getIntegerArry(String[] object) { - int len = object.length; - Integer[] result = new Integer[len]; - try { - for (int i = 0; i < len; i++) { - result[i] = new Integer(object[i].trim()); - } - return result; - } catch (NumberFormatException e) { - return null; - } - } - - public static String getString(String s) { - return (getString(s, "")); - } - - /** - * 转义成Unicode编码 - * @param s - * @return - */ - public static String escapeJava(Object s) { - return StringEscapeUtils.escapeJava(getString(s)); - } - - public static String getString(Object object) { - if (isEmpty(object)) { - return ""; - } - return (object.toString().trim()); - } - - public static String getString(int i) { - return (String.valueOf(i)); - } - - public static String getString(float i) { - return (String.valueOf(i)); - } - - public static String getString(String s, String defval) { - if (isEmpty(s)) { - return (defval); - } - return (s.trim()); - } - - public static String getString(Object s, String defval) { - if (isEmpty(s)) { - return (defval); - } - return (s.toString().trim()); - } - - public static long stringToLong(String str) { - Long test = new Long(0); - try { - test = Long.valueOf(str); - } catch (Exception e) { - } - return test.longValue(); - } - - /** - * 获取本机IP - */ - public static String getIp() { - String ip = null; - try { - InetAddress address = InetAddress.getLocalHost(); - ip = address.getHostAddress(); - - } catch (UnknownHostException e) { - e.printStackTrace(); - } - return ip; - } - - /** - * 判断一个类是否为基本数据类型。 - * - * @param clazz - * 要判断的类。 - * @return true 表示为基本数据类型。 - */ - private static boolean isBaseDataType(Class clazz) throws Exception { - return (clazz.equals(String.class) || clazz.equals(Integer.class) || clazz.equals(Byte.class) || clazz.equals(Long.class) || clazz.equals(Double.class) || clazz.equals(Float.class) || clazz.equals(Character.class) || clazz.equals(Short.class) || clazz.equals(BigDecimal.class) || clazz.equals(BigInteger.class) || clazz.equals(Boolean.class) || clazz.equals(Date.class) || clazz.isPrimitive()); - } - - /** - * @param request - * IP - * @return IP Address - */ - public static String getIpAddrByRequest(HttpServletRequest request) { - String ip = request.getHeader("x-forwarded-for"); - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { - ip = request.getHeader("Proxy-Client-IP"); - } - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { - ip = request.getHeader("WL-Proxy-Client-IP"); - } - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { - ip = request.getRemoteAddr(); - } - return ip; - } - - /** - * @return 本机IP - * @throws SocketException - */ - public static String getRealIp() throws SocketException { - String localip = null;// 本地IP,如果没有配置外网IP则返回它 - String netip = null;// 外网IP - - Enumeration netInterfaces = NetworkInterface.getNetworkInterfaces(); - InetAddress ip = null; - boolean finded = false;// 是否找到外网IP - while (netInterfaces.hasMoreElements() && !finded) { - NetworkInterface ni = netInterfaces.nextElement(); - Enumeration address = ni.getInetAddresses(); - while (address.hasMoreElements()) { - ip = address.nextElement(); - if (!ip.isSiteLocalAddress() && !ip.isLoopbackAddress() && ip.getHostAddress().indexOf(":") == -1) {// 外网IP - netip = ip.getHostAddress(); - finded = true; - break; - } else if (ip.isSiteLocalAddress() && !ip.isLoopbackAddress() && ip.getHostAddress().indexOf(":") == -1) {// 内网IP - localip = ip.getHostAddress(); - } - } - } - - if (netip != null && !"".equals(netip)) { - return netip; - } else { - return localip; - } - } - - /** - * java去除字符串中的空格、回车、换行符、制表符 - * - * @param str - * @return - */ - public static String replaceBlank(String str) { - String dest = ""; - if (str != null) { - Pattern p = Pattern.compile("\\s*|\t|\r|\n"); - Matcher m = p.matcher(str); - dest = m.replaceAll(""); - } - return dest; - - } - - /** - * 判断元素是否在数组内 - * - * @param substring - * @param source - * @return - */ - public static boolean isIn(String substring, String[] source) { - if (source == null || source.length == 0) { - return false; - } - for (int i = 0; i < source.length; i++) { - String aSource = source[i]; - if (aSource.equals(substring)) { - return true; - } - } - return false; - } - - /** - * 获取Map对象 - */ - public static Map getHashMap() { - return new HashMap(); - } - - /** - * SET转换MAP - * - * @param str - * @return - */ - public static Map SetToMap(Set setobj) { - Map map = getHashMap(); - for (Iterator iterator = setobj.iterator(); iterator.hasNext();) { - Map.Entry entry = (Map.Entry) iterator.next(); - map.put(entry.getKey().toString(), entry.getValue() == null ? "" : entry.getValue().toString().trim()); - } - return map; - - } - - public static boolean isInnerIP(String ipAddress) { - boolean isInnerIp = false; - long ipNum = getIpNum(ipAddress); - /** - * 私有IP:A类 10.0.0.0-10.255.255.255 B类 172.16.0.0-172.31.255.255 C类 192.168.0.0-192.168.255.255 当然,还有127这个网段是环回地址 - **/ - long aBegin = getIpNum("10.0.0.0"); - long aEnd = getIpNum("10.255.255.255"); - long bBegin = getIpNum("172.16.0.0"); - long bEnd = getIpNum("172.31.255.255"); - long cBegin = getIpNum("192.168.0.0"); - long cEnd = getIpNum("192.168.255.255"); - isInnerIp = isInner(ipNum, aBegin, aEnd) || isInner(ipNum, bBegin, bEnd) || isInner(ipNum, cBegin, cEnd) || ipAddress.equals("127.0.0.1"); - return isInnerIp; - } - - private static long getIpNum(String ipAddress) { - String[] ip = ipAddress.split("\\."); - long a = Integer.parseInt(ip[0]); - long b = Integer.parseInt(ip[1]); - long c = Integer.parseInt(ip[2]); - long d = Integer.parseInt(ip[3]); - - long ipNum = a * 256 * 256 * 256 + b * 256 * 256 + c * 256 + d; - return ipNum; - } - - private static boolean isInner(long userIp, long begin, long end) { - return (userIp >= begin) && (userIp <= end); - } - - /** - * 将下划线大写方式命名的字符串转换为驼峰式。 - * 如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。
- * 例如:hello_world->helloWorld - * - * @param name - * 转换前的下划线大写方式命名的字符串 - * @return 转换后的驼峰式命名的字符串 - */ - public static String camelName(String name) { - StringBuilder result = new StringBuilder(); - // 快速检查 - if (name == null || name.isEmpty()) { - // 没必要转换 - return ""; - } else if (!name.contains("_")) { - // 不含下划线,仅将首字母小写 - - return name.substring(0, 1).toLowerCase() + name.substring(1).toLowerCase(); - - } - // 用下划线将原始字符串分割 - String camels[] = name.split("_"); - for (String camel : camels) { - // 跳过原始字符串中开头、结尾的下换线或双重下划线 - if (camel.isEmpty()) { - continue; - } - // 处理真正的驼峰片段 - if (result.length() == 0) { - // 第一个驼峰片段,全部字母都小写 - result.append(camel.toLowerCase()); - } else { - // 其他的驼峰片段,首字母大写 - result.append(camel.substring(0, 1).toUpperCase()); - result.append(camel.substring(1).toLowerCase()); - } - } - return result.toString(); - } - - /** - * 将下划线大写方式命名的字符串转换为驼峰式。 - * 如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。
- * 例如:hello_world,test_id->helloWorld,testId - * - * @param names - * 转换前的下划线大写方式命名的字符串 - * @return 转换后的驼峰式命名的字符串 - */ - public static String camelNames(String names) { - if(names==null||names.equals("")){ - return null; - } - StringBuffer sf = new StringBuffer(); - String[] fs = names.split(","); - for (String field : fs) { - field = camelName(field); - sf.append(field + ","); - } - String result = sf.toString(); - return result.substring(0, result.length() - 1); - } - - /** - * 将下划线大写方式命名的字符串转换为驼峰式。(首字母写) - * 如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。
- * 例如:hello_world->HelloWorld - * - * @param name - * 转换前的下划线大写方式命名的字符串 - * @return 转换后的驼峰式命名的字符串 - */ - public static String camelNameCapFirst(String name) { - StringBuilder result = new StringBuilder(); - // 快速检查 - if (name == null || name.isEmpty()) { - // 没必要转换 - return ""; - } else if (!name.contains("_")) { - // 不含下划线,仅将首字母小写 - return name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase(); - } - // 用下划线将原始字符串分割 - String camels[] = name.split("_"); - for (String camel : camels) { - // 跳过原始字符串中开头、结尾的下换线或双重下划线 - if (camel.isEmpty()) { - continue; - } - // 其他的驼峰片段,首字母大写 - result.append(camel.substring(0, 1).toUpperCase()); - result.append(camel.substring(1).toLowerCase()); - } - return result.toString(); - } - -} diff --git a/src/main/java/com/rymcu/forest/web/api/admin/AdminController.java b/src/main/java/com/rymcu/forest/web/api/admin/AdminController.java index 6dee51a..69cc224 100644 --- a/src/main/java/com/rymcu/forest/web/api/admin/AdminController.java +++ b/src/main/java/com/rymcu/forest/web/api/admin/AdminController.java @@ -18,6 +18,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import static java.util.Comparator.comparing; + /** * @author ronger * */ @@ -40,6 +42,8 @@ public class AdminController { public GlobalResult> users(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){ PageHelper.startPage(page, rows); List list = userService.findAll(); + // 按最后登录时间进行倒序排序 + list.sort(comparing(User::getLastLoginTime).reversed()); PageInfo pageInfo = new PageInfo<>(list); Map map = new HashMap(2); map.put("users", pageInfo.getList()); diff --git a/src/main/java/com/rymcu/forest/web/api/article/ArticleController.java b/src/main/java/com/rymcu/forest/web/api/article/ArticleController.java index 118bf38..32c7526 100644 --- a/src/main/java/com/rymcu/forest/web/api/article/ArticleController.java +++ b/src/main/java/com/rymcu/forest/web/api/article/ArticleController.java @@ -7,8 +7,12 @@ import com.rymcu.forest.core.result.GlobalResultGenerator; import com.rymcu.forest.dto.ArticleDTO; import com.rymcu.forest.dto.CommentDTO; import com.rymcu.forest.entity.Article; +import com.rymcu.forest.entity.ArticleThumbsUp; +import com.rymcu.forest.entity.Sponsor; import com.rymcu.forest.service.ArticleService; +import com.rymcu.forest.service.ArticleThumbsUpService; import com.rymcu.forest.service.CommentService; +import com.rymcu.forest.service.SponsorService; import com.rymcu.forest.util.Utils; import com.rymcu.forest.web.api.exception.BaseApiException; import org.springframework.web.bind.annotation.*; @@ -31,10 +35,14 @@ public class ArticleController { private ArticleService articleService; @Resource private CommentService commentService; + @Resource + private ArticleThumbsUpService articleThumbsUpService; + @Resource + private SponsorService sponsorService; @GetMapping("/detail/{id}") - public GlobalResult> detail(@PathVariable Integer id, @RequestParam(defaultValue = "2") Integer type){ - ArticleDTO articleDTO = articleService.findArticleDTOById(id,type); + public GlobalResult> detail(@PathVariable Integer id, @RequestParam(defaultValue = "2") Integer type) { + ArticleDTO articleDTO = articleService.findArticleDTOById(id, type); Map map = new HashMap<>(1); map.put("article", articleDTO); return GlobalResultGenerator.genSuccessResult(map); @@ -42,24 +50,24 @@ public class ArticleController { @PostMapping("/post") public GlobalResult postArticle(@RequestBody ArticleDTO article, HttpServletRequest request) throws BaseApiException, UnsupportedEncodingException { - Map map = articleService.postArticle(article,request); + Map map = articleService.postArticle(article, request); return GlobalResultGenerator.genSuccessResult(map); } @PutMapping("/post") public GlobalResult updateArticle(@RequestBody ArticleDTO article, HttpServletRequest request) throws BaseApiException, UnsupportedEncodingException { - Map map = articleService.postArticle(article,request); + Map map = articleService.postArticle(article, request); return GlobalResultGenerator.genSuccessResult(map); } @DeleteMapping("/delete/{id}") - public GlobalResult delete(@PathVariable Integer id){ + public GlobalResult delete(@PathVariable Integer id) { Map map = articleService.delete(id); return GlobalResultGenerator.genSuccessResult(map); } @GetMapping("/{id}/comments") - public GlobalResult> commons(@PathVariable Integer id){ + public GlobalResult> commons(@PathVariable Integer id) { List commentDTOList = commentService.getArticleComments(id); Map map = new HashMap<>(1); map.put("comments", commentDTOList); @@ -87,4 +95,22 @@ public class ArticleController { return GlobalResultGenerator.genSuccessResult(map); } + @PatchMapping("/update-perfect") + public GlobalResult updatePerfect(@RequestBody Article article) { + Map map = articleService.updatePerfect(article.getIdArticle(), article.getArticlePerfect()); + return GlobalResultGenerator.genSuccessResult(map); + } + + @PostMapping("/thumbs-up") + public GlobalResult thumbsUp(@RequestBody ArticleThumbsUp articleThumbsUp) throws BaseApiException { + Map map = articleThumbsUpService.thumbsUp(articleThumbsUp); + return GlobalResultGenerator.genSuccessResult(map); + } + + @PostMapping("/sponsor") + public GlobalResult sponsor(@RequestBody Sponsor sponsor) throws Exception { + Map map = sponsorService.sponsorship(sponsor); + return GlobalResultGenerator.genSuccessResult(map); + } + } diff --git a/src/main/java/com/rymcu/forest/web/api/bank/BankAccountController.java b/src/main/java/com/rymcu/forest/web/api/bank/BankAccountController.java new file mode 100644 index 0000000..acfacbf --- /dev/null +++ b/src/main/java/com/rymcu/forest/web/api/bank/BankAccountController.java @@ -0,0 +1,52 @@ +package com.rymcu.forest.web.api.bank; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.rymcu.forest.core.result.GlobalResult; +import com.rymcu.forest.core.result.GlobalResultGenerator; +import com.rymcu.forest.dto.ArticleDTO; +import com.rymcu.forest.dto.BankAccountDTO; +import com.rymcu.forest.dto.BankAccountSearchDTO; +import com.rymcu.forest.entity.Bank; +import com.rymcu.forest.entity.BankAccount; +import com.rymcu.forest.service.BankAccountService; +import com.rymcu.forest.service.BankService; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author ronger + */ +@RestController +@RequestMapping("/api/v1/admin/bank-account") +public class BankAccountController { + + @Resource + private BankAccountService bankAccountService; + + @GetMapping("/list") + public GlobalResult banks(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, BankAccountSearchDTO bankAccountSearchDTO) { + PageHelper.startPage(page, rows); + List list = bankAccountService.findBankAccounts(bankAccountSearchDTO); + PageInfo pageInfo = new PageInfo(list); + Map map = new HashMap(2); + map.put("bankAccounts", pageInfo.getList()); + Map pagination = new HashMap(4); + pagination.put("pageSize", pageInfo.getPageSize()); + pagination.put("total", pageInfo.getTotal()); + pagination.put("currentPage", pageInfo.getPageNum()); + map.put("pagination", pagination); + return GlobalResultGenerator.genSuccessResult(map); + } + + @GetMapping("/{idUser}") + public GlobalResult detail(@PathVariable Integer idUser) { + BankAccountDTO bankAccount = bankAccountService.findBankAccountByIdUser(idUser); + return GlobalResultGenerator.genSuccessResult(bankAccount); + } + +} diff --git a/src/main/java/com/rymcu/forest/web/api/bank/BankController.java b/src/main/java/com/rymcu/forest/web/api/bank/BankController.java new file mode 100644 index 0000000..6dda2de --- /dev/null +++ b/src/main/java/com/rymcu/forest/web/api/bank/BankController.java @@ -0,0 +1,47 @@ +package com.rymcu.forest.web.api.bank; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.rymcu.forest.core.result.GlobalResult; +import com.rymcu.forest.core.result.GlobalResultGenerator; +import com.rymcu.forest.dto.ArticleDTO; +import com.rymcu.forest.dto.BankDTO; +import com.rymcu.forest.entity.Bank; +import com.rymcu.forest.service.BankService; +import com.rymcu.forest.util.Utils; +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.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author ronger + */ +@RestController +@RequestMapping("/api/v1/admin/bank") +public class BankController { + + @Resource + private BankService bankService; + + @GetMapping("/list") + public GlobalResult banks(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) { + PageHelper.startPage(page, rows); + List list = bankService.findBanks(); + PageInfo pageInfo = new PageInfo(list); + Map map = new HashMap(2); + map.put("banks", pageInfo.getList()); + Map pagination = new HashMap(4); + pagination.put("pageSize", pageInfo.getPageSize()); + pagination.put("total", pageInfo.getTotal()); + pagination.put("currentPage", pageInfo.getPageNum()); + map.put("pagination", pagination); + return GlobalResultGenerator.genSuccessResult(map); + } + +} diff --git a/src/main/java/com/rymcu/forest/web/api/bank/TransactionRecordController.java b/src/main/java/com/rymcu/forest/web/api/bank/TransactionRecordController.java new file mode 100644 index 0000000..2cc999b --- /dev/null +++ b/src/main/java/com/rymcu/forest/web/api/bank/TransactionRecordController.java @@ -0,0 +1,30 @@ +package com.rymcu.forest.web.api.bank; + +import com.rymcu.forest.core.result.GlobalResult; +import com.rymcu.forest.core.result.GlobalResultGenerator; +import com.rymcu.forest.entity.TransactionRecord; +import com.rymcu.forest.service.TransactionRecordService; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * @author ronger + */ +@RestController +@RequestMapping("/api/v1/transaction") +public class TransactionRecordController { + + @Resource + private TransactionRecordService transactionRecordService; + + @PostMapping("/transfer") + public GlobalResult transfer(@RequestBody TransactionRecord transactionRecord) throws Exception { + transactionRecord = transactionRecordService.transfer(transactionRecord); + return GlobalResultGenerator.genSuccessResult(transactionRecord); + } + +} diff --git a/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java b/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java index 715f8de..d9e330a 100644 --- a/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java +++ b/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java @@ -8,10 +8,7 @@ import com.rymcu.forest.core.result.GlobalResultMessage; import com.rymcu.forest.core.service.log.annotation.VisitLogger; import com.rymcu.forest.dto.*; import com.rymcu.forest.entity.User; -import com.rymcu.forest.service.ArticleService; -import com.rymcu.forest.service.JavaMailService; -import com.rymcu.forest.service.PortfolioService; -import com.rymcu.forest.service.UserService; +import com.rymcu.forest.service.*; import com.rymcu.forest.util.UserUtils; import com.rymcu.forest.util.Utils; import org.springframework.web.bind.annotation.*; @@ -37,6 +34,8 @@ public class CommonApiController { private ArticleService articleService; @Resource private PortfolioService portfolioService; + @Resource + private SearchService SearchService; @GetMapping("/get-email-code") public GlobalResult> getEmailCode(@RequestParam("email") String email) throws MessagingException { @@ -135,4 +134,10 @@ public class CommonApiController { Map map = Utils.getArticlesGlobalResult(pageInfo); return GlobalResultGenerator.genSuccessResult(map); } + + @GetMapping("/initial-search") + public GlobalResult initialSearch() { + List list = SearchService.initialSearch(); + return GlobalResultGenerator.genSuccessResult(list); + } } diff --git a/src/main/java/com/rymcu/forest/web/api/rule/CurrencyRuleController.java b/src/main/java/com/rymcu/forest/web/api/rule/CurrencyRuleController.java new file mode 100644 index 0000000..1ecd932 --- /dev/null +++ b/src/main/java/com/rymcu/forest/web/api/rule/CurrencyRuleController.java @@ -0,0 +1,30 @@ +package com.rymcu.forest.web.api.rule; + +import com.rymcu.forest.core.result.GlobalResult; +import com.rymcu.forest.core.result.GlobalResultGenerator; +import com.rymcu.forest.entity.CurrencyRule; +import com.rymcu.forest.service.CurrencyRuleService; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @author ronger + */ +@RestController +@RequestMapping("/api/v1/rule/currency") +public class CurrencyRuleController { + + @Resource + private CurrencyRuleService currencyRuleService; + + @GetMapping("/list") + public GlobalResult list() { + List list = currencyRuleService.findAll(); + return GlobalResultGenerator.genSuccessResult(list); + } + +} diff --git a/src/main/java/mapper/ArticleMapper.xml b/src/main/java/mapper/ArticleMapper.xml index e181ab9..240f694 100644 --- a/src/main/java/mapper/ArticleMapper.xml +++ b/src/main/java/mapper/ArticleMapper.xml @@ -13,11 +13,15 @@ - + + + + + @@ -38,6 +42,9 @@ + + + @@ -56,88 +63,91 @@ - - + + - insert into vertical_article_content (id_article,article_content,article_content_html,created_time,updated_time) + insert into forest_article_content (id_article,article_content,article_content_html,created_time,updated_time) values (#{idArticle},#{articleContent},#{articleContentHtml},sysdate(),sysdate()) - update vertical_article_content set article_content = #{articleContent},article_content_html = #{articleContentHtml},updated_time = sysdate() where id_article = #{idArticle} + update forest_article_content set article_content = #{articleContent},article_content_html = #{articleContentHtml},updated_time = sysdate() where id_article = #{idArticle} - update vertical_article set article_view_count = #{articleViewCount} where id = #{id} + update forest_article set article_view_count = #{articleViewCount} where id = #{id} - update vertical_article set article_tags = #{tags} where id = #{idArticle} + update forest_article set article_tags = #{tags} where id = #{idArticle} - update vertical_article set article_link = #{articleLink}, article_permalink = #{articlePermalink}, article_preview_content = #{articlePreviewContent} where id = #{idArticle} + update forest_article set article_link = #{articleLink}, article_permalink = #{articlePermalink}, article_preview_content = #{articlePreviewContent} where id = #{idArticle} + + + update forest_article set article_perfect = #{articlePerfect} where id = #{idArticle} - delete from vertical_tag_article where id_article = #{id} + delete from forest_tag_article where id_article = #{id} - delete from vertical_tag_article where id = #{idArticleTag} + delete from forest_tag_article where id = #{idArticleTag} - delete from vertical_portfolio_article where id_vertical_article = #{id} + delete from forest_portfolio_article where id_article = #{id} \ No newline at end of file diff --git a/src/main/java/mapper/ArticleThumbsUpMapper.xml b/src/main/java/mapper/ArticleThumbsUpMapper.xml new file mode 100644 index 0000000..ea830cc --- /dev/null +++ b/src/main/java/mapper/ArticleThumbsUpMapper.xml @@ -0,0 +1,7 @@ + + + + + update forest_article set article_thumbs_up_count = article_thumbs_up_count + #{thumbsUpNumber} where id = #{idArticle} + + \ No newline at end of file diff --git a/src/main/java/mapper/BankAccountMapper.xml b/src/main/java/mapper/BankAccountMapper.xml new file mode 100644 index 0000000..2cc2765 --- /dev/null +++ b/src/main/java/mapper/BankAccountMapper.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/mapper/BankMapper.xml b/src/main/java/mapper/BankMapper.xml new file mode 100644 index 0000000..0cee4a1 --- /dev/null +++ b/src/main/java/mapper/BankMapper.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/mapper/CommentMapper.xml b/src/main/java/mapper/CommentMapper.xml index ffb41a9..183286a 100644 --- a/src/main/java/mapper/CommentMapper.xml +++ b/src/main/java/mapper/CommentMapper.xml @@ -35,15 +35,15 @@ - update vertical_comment set comment_sharp_url = #{commentSharpUrl} where id = #{idComment} + update forest_comment set comment_sharp_url = #{commentSharpUrl} where id = #{idComment} \ No newline at end of file diff --git a/src/main/java/mapper/CurrencyRuleMapper.xml b/src/main/java/mapper/CurrencyRuleMapper.xml new file mode 100644 index 0000000..7657e49 --- /dev/null +++ b/src/main/java/mapper/CurrencyRuleMapper.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/main/java/mapper/DashboardMapper.xml b/src/main/java/mapper/DashboardMapper.xml index 4db3f61..0be4881 100644 --- a/src/main/java/mapper/DashboardMapper.xml +++ b/src/main/java/mapper/DashboardMapper.xml @@ -6,45 +6,45 @@ \ No newline at end of file diff --git a/src/main/java/mapper/FollowMapper.xml b/src/main/java/mapper/FollowMapper.xml index 8e82fe5..73a663e 100644 --- a/src/main/java/mapper/FollowMapper.xml +++ b/src/main/java/mapper/FollowMapper.xml @@ -10,15 +10,15 @@ \ No newline at end of file diff --git a/src/main/java/mapper/NotificationMapper.xml b/src/main/java/mapper/NotificationMapper.xml index a6e8dc2..81fa9b0 100644 --- a/src/main/java/mapper/NotificationMapper.xml +++ b/src/main/java/mapper/NotificationMapper.xml @@ -11,18 +11,18 @@ - insert into vertical_notification (id_user, data_type, data_id, data_summary, created_time) values (#{idUser}, #{dataType}, #{dataId}, #{dataSummary}, sysdate()) + insert into forest_notification (id_user, data_type, data_id, data_summary, created_time) values (#{idUser}, #{dataType}, #{dataId}, #{dataSummary}, sysdate()) - update vertical_notification set has_read = '1' where id = #{id} + update forest_notification set has_read = '1' where id = #{id} \ No newline at end of file diff --git a/src/main/java/mapper/PermissionMapper.xml b/src/main/java/mapper/PermissionMapper.xml index d0a9d8f..99f061e 100644 --- a/src/main/java/mapper/PermissionMapper.xml +++ b/src/main/java/mapper/PermissionMapper.xml @@ -10,6 +10,6 @@ \ No newline at end of file diff --git a/src/main/java/mapper/PortfolioMapper.xml b/src/main/java/mapper/PortfolioMapper.xml index d6f24d8..58c6eb9 100644 --- a/src/main/java/mapper/PortfolioMapper.xml +++ b/src/main/java/mapper/PortfolioMapper.xml @@ -19,16 +19,16 @@ - insert into vertical_portfolio_article (id_vertical_portfolio, id_vertical_article, sort_no) values (#{idPortfolio}, #{idArticle}, #{maxSortNo}) + insert into forest_portfolio_article (id_portfolio, id_article, sort_no) values (#{idPortfolio}, #{idArticle}, #{maxSortNo}) - update vertical_portfolio_article set sort_no = #{sortNo} where id_vertical_portfolio = #{idPortfolio} and id_vertical_article = #{idArticle} + update forest_portfolio_article set sort_no = #{sortNo} where id_portfolio = #{idPortfolio} and id_article = #{idArticle} - delete from vertical_portfolio_article where id_vertical_portfolio = #{idPortfolio} and id_vertical_article = #{idArticle} + delete from forest_portfolio_article where id_portfolio = #{idPortfolio} and id_article = #{idArticle} \ No newline at end of file diff --git a/src/main/java/mapper/RoleMapper.xml b/src/main/java/mapper/RoleMapper.xml index 864639b..8b03041 100644 --- a/src/main/java/mapper/RoleMapper.xml +++ b/src/main/java/mapper/RoleMapper.xml @@ -14,17 +14,17 @@ - update vertical_role set status = #{status},updated_time = sysdate() where id = #{idRole} + update forest_role set status = #{status},updated_time = sysdate() where id = #{idRole} - update vertical_role set name = #{name}, input_code = #{inputCode}, weights = #{weights}, updated_time = sysdate() where id = #{idRole} + update forest_role set name = #{name}, input_code = #{inputCode}, weights = #{weights}, updated_time = sysdate() where id = #{idRole} \ No newline at end of file diff --git a/src/main/java/mapper/SearchMapper.xml b/src/main/java/mapper/SearchMapper.xml new file mode 100644 index 0000000..f159899 --- /dev/null +++ b/src/main/java/mapper/SearchMapper.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/mapper/SponsorMapper.xml b/src/main/java/mapper/SponsorMapper.xml new file mode 100644 index 0000000..29e42c4 --- /dev/null +++ b/src/main/java/mapper/SponsorMapper.xml @@ -0,0 +1,7 @@ + + + + + update forest_article set article_sponsor_count = article_sponsor_count + 1 where id = #{idArticle} + + \ No newline at end of file diff --git a/src/main/java/mapper/TagMapper.xml b/src/main/java/mapper/TagMapper.xml index 108f4db..63953f1 100644 --- a/src/main/java/mapper/TagMapper.xml +++ b/src/main/java/mapper/TagMapper.xml @@ -23,24 +23,24 @@ - insert into vertical_tag_article (id_tag,id_article,created_time,updated_time) values (#{idTag},#{idArticle},sysdate(),sysdate()) + insert into forest_tag_article (id_tag,id_article,created_time,updated_time) values (#{idTag},#{idArticle},sysdate(),sysdate()) - insert into vertical_user_tag (id_tag,id_user,type,created_time,updated_time) values (#{idTag},#{idUser},#{type},sysdate(),sysdate()) + insert into forest_user_tag (id_tag,id_user,type,created_time,updated_time) values (#{idTag},#{idUser},#{type},sysdate(),sysdate()) - update vertical_tag set tag_uri = #{tagUri}, tag_icon_path = #{tagIconPath}, tag_status = #{tagStatus}, tag_description = #{tagDescription}, tag_reservation = #{tagReservation} where id = #{idTag} + update forest_tag set tag_uri = #{tagUri}, tag_icon_path = #{tagIconPath}, tag_status = #{tagStatus}, tag_description = #{tagDescription}, tag_reservation = #{tagReservation} where id = #{idTag} - delete from vertical_tag where tag_reservation = 0 and id not in (select * from (select id_tag from vertical_tag_article vta left join vertical_article va on vta.id_article = va.id where va.id is not null) tmp); + delete from forest_tag where tag_reservation = 0 and id not in (select * from (select id_tag from forest_tag_article vta left join forest_article va on vta.id_article = va.id where va.id is not null) tmp); \ No newline at end of file diff --git a/src/main/java/mapper/TopicMapper.xml b/src/main/java/mapper/TopicMapper.xml index 6c859f4..cd27fc7 100644 --- a/src/main/java/mapper/TopicMapper.xml +++ b/src/main/java/mapper/TopicMapper.xml @@ -51,27 +51,27 @@ - insert into vertical_topic_tag (id_topic, id_tag, created_time, updated_time) values (#{idTopic}, #{idTag}, sysdate(), sysdate()) + insert into forest_topic_tag (id_topic, id_tag, created_time, updated_time) values (#{idTopic}, #{idTag}, sysdate(), sysdate()) - update vertical_topic set topic_title = #{topicTitle},topic_uri = #{topicUri},topic_icon_path = #{topicIconPath}, updated_time = sysdate(), + update forest_topic set topic_title = #{topicTitle},topic_uri = #{topicUri},topic_icon_path = #{topicIconPath}, updated_time = sysdate(), topic_nva = #{topicNva},topic_status = #{topicStatus},topic_sort = #{topicSort},topic_description = #{topicDescription},topic_description_html = #{topicDescriptionHtml} where id = #{idTopic} - delete from vertical_topic_tag where id_topic = #{idTopic} and id_tag = #{idTag} + delete from forest_topic_tag where id_topic = #{idTopic} and id_tag = #{idTag} + select * from forest_transaction_record where form_bank_account = #{bankAccount} or to_bank_account = #{bankAccount} + + \ No newline at end of file diff --git a/src/main/java/mapper/UserExtendMapper.xml b/src/main/java/mapper/UserExtendMapper.xml index 565428b..953895f 100644 --- a/src/main/java/mapper/UserExtendMapper.xml +++ b/src/main/java/mapper/UserExtendMapper.xml @@ -10,7 +10,7 @@ \ No newline at end of file diff --git a/src/main/java/mapper/UserMapper.xml b/src/main/java/mapper/UserMapper.xml index 6c770b7..c0d14f9 100644 --- a/src/main/java/mapper/UserMapper.xml +++ b/src/main/java/mapper/UserMapper.xml @@ -47,57 +47,57 @@ - insert into vertical_user_role (id_user,id_role,created_time) values (#{idUser},#{idRole},sysdate()) + insert into forest_user_role (id_user,id_role,created_time) values (#{idUser},#{idRole},sysdate()) - update vertical_user set password = #{password} where account = #{account} + update forest_user set password = #{password} where account = #{account} - update vertical_user_role set id_role = #{idRole},created_time = sysdate() where id_user = #{idUser} + update forest_user_role set id_role = #{idRole},created_time = sysdate() where id_user = #{idUser} - update vertical_user set status = #{status} where id = #{idUser} + update forest_user set status = #{status} where id = #{idUser} - update vertical_user set nickname = #{nickname},email = #{email},signature = #{signature},avatar_type = #{avatarType},avatar_url = #{avatarUrl},sex = #{sex} + update forest_user set nickname = #{nickname},email = #{email},signature = #{signature},avatar_type = #{avatarType},avatar_url = #{avatarUrl},sex = #{sex} ,phone = #{phone} where id = #{idUser} - update vertical_user set last_login_time = sysdate() where id = #{idUser} + update forest_user set last_login_time = sysdate() where id = #{idUser} - update vertical_user set email = #{email} where id = #{idUser} + update forest_user set email = #{email} where id = #{idUser} - update vertical_user set password = #{password} where id = #{idUser} + update forest_user set password = #{password} where id = #{idUser} \ No newline at end of file diff --git a/src/main/resources/static/forest.sql b/src/main/resources/static/forest.sql new file mode 100644 index 0000000..bd27ce5 --- /dev/null +++ b/src/main/resources/static/forest.sql @@ -0,0 +1,350 @@ +create database forest default character set utf8mb4 collate utf8mb4_unicode_ci; + +use forest; + +create table forest_article +( + id bigint auto_increment comment '主键' + primary key, + article_title varchar(128) null comment '文章标题', + article_thumbnail_url varchar(128) null comment '文章缩略图', + article_author_id bigint null comment '文章作者id', + article_type char default '0' null comment '文章类型', + article_tags varchar(128) null comment '文章标签', + article_view_count int default 1 null comment '浏览总数', + article_preview_content varchar(256) null comment '预览内容', + article_comment_count int default 0 null comment '评论总数', + article_permalink varchar(128) null comment '文章永久链接', + article_link varchar(32) null comment '站内链接', + created_time datetime null comment '创建时间', + updated_time datetime null comment '更新时间', + article_perfect char default '0' null comment '0:非优选1:优选', + article_status char default '0' null comment '文章状态', + article_thumbs_up_count int default 0 null comment '点赞总数', + article_sponsor_count int default 0 null comment '赞赏总数' +) + comment ' ' collate = utf8mb4_unicode_ci; + +create table forest_article_content +( + id_article bigint not null comment '主键', + article_content text null comment '文章内容原文', + article_content_html text null comment '文章内容Html', + created_time datetime null comment '创建时间', + updated_time datetime null comment '更新时间' +) + comment ' ' collate = utf8mb4_unicode_ci; + +create index forest_article_content_id_article_index + on forest_article_content (id_article); + +create table forest_article_thumbs_up +( + id bigint auto_increment comment '主键' + primary key, + id_article bigint null comment '文章表主键', + id_user bigint null comment '用户表主键', + thumbs_up_time datetime null comment '点赞时间' +) + comment '文章点赞表 '; + +create table forest_bank +( + id bigint auto_increment comment '主键' + primary key, + bank_name varchar(64) null comment '银行名称', + bank_owner bigint null comment '银行负责人', + bank_description varchar(512) null comment '银行描述', + created_by bigint null comment '创建人', + created_time datetime null comment '创建时间' +) + comment '银行表 '; + +create table forest_bank_account +( + id bigint auto_increment comment '主键' + primary key, + id_bank bigint null comment '所属银行', + bank_account varchar(32) null comment '银行账户', + account_balance decimal(32, 8) null comment '账户余额', + account_owner bigint null comment '账户所有者', + created_time datetime null comment '创建时间', + account_type char default '0' null comment '0: 普通账户 1: 银行账户' +) + comment '银行账户表 '; + +create table forest_comment +( + id bigint auto_increment comment '主键' + primary key, + comment_content text null comment '评论内容', + comment_author_id bigint null comment '作者 id', + comment_article_id bigint null comment '文章 id', + comment_sharp_url varchar(256) null comment '锚点 url', + comment_original_comment_id bigint null comment '父评论 id', + comment_status char default '0' null comment '状态', + comment_ip varchar(128) null comment '评论 IP', + comment_ua varchar(128) null comment 'User-Agent', + comment_anonymous char null comment '0:公开回帖,1:匿名回帖', + comment_reply_count int null comment '回帖计数', + comment_visible char null comment '0:所有人可见,1:仅楼主和自己可见', + created_time datetime null comment '创建时间' +) + comment '评论表 ' collate = utf8mb4_unicode_ci; + +create table forest_currency_issue +( + id bigint auto_increment comment '主键' + primary key, + issue_value decimal(32, 8) null comment '发行数额', + created_by bigint null comment '发行人', + created_time datetime null comment '发行时间' +) + comment '货币发行表 '; + +create table forest_currency_rule +( + id bigint auto_increment comment '主键' + primary key, + rule_name varchar(128) null comment '规则名称', + rule_sign varchar(64) null comment '规则标志(与枚举变量对应)', + rule_description varchar(1024) null comment '规则描述', + money decimal(32, 8) null comment '金额', + award_status char default '0' null comment '奖励(0)/消耗(1)状态', + maximum_money decimal(32, 8) null comment '上限金额', + repeat_days int default 0 null comment '重复(0: 不重复,单位:天)', + status char default '0' null comment '状态' +) + comment '货币规则表 '; + +create table forest_follow +( + id bigint auto_increment comment '主键' + primary key, + follower_id bigint null comment '关注者 id', + following_id bigint null comment '关注数据 id', + following_type char null comment '0:用户,1:标签,2:帖子收藏,3:帖子关注' +) + comment '关注表 ' collate = utf8mb4_unicode_ci; + +create table forest_notification +( + id bigint auto_increment comment '主键' + primary key, + id_user bigint null comment '用户id', + data_type char null comment '数据类型', + data_id bigint null comment '数据id', + has_read char default '0' null comment '是否已读', + data_summary varchar(256) null comment '数据摘要', + created_time datetime null comment '创建时间' +) + comment '通知表 ' collate = utf8mb4_unicode_ci; + +create table forest_portfolio +( + id bigint auto_increment comment '主键' + primary key, + portfolio_head_img_url varchar(500) null comment '作品集头像', + portfolio_title varchar(32) null comment '作品集名称', + portfolio_author_id bigint null comment '作品集作者', + portfolio_description varchar(1024) null comment '作品集介绍', + created_time datetime null comment '创建时间', + updated_time datetime null comment '更新时间', + portfolio_description_html varchar(1024) null comment ' 作品集介绍HTML' +) + comment '作品集表' collate = utf8mb4_unicode_ci; + +create table forest_portfolio_article +( + id bigint auto_increment comment '主键' + primary key, + id_portfolio bigint null comment '作品集表主键', + id_article bigint null comment '文章表主键', + sort_no int null comment '排序号' +) + comment '作品集与文章关系表' collate = utf8mb4_unicode_ci; + +create table forest_role +( + id bigint auto_increment comment '主键' + primary key, + name varchar(32) null comment '名称', + input_code varchar(32) null comment '拼音码', + status char default '0' null comment '状态', + created_time datetime null comment '创建时间', + updated_time datetime null comment '更新时间', + weights tinyint default 0 null comment '权重,数值越小权限越大;0:无权限' +) + comment ' ' collate = utf8mb4_unicode_ci; + +create table forest_sponsor +( + id bigint auto_increment comment '主键' + primary key, + data_type char null comment '数据类型', + data_id bigint null comment '数据主键', + sponsor bigint null comment '赞赏人', + sponsorship_time datetime null comment '赞赏日期', + sponsorship_money decimal(32, 8) null comment '赞赏金额' +) + comment '赞赏表 '; + +create table forest_tag +( + id bigint auto_increment comment '主键' + primary key, + tag_title varchar(32) null comment '标签名', + tag_icon_path varchar(512) null comment '标签图标', + tag_uri varchar(128) null comment '标签uri', + tag_description text null comment '描述', + tag_view_count int default 0 null comment '浏览量', + tag_article_count int default 0 null comment '关联文章总数', + tag_ad char null comment '标签广告', + tag_show_side_ad char null comment '是否显示全站侧边栏广告', + created_time datetime null comment '创建时间', + updated_time datetime null comment '更新时间', + tag_status char default '0' null comment '标签状态', + tag_reservation char default '0' null comment '保留标签', + tag_description_html text null +) + comment '标签表 ' collate = utf8mb4_unicode_ci; + +create table forest_tag_article +( + id bigint auto_increment comment '主键' + primary key, + id_tag bigint null comment '标签 id', + id_article varchar(32) null comment '帖子 id', + article_comment_count int default 0 null comment '帖子评论计数 0', + article_perfect int default 0 null comment '0:非优选1:优选 0', + created_time datetime null comment '创建时间', + updated_time datetime null comment '更新时间' +) + comment '标签 - 帖子关联表 ' collate = utf8mb4_unicode_ci; + +create index forest_tag_article_id_tag_index + on forest_tag_article (id_tag); + +create table forest_topic +( + id bigint auto_increment comment '主键' + primary key, + topic_title varchar(32) null comment '专题标题', + topic_uri varchar(32) null comment '专题路径', + topic_description text null comment '专题描述', + topic_type varchar(32) null comment '专题类型', + topic_sort int default 10 null comment '专题序号 10', + topic_icon_path varchar(128) null comment '专题图片路径', + topic_nva char default '0' null comment '0:作为导航1:不作为导航 0', + topic_tag_count int default 0 null comment '专题下标签总数 0', + topic_status char default '0' null comment '0:正常1:禁用 0', + created_time datetime null comment '创建时间', + updated_time datetime null comment '更新时间', + topic_description_html text null comment '专题描述 Html' +) + comment '主题表' collate = utf8mb4_unicode_ci; + +create table forest_topic_tag +( + id bigint auto_increment comment '主键' + primary key, + id_topic bigint null comment '专题id', + id_tag bigint null comment '标签id', + created_time datetime null comment '创建时间', + updated_time datetime null comment '更新时间' +) + comment '专题- 标签关联表 ' collate = utf8mb4_unicode_ci; + +create index forest_topic_tag_id_topic_index + on forest_topic_tag (id_topic); + +create table forest_transaction_record +( + id bigint auto_increment comment '交易主键' + primary key, + transaction_no varchar(32) null comment '交易流水号', + funds varchar(32) null comment '款项', + form_bank_account varchar(32) null comment '交易发起方', + to_bank_account varchar(32) null comment '交易收款方', + money decimal(32, 8) null comment '交易金额', + transaction_type char default '0' null comment '交易类型', + transaction_time datetime null comment '交易时间' +) + comment '交易记录表 '; + +create table forest_user +( + id bigint auto_increment comment '用户ID' + primary key, + account varchar(32) null comment '账号', + password varchar(64) not null comment '密码', + nickname varchar(128) null comment '昵称', + real_name varchar(32) null comment '真实姓名', + sex char default '0' null comment '性别', + avatar_type char default '0' null comment '头像类型', + avatar_url varchar(512) null comment '头像路径', + email varchar(64) null comment '邮箱', + phone varchar(11) null comment '电话', + status char default '0' null comment '状态', + created_time datetime null comment '创建时间', + updated_time datetime null comment '更新时间', + last_login_time datetime null comment '最后登录时间', + signature varchar(128) null comment '签名' +) + comment ' ' collate = utf8mb4_unicode_ci; + +create table forest_user_extend +( + id_user bigint not null comment '用户表主键', + github varchar(64) null comment 'github', + weibo varchar(32) null comment '微博', + weixin varchar(32) null comment '微信', + qq varchar(32) null comment 'qq', + blog varchar(500) null comment '博客' +) + comment '用户扩展表 '; + +create table forest_user_role +( + id_user bigint not null comment '用户表主键', + id_role bigint not null comment '角色表主键', + created_time datetime null comment '创建时间' +) + comment ' ' collate = utf8mb4_unicode_ci; + +create table forest_user_tag +( + id bigint auto_increment comment '主键' + primary key, + id_user bigint null comment '用户 id', + id_tag varchar(32) null comment '标签 id', + type char null comment '0:创建者,1:帖子使用,2:用户自评标签', + created_time datetime null comment '创建时间', + updated_time datetime null comment '更新时间' +) + comment '用户 - 标签关联表 ' collate = utf8mb4_unicode_ci; + +create table forest_visit +( + id bigint auto_increment comment '主键' + primary key, + visit_url varchar(256) null comment '浏览链接', + visit_ip varchar(128) null comment 'IP', + visit_ua varchar(512) null comment 'User-Agent', + visit_city varchar(32) null comment '城市', + visit_device_id varchar(256) null comment '设备唯一标识', + visit_user_id bigint null comment '浏览者 id', + visit_referer_url varchar(256) null comment '上游链接', + created_time datetime null comment '创建时间', + expired_time datetime null comment '过期时间' +) + comment '浏览表' collate = utf8mb4_unicode_ci; + +insert into forest.forest_role (id, name, input_code, status, created_time, updated_time, weights) values (1, '管理员', 'admin', '0', '2019-11-16 04:22:45', '2019-11-16 04:22:45', 1); +insert into forest.forest_role (id, name, input_code, status, created_time, updated_time, weights) values (2, '社区管理员', 'blog_admin', '0', '2019-12-05 03:10:05', '2019-12-05 17:11:35', 2); +insert into forest.forest_role (id, name, input_code, status, created_time, updated_time, weights) values (3, '作者', 'zz', '0', '2020-03-12 15:07:27', '2020-03-12 15:07:27', 3); +insert into forest.forest_role (id, name, input_code, status, created_time, updated_time, weights) values (4, '普通用户', 'user', '0', '2019-12-05 03:10:59', '2020-03-12 15:13:49', 4); + +insert into forest.forest_user (id, account, password, nickname, real_name, sex, avatar_type, avatar_url, email, phone, status, created_time, updated_time, last_login_time, signature) values (1, 'admin', '8ce2dd866238958ac4f07870766813cdaa39a9b83a8c75e26aa50f23', 'admin', 'admin', '0', '0', null, null, null, '0', '2021-01-25 18:21:51', '2021-01-25 18:21:54', null, null); + +insert into forest.forest_user_role (id_user, id_role, created_time) values (1, 1, '2021-01-25 18:22:12'); \ No newline at end of file