🎨 代码优化
This commit is contained in:
parent
4c17685ff0
commit
e9c0475e50
@ -0,0 +1,28 @@
|
|||||||
|
package com.rymcu.forest.core.exception;
|
||||||
|
|
||||||
|
import org.apache.shiro.authc.AccountException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created on 2022/8/25 19:27.
|
||||||
|
*
|
||||||
|
* @author ronger
|
||||||
|
* @email ronger-x@outlook.com
|
||||||
|
*/
|
||||||
|
public class AccountExistsException extends AccountException {
|
||||||
|
private static final long serialVersionUID = 3206734387536223284L;
|
||||||
|
|
||||||
|
public AccountExistsException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public AccountExistsException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AccountExistsException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AccountExistsException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.rymcu.forest.core.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created on 2022/8/25 19:11.
|
||||||
|
*
|
||||||
|
* @author ronger
|
||||||
|
* @email ronger-x@outlook.com
|
||||||
|
*/
|
||||||
|
public class NicknameOccupyException extends BusinessException {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 3206744387536223284L;
|
||||||
|
|
||||||
|
public NicknameOccupyException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public NicknameOccupyException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NicknameOccupyException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NicknameOccupyException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NicknameOccupyException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||||
|
super(message, cause, enableSuppression, writableStackTrace);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,7 +5,7 @@ import com.rymcu.forest.enumerate.TransactionCode;
|
|||||||
/**
|
/**
|
||||||
* @author ronger
|
* @author ronger
|
||||||
*/
|
*/
|
||||||
public class TransactionException extends Exception {
|
public class TransactionException extends BusinessException {
|
||||||
|
|
||||||
private int code;
|
private int code;
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ public interface ArticleThumbsUpService extends Service<ArticleThumbsUp> {
|
|||||||
*
|
*
|
||||||
* @param articleThumbsUp
|
* @param articleThumbsUp
|
||||||
* @return
|
* @return
|
||||||
* @throws BaseApiException
|
|
||||||
*/
|
*/
|
||||||
String thumbsUp(ArticleThumbsUp articleThumbsUp) throws Exception;
|
int thumbsUp(ArticleThumbsUp articleThumbsUp);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package com.rymcu.forest.service;
|
package com.rymcu.forest.service;
|
||||||
|
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.rymcu.forest.core.exception.ServiceException;
|
||||||
import com.rymcu.forest.core.service.Service;
|
import com.rymcu.forest.core.service.Service;
|
||||||
|
import com.rymcu.forest.dto.ArticleDTO;
|
||||||
import com.rymcu.forest.dto.PortfolioArticleDTO;
|
import com.rymcu.forest.dto.PortfolioArticleDTO;
|
||||||
import com.rymcu.forest.dto.PortfolioDTO;
|
import com.rymcu.forest.dto.PortfolioDTO;
|
||||||
import com.rymcu.forest.dto.UserDTO;
|
import com.rymcu.forest.dto.UserDTO;
|
||||||
@ -35,35 +37,34 @@ public interface PortfolioService extends Service<Portfolio> {
|
|||||||
* @throws BaseApiException
|
* @throws BaseApiException
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Portfolio postPortfolio(Portfolio portfolio) throws BaseApiException;
|
Portfolio postPortfolio(Portfolio portfolio);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询作品集下未绑定文章
|
* 查询作品集下未绑定文章
|
||||||
*
|
|
||||||
* @param page
|
* @param page
|
||||||
* @param rows
|
* @param rows
|
||||||
* @param searchText
|
* @param searchText
|
||||||
* @param idPortfolio
|
* @param idPortfolio
|
||||||
|
* @param idUser
|
||||||
* @return
|
* @return
|
||||||
* @throws BaseApiException
|
|
||||||
*/
|
*/
|
||||||
PageInfo findUnbindArticles(Integer page, Integer rows, String searchText, Long idPortfolio) throws Exception;
|
PageInfo<ArticleDTO> findUnbindArticles(Integer page, Integer rows, String searchText, Long idPortfolio, Long idUser);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 绑定文章
|
* 绑定文章
|
||||||
*
|
|
||||||
* @param portfolioArticle
|
* @param portfolioArticle
|
||||||
* @return
|
* @return
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
boolean bindArticle(PortfolioArticleDTO portfolioArticle) throws Exception;
|
boolean bindArticle(PortfolioArticleDTO portfolioArticle) throws ServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新文章排序号
|
* 更新文章排序号
|
||||||
*
|
|
||||||
* @param portfolioArticle
|
* @param portfolioArticle
|
||||||
* @return
|
* @return
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
boolean updateArticleSortNo(PortfolioArticleDTO portfolioArticle) throws Exception;
|
boolean updateArticleSortNo(PortfolioArticleDTO portfolioArticle) throws ServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取消绑定文章
|
* 取消绑定文章
|
||||||
@ -71,8 +72,9 @@ public interface PortfolioService extends Service<Portfolio> {
|
|||||||
* @param idPortfolio
|
* @param idPortfolio
|
||||||
* @param idArticle
|
* @param idArticle
|
||||||
* @return
|
* @return
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
boolean unbindArticle(Long idPortfolio, Long idArticle) throws Exception;
|
boolean unbindArticle(Long idPortfolio, Long idArticle) throws ServiceException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,10 +84,8 @@ public interface PortfolioService extends Service<Portfolio> {
|
|||||||
* @param idUser
|
* @param idUser
|
||||||
* @param roleWeights
|
* @param roleWeights
|
||||||
* @return
|
* @return
|
||||||
* @throws BaseApiException
|
|
||||||
* @throws IllegalAccessException
|
|
||||||
*/
|
*/
|
||||||
boolean deletePortfolio(Long idPortfolio, Long idUser, Integer roleWeights) throws BaseApiException, IllegalAccessException;
|
boolean deletePortfolio(Long idPortfolio, Long idUser, Integer roleWeights);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.rymcu.forest.service;
|
package com.rymcu.forest.service;
|
||||||
|
|
||||||
|
import com.rymcu.forest.core.exception.ServiceException;
|
||||||
import com.rymcu.forest.core.service.Service;
|
import com.rymcu.forest.core.service.Service;
|
||||||
import com.rymcu.forest.entity.Role;
|
import com.rymcu.forest.entity.Role;
|
||||||
import com.rymcu.forest.entity.User;
|
import com.rymcu.forest.entity.User;
|
||||||
@ -30,18 +31,18 @@ public interface RoleService extends Service<Role> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新用户状态
|
* 更新用户状态
|
||||||
*
|
|
||||||
* @param idRole
|
* @param idRole
|
||||||
* @param status
|
* @param status
|
||||||
* @return
|
* @return
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
boolean updateStatus(Long idRole, String status) throws Exception;
|
boolean updateStatus(Long idRole, String status) throws ServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加/更新角色
|
* 添加/更新角色
|
||||||
*
|
|
||||||
* @param role
|
* @param role
|
||||||
* @return
|
* @return
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
boolean saveRole(Role role) throws Exception;
|
boolean saveRole(Role role) throws ServiceException;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package com.rymcu.forest.service;
|
package com.rymcu.forest.service;
|
||||||
|
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.rymcu.forest.core.exception.ServiceException;
|
||||||
import com.rymcu.forest.core.service.Service;
|
import com.rymcu.forest.core.service.Service;
|
||||||
|
import com.rymcu.forest.dto.admin.TagDTO;
|
||||||
import com.rymcu.forest.dto.admin.TopicTagDTO;
|
import com.rymcu.forest.dto.admin.TopicTagDTO;
|
||||||
import com.rymcu.forest.entity.Tag;
|
import com.rymcu.forest.entity.Tag;
|
||||||
import com.rymcu.forest.entity.Topic;
|
import com.rymcu.forest.entity.Topic;
|
||||||
@ -15,15 +16,17 @@ public interface TopicService extends Service<Topic> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取导航主题数据
|
* 获取导航主题数据
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
* */
|
*/
|
||||||
List<Topic> findTopicNav();
|
List<Topic> findTopicNav();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据 topicUri 获取主题信息及旗下标签数据
|
* 根据 topicUri 获取主题信息及旗下标签数据
|
||||||
|
*
|
||||||
* @param topicUri 主题 URI
|
* @param topicUri 主题 URI
|
||||||
* @return
|
* @return
|
||||||
* */
|
*/
|
||||||
Topic findTopicByTopicUri(String topicUri);
|
Topic findTopicByTopicUri(String topicUri);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,11 +34,13 @@ public interface TopicService extends Service<Topic> {
|
|||||||
*
|
*
|
||||||
* @param topic 主题信息
|
* @param topic 主题信息
|
||||||
* @return
|
* @return
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
Topic saveTopic(Topic topic) throws Exception;
|
Topic saveTopic(Topic topic) throws ServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询未绑定标签
|
* 查询未绑定标签
|
||||||
|
*
|
||||||
* @param idTopic
|
* @param idTopic
|
||||||
* @param tagTitle
|
* @param tagTitle
|
||||||
* @return
|
* @return
|
||||||
@ -47,24 +52,24 @@ public interface TopicService extends Service<Topic> {
|
|||||||
*
|
*
|
||||||
* @param topicTag
|
* @param topicTag
|
||||||
* @return
|
* @return
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
TopicTagDTO bindTopicTag(TopicTagDTO topicTag) throws Exception;
|
TopicTagDTO bindTopicTag(TopicTagDTO topicTag) throws ServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取消绑定标签
|
* 取消绑定标签
|
||||||
*
|
*
|
||||||
* @param topicTag
|
* @param topicTag
|
||||||
* @return
|
* @return
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
TopicTagDTO unbindTopicTag(TopicTagDTO topicTag) throws Exception;
|
TopicTagDTO unbindTopicTag(TopicTagDTO topicTag) throws ServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取主题下标签列表
|
* 获取主题下标签列表
|
||||||
*
|
*
|
||||||
* @param topicUri
|
* @param topicUri
|
||||||
* @param page
|
|
||||||
* @param rows
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
PageInfo findTagsByTopicUri(String topicUri, Integer page, Integer rows);
|
List<TagDTO> findTagsByTopicUri(String topicUri);
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,8 @@ public interface TransactionRecordService extends Service<TransactionRecord> {
|
|||||||
* 交易
|
* 交易
|
||||||
* @param transactionRecord
|
* @param transactionRecord
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
TransactionRecord transfer(TransactionRecord transactionRecord) throws Exception;
|
TransactionRecord transfer(TransactionRecord transactionRecord);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询指定账户的交易记录
|
* 查询指定账户的交易记录
|
||||||
@ -34,24 +33,21 @@ public interface TransactionRecordService extends Service<TransactionRecord> {
|
|||||||
* @param formUserId
|
* @param formUserId
|
||||||
* @param transactionType
|
* @param transactionType
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
TransactionRecord userTransfer(Long toUserId, Long formUserId, TransactionEnum transactionType) throws Exception;
|
TransactionRecord userTransfer(Long toUserId, Long formUserId, TransactionEnum transactionType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 社区银行转账/奖励发放
|
* 社区银行转账/奖励发放
|
||||||
* @param idUser
|
* @param idUser
|
||||||
* @param transactionType
|
* @param transactionType
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
TransactionRecord bankTransfer(Long idUser, TransactionEnum transactionType) throws Exception;
|
TransactionRecord bankTransfer(Long idUser, TransactionEnum transactionType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发放新手奖励
|
* 发放新手奖励
|
||||||
* @param transactionRecord
|
* @param transactionRecord
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
TransactionRecord newbieRewards(TransactionRecord transactionRecord) throws Exception;
|
TransactionRecord newbieRewards(TransactionRecord transactionRecord);
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author CodeGenerator
|
* @author CodeGenerator
|
||||||
* @date 2018/05/29
|
* @date 2018/05/29
|
||||||
*/
|
*/
|
||||||
@ -20,10 +19,11 @@ public interface UserService extends Service<User> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过账号查询用户信息
|
* 通过账号查询用户信息
|
||||||
|
*
|
||||||
* @param account
|
* @param account
|
||||||
* @throws TooManyResultsException
|
|
||||||
* @return User
|
* @return User
|
||||||
* */
|
* @throws TooManyResultsException
|
||||||
|
*/
|
||||||
User findByAccount(String account) throws TooManyResultsException;
|
User findByAccount(String account) throws TooManyResultsException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +34,7 @@ public interface UserService extends Service<User> {
|
|||||||
* @param code 验证码
|
* @param code 验证码
|
||||||
* @return Map
|
* @return Map
|
||||||
*/
|
*/
|
||||||
void register(String email, String password, String code) throws ServiceException;
|
boolean register(String email, String password, String code);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录接口
|
* 登录接口
|
||||||
@ -47,9 +47,10 @@ public interface UserService extends Service<User> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过 account 获取用户信息接口
|
* 通过 account 获取用户信息接口
|
||||||
|
*
|
||||||
* @param account 昵称
|
* @param account 昵称
|
||||||
* @return UserDTO
|
* @return UserDTO
|
||||||
* */
|
*/
|
||||||
UserDTO findUserDTOByAccount(String account);
|
UserDTO findUserDTOByAccount(String account);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,8 +59,9 @@ public interface UserService extends Service<User> {
|
|||||||
* @param code 验证码
|
* @param code 验证码
|
||||||
* @param password 密码
|
* @param password 密码
|
||||||
* @return Map
|
* @return Map
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
String forgetPassword(String code, String password) throws ServiceException;
|
boolean forgetPassword(String code, String password) throws ServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新用户角色接口
|
* 更新用户角色接口
|
||||||
@ -67,6 +69,7 @@ public interface UserService extends Service<User> {
|
|||||||
* @param idUser 用户 id
|
* @param idUser 用户 id
|
||||||
* @param idRole 角色 id
|
* @param idRole 角色 id
|
||||||
* @return Map
|
* @return Map
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
boolean updateUserRole(Long idUser, Long idRole) throws ServiceException;
|
boolean updateUserRole(Long idUser, Long idRole) throws ServiceException;
|
||||||
|
|
||||||
@ -76,23 +79,26 @@ public interface UserService extends Service<User> {
|
|||||||
* @param idUser 用户 id
|
* @param idUser 用户 id
|
||||||
* @param status 状态
|
* @param status 状态
|
||||||
* @return Map
|
* @return Map
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
boolean updateStatus(Long idUser, String status) throws ServiceException;
|
boolean updateStatus(Long idUser, String status) throws ServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户信息
|
* 获取用户信息
|
||||||
|
*
|
||||||
* @param idUser
|
* @param idUser
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Map findUserInfo(Long idUser);
|
UserInfoDTO findUserInfo(Long idUser);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新用户信息
|
* 更新用户信息
|
||||||
*
|
*
|
||||||
* @param user
|
* @param user
|
||||||
* @return
|
* @return
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
UserInfoDTO updateUserInfo(UserInfoDTO user) throws Exception;
|
UserInfoDTO updateUserInfo(UserInfoDTO user) throws ServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证昵称是否重复
|
* 验证昵称是否重复
|
||||||
@ -101,10 +107,11 @@ public interface UserService extends Service<User> {
|
|||||||
* @param nickname
|
* @param nickname
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
boolean checkNickname(Long idUser, String nickname) throws ServiceException;
|
boolean checkNicknameByIdUser(Long idUser, String nickname);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户权限
|
* 获取用户权限
|
||||||
|
*
|
||||||
* @param idUser
|
* @param idUser
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -112,6 +119,7 @@ public interface UserService extends Service<User> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询作者信息
|
* 查询作者信息
|
||||||
|
*
|
||||||
* @param idUser
|
* @param idUser
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -127,6 +135,7 @@ public interface UserService extends Service<User> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户扩展信息
|
* 获取用户扩展信息
|
||||||
|
*
|
||||||
* @param account
|
* @param account
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -137,8 +146,9 @@ public interface UserService extends Service<User> {
|
|||||||
*
|
*
|
||||||
* @param changeEmailDTO
|
* @param changeEmailDTO
|
||||||
* @return
|
* @return
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
String updateEmail(ChangeEmailDTO changeEmailDTO) throws ServiceException;
|
boolean updateEmail(ChangeEmailDTO changeEmailDTO) throws ServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新密码
|
* 更新密码
|
||||||
@ -150,15 +160,25 @@ public interface UserService extends Service<User> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户列表
|
* 查询用户列表
|
||||||
|
*
|
||||||
* @param searchDTO
|
* @param searchDTO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<UserInfoDTO> findUsers(UserSearchDTO searchDTO);
|
List<UserInfoDTO> findUsers(UserSearchDTO searchDTO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过邮箱查询用户信息
|
* 通过邮箱更新用户最后登录时间
|
||||||
|
*
|
||||||
* @param email
|
* @param email
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Integer updateLastOnlineTimeByEmail(String email);
|
Integer updateLastOnlineTimeByEmail(String email);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户扩展信息
|
||||||
|
*
|
||||||
|
* @param idUser
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
UserExtend findUserExtendInfo(Long idUser);
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,9 @@ import com.rymcu.forest.core.exception.BusinessException;
|
|||||||
import com.rymcu.forest.core.service.AbstractService;
|
import com.rymcu.forest.core.service.AbstractService;
|
||||||
import com.rymcu.forest.entity.Article;
|
import com.rymcu.forest.entity.Article;
|
||||||
import com.rymcu.forest.entity.ArticleThumbsUp;
|
import com.rymcu.forest.entity.ArticleThumbsUp;
|
||||||
import com.rymcu.forest.entity.User;
|
|
||||||
import com.rymcu.forest.mapper.ArticleThumbsUpMapper;
|
import com.rymcu.forest.mapper.ArticleThumbsUpMapper;
|
||||||
import com.rymcu.forest.service.ArticleService;
|
import com.rymcu.forest.service.ArticleService;
|
||||||
import com.rymcu.forest.service.ArticleThumbsUpService;
|
import com.rymcu.forest.service.ArticleThumbsUpService;
|
||||||
import com.rymcu.forest.util.UserUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -29,34 +27,25 @@ public class ArticleThumbsUpServiceImpl extends AbstractService<ArticleThumbsUp>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public String thumbsUp(ArticleThumbsUp articleThumbsUp) throws Exception {
|
public int thumbsUp(ArticleThumbsUp articleThumbsUp) {
|
||||||
if (Objects.isNull(articleThumbsUp) || Objects.isNull(articleThumbsUp.getIdArticle())) {
|
int thumbsUpNumber = 1;
|
||||||
|
Article article = articleService.findById(String.valueOf(articleThumbsUp.getIdArticle()));
|
||||||
|
if (Objects.isNull(article)) {
|
||||||
throw new BusinessException("数据异常,文章不存在!");
|
throw new BusinessException("数据异常,文章不存在!");
|
||||||
} else {
|
} else {
|
||||||
Integer thumbsUpNumber = 1;
|
ArticleThumbsUp thumbsUp = articleThumbsUpMapper.selectOne(articleThumbsUp);
|
||||||
Article article = articleService.findById(String.valueOf(articleThumbsUp.getIdArticle()));
|
if (Objects.isNull(thumbsUp)) {
|
||||||
if (Objects.isNull(article)) {
|
// 点赞
|
||||||
throw new BusinessException("数据异常,文章不存在!");
|
articleThumbsUp.setThumbsUpTime(new Date());
|
||||||
|
articleThumbsUpMapper.insertSelective(articleThumbsUp);
|
||||||
} else {
|
} else {
|
||||||
User user = UserUtils.getCurrentUserByToken();
|
// 取消点赞
|
||||||
articleThumbsUp.setIdUser(user.getIdUser());
|
articleThumbsUpMapper.deleteByPrimaryKey(thumbsUp.getIdArticleThumbsUp());
|
||||||
ArticleThumbsUp thumbsUp = articleThumbsUpMapper.selectOne(articleThumbsUp);
|
thumbsUpNumber = -1;
|
||||||
if (Objects.isNull(thumbsUp)) {
|
|
||||||
articleThumbsUp.setThumbsUpTime(new Date());
|
|
||||||
articleThumbsUpMapper.insertSelective(articleThumbsUp);
|
|
||||||
// 更新文章点赞数
|
|
||||||
} else {
|
|
||||||
articleThumbsUpMapper.deleteByPrimaryKey(thumbsUp.getIdArticleThumbsUp());
|
|
||||||
// 更新文章点赞数
|
|
||||||
thumbsUpNumber = -1;
|
|
||||||
}
|
|
||||||
articleThumbsUpMapper.updateArticleThumbsUpNumber(articleThumbsUp.getIdArticle(), thumbsUpNumber);
|
|
||||||
if (thumbsUpNumber > 0) {
|
|
||||||
return "点赞成功";
|
|
||||||
} else {
|
|
||||||
return "已取消点赞";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// 更新文章点赞数
|
||||||
|
articleThumbsUpMapper.updateArticleThumbsUpNumber(articleThumbsUp.getIdArticle(), thumbsUpNumber);
|
||||||
|
return thumbsUpNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,20 +4,18 @@ import com.github.pagehelper.PageHelper;
|
|||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.rymcu.forest.core.exception.BusinessException;
|
import com.rymcu.forest.core.exception.BusinessException;
|
||||||
import com.rymcu.forest.core.exception.ServiceException;
|
import com.rymcu.forest.core.exception.ServiceException;
|
||||||
|
import com.rymcu.forest.core.exception.UltraViresException;
|
||||||
import com.rymcu.forest.core.service.AbstractService;
|
import com.rymcu.forest.core.service.AbstractService;
|
||||||
import com.rymcu.forest.dto.*;
|
import com.rymcu.forest.dto.*;
|
||||||
import com.rymcu.forest.entity.Portfolio;
|
import com.rymcu.forest.entity.Portfolio;
|
||||||
import com.rymcu.forest.entity.User;
|
|
||||||
import com.rymcu.forest.lucene.model.PortfolioLucene;
|
import com.rymcu.forest.lucene.model.PortfolioLucene;
|
||||||
import com.rymcu.forest.lucene.util.PortfolioIndexUtil;
|
import com.rymcu.forest.lucene.util.PortfolioIndexUtil;
|
||||||
import com.rymcu.forest.mapper.PortfolioMapper;
|
import com.rymcu.forest.mapper.PortfolioMapper;
|
||||||
import com.rymcu.forest.service.ArticleService;
|
import com.rymcu.forest.service.ArticleService;
|
||||||
import com.rymcu.forest.service.PortfolioService;
|
import com.rymcu.forest.service.PortfolioService;
|
||||||
import com.rymcu.forest.service.UserService;
|
import com.rymcu.forest.service.UserService;
|
||||||
import com.rymcu.forest.util.UserUtils;
|
|
||||||
import com.rymcu.forest.util.XssUtils;
|
import com.rymcu.forest.util.XssUtils;
|
||||||
import com.rymcu.forest.web.api.common.UploadController;
|
import com.rymcu.forest.web.api.common.UploadController;
|
||||||
import com.rymcu.forest.web.api.exception.BaseApiException;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -64,15 +62,12 @@ public class PortfolioServiceImpl extends AbstractService<Portfolio> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Portfolio postPortfolio(Portfolio portfolio) throws BaseApiException {
|
public Portfolio postPortfolio(Portfolio portfolio) {
|
||||||
User user = UserUtils.getCurrentUserByToken();
|
|
||||||
assert user != null;
|
|
||||||
if (StringUtils.isNotBlank(portfolio.getHeadImgType())) {
|
if (StringUtils.isNotBlank(portfolio.getHeadImgType())) {
|
||||||
String headImgUrl = UploadController.uploadBase64File(portfolio.getHeadImgUrl(), 0);
|
String headImgUrl = UploadController.uploadBase64File(portfolio.getHeadImgUrl(), 0);
|
||||||
portfolio.setHeadImgUrl(headImgUrl);
|
portfolio.setHeadImgUrl(headImgUrl);
|
||||||
}
|
}
|
||||||
if (portfolio.getIdPortfolio() == null || portfolio.getIdPortfolio() == 0) {
|
if (portfolio.getIdPortfolio() == null || portfolio.getIdPortfolio() == 0) {
|
||||||
portfolio.setPortfolioAuthorId(user.getIdUser());
|
|
||||||
portfolio.setCreatedTime(new Date());
|
portfolio.setCreatedTime(new Date());
|
||||||
portfolio.setUpdatedTime(portfolio.getCreatedTime());
|
portfolio.setUpdatedTime(portfolio.getCreatedTime());
|
||||||
portfolio.setPortfolioDescriptionHtml(XssUtils.filterHtmlCode(portfolio.getPortfolioDescription()));
|
portfolio.setPortfolioDescriptionHtml(XssUtils.filterHtmlCode(portfolio.getPortfolioDescription()));
|
||||||
@ -97,61 +92,47 @@ public class PortfolioServiceImpl extends AbstractService<Portfolio> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageInfo findUnbindArticles(Integer page, Integer rows, String searchText, Long idPortfolio) throws Exception {
|
public PageInfo<ArticleDTO> findUnbindArticles(Integer page, Integer rows, String searchText, Long idPortfolio, Long idUser) {
|
||||||
User user = UserUtils.getCurrentUserByToken();
|
|
||||||
Portfolio portfolio = portfolioMapper.selectByPrimaryKey(idPortfolio);
|
Portfolio portfolio = portfolioMapper.selectByPrimaryKey(idPortfolio);
|
||||||
if (portfolio == null) {
|
if (portfolio == null) {
|
||||||
throw new ServiceException("该作品集不存在或已被删除!");
|
throw new BusinessException("该作品集不存在或已被删除!");
|
||||||
} else {
|
} else {
|
||||||
if (!user.getIdUser().equals(portfolio.getPortfolioAuthorId())) {
|
if (!idUser.equals(portfolio.getPortfolioAuthorId())) {
|
||||||
throw new ServiceException("非法操作!");
|
throw new UltraViresException("非法操作!");
|
||||||
} else {
|
} else {
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
List<ArticleDTO> articles = articleService.selectUnbindArticles(idPortfolio, searchText, user.getIdUser());
|
List<ArticleDTO> articles = articleService.selectUnbindArticles(idPortfolio, searchText, idUser);
|
||||||
PageInfo<ArticleDTO> pageInfo = new PageInfo(articles);
|
return new PageInfo<>(articles);
|
||||||
return pageInfo;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean bindArticle(PortfolioArticleDTO portfolioArticle) throws Exception {
|
public boolean bindArticle(PortfolioArticleDTO portfolioArticle) throws ServiceException {
|
||||||
Integer count = portfolioMapper.selectCountPortfolioArticle(portfolioArticle.getIdArticle(), portfolioArticle.getIdPortfolio());
|
Integer count = portfolioMapper.selectCountPortfolioArticle(portfolioArticle.getIdArticle(), portfolioArticle.getIdPortfolio());
|
||||||
if (count.equals(0)) {
|
if (count.equals(0)) {
|
||||||
Integer maxSortNo = portfolioMapper.selectMaxSortNo(portfolioArticle.getIdPortfolio());
|
Integer maxSortNo = portfolioMapper.selectMaxSortNo(portfolioArticle.getIdPortfolio());
|
||||||
portfolioMapper.insertPortfolioArticle(portfolioArticle.getIdArticle(), portfolioArticle.getIdPortfolio(), maxSortNo);
|
Integer result = portfolioMapper.insertPortfolioArticle(portfolioArticle.getIdArticle(), portfolioArticle.getIdPortfolio(), maxSortNo);
|
||||||
return true;
|
if (result == 0) {
|
||||||
|
throw new ServiceException("更新失败!");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new ServiceException("该文章已经在作品集下!!");
|
throw new BusinessException("该文章已经在作品集下!!");
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateArticleSortNo(PortfolioArticleDTO portfolioArticle) throws Exception {
|
public boolean updateArticleSortNo(PortfolioArticleDTO portfolioArticle) throws ServiceException {
|
||||||
if (portfolioArticle.getIdPortfolio() == null || portfolioArticle.getIdPortfolio().equals(0)) {
|
|
||||||
throw new ServiceException("作品集数据异常!");
|
|
||||||
}
|
|
||||||
if (portfolioArticle.getIdArticle() == null || portfolioArticle.getIdArticle().equals(0)) {
|
|
||||||
throw new ServiceException("文章数据异常!");
|
|
||||||
}
|
|
||||||
if (portfolioArticle.getSortNo() == null) {
|
|
||||||
throw new ServiceException("排序号不能为空!");
|
|
||||||
}
|
|
||||||
Integer result = portfolioMapper.updateArticleSortNo(portfolioArticle.getIdPortfolio(), portfolioArticle.getIdArticle(), portfolioArticle.getSortNo());
|
Integer result = portfolioMapper.updateArticleSortNo(portfolioArticle.getIdPortfolio(), portfolioArticle.getIdArticle(), portfolioArticle.getSortNo());
|
||||||
if (result > 0) {
|
if (result == 0) {
|
||||||
throw new ServiceException("更新失败!");
|
throw new ServiceException("更新失败!");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean unbindArticle(Long idPortfolio, Long idArticle) throws Exception {
|
public boolean unbindArticle(Long idPortfolio, Long idArticle) throws ServiceException {
|
||||||
if (idPortfolio == null || idPortfolio.equals(0)) {
|
|
||||||
throw new ServiceException("作品集数据异常");
|
|
||||||
}
|
|
||||||
if (idArticle == null || idArticle.equals(0)) {
|
|
||||||
throw new ServiceException("文章数据异常");
|
|
||||||
}
|
|
||||||
Integer result = portfolioMapper.unbindArticle(idPortfolio, idArticle);
|
Integer result = portfolioMapper.unbindArticle(idPortfolio, idArticle);
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
throw new ServiceException("操作失败!");
|
throw new ServiceException("操作失败!");
|
||||||
@ -160,7 +141,7 @@ public class PortfolioServiceImpl extends AbstractService<Portfolio> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean deletePortfolio(Long idPortfolio, Long idUser, Integer roleWeights) throws BaseApiException, IllegalAccessException {
|
public boolean deletePortfolio(Long idPortfolio, Long idUser, Integer roleWeights) {
|
||||||
if (idPortfolio == null || idPortfolio == 0) {
|
if (idPortfolio == null || idPortfolio == 0) {
|
||||||
throw new IllegalArgumentException("作品集数据异常!");
|
throw new IllegalArgumentException("作品集数据异常!");
|
||||||
}
|
}
|
||||||
@ -168,7 +149,7 @@ public class PortfolioServiceImpl extends AbstractService<Portfolio> implements
|
|||||||
if (roleWeights > 2) {
|
if (roleWeights > 2) {
|
||||||
Portfolio portfolio = portfolioMapper.selectByPrimaryKey(idPortfolio);
|
Portfolio portfolio = portfolioMapper.selectByPrimaryKey(idPortfolio);
|
||||||
if (!idUser.equals(portfolio.getPortfolioAuthorId())) {
|
if (!idUser.equals(portfolio.getPortfolioAuthorId())) {
|
||||||
throw new IllegalAccessException("非法访问!");
|
throw new UltraViresException("非法访问!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,7 @@ public class RoleServiceImpl extends AbstractService<Role> implements RoleServic
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Role> selectRoleByUser(User sysUser) {
|
public List<Role> selectRoleByUser(User sysUser) {
|
||||||
List<Role> roles = roleMapper.selectRoleByIdUser(sysUser.getIdUser());
|
return roleMapper.selectRoleByIdUser(sysUser.getIdUser());
|
||||||
return roles;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -36,8 +35,8 @@ public class RoleServiceImpl extends AbstractService<Role> implements RoleServic
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean updateStatus(Long idRole, String status) throws Exception {
|
public boolean updateStatus(Long idRole, String status) throws ServiceException {
|
||||||
Integer result = roleMapper.updateStatus(idRole, status);
|
Integer result = roleMapper.updateStatus(idRole, status);
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
throw new ServiceException("更新失败");
|
throw new ServiceException("更新失败");
|
||||||
@ -46,7 +45,7 @@ public class RoleServiceImpl extends AbstractService<Role> implements RoleServic
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveRole(Role role) throws Exception {
|
public boolean saveRole(Role role) throws ServiceException {
|
||||||
Integer result;
|
Integer result;
|
||||||
if (role.getIdRole() == null) {
|
if (role.getIdRole() == null) {
|
||||||
role.setCreatedTime(new Date());
|
role.setCreatedTime(new Date());
|
||||||
|
@ -39,25 +39,22 @@ public class SponsorServiceImpl extends AbstractService<Sponsor> implements Spon
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean sponsorship(Sponsor sponsor) throws Exception {
|
public boolean sponsorship(Sponsor sponsor) throws Exception {
|
||||||
if (Objects.isNull(sponsor) || Objects.isNull(sponsor.getDataId()) || Objects.isNull(sponsor.getDataType())) {
|
TransactionEnum transactionEnum = TransactionEnum.findTransactionEnum(sponsor.getDataType());
|
||||||
throw new ServiceException("数据异常");
|
BigDecimal money = BigDecimal.valueOf(transactionEnum.getMoney());
|
||||||
} else {
|
sponsor.setSponsorshipMoney(money);
|
||||||
TransactionEnum result = TransactionEnum.findTransactionEnum(sponsor.getDataType());
|
sponsor.setSponsorshipTime(new Date());
|
||||||
BigDecimal money = BigDecimal.valueOf(result.getMoney());
|
sponsorMapper.insertSelective(sponsor);
|
||||||
sponsor.setSponsorshipMoney(money);
|
// 赞赏金额划转
|
||||||
User user = UserUtils.getCurrentUserByToken();
|
if (transactionEnum.isArticleSponsor()) {
|
||||||
sponsor.setSponsor(user.getIdUser());
|
ArticleDTO articleDTO = articleService.findArticleDTOById(sponsor.getDataId(), 1);
|
||||||
sponsor.setSponsorshipTime(new Date());
|
TransactionRecord transactionRecord = transactionRecordService.userTransfer(articleDTO.getArticleAuthorId(), sponsor.getSponsor(), transactionEnum);
|
||||||
sponsorMapper.insertSelective(sponsor);
|
if (Objects.isNull(transactionRecord.getIdTransactionRecord())) {
|
||||||
// 赞赏金额划转
|
throw new TransactionException(TransactionCode.InsufficientBalance);
|
||||||
if (result.isArticleSponsor()) {
|
}
|
||||||
ArticleDTO articleDTO = articleService.findArticleDTOById(sponsor.getDataId(), 1);
|
// 更新文章赞赏数
|
||||||
TransactionRecord transactionRecord = transactionRecordService.userTransfer(articleDTO.getArticleAuthorId(), user.getIdUser(), result);
|
int result = sponsorMapper.updateArticleSponsorCount(articleDTO.getIdArticle());
|
||||||
if (Objects.isNull(transactionRecord.getIdTransactionRecord())) {
|
if (result == 0) {
|
||||||
throw new TransactionException(TransactionCode.InsufficientBalance);
|
throw new ServiceException("操作失败!");
|
||||||
}
|
|
||||||
// 更新文章赞赏数
|
|
||||||
sponsorMapper.updateArticleSponsorCount(articleDTO.getIdArticle());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.rymcu.forest.service.impl;
|
package com.rymcu.forest.service.impl;
|
||||||
|
|
||||||
|
import com.rymcu.forest.core.exception.BusinessException;
|
||||||
import com.rymcu.forest.core.exception.ServiceException;
|
import com.rymcu.forest.core.exception.ServiceException;
|
||||||
import com.rymcu.forest.core.service.AbstractService;
|
import com.rymcu.forest.core.service.AbstractService;
|
||||||
import com.rymcu.forest.dto.ArticleTagDTO;
|
import com.rymcu.forest.dto.ArticleTagDTO;
|
||||||
@ -120,17 +121,16 @@ public class TagServiceImpl extends AbstractService<Tag> implements TagService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Tag saveTag(Tag tag) throws Exception {
|
public Tag saveTag(Tag tag) throws Exception {
|
||||||
Integer result;
|
Integer result;
|
||||||
|
|
||||||
tag.setTagDescription(XssUtils.filterHtmlCode(tag.getTagDescription()));
|
tag.setTagDescription(XssUtils.filterHtmlCode(tag.getTagDescription()));
|
||||||
if (tag.getIdTag() == null) {
|
if (tag.getIdTag() == null) {
|
||||||
if (StringUtils.isBlank(tag.getTagTitle())) {
|
if (StringUtils.isBlank(tag.getTagTitle())) {
|
||||||
throw new ServiceException("标签名不能为空!");
|
throw new IllegalArgumentException("标签名不能为空!");
|
||||||
} else {
|
} else {
|
||||||
Condition tagCondition = new Condition(Tag.class);
|
Condition tagCondition = new Condition(Tag.class);
|
||||||
tagCondition.createCriteria().andCondition("tag_title =", tag.getTagTitle());
|
tagCondition.createCriteria().andCondition("tag_title =", tag.getTagTitle());
|
||||||
List<Tag> tags = tagMapper.selectByCondition(tagCondition);
|
List<Tag> tags = tagMapper.selectByCondition(tagCondition);
|
||||||
if (!tags.isEmpty()) {
|
if (!tags.isEmpty()) {
|
||||||
throw new ServiceException("标签 '" + tag.getTagTitle() + "' 已存在!");
|
throw new BusinessException("标签 '" + tag.getTagTitle() + "' 已存在!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tag = new Tag();
|
tag = new Tag();
|
||||||
|
@ -2,6 +2,7 @@ package com.rymcu.forest.service.impl;
|
|||||||
|
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.rymcu.forest.core.exception.BusinessException;
|
||||||
import com.rymcu.forest.core.exception.ServiceException;
|
import com.rymcu.forest.core.exception.ServiceException;
|
||||||
import com.rymcu.forest.core.service.AbstractService;
|
import com.rymcu.forest.core.service.AbstractService;
|
||||||
import com.rymcu.forest.dto.admin.TagDTO;
|
import com.rymcu.forest.dto.admin.TagDTO;
|
||||||
@ -33,8 +34,7 @@ public class TopicServiceImpl extends AbstractService<Topic> implements TopicSer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Topic> findTopicNav() {
|
public List<Topic> findTopicNav() {
|
||||||
List<Topic> topics = topicMapper.selectTopicNav();
|
return topicMapper.selectTopicNav();
|
||||||
return topics;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -46,18 +46,18 @@ public class TopicServiceImpl extends AbstractService<Topic> implements TopicSer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Topic saveTopic(Topic topic) throws Exception {
|
public Topic saveTopic(Topic topic) throws ServiceException {
|
||||||
Integer result;
|
Integer result;
|
||||||
topic.setTopicDescriptionHtml(XssUtils.filterHtmlCode(topic.getTopicDescriptionHtml()));
|
topic.setTopicDescriptionHtml(XssUtils.filterHtmlCode(topic.getTopicDescriptionHtml()));
|
||||||
if (topic.getIdTopic() == null) {
|
if (topic.getIdTopic() == null) {
|
||||||
if (StringUtils.isBlank(topic.getTopicTitle())) {
|
if (StringUtils.isBlank(topic.getTopicTitle())) {
|
||||||
throw new ServiceException("标签名不能为空!");
|
throw new IllegalArgumentException("标签名不能为空!");
|
||||||
} else {
|
} else {
|
||||||
Condition topicCondition = new Condition(Topic.class);
|
Condition topicCondition = new Condition(Topic.class);
|
||||||
topicCondition.createCriteria().andCondition("topic_title =", topic.getTopicTitle());
|
topicCondition.createCriteria().andCondition("topic_title =", topic.getTopicTitle());
|
||||||
List<Topic> topics = topicMapper.selectByCondition(topicCondition);
|
List<Topic> topics = topicMapper.selectByCondition(topicCondition);
|
||||||
if (!topics.isEmpty()) {
|
if (!topics.isEmpty()) {
|
||||||
throw new ServiceException("专题 '" + topic.getTopicTitle() + "' 已存在!");
|
throw new BusinessException("专题 '" + topic.getTopicTitle() + "' 已存在!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
topic = new Topic();
|
topic = new Topic();
|
||||||
@ -103,7 +103,7 @@ public class TopicServiceImpl extends AbstractService<Topic> implements TopicSer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public TopicTagDTO bindTopicTag(TopicTagDTO topicTag) throws Exception {
|
public TopicTagDTO bindTopicTag(TopicTagDTO topicTag) throws ServiceException {
|
||||||
Integer result = topicMapper.insertTopicTag(topicTag.getIdTopic(), topicTag.getIdTag());
|
Integer result = topicMapper.insertTopicTag(topicTag.getIdTopic(), topicTag.getIdTag());
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
throw new ServiceException("操作失败!");
|
throw new ServiceException("操作失败!");
|
||||||
@ -113,7 +113,7 @@ public class TopicServiceImpl extends AbstractService<Topic> implements TopicSer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public TopicTagDTO unbindTopicTag(TopicTagDTO topicTag) throws Exception {
|
public TopicTagDTO unbindTopicTag(TopicTagDTO topicTag) throws ServiceException {
|
||||||
Integer result = topicMapper.deleteTopicTag(topicTag.getIdTopic(), topicTag.getIdTag());
|
Integer result = topicMapper.deleteTopicTag(topicTag.getIdTopic(), topicTag.getIdTag());
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
throw new ServiceException("操作失败!");
|
throw new ServiceException("操作失败!");
|
||||||
@ -122,14 +122,11 @@ public class TopicServiceImpl extends AbstractService<Topic> implements TopicSer
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageInfo findTagsByTopicUri(String topicUri, Integer page, Integer rows) {
|
public List<TagDTO> findTagsByTopicUri(String topicUri) {
|
||||||
TopicDTO topic = topicMapper.selectTopicByTopicUri(topicUri);
|
TopicDTO topic = topicMapper.selectTopicByTopicUri(topicUri);
|
||||||
if (topic == null) {
|
if (topic == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
PageHelper.startPage(page, rows);
|
return topicMapper.selectTopicTag(topic.getIdTopic());
|
||||||
List<TagDTO> list = topicMapper.selectTopicTag(topic.getIdTopic());
|
|
||||||
PageInfo pageInfo = new PageInfo(list);
|
|
||||||
return pageInfo;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class TransactionRecordServiceImpl extends AbstractService<TransactionRec
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public TransactionRecord transfer(TransactionRecord transactionRecord) throws Exception {
|
public TransactionRecord transfer(TransactionRecord transactionRecord) {
|
||||||
// 判断发起者账户状态
|
// 判断发起者账户状态
|
||||||
boolean formAccountStatus = checkFormAccountStatus(transactionRecord.getFormBankAccount(), transactionRecord.getMoney());
|
boolean formAccountStatus = checkFormAccountStatus(transactionRecord.getFormBankAccount(), transactionRecord.getMoney());
|
||||||
if (formAccountStatus) {
|
if (formAccountStatus) {
|
||||||
@ -70,7 +70,7 @@ public class TransactionRecordServiceImpl extends AbstractService<TransactionRec
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TransactionRecord userTransfer(Long toUserId, Long formUserId, TransactionEnum transactionType) throws Exception {
|
public TransactionRecord userTransfer(Long toUserId, Long formUserId, TransactionEnum transactionType) {
|
||||||
BankAccountDTO toBankAccount = bankAccountService.findBankAccountByIdUser(toUserId);
|
BankAccountDTO toBankAccount = bankAccountService.findBankAccountByIdUser(toUserId);
|
||||||
BankAccountDTO formBankAccount = bankAccountService.findBankAccountByIdUser(formUserId);
|
BankAccountDTO formBankAccount = bankAccountService.findBankAccountByIdUser(formUserId);
|
||||||
TransactionRecord transactionRecord = new TransactionRecord();
|
TransactionRecord transactionRecord = new TransactionRecord();
|
||||||
@ -82,7 +82,7 @@ public class TransactionRecordServiceImpl extends AbstractService<TransactionRec
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TransactionRecord bankTransfer(Long idUser, TransactionEnum transactionType) throws Exception {
|
public TransactionRecord bankTransfer(Long idUser, TransactionEnum transactionType) {
|
||||||
BankAccountDTO toBankAccount = bankAccountService.findBankAccountByIdUser(idUser);
|
BankAccountDTO toBankAccount = bankAccountService.findBankAccountByIdUser(idUser);
|
||||||
Boolean isTrue;
|
Boolean isTrue;
|
||||||
// 校验货币规则
|
// 校验货币规则
|
||||||
@ -107,7 +107,7 @@ public class TransactionRecordServiceImpl extends AbstractService<TransactionRec
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TransactionRecord newbieRewards(TransactionRecord transactionRecord) throws Exception {
|
public TransactionRecord newbieRewards(TransactionRecord transactionRecord) {
|
||||||
// 判断是否重复发放
|
// 判断是否重复发放
|
||||||
Boolean result = transactionRecordMapper.existsWithNewbieRewards(transactionRecord.getToBankAccount());
|
Boolean result = transactionRecordMapper.existsWithNewbieRewards(transactionRecord.getToBankAccount());
|
||||||
if (result) {
|
if (result) {
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package com.rymcu.forest.service.impl;
|
package com.rymcu.forest.service.impl;
|
||||||
|
|
||||||
import com.rymcu.forest.core.exception.CaptchaException;
|
import com.rymcu.forest.core.exception.*;
|
||||||
import com.rymcu.forest.core.exception.ContentNotExistException;
|
|
||||||
import com.rymcu.forest.core.exception.ServiceException;
|
|
||||||
import com.rymcu.forest.core.service.AbstractService;
|
import com.rymcu.forest.core.service.AbstractService;
|
||||||
import com.rymcu.forest.core.service.redis.RedisService;
|
import com.rymcu.forest.core.service.redis.RedisService;
|
||||||
import com.rymcu.forest.dto.*;
|
import com.rymcu.forest.dto.*;
|
||||||
@ -61,13 +59,13 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void register(String email, String password, String code) throws ServiceException {
|
public boolean register(String email, String password, String code) {
|
||||||
String vCode = redisService.get(email);
|
String vCode = redisService.get(email);
|
||||||
if (StringUtils.isNotBlank(vCode)) {
|
if (StringUtils.isNotBlank(vCode)) {
|
||||||
if (vCode.equals(code)) {
|
if (vCode.equals(code)) {
|
||||||
User user = userMapper.findByAccount(email);
|
User user = userMapper.findByAccount(email);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
throw new ServiceException("该邮箱已被注册!");
|
throw new AccountExistsException("该邮箱已被注册!");
|
||||||
} else {
|
} else {
|
||||||
user = new User();
|
user = new User();
|
||||||
String nickname = email.split("@")[0];
|
String nickname = email.split("@")[0];
|
||||||
@ -88,11 +86,11 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|||||||
.signature(user.getSignature())
|
.signature(user.getSignature())
|
||||||
.build());
|
.build());
|
||||||
redisService.delete(email);
|
redisService.delete(email);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new ServiceException("验证码无效!");
|
throw new CaptchaException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String checkNickname(String nickname) {
|
private String checkNickname(String nickname) {
|
||||||
@ -143,13 +141,16 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String forgetPassword(String code, String password) throws ServiceException {
|
public boolean forgetPassword(String code, String password) throws ServiceException {
|
||||||
String email = redisService.get(code);
|
String email = redisService.get(code);
|
||||||
if (StringUtils.isBlank(email)) {
|
if (StringUtils.isBlank(email)) {
|
||||||
throw new ServiceException("链接已失效");
|
throw new ServiceException("链接已失效");
|
||||||
} else {
|
} else {
|
||||||
userMapper.updatePasswordByEmail(email, Utils.entryptPassword(password));
|
int result = userMapper.updatePasswordByEmail(email, Utils.entryptPassword(password));
|
||||||
return "修改成功,正在跳转登录登陆界面!";
|
if (result == 0) {
|
||||||
|
throw new ServiceException("密码修改失败!");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,31 +175,21 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map findUserInfo(Long idUser) {
|
public UserInfoDTO findUserInfo(Long idUser) {
|
||||||
Map map = new HashMap(2);
|
|
||||||
UserInfoDTO user = userMapper.selectUserInfo(idUser);
|
UserInfoDTO user = userMapper.selectUserInfo(idUser);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new ContentNotExistException("用户不存在!");
|
throw new ContentNotExistException("用户不存在!");
|
||||||
} else {
|
|
||||||
UserExtend userExtend = userExtendMapper.selectByPrimaryKey(user.getIdUser());
|
|
||||||
if (Objects.isNull(userExtend)) {
|
|
||||||
userExtend = new UserExtend();
|
|
||||||
userExtend.setIdUser(user.getIdUser());
|
|
||||||
userExtendMapper.insertSelective(userExtend);
|
|
||||||
}
|
|
||||||
map.put("user", user);
|
|
||||||
map.put("userExtend", userExtend);
|
|
||||||
}
|
}
|
||||||
return map;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public UserInfoDTO updateUserInfo(UserInfoDTO user) throws Exception {
|
public UserInfoDTO updateUserInfo(UserInfoDTO user) throws ServiceException {
|
||||||
user.setNickname(formatNickname(user.getNickname()));
|
user.setNickname(formatNickname(user.getNickname()));
|
||||||
Integer number = userMapper.checkNicknameByIdUser(user.getIdUser(), user.getNickname());
|
Integer number = userMapper.checkNicknameByIdUser(user.getIdUser(), user.getNickname());
|
||||||
if (number > 0) {
|
if (number > 0) {
|
||||||
throw new ServiceException("该昵称已使用!");
|
throw new NicknameOccupyException("该昵称已使用!");
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(user.getAvatarType()) && AVATAR_SVG_TYPE.equals(user.getAvatarType())) {
|
if (StringUtils.isNotBlank(user.getAvatarType()) && AVATAR_SVG_TYPE.equals(user.getAvatarType())) {
|
||||||
String avatarUrl = UploadController.uploadBase64File(user.getAvatarUrl(), 0);
|
String avatarUrl = UploadController.uploadBase64File(user.getAvatarUrl(), 0);
|
||||||
@ -222,12 +213,10 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|||||||
return nickname.replaceAll("\\.", "");
|
return nickname.replaceAll("\\.", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean checkNicknameByIdUser(Long idUser, String nickname) {
|
||||||
public boolean checkNickname(Long idUser, String nickname) throws ServiceException {
|
|
||||||
Map map = new HashMap(2);
|
|
||||||
Integer number = userMapper.checkNicknameByIdUser(idUser, nickname);
|
Integer number = userMapper.checkNicknameByIdUser(idUser, nickname);
|
||||||
if (number > 0) {
|
if (number > 0) {
|
||||||
throw new ServiceException("该昵称已使用!");
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -244,7 +233,7 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserExtend updateUserExtend(UserExtend userExtend) throws ServiceException {
|
public UserExtend updateUserExtend(UserExtend userExtend) throws ServiceException {
|
||||||
int result = userExtendMapper.updateByPrimaryKeySelective(userExtend);
|
int result = userExtendMapper.updateByPrimaryKey(userExtend);
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
throw new ServiceException("操作失败!");
|
throw new ServiceException("操作失败!");
|
||||||
}
|
}
|
||||||
@ -257,14 +246,17 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String updateEmail(ChangeEmailDTO changeEmailDTO) throws ServiceException {
|
public boolean updateEmail(ChangeEmailDTO changeEmailDTO) throws ServiceException {
|
||||||
Long idUser = changeEmailDTO.getIdUser();
|
Long idUser = changeEmailDTO.getIdUser();
|
||||||
String email = changeEmailDTO.getEmail();
|
String email = changeEmailDTO.getEmail();
|
||||||
String code = changeEmailDTO.getCode();
|
String code = changeEmailDTO.getCode();
|
||||||
String vCode = redisService.get(email);
|
String vCode = redisService.get(email);
|
||||||
if (StringUtils.isNotBlank(vCode) && StringUtils.isNotBlank(code) && vCode.equals(code)) {
|
if (StringUtils.isNotBlank(vCode) && StringUtils.isNotBlank(code) && vCode.equals(code)) {
|
||||||
userMapper.updateEmail(idUser, email);
|
int result = userMapper.updateEmail(idUser, email);
|
||||||
return email;
|
if (result == 0) {
|
||||||
|
throw new ServiceException("修改邮箱失败!");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
throw new CaptchaException();
|
throw new CaptchaException();
|
||||||
}
|
}
|
||||||
@ -297,4 +289,15 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|||||||
public Integer updateLastOnlineTimeByEmail(String email) {
|
public Integer updateLastOnlineTimeByEmail(String email) {
|
||||||
return userMapper.updateLastOnlineTimeByEmail(email);
|
return userMapper.updateLastOnlineTimeByEmail(email);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserExtend findUserExtendInfo(Long idUser) {
|
||||||
|
UserExtend userExtend = userExtendMapper.selectByPrimaryKey(idUser);
|
||||||
|
if (Objects.isNull(userExtend)) {
|
||||||
|
userExtend = new UserExtend();
|
||||||
|
userExtend.setIdUser(idUser);
|
||||||
|
userExtendMapper.insertSelective(userExtend);
|
||||||
|
}
|
||||||
|
return userExtend;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import com.rymcu.forest.core.exception.ServiceException;
|
|||||||
import com.rymcu.forest.core.result.GlobalResult;
|
import com.rymcu.forest.core.result.GlobalResult;
|
||||||
import com.rymcu.forest.core.result.GlobalResultGenerator;
|
import com.rymcu.forest.core.result.GlobalResultGenerator;
|
||||||
import com.rymcu.forest.dto.*;
|
import com.rymcu.forest.dto.*;
|
||||||
|
import com.rymcu.forest.dto.admin.TagDTO;
|
||||||
import com.rymcu.forest.dto.admin.TopicTagDTO;
|
import com.rymcu.forest.dto.admin.TopicTagDTO;
|
||||||
import com.rymcu.forest.dto.admin.UserRoleDTO;
|
import com.rymcu.forest.dto.admin.UserRoleDTO;
|
||||||
import com.rymcu.forest.entity.*;
|
import com.rymcu.forest.entity.*;
|
||||||
@ -19,7 +20,7 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ronger
|
* @author ronger
|
||||||
* */
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/admin")
|
@RequestMapping("/api/v1/admin")
|
||||||
public class AdminController {
|
public class AdminController {
|
||||||
@ -42,7 +43,7 @@ public class AdminController {
|
|||||||
private ProductService productService;
|
private ProductService productService;
|
||||||
|
|
||||||
@GetMapping("/users")
|
@GetMapping("/users")
|
||||||
public GlobalResult<PageInfo<UserInfoDTO>> users(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, UserSearchDTO searchDTO){
|
public GlobalResult<PageInfo<UserInfoDTO>> users(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, UserSearchDTO searchDTO) {
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
List<UserInfoDTO> list = userService.findUsers(searchDTO);
|
List<UserInfoDTO> list = userService.findUsers(searchDTO);
|
||||||
PageInfo<UserInfoDTO> pageInfo = new PageInfo<>(list);
|
PageInfo<UserInfoDTO> pageInfo = new PageInfo<>(list);
|
||||||
@ -50,13 +51,13 @@ public class AdminController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/user/{idUser}/role")
|
@GetMapping("/user/{idUser}/role")
|
||||||
public GlobalResult<List<Role>> userRole(@PathVariable Long idUser){
|
public GlobalResult<List<Role>> userRole(@PathVariable Long idUser) {
|
||||||
List<Role> roles = roleService.findByIdUser(idUser);
|
List<Role> roles = roleService.findByIdUser(idUser);
|
||||||
return GlobalResultGenerator.genSuccessResult(roles);
|
return GlobalResultGenerator.genSuccessResult(roles);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/roles")
|
@GetMapping("/roles")
|
||||||
public GlobalResult<PageInfo<Role>> roles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){
|
public GlobalResult<PageInfo<Role>> roles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) {
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
List<Role> list = roleService.findAll();
|
List<Role> list = roleService.findAll();
|
||||||
PageInfo<Role> pageInfo = new PageInfo<>(list);
|
PageInfo<Role> pageInfo = new PageInfo<>(list);
|
||||||
@ -76,25 +77,25 @@ public class AdminController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("/role/update-status")
|
@PatchMapping("/role/update-status")
|
||||||
public GlobalResult<Boolean> updateRoleStatus(@RequestBody Role role) throws Exception {
|
public GlobalResult<Boolean> updateRoleStatus(@RequestBody Role role) throws ServiceException {
|
||||||
boolean flag = roleService.updateStatus(role.getIdRole(), role.getStatus());
|
boolean flag = roleService.updateStatus(role.getIdRole(), role.getStatus());
|
||||||
return GlobalResultGenerator.genSuccessResult(flag);
|
return GlobalResultGenerator.genSuccessResult(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/role/post")
|
@PostMapping("/role/post")
|
||||||
public GlobalResult<Role> addRole(@RequestBody Role role) throws Exception {
|
public GlobalResult<Boolean> addRole(@RequestBody Role role) throws ServiceException {
|
||||||
boolean flag = roleService.saveRole(role);
|
boolean flag = roleService.saveRole(role);
|
||||||
return GlobalResultGenerator.genSuccessResult(role);
|
return GlobalResultGenerator.genSuccessResult(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/role/post")
|
@PutMapping("/role/post")
|
||||||
public GlobalResult<Role> updateRole(@RequestBody Role role) throws Exception {
|
public GlobalResult<Boolean> updateRole(@RequestBody Role role) throws Exception {
|
||||||
boolean flag = roleService.saveRole(role);
|
boolean flag = roleService.saveRole(role);
|
||||||
return GlobalResultGenerator.genSuccessResult(role);
|
return GlobalResultGenerator.genSuccessResult(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/topics")
|
@GetMapping("/topics")
|
||||||
public GlobalResult<PageInfo<Topic>> topics(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){
|
public GlobalResult<PageInfo<Topic>> topics(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) {
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
List<Topic> list = topicService.findAll();
|
List<Topic> list = topicService.findAll();
|
||||||
PageInfo<Topic> pageInfo = new PageInfo<>(list);
|
PageInfo<Topic> pageInfo = new PageInfo<>(list);
|
||||||
@ -102,31 +103,33 @@ public class AdminController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/topic/{topicUri}")
|
@GetMapping("/topic/{topicUri}")
|
||||||
public GlobalResult topic(@PathVariable String topicUri){
|
public GlobalResult topic(@PathVariable String topicUri) {
|
||||||
if (StringUtils.isBlank(topicUri)) {
|
if (StringUtils.isBlank(topicUri)) {
|
||||||
return GlobalResultGenerator.genErrorResult("数据异常!");
|
throw new IllegalArgumentException("参数异常!");
|
||||||
}
|
}
|
||||||
Topic topic = topicService.findTopicByTopicUri(topicUri);
|
Topic topic = topicService.findTopicByTopicUri(topicUri);
|
||||||
return GlobalResultGenerator.genSuccessResult(topic);
|
return GlobalResultGenerator.genSuccessResult(topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/topic/{topicUri}/tags")
|
@GetMapping("/topic/{topicUri}/tags")
|
||||||
public GlobalResult topicTags(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows,@PathVariable String topicUri) {
|
public GlobalResult<PageInfo<TagDTO>> topicTags(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @PathVariable String topicUri) {
|
||||||
if (StringUtils.isBlank(topicUri)) {
|
if (StringUtils.isBlank(topicUri)) {
|
||||||
return GlobalResultGenerator.genErrorResult("数据异常!");
|
throw new IllegalArgumentException("参数异常!");
|
||||||
}
|
}
|
||||||
PageInfo pageInfo = topicService.findTagsByTopicUri(topicUri, page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
|
List<TagDTO> list = topicService.findTagsByTopicUri(topicUri);
|
||||||
|
PageInfo<TagDTO> pageInfo = new PageInfo<>(list);
|
||||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/topic/detail/{idTopic}")
|
@GetMapping("/topic/detail/{idTopic}")
|
||||||
public GlobalResult<Topic> topicDetail(@PathVariable Integer idTopic){
|
public GlobalResult<Topic> topicDetail(@PathVariable Integer idTopic) {
|
||||||
Topic topic = topicService.findById(idTopic.toString());
|
Topic topic = topicService.findById(idTopic.toString());
|
||||||
return GlobalResultGenerator.genSuccessResult(topic);
|
return GlobalResultGenerator.genSuccessResult(topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/topic/unbind-topic-tags")
|
@GetMapping("/topic/unbind-topic-tags")
|
||||||
public GlobalResult<PageInfo<Tag>> unbindTopicTags(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, HttpServletRequest request){
|
public GlobalResult<PageInfo<Tag>> unbindTopicTags(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, HttpServletRequest request) {
|
||||||
Long idTopic = Long.valueOf(request.getParameter("idTopic"));
|
Long idTopic = Long.valueOf(request.getParameter("idTopic"));
|
||||||
String tagTitle = request.getParameter("tagTitle");
|
String tagTitle = request.getParameter("tagTitle");
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
@ -160,7 +163,7 @@ public class AdminController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/tags")
|
@GetMapping("/tags")
|
||||||
public GlobalResult<PageInfo<Tag>> tags(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows){
|
public GlobalResult<PageInfo<Tag>> tags(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) {
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
List<Tag> list = tagService.findAll();
|
List<Tag> list = tagService.findAll();
|
||||||
PageInfo<Tag> pageInfo = new PageInfo<>(list);
|
PageInfo<Tag> pageInfo = new PageInfo<>(list);
|
||||||
@ -174,7 +177,7 @@ public class AdminController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/tag/detail/{idTag}")
|
@GetMapping("/tag/detail/{idTag}")
|
||||||
public GlobalResult<Tag> tagDetail(@PathVariable Integer idTag){
|
public GlobalResult<Tag> tagDetail(@PathVariable Integer idTag) {
|
||||||
Tag tag = tagService.findById(idTag.toString());
|
Tag tag = tagService.findById(idTag.toString());
|
||||||
return GlobalResultGenerator.genSuccessResult(tag);
|
return GlobalResultGenerator.genSuccessResult(tag);
|
||||||
}
|
}
|
||||||
@ -224,5 +227,4 @@ public class AdminController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.rymcu.forest.web.api.article;
|
|||||||
|
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.rymcu.forest.core.exception.BusinessException;
|
||||||
import com.rymcu.forest.core.result.GlobalResult;
|
import com.rymcu.forest.core.result.GlobalResult;
|
||||||
import com.rymcu.forest.core.result.GlobalResultGenerator;
|
import com.rymcu.forest.core.result.GlobalResultGenerator;
|
||||||
import com.rymcu.forest.core.service.security.annotation.AuthorshipInterceptor;
|
import com.rymcu.forest.core.service.security.annotation.AuthorshipInterceptor;
|
||||||
@ -105,13 +106,22 @@ public class ArticleController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/thumbs-up")
|
@PostMapping("/thumbs-up")
|
||||||
public GlobalResult thumbsUp(@RequestBody ArticleThumbsUp articleThumbsUp) throws Exception {
|
public GlobalResult<Integer> thumbsUp(@RequestBody ArticleThumbsUp articleThumbsUp) throws Exception {
|
||||||
String str = articleThumbsUpService.thumbsUp(articleThumbsUp);
|
if (Objects.isNull(articleThumbsUp) || Objects.isNull(articleThumbsUp.getIdArticle())) {
|
||||||
return GlobalResultGenerator.genSuccessResult(str);
|
throw new BusinessException("数据异常,文章不存在!");
|
||||||
|
}
|
||||||
|
User user = UserUtils.getCurrentUserByToken();
|
||||||
|
articleThumbsUp.setIdUser(user.getIdUser());
|
||||||
|
return GlobalResultGenerator.genSuccessResult(articleThumbsUpService.thumbsUp(articleThumbsUp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/sponsor")
|
@PostMapping("/sponsor")
|
||||||
public GlobalResult sponsor(@RequestBody Sponsor sponsor) throws Exception {
|
public GlobalResult sponsor(@RequestBody Sponsor sponsor) throws Exception {
|
||||||
|
if (Objects.isNull(sponsor) || Objects.isNull(sponsor.getDataId()) || Objects.isNull(sponsor.getDataType())) {
|
||||||
|
throw new IllegalArgumentException("数据异常");
|
||||||
|
}
|
||||||
|
User user = UserUtils.getCurrentUserByToken();
|
||||||
|
sponsor.setSponsor(user.getIdUser());
|
||||||
boolean flag = sponsorService.sponsorship(sponsor);
|
boolean flag = sponsorService.sponsorship(sponsor);
|
||||||
return GlobalResultGenerator.genSuccessResult(flag);
|
return GlobalResultGenerator.genSuccessResult(flag);
|
||||||
}
|
}
|
||||||
|
@ -22,13 +22,13 @@ public class TransactionRecordController {
|
|||||||
private TransactionRecordService transactionRecordService;
|
private TransactionRecordService transactionRecordService;
|
||||||
|
|
||||||
@PostMapping("/transfer")
|
@PostMapping("/transfer")
|
||||||
public GlobalResult transfer(@RequestBody TransactionRecord transactionRecord) throws Exception {
|
public GlobalResult transfer(@RequestBody TransactionRecord transactionRecord) {
|
||||||
transactionRecord = transactionRecordService.transfer(transactionRecord);
|
transactionRecord = transactionRecordService.transfer(transactionRecord);
|
||||||
return GlobalResultGenerator.genSuccessResult(transactionRecord);
|
return GlobalResultGenerator.genSuccessResult(transactionRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/newbie-rewards")
|
@PostMapping("/newbie-rewards")
|
||||||
public GlobalResult newbieRewards(@RequestBody TransactionRecord transactionRecord) throws Exception {
|
public GlobalResult newbieRewards(@RequestBody TransactionRecord transactionRecord) {
|
||||||
transactionRecord = transactionRecordService.newbieRewards(transactionRecord);
|
transactionRecord = transactionRecordService.newbieRewards(transactionRecord);
|
||||||
return GlobalResultGenerator.genSuccessResult(transactionRecord);
|
return GlobalResultGenerator.genSuccessResult(transactionRecord);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.rymcu.forest.web.api.common;
|
|||||||
|
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.rymcu.forest.core.exception.AccountExistsException;
|
||||||
import com.rymcu.forest.core.exception.ServiceException;
|
import com.rymcu.forest.core.exception.ServiceException;
|
||||||
import com.rymcu.forest.core.result.GlobalResult;
|
import com.rymcu.forest.core.result.GlobalResult;
|
||||||
import com.rymcu.forest.core.result.GlobalResultGenerator;
|
import com.rymcu.forest.core.result.GlobalResultGenerator;
|
||||||
@ -10,6 +11,7 @@ import com.rymcu.forest.core.service.log.annotation.VisitLogger;
|
|||||||
import com.rymcu.forest.dto.*;
|
import com.rymcu.forest.dto.*;
|
||||||
import com.rymcu.forest.entity.User;
|
import com.rymcu.forest.entity.User;
|
||||||
import com.rymcu.forest.service.*;
|
import com.rymcu.forest.service.*;
|
||||||
|
import org.apache.shiro.authc.UnknownAccountException;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -42,7 +44,7 @@ public class CommonApiController {
|
|||||||
map.put("message", GlobalResultMessage.SEND_SUCCESS.getMessage());
|
map.put("message", GlobalResultMessage.SEND_SUCCESS.getMessage());
|
||||||
User user = userService.findByAccount(email);
|
User user = userService.findByAccount(email);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
map.put("message", "该邮箱已被注册!");
|
throw new AccountExistsException("该邮箱已被注册!");
|
||||||
} else {
|
} else {
|
||||||
Integer result = javaMailService.sendEmailCode(email);
|
Integer result = javaMailService.sendEmailCode(email);
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
@ -53,25 +55,23 @@ public class CommonApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/get-forget-password-email")
|
@GetMapping("/get-forget-password-email")
|
||||||
public GlobalResult<Map<Object, Object>> getForgetPasswordEmail(@RequestParam("email") String email) throws MessagingException {
|
public GlobalResult getForgetPasswordEmail(@RequestParam("email") String email) throws MessagingException, ServiceException {
|
||||||
Map<Object, Object> map = new HashMap<>(1);
|
|
||||||
map.put("message", GlobalResultMessage.SEND_SUCCESS.getMessage());
|
|
||||||
User user = userService.findByAccount(email);
|
User user = userService.findByAccount(email);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
Integer result = javaMailService.sendForgetPasswordEmail(email);
|
Integer result = javaMailService.sendForgetPasswordEmail(email);
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
map.put("message", GlobalResultMessage.SEND_FAIL.getMessage());
|
throw new ServiceException(GlobalResultMessage.SEND_FAIL.getMessage());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
map.put("message", "该邮箱未注册!");
|
throw new UnknownAccountException("该邮箱未注册!");
|
||||||
}
|
}
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(GlobalResultMessage.SEND_SUCCESS.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/register")
|
@PostMapping("/register")
|
||||||
public GlobalResult<Map> register(@RequestBody UserRegisterInfoDTO registerInfo) throws ServiceException {
|
public GlobalResult<Boolean> register(@RequestBody UserRegisterInfoDTO registerInfo) {
|
||||||
userService.register(registerInfo.getEmail(), registerInfo.getPassword(), registerInfo.getCode());
|
boolean flag = userService.register(registerInfo.getEmail(), registerInfo.getPassword(), registerInfo.getCode());
|
||||||
return GlobalResultGenerator.genSuccessResult();
|
return GlobalResultGenerator.genSuccessResult(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
@ -90,7 +90,7 @@ public class CommonApiController {
|
|||||||
public GlobalResult<PageInfo<ArticleDTO>> articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, ArticleSearchDTO searchDTO) {
|
public GlobalResult<PageInfo<ArticleDTO>> articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, ArticleSearchDTO searchDTO) {
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
List<ArticleDTO> list = articleService.findArticles(searchDTO);
|
List<ArticleDTO> list = articleService.findArticles(searchDTO);
|
||||||
PageInfo<ArticleDTO> pageInfo = new PageInfo(list);
|
PageInfo<ArticleDTO> pageInfo = new PageInfo<>(list);
|
||||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ public class CommonApiController {
|
|||||||
public GlobalResult<PageInfo<ArticleDTO>> announcements(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "5") Integer rows) {
|
public GlobalResult<PageInfo<ArticleDTO>> announcements(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "5") Integer rows) {
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
List<ArticleDTO> list = articleService.findAnnouncements();
|
List<ArticleDTO> list = articleService.findAnnouncements();
|
||||||
PageInfo<ArticleDTO> pageInfo = new PageInfo(list);
|
PageInfo<ArticleDTO> pageInfo = new PageInfo<>(list);
|
||||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,9 +110,9 @@ public class CommonApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("/forget-password")
|
@PatchMapping("/forget-password")
|
||||||
public GlobalResult<String> forgetPassword(@RequestBody ForgetPasswordDTO forgetPassword) throws ServiceException {
|
public GlobalResult<Boolean> forgetPassword(@RequestBody ForgetPasswordDTO forgetPassword) throws ServiceException {
|
||||||
String str = userService.forgetPassword(forgetPassword.getCode(), forgetPassword.getPassword());
|
boolean flag = userService.forgetPassword(forgetPassword.getCode(), forgetPassword.getPassword());
|
||||||
return GlobalResultGenerator.genSuccessResult(str);
|
return GlobalResultGenerator.genSuccessResult(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/portfolio/{id}")
|
@GetMapping("/portfolio/{id}")
|
||||||
@ -126,7 +126,7 @@ public class CommonApiController {
|
|||||||
public GlobalResult<PageInfo<ArticleDTO>> articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @PathVariable Long id) {
|
public GlobalResult<PageInfo<ArticleDTO>> articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @PathVariable Long id) {
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
List<ArticleDTO> list = articleService.findArticlesByIdPortfolio(id);
|
List<ArticleDTO> list = articleService.findArticlesByIdPortfolio(id);
|
||||||
PageInfo<ArticleDTO> pageInfo = new PageInfo(list);
|
PageInfo<ArticleDTO> pageInfo = new PageInfo<>(list);
|
||||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ public class CommonApiController {
|
|||||||
public GlobalResult<PageInfo<PortfolioDTO>> portfolios(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows) {
|
public GlobalResult<PageInfo<PortfolioDTO>> portfolios(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows) {
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
List<PortfolioDTO> list = portfolioService.findPortfolios();
|
List<PortfolioDTO> list = portfolioService.findPortfolios();
|
||||||
PageInfo<PortfolioDTO> pageInfo = new PageInfo(list);
|
PageInfo<PortfolioDTO> pageInfo = new PageInfo<>(list);
|
||||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ public class CommonApiController {
|
|||||||
public GlobalResult<PageInfo<ProductDTO>> products(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows) {
|
public GlobalResult<PageInfo<ProductDTO>> products(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows) {
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
List<ProductDTO> list = productService.findProducts();
|
List<ProductDTO> list = productService.findProducts();
|
||||||
PageInfo<ProductDTO> pageInfo = new PageInfo(list);
|
PageInfo<ProductDTO> pageInfo = new PageInfo<>(list);
|
||||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.rymcu.forest.web.api.portfolio;
|
package com.rymcu.forest.web.api.portfolio;
|
||||||
|
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.rymcu.forest.core.exception.ServiceException;
|
||||||
import com.rymcu.forest.core.result.GlobalResult;
|
import com.rymcu.forest.core.result.GlobalResult;
|
||||||
import com.rymcu.forest.core.result.GlobalResultGenerator;
|
import com.rymcu.forest.core.result.GlobalResultGenerator;
|
||||||
import com.rymcu.forest.core.service.security.annotation.AuthorshipInterceptor;
|
import com.rymcu.forest.core.service.security.annotation.AuthorshipInterceptor;
|
||||||
@ -32,62 +33,94 @@ public class PortfolioController {
|
|||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
@GetMapping("/detail/{idPortfolio}")
|
@GetMapping("/detail/{idPortfolio}")
|
||||||
public GlobalResult detail(@PathVariable Long idPortfolio,@RequestParam(defaultValue = "0") Integer type) {
|
public GlobalResult<PortfolioDTO> detail(@PathVariable Long idPortfolio, @RequestParam(defaultValue = "0") Integer type) {
|
||||||
PortfolioDTO portfolio = portfolioService.findPortfolioDTOById(idPortfolio, type);
|
if (idPortfolio == null || idPortfolio == 0) {
|
||||||
Map map = new HashMap<>(1);
|
throw new IllegalArgumentException("作品集主键参数异常!");
|
||||||
map.put("portfolio", portfolio);
|
}
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(portfolioService.findPortfolioDTOById(idPortfolio, type));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/post")
|
@PostMapping("/post")
|
||||||
public GlobalResult add(@RequestBody Portfolio portfolio) throws BaseApiException {
|
public GlobalResult<Portfolio> add(@RequestBody Portfolio portfolio) throws BaseApiException {
|
||||||
|
User user = UserUtils.getCurrentUserByToken();
|
||||||
|
portfolio.setPortfolioAuthorId(user.getIdUser());
|
||||||
portfolio = portfolioService.postPortfolio(portfolio);
|
portfolio = portfolioService.postPortfolio(portfolio);
|
||||||
return GlobalResultGenerator.genSuccessResult(portfolio);
|
return GlobalResultGenerator.genSuccessResult(portfolio);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/post")
|
@PutMapping("/post")
|
||||||
@AuthorshipInterceptor(moduleName = Module.PORTFOLIO)
|
@AuthorshipInterceptor(moduleName = Module.PORTFOLIO)
|
||||||
public GlobalResult update(@RequestBody Portfolio portfolio) throws BaseApiException {
|
public GlobalResult<Portfolio> update(@RequestBody Portfolio portfolio) throws BaseApiException {
|
||||||
|
if (portfolio.getIdPortfolio() == null || portfolio.getIdPortfolio() == 0) {
|
||||||
|
throw new IllegalArgumentException("作品集主键参数异常!");
|
||||||
|
}
|
||||||
|
User user = UserUtils.getCurrentUserByToken();
|
||||||
|
portfolio.setPortfolioAuthorId(user.getIdUser());
|
||||||
portfolio = portfolioService.postPortfolio(portfolio);
|
portfolio = portfolioService.postPortfolio(portfolio);
|
||||||
return GlobalResultGenerator.genSuccessResult(portfolio);
|
return GlobalResultGenerator.genSuccessResult(portfolio);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{idPortfolio}/unbind-articles")
|
@GetMapping("/{idPortfolio}/unbind-articles")
|
||||||
@AuthorshipInterceptor(moduleName = Module.PORTFOLIO)
|
@AuthorshipInterceptor(moduleName = Module.PORTFOLIO)
|
||||||
public GlobalResult unbindArticles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @RequestParam(defaultValue = "") String searchText, @PathVariable Long idPortfolio) throws Exception {
|
public GlobalResult<PageInfo> unbindArticles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @RequestParam(defaultValue = "") String searchText, @PathVariable Long idPortfolio) throws BaseApiException {
|
||||||
PageInfo pageInfo = portfolioService.findUnbindArticles(page, rows, searchText, idPortfolio);
|
if (idPortfolio == null || idPortfolio == 0) {
|
||||||
|
throw new IllegalArgumentException("作品集主键参数异常!");
|
||||||
|
}
|
||||||
|
User user = UserUtils.getCurrentUserByToken();
|
||||||
|
PageInfo pageInfo = portfolioService.findUnbindArticles(page, rows, searchText, idPortfolio, user.getIdUser());
|
||||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/bind-article")
|
@PostMapping("/bind-article")
|
||||||
@AuthorshipInterceptor(moduleName = Module.PORTFOLIO)
|
@AuthorshipInterceptor(moduleName = Module.PORTFOLIO)
|
||||||
public GlobalResult bindArticle(@RequestBody PortfolioArticleDTO portfolioArticle) throws Exception {
|
public GlobalResult<Boolean> bindArticle(@RequestBody PortfolioArticleDTO portfolioArticle) throws ServiceException {
|
||||||
|
if (portfolioArticle.getIdPortfolio() == null || portfolioArticle.getIdPortfolio() == 0) {
|
||||||
|
throw new IllegalArgumentException("作品集主键参数异常!");
|
||||||
|
}
|
||||||
boolean flag = portfolioService.bindArticle(portfolioArticle);
|
boolean flag = portfolioService.bindArticle(portfolioArticle);
|
||||||
return GlobalResultGenerator.genSuccessResult(flag);
|
return GlobalResultGenerator.genSuccessResult(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update-article-sort-no")
|
@PutMapping("/update-article-sort-no")
|
||||||
@AuthorshipInterceptor(moduleName = Module.PORTFOLIO)
|
@AuthorshipInterceptor(moduleName = Module.PORTFOLIO)
|
||||||
public GlobalResult updateArticleSortNo(@RequestBody PortfolioArticleDTO portfolioArticle) throws Exception {
|
public GlobalResult<Boolean> updateArticleSortNo(@RequestBody PortfolioArticleDTO portfolioArticle) throws ServiceException {
|
||||||
|
if (portfolioArticle.getIdPortfolio() == null || portfolioArticle.getIdPortfolio() == 0) {
|
||||||
|
throw new IllegalArgumentException("作品集主键参数异常!");
|
||||||
|
}
|
||||||
|
if (portfolioArticle.getIdArticle() == null || portfolioArticle.getIdArticle() == 0) {
|
||||||
|
throw new IllegalArgumentException("文章主键参数异常!");
|
||||||
|
}
|
||||||
|
if (portfolioArticle.getSortNo() == null) {
|
||||||
|
throw new IllegalArgumentException("排序号不能为空!");
|
||||||
|
}
|
||||||
boolean flag = portfolioService.updateArticleSortNo(portfolioArticle);
|
boolean flag = portfolioService.updateArticleSortNo(portfolioArticle);
|
||||||
return GlobalResultGenerator.genSuccessResult(flag);
|
return GlobalResultGenerator.genSuccessResult(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/unbind-article")
|
@DeleteMapping("/unbind-article")
|
||||||
@AuthorshipInterceptor(moduleName = Module.PORTFOLIO)
|
@AuthorshipInterceptor(moduleName = Module.PORTFOLIO)
|
||||||
public GlobalResult unbindArticle(Long idArticle, Long idPortfolio) throws Exception {
|
public GlobalResult<Boolean> unbindArticle(Long idArticle, Long idPortfolio) throws ServiceException {
|
||||||
|
if (idPortfolio == null || idPortfolio == 0) {
|
||||||
|
throw new IllegalArgumentException("作品集主键参数异常");
|
||||||
|
}
|
||||||
|
if (idArticle == null || idArticle == 0) {
|
||||||
|
throw new IllegalArgumentException("文章主键参数异常");
|
||||||
|
}
|
||||||
boolean flag = portfolioService.unbindArticle(idPortfolio, idArticle);
|
boolean flag = portfolioService.unbindArticle(idPortfolio, idArticle);
|
||||||
return GlobalResultGenerator.genSuccessResult(flag);
|
return GlobalResultGenerator.genSuccessResult(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/delete")
|
||||||
@AuthorshipInterceptor(moduleName = Module.PORTFOLIO)
|
@AuthorshipInterceptor(moduleName = Module.PORTFOLIO)
|
||||||
public GlobalResult delete(Long idPortfolio) throws BaseApiException, IllegalAccessException {
|
public GlobalResult<Boolean> delete(Long idPortfolio) throws BaseApiException {
|
||||||
|
if (idPortfolio == null || idPortfolio == 0) {
|
||||||
|
throw new IllegalArgumentException("参数异常!");
|
||||||
|
}
|
||||||
User user = UserUtils.getCurrentUserByToken();
|
User user = UserUtils.getCurrentUserByToken();
|
||||||
Long idUser = user.getIdUser();
|
Long idUser = user.getIdUser();
|
||||||
Integer roleWeights = userService.findRoleWeightsByUser(idUser);
|
Integer roleWeights = userService.findRoleWeightsByUser(idUser);
|
||||||
boolean map = portfolioService.deletePortfolio(idPortfolio, idUser, roleWeights);
|
boolean flag = portfolioService.deletePortfolio(idPortfolio, idUser, roleWeights);
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,57 +35,59 @@ public class UserInfoController {
|
|||||||
|
|
||||||
@GetMapping("/detail/{idUser}")
|
@GetMapping("/detail/{idUser}")
|
||||||
@SecurityInterceptor
|
@SecurityInterceptor
|
||||||
public GlobalResult detail(@PathVariable Long idUser) {
|
public GlobalResult<UserInfoDTO> detail(@PathVariable Long idUser) {
|
||||||
Map map = userService.findUserInfo(idUser);
|
UserInfoDTO userInfo = userService.findUserInfo(idUser);
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(userInfo);
|
||||||
|
}
|
||||||
|
@GetMapping("/detail/{idUser}/extend-info")
|
||||||
|
@SecurityInterceptor
|
||||||
|
public GlobalResult<UserExtend> extendInfo(@PathVariable Long idUser) {
|
||||||
|
UserExtend userExtend = userService.findUserExtendInfo(idUser);
|
||||||
|
return GlobalResultGenerator.genSuccessResult(userExtend);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/check-nickname")
|
@GetMapping("/check-nickname")
|
||||||
@SecurityInterceptor
|
@SecurityInterceptor
|
||||||
public GlobalResult checkNickname(@RequestParam Long idUser, @RequestParam String nickname) throws ServiceException {
|
public GlobalResult checkNickname(@RequestParam Long idUser, @RequestParam String nickname) {
|
||||||
boolean flag = userService.checkNickname(idUser, nickname);
|
boolean flag = userService.checkNicknameByIdUser(idUser, nickname);
|
||||||
return GlobalResultGenerator.genSuccessResult(flag);
|
return GlobalResultGenerator.genSuccessResult(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("/update")
|
@PatchMapping("/update")
|
||||||
@SecurityInterceptor
|
@SecurityInterceptor
|
||||||
public GlobalResult updateUserInfo(@RequestBody UserInfoDTO user) throws Exception {
|
public GlobalResult<UserInfoDTO> updateUserInfo(@RequestBody UserInfoDTO user) throws ServiceException {
|
||||||
UserInfoDTO newUsers = userService.updateUserInfo(user);
|
user = userService.updateUserInfo(user);
|
||||||
return GlobalResultGenerator.genSuccessResult(newUsers);
|
return GlobalResultGenerator.genSuccessResult(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("/update-extend")
|
@PatchMapping("/update-extend")
|
||||||
@SecurityInterceptor
|
@SecurityInterceptor
|
||||||
public GlobalResult updateUserExtend(@RequestBody UserExtend userExtend) throws ServiceException {
|
public GlobalResult<UserExtend> updateUserExtend(@RequestBody UserExtend userExtend) throws ServiceException {
|
||||||
UserExtend map = userService.updateUserExtend(userExtend);
|
userExtend = userService.updateUserExtend(userExtend);
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(userExtend);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("/update-email")
|
@PatchMapping("/update-email")
|
||||||
@SecurityInterceptor
|
@SecurityInterceptor
|
||||||
public GlobalResult updateEmail(@RequestBody ChangeEmailDTO changeEmailDTO) throws ServiceException {
|
public GlobalResult<Boolean> updateEmail(@RequestBody ChangeEmailDTO changeEmailDTO) throws ServiceException {
|
||||||
String email = userService.updateEmail(changeEmailDTO);
|
boolean flag = userService.updateEmail(changeEmailDTO);
|
||||||
return GlobalResultGenerator.genSuccessResult(email);
|
return GlobalResultGenerator.genSuccessResult(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("/update-password")
|
@PatchMapping("/update-password")
|
||||||
@SecurityInterceptor
|
@SecurityInterceptor
|
||||||
public GlobalResult updatePassword(@RequestBody UpdatePasswordDTO updatePasswordDTO) {
|
public GlobalResult<Boolean> updatePassword(@RequestBody UpdatePasswordDTO updatePasswordDTO) {
|
||||||
boolean flag = userService.updatePassword(updatePasswordDTO);
|
boolean flag = userService.updatePassword(updatePasswordDTO);
|
||||||
return GlobalResultGenerator.genSuccessResult(flag);
|
return GlobalResultGenerator.genSuccessResult(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/login-records")
|
@GetMapping("/login-records")
|
||||||
@SecurityInterceptor
|
@SecurityInterceptor
|
||||||
public GlobalResult loginRecords(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @RequestParam Integer idUser) {
|
public GlobalResult<PageInfo<LoginRecord>> loginRecords(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @RequestParam Integer idUser) {
|
||||||
PageHelper.startPage(page, rows);
|
PageHelper.startPage(page, rows);
|
||||||
List<LoginRecord> list = loginRecordService.findLoginRecordByIdUser(idUser);
|
List<LoginRecord> list = loginRecordService.findLoginRecordByIdUser(idUser);
|
||||||
PageInfo<LoginRecord> pageInfo = new PageInfo<>(list);
|
PageInfo<LoginRecord> pageInfo = new PageInfo<>(list);
|
||||||
Map<String, Object> map = new HashMap<String, Object>(2);
|
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||||
map.put("records", pageInfo.getList());
|
|
||||||
Map pagination = Utils.getPagination(pageInfo);
|
|
||||||
map.put("pagination", pagination);
|
|
||||||
return GlobalResultGenerator.genSuccessResult(map);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user