commit
575b4ce6bb
2
.gitignore
vendored
2
.gitignore
vendored
@ -18,6 +18,7 @@ target/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
/.mvn/
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
@ -29,4 +30,3 @@ build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
/.mvn/
|
||||
|
35
README.md
35
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)
|
||||
更新密码
|
||||
更新用户名
|
||||
永久停用账号
|
||||
邀请
|
||||
邀请链接
|
||||
兑换邀请码
|
||||
钱包
|
||||
转账记录
|
||||
交易记录
|
||||
帮助
|
||||
使用入门
|
||||
基础知识
|
||||
|
48
src/main/java/com/rymcu/forest/answer/AnswerController.java
Normal file
48
src/main/java/com/rymcu/forest/answer/AnswerController.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
@ -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/**");
|
||||
|
||||
}
|
||||
|
||||
|
17
src/main/java/com/rymcu/forest/dto/AnswerDTO.java
Normal file
17
src/main/java/com/rymcu/forest/dto/AnswerDTO.java
Normal file
@ -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;
|
||||
|
||||
}
|
@ -53,4 +53,10 @@ public class ArticleDTO {
|
||||
private List<PortfolioArticleDTO> portfolios;
|
||||
|
||||
private Integer sortNo;
|
||||
/** 0:非优选1:优选;0 */
|
||||
private String articlePerfect;
|
||||
/** 点赞总数 */
|
||||
private Integer articleThumbsUpCount;
|
||||
/** 赞赏总数 */
|
||||
private Integer articleSponsorCount;
|
||||
}
|
||||
|
35
src/main/java/com/rymcu/forest/dto/BankAccountDTO.java
Normal file
35
src/main/java/com/rymcu/forest/dto/BankAccountDTO.java
Normal file
@ -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<TransactionRecordDTO> transactionRecords;
|
||||
|
||||
}
|
17
src/main/java/com/rymcu/forest/dto/BankAccountSearchDTO.java
Normal file
17
src/main/java/com/rymcu/forest/dto/BankAccountSearchDTO.java
Normal file
@ -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;
|
||||
|
||||
}
|
33
src/main/java/com/rymcu/forest/dto/BankDTO.java
Normal file
33
src/main/java/com/rymcu/forest/dto/BankDTO.java
Normal file
@ -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;
|
||||
}
|
17
src/main/java/com/rymcu/forest/dto/SearchModel.java
Normal file
17
src/main/java/com/rymcu/forest/dto/SearchModel.java
Normal file
@ -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;
|
||||
|
||||
}
|
32
src/main/java/com/rymcu/forest/dto/TransactionRecordDTO.java
Normal file
32
src/main/java/com/rymcu/forest/dto/TransactionRecordDTO.java
Normal file
@ -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;
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
37
src/main/java/com/rymcu/forest/entity/ArticleThumbsUp.java
Normal file
37
src/main/java/com/rymcu/forest/entity/ArticleThumbsUp.java
Normal file
@ -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;
|
||||
}
|
37
src/main/java/com/rymcu/forest/entity/Bank.java
Normal file
37
src/main/java/com/rymcu/forest/entity/Bank.java
Normal file
@ -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;
|
||||
|
||||
}
|
38
src/main/java/com/rymcu/forest/entity/BankAccount.java
Normal file
38
src/main/java/com/rymcu/forest/entity/BankAccount.java
Normal file
@ -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;
|
||||
}
|
@ -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
|
||||
|
29
src/main/java/com/rymcu/forest/entity/CurrencyIssue.java
Normal file
29
src/main/java/com/rymcu/forest/entity/CurrencyIssue.java
Normal file
@ -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;
|
||||
|
||||
}
|
57
src/main/java/com/rymcu/forest/entity/CurrencyRule.java
Normal file
57
src/main/java/com/rymcu/forest/entity/CurrencyRule.java
Normal file
@ -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;
|
||||
}
|
@ -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
|
||||
|
@ -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 {
|
||||
/**
|
||||
* 主键
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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")
|
||||
|
@ -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
|
||||
|
44
src/main/java/com/rymcu/forest/entity/Sponsor.java
Normal file
44
src/main/java/com/rymcu/forest/entity/Sponsor.java
Normal file
@ -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;
|
||||
}
|
@ -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
|
||||
|
@ -12,7 +12,7 @@ import java.util.Date;
|
||||
* @author ronger
|
||||
*/
|
||||
@Data
|
||||
@Table(name = "vertical_topic")
|
||||
@Table(name = "forest_topic")
|
||||
public class Topic {
|
||||
|
||||
/** 主键 */
|
||||
|
38
src/main/java/com/rymcu/forest/entity/TransactionRecord.java
Normal file
38
src/main/java/com/rymcu/forest/entity/TransactionRecord.java
Normal file
@ -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;
|
||||
}
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
||||
/** 主键 */
|
||||
|
@ -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
|
||||
|
30
src/main/java/com/rymcu/forest/enumerate/SponsorEnum.java
Normal file
30
src/main/java/com/rymcu/forest/enumerate/SponsorEnum.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
@ -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());
|
||||
|
@ -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<NetworkInterface> netInterfaces = NetworkInterface.getNetworkInterfaces();
|
||||
InetAddress ip = null;
|
||||
boolean finded = false;// 是否找到外网IP
|
||||
while (netInterfaces.hasMoreElements() && !finded) {
|
||||
NetworkInterface ni = netInterfaces.nextElement();
|
||||
Enumeration<InetAddress> 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<Object, Object> getHashMap() {
|
||||
return new HashMap<Object, Object>();
|
||||
}
|
||||
|
||||
/**
|
||||
* SET转换MAP
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static Map<Object, Object> SetToMap(Set<Object> setobj) {
|
||||
Map<Object, Object> map = getHashMap();
|
||||
for (Iterator iterator = setobj.iterator(); iterator.hasNext();) {
|
||||
Map.Entry<Object, Object> entry = (Map.Entry<Object, Object>) 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将下划线大写方式命名的字符串转换为驼峰式。
|
||||
* 如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。</br>
|
||||
* 例如: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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将下划线大写方式命名的字符串转换为驼峰式。
|
||||
* 如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。</br>
|
||||
* 例如: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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将下划线大写方式命名的字符串转换为驼峰式。(首字母写)
|
||||
* 如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。</br>
|
||||
* 例如: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();
|
||||
}
|
||||
|
||||
}
|
@ -176,4 +176,12 @@ public interface ArticleMapper extends Mapper<Article> {
|
||||
* @return
|
||||
*/
|
||||
List<ArticleDTO> selectPortfolioArticlesByIdPortfolioAndSortNo(@Param("idPortfolio") Integer idPortfolio, @Param("sortNo") Integer sortNo);
|
||||
|
||||
/**
|
||||
* 更新文章优选状态
|
||||
* @param idArticle
|
||||
* @param articlePerfect
|
||||
* @return
|
||||
*/
|
||||
int updatePerfect(@Param("idArticle") Integer idArticle, @Param("articlePerfect") String articlePerfect);
|
||||
}
|
||||
|
@ -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<ArticleThumbsUp> {
|
||||
/**
|
||||
* 更新文章点赞数
|
||||
* @param idArticle
|
||||
* @param thumbsUpNumber
|
||||
* @return
|
||||
*/
|
||||
Integer updateArticleThumbsUpNumber(@Param("idArticle") Integer idArticle, @Param("thumbsUpNumber") Integer thumbsUpNumber);
|
||||
}
|
35
src/main/java/com/rymcu/forest/mapper/BankAccountMapper.java
Normal file
35
src/main/java/com/rymcu/forest/mapper/BankAccountMapper.java
Normal file
@ -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<BankAccount> {
|
||||
/**
|
||||
* 查询银行账户
|
||||
* @param bankName
|
||||
* @param accountOwnerName
|
||||
* @param bankAccount
|
||||
* @return
|
||||
*/
|
||||
List<BankAccountDTO> 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();
|
||||
}
|
18
src/main/java/com/rymcu/forest/mapper/BankMapper.java
Normal file
18
src/main/java/com/rymcu/forest/mapper/BankMapper.java
Normal file
@ -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<Bank> {
|
||||
/**
|
||||
* 查询银行列表数据
|
||||
* @return
|
||||
*/
|
||||
List<BankDTO> selectBanks();
|
||||
}
|
@ -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<CurrencyRule> {
|
||||
}
|
28
src/main/java/com/rymcu/forest/mapper/SearchMapper.java
Normal file
28
src/main/java/com/rymcu/forest/mapper/SearchMapper.java
Normal file
@ -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<SearchModel> searchInitialArticleSearch();
|
||||
|
||||
/**
|
||||
* 初始化作品集搜索数据
|
||||
* @return
|
||||
*/
|
||||
List<SearchModel> searchInitialPortfolioSearch();
|
||||
|
||||
/**
|
||||
* 初始化用户搜索数据
|
||||
* @return
|
||||
*/
|
||||
List<SearchModel> searchInitialUserSearch();
|
||||
}
|
17
src/main/java/com/rymcu/forest/mapper/SponsorMapper.java
Normal file
17
src/main/java/com/rymcu/forest/mapper/SponsorMapper.java
Normal file
@ -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<Sponsor> {
|
||||
/**
|
||||
* 更新文章赞赏数
|
||||
* @param idArticle
|
||||
* @return
|
||||
*/
|
||||
Integer updateArticleSponsorCount(@Param("idArticle") Integer idArticle);
|
||||
}
|
@ -13,7 +13,7 @@ import java.util.List;
|
||||
public interface TagMapper extends Mapper<Tag> {
|
||||
|
||||
/**
|
||||
* 插入标签文章表(vertical_tag_article)相关信息
|
||||
* 插入标签文章表(forest_tag_article)相关信息
|
||||
* @param idTag
|
||||
* @param idArticle
|
||||
* @return
|
||||
|
@ -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<TransactionRecord> {
|
||||
/**
|
||||
* 交易
|
||||
* @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<TransactionRecordDTO> selectTransactionRecords(@Param("bankAccount") String bankAccount);
|
||||
}
|
@ -111,6 +111,16 @@ public interface ArticleService extends Service<Article> {
|
||||
* @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);
|
||||
}
|
||||
|
@ -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<ArticleThumbsUp> {
|
||||
/**
|
||||
* 点赞
|
||||
* @param articleThumbsUp
|
||||
* @throws BaseApiException
|
||||
* @return
|
||||
*/
|
||||
Map thumbsUp(ArticleThumbsUp articleThumbsUp) throws BaseApiException;
|
||||
}
|
@ -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<BankAccount> {
|
||||
/**
|
||||
* 查询银行账户列表
|
||||
* @param bankAccountSearchDTO
|
||||
* @return
|
||||
*/
|
||||
List<BankAccountDTO> findBankAccounts(BankAccountSearchDTO bankAccountSearchDTO);
|
||||
|
||||
/**
|
||||
* 查询用户银行账户
|
||||
* @param idUser
|
||||
* @return
|
||||
*/
|
||||
BankAccountDTO findBankAccountByIdUser(Integer idUser);
|
||||
|
||||
/**
|
||||
* 根据账户查询银行账户信息
|
||||
* @param bankAccount
|
||||
* @return
|
||||
*/
|
||||
BankAccount findByBankAccount(String bankAccount);
|
||||
}
|
14
src/main/java/com/rymcu/forest/service/BankService.java
Normal file
14
src/main/java/com/rymcu/forest/service/BankService.java
Normal file
@ -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<Bank> {
|
||||
List<BankDTO> findBanks();
|
||||
}
|
@ -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<CurrencyRule> {
|
||||
}
|
16
src/main/java/com/rymcu/forest/service/SearchService.java
Normal file
16
src/main/java/com/rymcu/forest/service/SearchService.java
Normal file
@ -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<SearchModel> initialSearch();
|
||||
}
|
19
src/main/java/com/rymcu/forest/service/SponsorService.java
Normal file
19
src/main/java/com/rymcu/forest/service/SponsorService.java
Normal file
@ -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<Sponsor> {
|
||||
/**
|
||||
* 赞赏
|
||||
* @param sponsor
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
Map sponsorship(Sponsor sponsor) throws Exception;
|
||||
}
|
@ -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<TransactionRecord> {
|
||||
/**
|
||||
* 交易
|
||||
* @param transactionRecord
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
TransactionRecord transfer(TransactionRecord transactionRecord) throws Exception;
|
||||
|
||||
/**
|
||||
* 查询指定账户的交易记录
|
||||
* @param bankAccount
|
||||
* @return
|
||||
*/
|
||||
List<TransactionRecordDTO> findTransactionRecords(String bankAccount);
|
||||
|
||||
/**
|
||||
* 根据用户主键进行交易
|
||||
* @param toUserId
|
||||
* @param formUserId
|
||||
* @param money
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
TransactionRecord transferByUserId(Integer toUserId, Integer formUserId, BigDecimal money) throws Exception;
|
||||
}
|
@ -334,24 +334,37 @@ public class ArticleServiceImpl extends AbstractService<Article> 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<ArticleTagDTO> 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<PortfolioArticleDTO> 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());
|
||||
|
@ -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<ArticleThumbsUp> 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;
|
||||
}
|
||||
}
|
@ -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<BankAccount> implements BankAccountService {
|
||||
|
||||
private static String DEFAULT_ACCOUNT_TYPE = "0";
|
||||
|
||||
@Resource
|
||||
BankAccountMapper bankAccountMapper;
|
||||
@Resource
|
||||
TransactionRecordService transactionRecordService;
|
||||
|
||||
@Override
|
||||
public List<BankAccountDTO> findBankAccounts(BankAccountSearchDTO bankAccountSearchDTO) {
|
||||
List<BankAccountDTO> 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<BankAccount> 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<TransactionRecordDTO> 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;
|
||||
}
|
||||
}
|
@ -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<Bank> implements BankService {
|
||||
|
||||
@Resource
|
||||
private BankMapper bankMapper;
|
||||
|
||||
@Override
|
||||
public List<BankDTO> findBanks() {
|
||||
List<BankDTO> banks = bankMapper.selectBanks();
|
||||
return banks;
|
||||
}
|
||||
}
|
@ -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<CurrencyRule> implements CurrencyRuleService {
|
||||
|
||||
@Resource
|
||||
private CurrencyRuleMapper currencyRuleMapper;
|
||||
|
||||
}
|
@ -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<Portfolio> 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());
|
||||
|
@ -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<SearchModel> initialSearch() {
|
||||
String searchKey = "initialSearch";
|
||||
RedisResult<SearchModel> result = redisService.getListResult(searchKey, SearchModel.class);
|
||||
if (Objects.nonNull(result.getListResult())) {
|
||||
return result.getListResult();
|
||||
}
|
||||
List<SearchModel> list = new ArrayList<>();
|
||||
List<SearchModel> articleSearchModels = searchMapper.searchInitialArticleSearch();
|
||||
List<SearchModel> portfolioSearchModels = searchMapper.searchInitialPortfolioSearch();
|
||||
List<SearchModel> userSearchModels = searchMapper.searchInitialUserSearch();
|
||||
list.addAll(articleSearchModels);
|
||||
list.addAll(portfolioSearchModels);
|
||||
list.addAll(userSearchModels);
|
||||
redisService.set(searchKey, list, 24 * 60 * 60);
|
||||
return list;
|
||||
}
|
||||
}
|
@ -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<Sponsor> 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;
|
||||
}
|
||||
}
|
@ -103,8 +103,10 @@ public class TagServiceImpl extends AbstractService<Tag> implements TagService {
|
||||
tags.append(tagNlpDTO.getTag()).append(",");
|
||||
}
|
||||
article.setArticleTags(tags.toString());
|
||||
saveTagArticle(article, articleContentHtml);
|
||||
} else {
|
||||
article.setArticleTags("待分类");
|
||||
}
|
||||
saveTagArticle(article, articleContentHtml);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -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<TransactionRecord> 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<TransactionRecordDTO> 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;
|
||||
}
|
||||
}
|
38
src/main/java/com/rymcu/forest/util/DateUtil.java
Normal file
38
src/main/java/com/rymcu/forest/util/DateUtil.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 判断文件是否为图片<br>
|
||||
* <br>
|
||||
*
|
||||
* @param filename
|
||||
* 文件名<br>
|
||||
* 判断具体文件类型<br>
|
||||
* @return 检查后的结果<br>
|
||||
* @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<br>
|
||||
* <br>
|
||||
*
|
||||
* @param filename
|
||||
* 文件名<br>
|
||||
* 判断具体文件类型<br>
|
||||
* @return 检查后的结果<br>
|
||||
* @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);
|
||||
/**
|
||||
* 判断文件是否为图片<br>
|
||||
* <br>
|
||||
*
|
||||
* @param filename 文件名<br>
|
||||
* 判断具体文件类型<br>
|
||||
* @return 检查后的结果<br>
|
||||
* @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<br>
|
||||
* <br>
|
||||
*
|
||||
* @param filename 文件名<br>
|
||||
* 判断具体文件类型<br>
|
||||
* @return 检查后的结果<br>
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
34
src/main/java/com/rymcu/forest/util/HttpUtils.java
Normal file
34
src/main/java/com/rymcu/forest/util/HttpUtils.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
@ -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());
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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<NetworkInterface> netInterfaces = NetworkInterface.getNetworkInterfaces();
|
||||
InetAddress ip = null;
|
||||
boolean finded = false;// 是否找到外网IP
|
||||
while (netInterfaces.hasMoreElements() && !finded) {
|
||||
NetworkInterface ni = netInterfaces.nextElement();
|
||||
Enumeration<InetAddress> 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<Object, Object> getHashMap() {
|
||||
return new HashMap<Object, Object>();
|
||||
}
|
||||
|
||||
/**
|
||||
* SET转换MAP
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static Map<Object, Object> SetToMap(Set<Object> setobj) {
|
||||
Map<Object, Object> map = getHashMap();
|
||||
for (Iterator iterator = setobj.iterator(); iterator.hasNext();) {
|
||||
Map.Entry<Object, Object> entry = (Map.Entry<Object, Object>) 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将下划线大写方式命名的字符串转换为驼峰式。
|
||||
* 如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。</br>
|
||||
* 例如: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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将下划线大写方式命名的字符串转换为驼峰式。
|
||||
* 如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。</br>
|
||||
* 例如: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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将下划线大写方式命名的字符串转换为驼峰式。(首字母写)
|
||||
* 如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。</br>
|
||||
* 例如: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();
|
||||
}
|
||||
|
||||
}
|
@ -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<Map<String, Object>> users(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){
|
||||
PageHelper.startPage(page, rows);
|
||||
List<User> list = userService.findAll();
|
||||
// 按最后登录时间进行倒序排序
|
||||
list.sort(comparing(User::getLastLoginTime).reversed());
|
||||
PageInfo<User> pageInfo = new PageInfo<>(list);
|
||||
Map<String, Object> map = new HashMap<String, Object>(2);
|
||||
map.put("users", pageInfo.getList());
|
||||
|
@ -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<Map<String, Object>> detail(@PathVariable Integer id, @RequestParam(defaultValue = "2") Integer type){
|
||||
ArticleDTO articleDTO = articleService.findArticleDTOById(id,type);
|
||||
public GlobalResult<Map<String, Object>> 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<Map<String, Object>> commons(@PathVariable Integer id){
|
||||
public GlobalResult<Map<String, Object>> commons(@PathVariable Integer id) {
|
||||
List<CommentDTO> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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<BankAccountDTO> list = bankAccountService.findBankAccounts(bankAccountSearchDTO);
|
||||
PageInfo<BankAccountDTO> 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);
|
||||
}
|
||||
|
||||
}
|
@ -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<BankDTO> list = bankService.findBanks();
|
||||
PageInfo<BankDTO> 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);
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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<Map<String, String>> 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<SearchModel> list = SearchService.initialSearch();
|
||||
return GlobalResultGenerator.genSuccessResult(list);
|
||||
}
|
||||
}
|
||||
|
@ -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<CurrencyRule> list = currencyRuleService.findAll();
|
||||
return GlobalResultGenerator.genSuccessResult(list);
|
||||
}
|
||||
|
||||
}
|
@ -13,11 +13,15 @@
|
||||
<result column="article_tags" property="articleTags"></result>
|
||||
<result column="article_view_count" property="articleViewCount"></result>
|
||||
<result column="article_preview_content" property="articlePreviewContent"></result>
|
||||
<result column="comment_count" property="articleCommentCount"></result>
|
||||
<result column="article_comment_count" property="articleCommentCount"></result>
|
||||
<result column="article_permalink" property="articlePermalink"></result>
|
||||
<result column="article_link" property="articleLink"></result>
|
||||
<result column="created_time" property="createdTime"></result>
|
||||
<result column="updated_time" property="updatedTime"></result>
|
||||
<result column="article_thumbs_up_count" property="articleThumbsUpCount"></result>
|
||||
<result column="article_status" property="articleStatus"></result>
|
||||
<result column="article_perfect" property="articlePerfect"></result>
|
||||
<result column="article_sponsor_count" property="articleSponsorCount"></result>
|
||||
</resultMap>
|
||||
<resultMap id="DTOResultMap" type="com.rymcu.forest.dto.ArticleDTO">
|
||||
<result column="id" property="idArticle"></result>
|
||||
@ -38,6 +42,9 @@
|
||||
<result column="article_status" property="articleStatus"></result>
|
||||
<result column="updated_time" property="updatedTime"></result>
|
||||
<result column="sort_no" property="sortNo"></result>
|
||||
<result column="article_perfect" property="articlePerfect"></result>
|
||||
<result column="article_thumbs_up_count" property="articleThumbsUpCount"></result>
|
||||
<result column="article_sponsor_count" property="articleSponsorCount"></result>
|
||||
</resultMap>
|
||||
<resultMap id="ArticleContentResultMap" type="com.rymcu.forest.entity.ArticleContent">
|
||||
<result column="id_article" property="idArticle"/>
|
||||
@ -56,88 +63,91 @@
|
||||
<result column="tag_description" property="tagDescription"></result>
|
||||
</resultMap>
|
||||
<resultMap id="PortfolioArticleResultMap" type="com.rymcu.forest.dto.PortfolioArticleDTO">
|
||||
<result column="id_vertical_portfolio" property="idPortfolio"></result>
|
||||
<result column="id_vertical_article" property="idArticle"></result>
|
||||
<result column="id_portfolio" property="idPortfolio"></result>
|
||||
<result column="id_article" property="idArticle"></result>
|
||||
<result column="portfolio_title" property="portfolioTitle"></result>
|
||||
<result column="portfolio_head_img_url" property="headImgUrl"></result>
|
||||
<result column="sort_no" property="sortNo"></result>
|
||||
</resultMap>
|
||||
<insert id="insertArticleContent">
|
||||
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())
|
||||
</insert>
|
||||
<update id="updateArticleContent">
|
||||
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>
|
||||
<update id="updateArticleViewCount">
|
||||
update vertical_article set article_view_count = #{articleViewCount} where id = #{id}
|
||||
update forest_article set article_view_count = #{articleViewCount} where id = #{id}
|
||||
</update>
|
||||
<update id="updateArticleTags">
|
||||
update vertical_article set article_tags = #{tags} where id = #{idArticle}
|
||||
update forest_article set article_tags = #{tags} where id = #{idArticle}
|
||||
</update>
|
||||
<update id="updateArticleLinkAndPreviewContent">
|
||||
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>
|
||||
<update id="updatePerfect">
|
||||
update forest_article set article_perfect = #{articlePerfect} where id = #{idArticle}
|
||||
</update>
|
||||
<delete id="deleteTagArticle">
|
||||
delete from vertical_tag_article where id_article = #{id}
|
||||
delete from forest_tag_article where id_article = #{id}
|
||||
</delete>
|
||||
<delete id="deleteUnusedArticleTag">
|
||||
delete from vertical_tag_article where id = #{idArticleTag}
|
||||
delete from forest_tag_article where id = #{idArticleTag}
|
||||
</delete>
|
||||
<delete id="deleteLinkedPortfolioData">
|
||||
delete from vertical_portfolio_article where id_vertical_article = #{id}
|
||||
delete from forest_portfolio_article where id_article = #{id}
|
||||
</delete>
|
||||
<select id="selectArticles" resultMap="DTOResultMap">
|
||||
select art.*,su.nickname,su.avatar_url from vertical_article art join vertical_user su on art.article_author_id = su.id
|
||||
where article_status = '0'
|
||||
select art.*,su.nickname,su.avatar_url from forest_article art join forest_user su on art.article_author_id = su.id
|
||||
where article_status = 0
|
||||
<if test="topicUri != 'news'">
|
||||
and FIND_IN_SET('划水',art.article_tags) = 0
|
||||
</if>
|
||||
order by updated_time desc
|
||||
</select>
|
||||
<select id="selectArticleDTOById" resultMap="DTOResultMap">
|
||||
select art.*,su.nickname,su.avatar_url from vertical_article art join vertical_user su on art.article_author_id = su.id where art.id = #{id}
|
||||
select art.*,su.nickname,su.avatar_url from forest_article art join forest_user su on art.article_author_id = su.id where art.id = #{id}
|
||||
<if test="type == 1">
|
||||
and art.article_status = 0
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectArticleContent" resultMap="ArticleContentResultMap">
|
||||
select article_content,article_content_html from vertical_article_content where id_article = #{idArticle}
|
||||
select article_content,article_content_html from forest_article_content where id_article = #{idArticle}
|
||||
</select>
|
||||
<select id="selectArticlesByTopicUri" resultMap="DTOResultMap">
|
||||
select art.*,su.nickname,su.avatar_url from vertical_article art join vertical_user su on art.article_author_id = su.id
|
||||
where exists(select * from vertical_tag_article vta where vta.id_article = art.id and exists(select * from vertical_topic_tag vtt
|
||||
join vertical_tag vt on vtt.id_tag = vt.id where vt.id = vta.id_tag and exists(select * from vertical_topic topic
|
||||
select art.*,su.nickname,su.avatar_url from forest_article art join forest_user su on art.article_author_id = su.id
|
||||
where art.article_status = 0 and exists(select * from forest_tag_article vta where vta.id_article = art.id and exists(select * from forest_topic_tag vtt
|
||||
join forest_tag vt on vtt.id_tag = vt.id where vt.id = vta.id_tag and exists(select * from forest_topic topic
|
||||
where topic.id = vtt.id_topic and topic.topic_uri = #{topicName}))) order by updated_time desc
|
||||
</select>
|
||||
<select id="selectArticlesByTagName" resultMap="DTOResultMap">
|
||||
select art.*,su.nickname,su.avatar_url from vertical_article art join vertical_user su on art.article_author_id = su.id order by updated_time desc
|
||||
select art.*,su.nickname,su.avatar_url from forest_article art join forest_user su on art.article_author_id = su.id order by updated_time desc
|
||||
</select>
|
||||
<select id="selectUserArticles" resultMap="DTOResultMap">
|
||||
select art.*,su.nickname,su.avatar_url from vertical_article art join vertical_user su on su.id = #{idUser}
|
||||
select art.*,su.nickname,su.avatar_url from forest_article art join forest_user su on su.id = #{idUser}
|
||||
and art.article_author_id = su.id where article_author_id = #{idUser} and art.article_status = 0 order by updated_time desc
|
||||
</select>
|
||||
<select id="selectTags" resultMap="ArticleTagDTOResultMap">
|
||||
select vta.id, vta.id_tag, vta.id_article, vt.tag_title, vt.tag_icon_path, vt.tag_uri, vt.tag_description from vertical_tag vt join vertical_tag_article vta on vt.id = vta.id_tag where vta.id_article = #{idArticle}
|
||||
select vta.id, vta.id_tag, vta.id_article, vt.tag_title, vt.tag_icon_path, vt.tag_uri, vt.tag_description from forest_tag vt join forest_tag_article vta on vt.id = vta.id_tag where vta.id_article = #{idArticle}
|
||||
</select>
|
||||
<select id="selectDrafts" resultMap="DTOResultMap">
|
||||
select art.*,su.nickname,su.avatar_url from vertical_article art join vertical_user su on art.article_author_id = su.id where article_status = '1' and art.article_author_id = #{idUser} order by updated_time desc
|
||||
select art.*,su.nickname,su.avatar_url from forest_article art join forest_user su on art.article_author_id = su.id where article_status = '1' and art.article_author_id = #{idUser} order by updated_time desc
|
||||
</select>
|
||||
<select id="selectArticlesByIdPortfolio" resultMap="DTOResultMap">
|
||||
select art.*,su.nickname,su.avatar_url,vpa.sort_no from vertical_article art join vertical_portfolio_article vpa on vpa.id_vertical_article = art.id and vpa.id_vertical_portfolio = #{idPortfolio}
|
||||
join vertical_user su on art.article_author_id = su.id where art.article_status = 0 and vpa.id_vertical_portfolio = #{idPortfolio} order by sort_no
|
||||
select art.*,su.nickname,su.avatar_url,vpa.sort_no from forest_article art join forest_portfolio_article vpa on vpa.id_article = art.id and vpa.id_portfolio = #{idPortfolio}
|
||||
join forest_user su on art.article_author_id = su.id where art.article_status = 0 and vpa.id_portfolio = #{idPortfolio} order by sort_no
|
||||
</select>
|
||||
<select id="selectUnbindArticlesByIdPortfolio" resultMap="DTOResultMap">
|
||||
select art.*,su.nickname,su.avatar_url from vertical_article art join vertical_user su on su.id = #{idUser} and art.article_author_id = su.id where art.article_author_id = #{idUser} and art.article_status = 0
|
||||
and instr(art.article_title, #{searchText}) > 0 and art.id not in (select id_vertical_article from vertical_portfolio_article where id_vertical_portfolio = #{idPortfolio}) order by updated_time desc
|
||||
select art.*,su.nickname,su.avatar_url from forest_article art join forest_user su on su.id = #{idUser} and art.article_author_id = su.id where art.article_author_id = #{idUser} and art.article_status = 0
|
||||
and instr(art.article_title, #{searchText}) > 0 and art.id not in (select id_article from forest_portfolio_article where id_portfolio = #{idPortfolio}) order by updated_time desc
|
||||
</select>
|
||||
<select id="selectPortfolioArticles" resultMap="PortfolioArticleResultMap">
|
||||
select vp.portfolio_title,vp.portfolio_head_img_url,vpa.id_vertical_portfolio,vpa.id_vertical_article,vpa.sort_no from vertical_portfolio vp join vertical_portfolio_article vpa on vp.id = vpa.id_vertical_portfolio where vpa.id_vertical_article = #{idArticle}
|
||||
select vp.portfolio_title,vp.portfolio_head_img_url,vpa.id_portfolio,vpa.id_article,vpa.sort_no from forest_portfolio vp join forest_portfolio_article vpa on vp.id = vpa.id_portfolio where vpa.id_article = #{idArticle}
|
||||
</select>
|
||||
<select id="existsCommentWithPrimaryKey" resultType="java.lang.Boolean">
|
||||
select exists (select * from vertical_comment where comment_article_id = #{id})
|
||||
select exists (select * from forest_comment where comment_article_id = #{id})
|
||||
</select>
|
||||
<select id="selectPortfolioArticlesByIdPortfolioAndSortNo" resultMap="DTOResultMap">
|
||||
select va.article_title, va.id, va.article_permalink from vertical_portfolio_article vpa join vertical_article va on va.id = vpa.id_vertical_article where id_vertical_portfolio = #{idPortfolio} order by sort_no
|
||||
select va.article_title, va.id, va.article_permalink from forest_portfolio_article vpa join forest_article va on va.id = vpa.id_article where id_portfolio = #{idPortfolio} order by sort_no
|
||||
</select>
|
||||
</mapper>
|
7
src/main/java/mapper/ArticleThumbsUpMapper.xml
Normal file
7
src/main/java/mapper/ArticleThumbsUpMapper.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.rymcu.forest.mapper.ArticleThumbsUpMapper">
|
||||
<update id="updateArticleThumbsUpNumber">
|
||||
update forest_article set article_thumbs_up_count = article_thumbs_up_count + #{thumbsUpNumber} where id = #{idArticle}
|
||||
</update>
|
||||
</mapper>
|
35
src/main/java/mapper/BankAccountMapper.xml
Normal file
35
src/main/java/mapper/BankAccountMapper.xml
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.rymcu.forest.mapper.BankAccountMapper">
|
||||
<resultMap id="DTOResultMap" type="com.rymcu.forest.dto.BankAccountDTO">
|
||||
<result column="id" property="idBankAccount"></result>
|
||||
<result column="id_bank" property="idBank"></result>
|
||||
<result column="bank_name" property="bankName"></result>
|
||||
<result column="bank_account" property="bankAccount"></result>
|
||||
<result column="account_balance" property="accountBalance"></result>
|
||||
<result column="account_owner" property="accountOwner"></result>
|
||||
<result column="account_owner_name" property="accountOwnerName"></result>
|
||||
<result column="created_time" property="createdTime"></result>
|
||||
</resultMap>
|
||||
<select id="selectBankAccounts" resultMap="DTOResultMap">
|
||||
select vb.bank_name, vu.nickname as account_owner_name, vba.* from forest_bank_account vba
|
||||
join forest_bank vb on vba.id_bank = vb.id
|
||||
join forest_user vu on vba.account_owner = vu.id where vba.account_type = 0
|
||||
<if test="bankName != null and bankName != ''">
|
||||
and vb.bank_name = #{bankName}
|
||||
</if>
|
||||
<if test="accountOwnerName != null and accountOwnerName != ''">
|
||||
and vu.nickname = #{accountOwnerName}
|
||||
</if>
|
||||
<if test="bankAccount != null and bankAccount != ''">
|
||||
and vba.bank_account = #{bankAccount}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectBankAccount" resultMap="DTOResultMap">
|
||||
select vb.bank_name, vba.* from forest_bank_account vba
|
||||
join forest_bank vb on vba.id_bank = vb.id where vba.id = #{idBank}
|
||||
</select>
|
||||
<select id="selectMaxBankAccount" resultType="java.lang.String">
|
||||
select max(bank_account) as max_bank_account from forest_bank_account where account_type = 0
|
||||
</select>
|
||||
</mapper>
|
19
src/main/java/mapper/BankMapper.xml
Normal file
19
src/main/java/mapper/BankMapper.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.rymcu.forest.mapper.BankMapper">
|
||||
<resultMap id="DTOResultMap" type="com.rymcu.forest.dto.BankDTO">
|
||||
<result column="id" property="idBank"></result>
|
||||
<result column="bank_name" property="bankName"></result>
|
||||
<result column="bank_owner" property="bankOwner"></result>
|
||||
<result column="bank_owner_name" property="bankOwnerName"></result>
|
||||
<result column="bank_account" property="bankAccount"></result>
|
||||
<result column="account_balance" property="accountBalance"></result>
|
||||
<result column="created_by" property="createdBy"></result>
|
||||
<result column="created_time" property="createdTime"></result>
|
||||
<result column="bank_description" property="bankDescription"></result>
|
||||
</resultMap>
|
||||
<select id="selectBanks" resultMap="DTOResultMap">
|
||||
select vb.*, vba.bank_account, vba.account_balance from forest_bank_account vba
|
||||
join forest_bank vb on vba.account_owner = vb.id where vba.account_type = 1
|
||||
</select>
|
||||
</mapper>
|
@ -35,15 +35,15 @@
|
||||
<result column="avatar_url" property="userAvatarURL"/>
|
||||
</resultMap>
|
||||
<update id="updateCommentSharpUrl">
|
||||
update vertical_comment set comment_sharp_url = #{commentSharpUrl} where id = #{idComment}
|
||||
update forest_comment set comment_sharp_url = #{commentSharpUrl} where id = #{idComment}
|
||||
</update>
|
||||
<select id="selectArticleComments" resultMap="DTOResultMap">
|
||||
select * from vertical_comment where comment_article_id = #{idArticle} order by created_time desc
|
||||
select * from forest_comment where comment_article_id = #{idArticle} order by created_time desc
|
||||
</select>
|
||||
<select id="selectAuthor" resultMap="AuthorResultMap">
|
||||
select id,nickname,avatar_url from vertical_user where id = #{commentAuthorId}
|
||||
select id,nickname,avatar_url from forest_user where id = #{commentAuthorId}
|
||||
</select>
|
||||
<select id="selectCommentOriginalAuthor" resultMap="AuthorResultMap">
|
||||
select vu.id,vu.nickname,vu.avatar_url from vertical_comment vc left join vertical_user vu on vu.id = vc.comment_author_id where vc.id = #{commentOriginalCommentId}
|
||||
select vu.id,vu.nickname,vu.avatar_url from forest_comment vc left join forest_user vu on vu.id = vc.comment_author_id where vc.id = #{commentOriginalCommentId}
|
||||
</select>
|
||||
</mapper>
|
4
src/main/java/mapper/CurrencyRuleMapper.xml
Normal file
4
src/main/java/mapper/CurrencyRuleMapper.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.rymcu.forest.mapper.CurrencyRuleMapper">
|
||||
</mapper>
|
@ -6,45 +6,45 @@
|
||||
<result column="value" property="value"></result>
|
||||
</resultMap>
|
||||
<select id="selectUserCount" resultType="java.lang.Integer">
|
||||
select count(*) from vertical_user
|
||||
select count(*) from forest_user
|
||||
</select>
|
||||
<select id="selectNewUserCount" resultType="java.lang.Integer">
|
||||
select count(*) from vertical_user where created_time > str_to_date(date_format(sysdate(),'%Y-%m-%d'),'%Y-%m-%d')
|
||||
select count(*) from forest_user where created_time > str_to_date(date_format(sysdate(),'%Y-%m-%d'),'%Y-%m-%d')
|
||||
</select>
|
||||
<select id="selectArticleCount" resultType="java.lang.Integer">
|
||||
select count(*) from vertical_article
|
||||
select count(*) from forest_article
|
||||
</select>
|
||||
<select id="selectNewArticleCount" resultType="java.lang.Integer">
|
||||
select count(*) from vertical_article where created_time > str_to_date(date_format(sysdate(),'%Y-%m-%d'),'%Y-%m-%d') and article_status = 0
|
||||
select count(*) from forest_article where created_time > str_to_date(date_format(sysdate(),'%Y-%m-%d'),'%Y-%m-%d') and article_status = 0
|
||||
</select>
|
||||
<select id="selectCountViewNum" resultType="java.lang.Integer">
|
||||
select count(*) from vertical_visit
|
||||
select count(*) from forest_visit
|
||||
</select>
|
||||
<select id="selectTodayViewNum" resultType="java.lang.Integer">
|
||||
select count(*) from vertical_visit where created_time > str_to_date(date_format(sysdate(),'%Y-%m-%d'),'%Y-%m-%d')
|
||||
select count(*) from forest_visit where created_time > str_to_date(date_format(sysdate(),'%Y-%m-%d'),'%Y-%m-%d')
|
||||
</select>
|
||||
<select id="selectLastThirtyDaysArticleData" resultMap="DashboardDataResultMap">
|
||||
select COUNT(*) as value, date_format(created_time, '%Y-%m-%d') as label from vertical_article
|
||||
select COUNT(*) as value, date_format(created_time, '%Y-%m-%d') as label from forest_article
|
||||
where created_time > str_to_date(date_format(date_sub(sysdate(),interval + 30 day),'%Y-%m-%d'),'%Y-%m-%d') and article_status = 0 GROUP BY date_format(created_time, '%Y-%m-%d')
|
||||
</select>
|
||||
<select id="selectLastThirtyDaysUserData" resultMap="DashboardDataResultMap">
|
||||
select COUNT(*) as value, date_format(created_time, '%Y-%m-%d') as label from vertical_user
|
||||
select COUNT(*) as value, date_format(created_time, '%Y-%m-%d') as label from forest_user
|
||||
where created_time > str_to_date(date_format(date_sub(sysdate(),interval + 30 day),'%Y-%m-%d'),'%Y-%m-%d') GROUP BY date_format(created_time, '%Y-%m-%d')
|
||||
</select>
|
||||
<select id="selectLastThirtyDaysVisitData" resultMap="DashboardDataResultMap">
|
||||
select COUNT(*) as value, date_format(created_time, '%Y-%m-%d') as label from vertical_visit
|
||||
select COUNT(*) as value, date_format(created_time, '%Y-%m-%d') as label from forest_visit
|
||||
where created_time > str_to_date(date_format(date_sub(sysdate(),interval + 30 day),'%Y-%m-%d'),'%Y-%m-%d') GROUP BY date_format(created_time, '%Y-%m-%d')
|
||||
</select>
|
||||
<select id="selectHistoryArticleData" resultMap="DashboardDataResultMap">
|
||||
select COUNT(*) as value, date_format(created_time, '%Y-%m') as label from vertical_article
|
||||
select COUNT(*) as value, date_format(created_time, '%Y-%m') as label from forest_article
|
||||
where created_time > str_to_date(date_format(date_sub(sysdate(),interval + 1 year),'%Y-%m-%d'),'%Y-%m-%d') and article_status = 0 GROUP BY date_format(created_time, '%Y-%m')
|
||||
</select>
|
||||
<select id="selectHistoryUserData" resultMap="DashboardDataResultMap">
|
||||
select COUNT(*) as value, date_format(created_time, '%Y-%m') as label from vertical_user
|
||||
select COUNT(*) as value, date_format(created_time, '%Y-%m') as label from forest_user
|
||||
where created_time > str_to_date(date_format(date_sub(sysdate(),interval + 1 year),'%Y-%m-%d'),'%Y-%m-%d') GROUP BY date_format(created_time, '%Y-%m')
|
||||
</select>
|
||||
<select id="selectHistoryVisitData" resultMap="DashboardDataResultMap">
|
||||
select COUNT(*) as value, date_format(created_time, '%Y-%m') as label from vertical_visit
|
||||
select COUNT(*) as value, date_format(created_time, '%Y-%m') as label from forest_visit
|
||||
where created_time > str_to_date(date_format(date_sub(sysdate(),interval + 1 year),'%Y-%m-%d'),'%Y-%m-%d') GROUP BY date_format(created_time, '%Y-%m')
|
||||
</select>
|
||||
</mapper>
|
@ -10,15 +10,15 @@
|
||||
<result column="signature" property="signature"/>
|
||||
</resultMap>
|
||||
<select id="isFollow" resultType="java.lang.Boolean">
|
||||
select ifnull((select true from vertical_follow where follower_id = #{followerId}
|
||||
select ifnull((select true from forest_follow where follower_id = #{followerId}
|
||||
and following_id = #{followingId} and following_type = #{followingType}), false)
|
||||
</select>
|
||||
<select id="selectUserFollowersByUser" resultMap="DTOResultMapper">
|
||||
select id, nickname, avatar_type, avatar_url, account, signature from vertical_user vu
|
||||
where exists (select * from vertical_follow vf where following_type = 0 and following_id = #{idUser} and follower_id = vu.id limit 1)
|
||||
select id, nickname, avatar_type, avatar_url, account, signature from forest_user vu
|
||||
where exists (select * from forest_follow vf where following_type = 0 and following_id = #{idUser} and follower_id = vu.id limit 1)
|
||||
</select>
|
||||
<select id="selectUserFollowingsByUser" resultMap="DTOResultMapper">
|
||||
select id, nickname, avatar_type, avatar_url, account, signature from vertical_user vu
|
||||
where exists (select * from vertical_follow vf where following_type = 0 and follower_id = #{idUser} and following_id = vu.id limit 1)
|
||||
select id, nickname, avatar_type, avatar_url, account, signature from forest_user vu
|
||||
where exists (select * from forest_follow vf where following_type = 0 and follower_id = #{idUser} and following_id = vu.id limit 1)
|
||||
</select>
|
||||
</mapper>
|
@ -11,18 +11,18 @@
|
||||
<result column="created_time" property="createdTime"></result>
|
||||
</resultMap>
|
||||
<insert id="insertNotification">
|
||||
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())
|
||||
</insert>
|
||||
<update id="readNotification">
|
||||
update vertical_notification set has_read = '1' where id = #{id}
|
||||
update forest_notification set has_read = '1' where id = #{id}
|
||||
</update>
|
||||
<select id="selectUnreadNotifications" resultMap="BaseResultMapper">
|
||||
select * from vertical_notification where has_read = '0' and id_user = #{idUser} order by created_time desc
|
||||
select * from forest_notification where has_read = '0' and id_user = #{idUser} order by created_time desc
|
||||
</select>
|
||||
<select id="selectNotifications" resultMap="BaseResultMapper">
|
||||
select * from vertical_notification where id_user = #{idUser} order by created_time desc
|
||||
select * from forest_notification where id_user = #{idUser} order by created_time desc
|
||||
</select>
|
||||
<select id="selectNotification" resultMap="BaseResultMapper">
|
||||
select * from vertical_notification where id_user = #{idUser} and data_id = #{dataId} and data_type = #{dataType}
|
||||
select * from forest_notification where id_user = #{idUser} and data_id = #{dataId} and data_type = #{dataType}
|
||||
</select>
|
||||
</mapper>
|
@ -10,6 +10,6 @@
|
||||
</resultMap>
|
||||
|
||||
<select id="selectMenuByIdRole" resultMap="BaseResultMap">
|
||||
select * from vertical_role_permission srm left join vertical_permission sm on srm.id = sm.id
|
||||
select * from forest_role_permission srm left join forest_permission sm on srm.id = sm.id
|
||||
</select>
|
||||
</mapper>
|
@ -19,16 +19,16 @@
|
||||
<result column="updated_time" property="updatedTime"></result>
|
||||
</resultMap>
|
||||
<insert id="insertPortfolioArticle">
|
||||
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})
|
||||
</insert>
|
||||
<update id="updateArticleSortNo">
|
||||
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}
|
||||
</update>
|
||||
<delete id="unbindArticle">
|
||||
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}
|
||||
</delete>
|
||||
<select id="selectUserPortfoliosByIdUser" resultMap="DTOResultMap">
|
||||
select id, portfolio_head_img_url, portfolio_title, portfolio_author_id, portfolio_description, updated_time from vertical_portfolio where portfolio_author_id = #{idUser}
|
||||
select id, portfolio_head_img_url, portfolio_title, portfolio_author_id, portfolio_description, updated_time from forest_portfolio where portfolio_author_id = #{idUser}
|
||||
</select>
|
||||
<select id="selectPortfolioDTOById" resultMap="DTOResultMap">
|
||||
select id, portfolio_head_img_url, portfolio_title, portfolio_author_id,
|
||||
@ -40,15 +40,15 @@
|
||||
portfolio_description,
|
||||
</otherwise>
|
||||
</choose>
|
||||
updated_time from vertical_portfolio where id = #{id}
|
||||
updated_time from forest_portfolio where id = #{id}
|
||||
</select>
|
||||
<select id="selectCountArticleNumber" resultType="java.lang.Integer">
|
||||
select count(*) from vertical_portfolio_article where id_vertical_portfolio = #{idPortfolio}
|
||||
select count(*) from forest_portfolio_article where id_portfolio = #{idPortfolio}
|
||||
</select>
|
||||
<select id="selectCountPortfolioArticle" resultType="java.lang.Integer">
|
||||
select count(*) from vertical_portfolio_article where id_vertical_portfolio = #{idPortfolio} and id_vertical_article = #{idArticle}
|
||||
select count(*) from forest_portfolio_article where id_portfolio = #{idPortfolio} and id_article = #{idArticle}
|
||||
</select>
|
||||
<select id="selectMaxSortNo" resultType="java.lang.Integer">
|
||||
select ifnull(max(sort_no),0) + 1 from vertical_portfolio_article where id_vertical_portfolio = #{idPortfolio}
|
||||
select ifnull(max(sort_no),0) + 1 from forest_portfolio_article where id_portfolio = #{idPortfolio}
|
||||
</select>
|
||||
</mapper>
|
@ -14,17 +14,17 @@
|
||||
<result column="status" jdbcType="INTEGER" property="status"/>
|
||||
</resultMap>
|
||||
<update id="updateStatus">
|
||||
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>
|
||||
<update id="update">
|
||||
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}
|
||||
</update>
|
||||
|
||||
<select id="selectRoleByIdUser" resultMap="BaseResultMap">
|
||||
select sr.* from vertical_user_role sur left join vertical_role sr on sur.id_role = sr.id where id_user = #{id}
|
||||
select sr.* from forest_user_role sur left join forest_role sr on sur.id_role = sr.id where id_user = #{id}
|
||||
</select>
|
||||
<select id="selectRoleByInputCode" resultMap="BaseResultMap">
|
||||
select * from vertical_role where input_code = #{inputCode}
|
||||
select * from forest_role where input_code = #{inputCode}
|
||||
</select>
|
||||
|
||||
</mapper>
|
18
src/main/java/mapper/SearchMapper.xml
Normal file
18
src/main/java/mapper/SearchMapper.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.rymcu.forest.mapper.SearchMapper">
|
||||
<resultMap id="BaseResultMap" type="com.rymcu.forest.dto.SearchModel">
|
||||
<result column="label" property="label"></result>
|
||||
<result column="value" property="value"></result>
|
||||
<result column="type" property="type"></result>
|
||||
</resultMap>
|
||||
<select id="searchInitialArticleSearch" resultMap="BaseResultMap">
|
||||
select article_title as label, id as value, 'article' as type from forest_article where article_status = 0
|
||||
</select>
|
||||
<select id="searchInitialPortfolioSearch" resultMap="BaseResultMap">
|
||||
select portfolio_title as label, id as value, 'portfolio' as type from forest_portfolio
|
||||
</select>
|
||||
<select id="searchInitialUserSearch" resultMap="BaseResultMap">
|
||||
select nickname as label, nickname as value, 'user' as type from forest_user where status = 0
|
||||
</select>
|
||||
</mapper>
|
7
src/main/java/mapper/SponsorMapper.xml
Normal file
7
src/main/java/mapper/SponsorMapper.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.rymcu.forest.mapper.SponsorMapper">
|
||||
<update id="updateArticleSponsorCount">
|
||||
update forest_article set article_sponsor_count = article_sponsor_count + 1 where id = #{idArticle}
|
||||
</update>
|
||||
</mapper>
|
@ -23,24 +23,24 @@
|
||||
<result column="tag_title" property="value"></result>
|
||||
</resultMap>
|
||||
<insert id="insertTagArticle">
|
||||
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>
|
||||
<insert id="insertUserTag">
|
||||
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())
|
||||
</insert>
|
||||
<update id="update">
|
||||
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}
|
||||
</update>
|
||||
<delete id="deleteUnusedTag">
|
||||
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);
|
||||
</delete>
|
||||
<select id="selectCountTagArticleById" resultType="java.lang.Integer">
|
||||
select count(*) from vertical_tag_article where id_tag = #{idTag} and id_article = #{idArticle}
|
||||
select count(*) from forest_tag_article where id_tag = #{idTag} and id_article = #{idArticle}
|
||||
</select>
|
||||
<select id="selectCountUserTagById" resultType="java.lang.Integer">
|
||||
select count(*) from vertical_user_tag where id_tag = #{idTag} and id_user = #{idUser}
|
||||
select count(*) from forest_user_tag where id_tag = #{idTag} and id_user = #{idUser}
|
||||
</select>
|
||||
<select id="selectTagLabels" resultMap="TagLabelResultMap">
|
||||
select tag_title from vertical_tag where tag_status = 0
|
||||
select tag_title from forest_tag where tag_status = 0
|
||||
</select>
|
||||
</mapper>
|
@ -51,27 +51,27 @@
|
||||
<id column="updated_time" property="updatedTime"/>
|
||||
</resultMap>
|
||||
<insert id="insertTopicTag">
|
||||
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())
|
||||
</insert>
|
||||
<update id="update">
|
||||
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}
|
||||
</update>
|
||||
<delete id="deleteTopicTag">
|
||||
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}
|
||||
</delete>
|
||||
<select id="selectTopicNav" resultMap="BaseResultMap">
|
||||
select id,topic_title,topic_uri,topic_icon_path from vertical_topic where topic_nva = 0 and topic_status = 0 order by topic_sort
|
||||
select id,topic_title,topic_uri,topic_icon_path from forest_topic where topic_nva = 0 and topic_status = 0 order by topic_sort
|
||||
</select>
|
||||
<select id="selectTopicByTopicUri" resultMap="DTOResultMap">
|
||||
select id,topic_title,topic_uri,topic_icon_path,topic_description,topic_tag_count,topic_status from vertical_topic where topic_uri = #{topicUri}
|
||||
select id,topic_title,topic_uri,topic_icon_path,topic_description,topic_tag_count,topic_status from forest_topic where topic_uri = #{topicUri}
|
||||
</select>
|
||||
<select id="selectTopicTag" resultMap="TagDTOResultMap">
|
||||
select vt.id,vt.tag_title,vt.tag_uri,vt.tag_description,vt.tag_icon_path from vertical_tag vt left join vertical_topic_tag vtt on vt.id = vtt.id_tag where vtt.id_topic = #{idTopic} order by vtt.created_time desc
|
||||
select vt.id,vt.tag_title,vt.tag_uri,vt.tag_description,vt.tag_icon_path from forest_tag vt left join forest_topic_tag vtt on vt.id = vtt.id_tag where vtt.id_topic = #{idTopic} order by vtt.created_time desc
|
||||
</select>
|
||||
<select id="selectUnbindTagsById" resultMap="TagResultMap">
|
||||
select * from vertical_tag vt where not exists(select * from vertical_topic_tag vtt where vtt.id_topic = #{idTopic} and vtt.id_tag = vt.id)
|
||||
select * from forest_tag vt where not exists(select * from forest_topic_tag vtt where vtt.id_topic = #{idTopic} and vtt.id_tag = vt.id)
|
||||
<if test="tagTitle != '' and tagTitle != null">
|
||||
and LOCATE(#{tagTitle}, vt.tag_title) > 0
|
||||
</if>
|
||||
|
21
src/main/java/mapper/TransactionRecordMapper.xml
Normal file
21
src/main/java/mapper/TransactionRecordMapper.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.rymcu.forest.mapper.TransactionRecordMapper">
|
||||
<resultMap id="DTOResultMap" type="com.rymcu.forest.dto.TransactionRecordDTO">
|
||||
<result column="id" property="idTransactionRecord"></result>
|
||||
<result column="transaction_no" property="transactionNo"></result>
|
||||
<result column="funds" property="funds"></result>
|
||||
<result column="form_bank_account" property="formBankAccount"></result>
|
||||
<result column="to_bank_account" property="toBankAccount"></result>
|
||||
<result column="money" property="money"></result>
|
||||
<result column="transaction_type" property="transactionType"></result>
|
||||
<result column="transaction_time" property="transactionTime"></result>
|
||||
</resultMap>
|
||||
<update id="transfer">
|
||||
update forest_bank_account set account_balance = account_balance - #{money} where bank_account = #{formBankAccount};
|
||||
update forest_bank_account set account_balance = account_balance + #{money} where bank_account = #{toBankAccount};
|
||||
</update>
|
||||
<select id="selectTransactionRecords" resultMap="DTOResultMap">
|
||||
select * from forest_transaction_record where form_bank_account = #{bankAccount} or to_bank_account = #{bankAccount}
|
||||
</select>
|
||||
</mapper>
|
@ -10,7 +10,7 @@
|
||||
<result column="blog" property="blog"></result>
|
||||
</resultMap>
|
||||
<select id="selectUserExtendByNickname" resultMap="BaseResultMap">
|
||||
select vue.* from vertical_user_extend vue join vertical_user vu on vue.id_user = vu.id
|
||||
select vue.* from forest_user_extend vue join forest_user vu on vue.id_user = vu.id
|
||||
where vu.nickname = #{nickname} limit 1
|
||||
</select>
|
||||
</mapper>
|
@ -47,57 +47,57 @@
|
||||
<result column="avatar_url" property="userAvatarURL"/>
|
||||
</resultMap>
|
||||
<insert id="insertUserRole">
|
||||
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())
|
||||
</insert>
|
||||
<update id="updatePasswordByAccount">
|
||||
update vertical_user set password = #{password} where account = #{account}
|
||||
update forest_user set password = #{password} where account = #{account}
|
||||
</update>
|
||||
<update id="updateUserRole">
|
||||
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>
|
||||
<update id="updateStatus">
|
||||
update vertical_user set status = #{status} where id = #{idUser}
|
||||
update forest_user set status = #{status} where id = #{idUser}
|
||||
</update>
|
||||
<update id="updateUserInfo">
|
||||
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}
|
||||
<if test="phone != null and phone != ''">
|
||||
,phone = #{phone}
|
||||
</if>
|
||||
where id = #{idUser}
|
||||
</update>
|
||||
<update id="updateLastLoginTime">
|
||||
update vertical_user set last_login_time = sysdate() where id = #{idUser}
|
||||
update forest_user set last_login_time = sysdate() where id = #{idUser}
|
||||
</update>
|
||||
<update id="updateEmail">
|
||||
update vertical_user set email = #{email} where id = #{idUser}
|
||||
update forest_user set email = #{email} where id = #{idUser}
|
||||
</update>
|
||||
<update id="updatePasswordById">
|
||||
update vertical_user set password = #{password} where id = #{idUser}
|
||||
update forest_user set password = #{password} where id = #{idUser}
|
||||
</update>
|
||||
|
||||
<select id="findByAccount" resultMap="BaseResultMap">
|
||||
select id, nickname, account, password, status, avatar_type, avatar_url from vertical_user where (account = #{account} or email = #{account} ) and status = 0
|
||||
select id, nickname, account, password, status, avatar_type, avatar_url from forest_user where (account = #{account} or email = #{account} ) and status = 0
|
||||
</select>
|
||||
<select id="findUserInfoByAccount" resultMap="UserInfoResultMapper">
|
||||
select id, nickname, sex, avatar_type, avatar_url, email, phone, account, status, signature, last_login_time from vertical_user where account = #{account}
|
||||
select id, nickname, sex, avatar_type, avatar_url, email, phone, account, status, signature, last_login_time from forest_user where account = #{account}
|
||||
</select>
|
||||
<select id="selectUserDTOByNickname" resultMap="DTOResultMapper">
|
||||
select id, nickname, avatar_type, avatar_url, account, signature from vertical_user where nickname = #{nickname} and status = 0
|
||||
select id, nickname, avatar_type, avatar_url, account, signature from forest_user where nickname = #{nickname} and status = 0
|
||||
</select>
|
||||
<select id="selectRoleWeightsByUser" resultType="java.lang.Integer">
|
||||
select vr.weights from vertical_role vr left join vertical_user_role vur on vr.id = vur.id_role where vur.id_user = #{idUser}
|
||||
select vr.weights from forest_role vr left join forest_user_role vur on vr.id = vur.id_role where vur.id_user = #{idUser}
|
||||
</select>
|
||||
<select id="selectCountByNickName" resultType="java.lang.Integer">
|
||||
select count(*) from vertical_user where nickname = #{nickname}
|
||||
select count(*) from forest_user where nickname = #{nickname}
|
||||
</select>
|
||||
<select id="selectUserInfo" resultMap="UserInfoResultMapper">
|
||||
select id, nickname, sex, avatar_type, avatar_url, email, phone, account, status, signature, last_login_time from vertical_user where id = #{idUser}
|
||||
select id, nickname, sex, avatar_type, avatar_url, email, phone, account, status, signature, last_login_time from forest_user where id = #{idUser}
|
||||
</select>
|
||||
<select id="checkNicknameByIdUser" resultType="java.lang.Integer">
|
||||
select count(*) from vertical_user where nickname = #{nickname} and id != #{idUser}
|
||||
select count(*) from forest_user where nickname = #{nickname} and id != #{idUser}
|
||||
</select>
|
||||
<select id="selectAuthor" resultMap="AuthorResultMap">
|
||||
select * from vertical_user where id = #{id}
|
||||
select * from forest_user where id = #{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
350
src/main/resources/static/forest.sql
Normal file
350
src/main/resources/static/forest.sql
Normal file
@ -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');
|
Loading…
Reference in New Issue
Block a user