🎨 代码优化
🎨 代码优化
This commit is contained in:
commit
de9227fc1c
@ -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
|
||||
*/
|
||||
public class TransactionException extends Exception {
|
||||
public class TransactionException extends BusinessException {
|
||||
|
||||
private int code;
|
||||
|
||||
|
@ -4,17 +4,15 @@ 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;
|
||||
int thumbsUp(ArticleThumbsUp articleThumbsUp);
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
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.dto.ArticleDTO;
|
||||
import com.rymcu.forest.dto.PortfolioArticleDTO;
|
||||
import com.rymcu.forest.dto.PortfolioDTO;
|
||||
import com.rymcu.forest.dto.UserDTO;
|
||||
@ -8,7 +11,6 @@ import com.rymcu.forest.entity.Portfolio;
|
||||
import com.rymcu.forest.web.api.exception.BaseApiException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ronger
|
||||
@ -35,41 +37,44 @@ public interface PortfolioService extends Service<Portfolio> {
|
||||
* @throws BaseApiException
|
||||
* @return
|
||||
*/
|
||||
Portfolio postPortfolio(Portfolio portfolio) throws BaseApiException;
|
||||
Portfolio postPortfolio(Portfolio portfolio);
|
||||
|
||||
/**
|
||||
* 查询作品集下未绑定文章
|
||||
*
|
||||
* @param page
|
||||
* @param rows
|
||||
* @param searchText
|
||||
* @param idPortfolio
|
||||
* @throws BaseApiException
|
||||
* @param idUser
|
||||
* @return
|
||||
*/
|
||||
Map findUnbindArticles(Integer page, Integer rows, String searchText, Long idPortfolio) throws BaseApiException;
|
||||
PageInfo<ArticleDTO> findUnbindArticles(Integer page, Integer rows, String searchText, Long idPortfolio, Long idUser);
|
||||
|
||||
/**
|
||||
* 绑定文章
|
||||
* @param portfolioArticle
|
||||
* @return
|
||||
* @throws ServiceException
|
||||
*/
|
||||
Map bindArticle(PortfolioArticleDTO portfolioArticle);
|
||||
boolean bindArticle(PortfolioArticleDTO portfolioArticle) throws ServiceException;
|
||||
|
||||
/**
|
||||
* 更新文章排序号
|
||||
* @param portfolioArticle
|
||||
* @return
|
||||
* @throws ServiceException
|
||||
*/
|
||||
Map updateArticleSortNo(PortfolioArticleDTO portfolioArticle);
|
||||
boolean updateArticleSortNo(PortfolioArticleDTO portfolioArticle) throws ServiceException;
|
||||
|
||||
/**
|
||||
* 取消绑定文章
|
||||
*
|
||||
* @param idPortfolio
|
||||
* @param idArticle
|
||||
* @return
|
||||
* @throws ServiceException
|
||||
*/
|
||||
Map unbindArticle(Long idPortfolio, Long idArticle);
|
||||
boolean unbindArticle(Long idPortfolio, Long idArticle) throws ServiceException;
|
||||
|
||||
|
||||
/**
|
||||
@ -79,10 +84,9 @@ public interface PortfolioService extends Service<Portfolio> {
|
||||
* @param idUser
|
||||
* @param roleWeights
|
||||
* @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,11 +1,11 @@
|
||||
package com.rymcu.forest.service;
|
||||
|
||||
import com.rymcu.forest.core.exception.ServiceException;
|
||||
import com.rymcu.forest.core.service.Service;
|
||||
import com.rymcu.forest.entity.Role;
|
||||
import com.rymcu.forest.entity.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@ -34,13 +34,15 @@ public interface RoleService extends Service<Role> {
|
||||
* @param idRole
|
||||
* @param status
|
||||
* @return
|
||||
* */
|
||||
Map updateStatus(Long idRole, String status);
|
||||
* @throws ServiceException
|
||||
*/
|
||||
boolean updateStatus(Long idRole, String status) throws ServiceException;
|
||||
|
||||
/**
|
||||
* 添加/更新角色
|
||||
* @param role
|
||||
* @return
|
||||
* */
|
||||
Map saveRole(Role role);
|
||||
* @throws ServiceException
|
||||
*/
|
||||
boolean saveRole(Role role) throws ServiceException;
|
||||
}
|
||||
|
@ -3,17 +3,16 @@ 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;
|
||||
boolean sponsorship(Sponsor sponsor) throws Exception;
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import com.rymcu.forest.web.api.exception.BaseApiException;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ronger
|
||||
@ -27,16 +26,18 @@ public interface TagService extends Service<Tag> {
|
||||
|
||||
/**
|
||||
* 清除未使用标签
|
||||
*
|
||||
* @return
|
||||
* */
|
||||
Map cleanUnusedTag();
|
||||
*/
|
||||
boolean cleanUnusedTag();
|
||||
|
||||
/**
|
||||
* 添加/更新标签
|
||||
*
|
||||
* @param tag
|
||||
* @return
|
||||
*/
|
||||
Map saveTag(Tag tag);
|
||||
Tag saveTag(Tag tag) throws Exception;
|
||||
|
||||
/**
|
||||
* 获取标签列表
|
||||
|
@ -1,12 +1,13 @@
|
||||
package com.rymcu.forest.service;
|
||||
|
||||
import com.rymcu.forest.core.exception.ServiceException;
|
||||
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.entity.Tag;
|
||||
import com.rymcu.forest.entity.Topic;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ronger
|
||||
@ -15,26 +16,31 @@ public interface TopicService extends Service<Topic> {
|
||||
|
||||
/**
|
||||
* 获取导航主题数据
|
||||
*
|
||||
* @return
|
||||
* */
|
||||
*/
|
||||
List<Topic> findTopicNav();
|
||||
|
||||
/**
|
||||
* 根据 topicUri 获取主题信息及旗下标签数据
|
||||
*
|
||||
* @param topicUri 主题 URI
|
||||
* @return
|
||||
* */
|
||||
*/
|
||||
Topic findTopicByTopicUri(String topicUri);
|
||||
|
||||
/**
|
||||
* 新增/更新主题信息
|
||||
*
|
||||
* @param topic 主题信息
|
||||
* @return
|
||||
* */
|
||||
Map saveTopic(Topic topic);
|
||||
* @throws ServiceException
|
||||
*/
|
||||
Topic saveTopic(Topic topic) throws ServiceException;
|
||||
|
||||
/**
|
||||
* 查询未绑定标签
|
||||
*
|
||||
* @param idTopic
|
||||
* @param tagTitle
|
||||
* @return
|
||||
@ -43,24 +49,27 @@ public interface TopicService extends Service<Topic> {
|
||||
|
||||
/**
|
||||
* 绑定标签
|
||||
*
|
||||
* @param topicTag
|
||||
* @return
|
||||
* @throws ServiceException
|
||||
*/
|
||||
Map bindTopicTag(TopicTagDTO topicTag);
|
||||
TopicTagDTO bindTopicTag(TopicTagDTO topicTag) throws ServiceException;
|
||||
|
||||
/**
|
||||
* 取消绑定标签
|
||||
*
|
||||
* @param topicTag
|
||||
* @return
|
||||
* @throws ServiceException
|
||||
*/
|
||||
Map unbindTopicTag(TopicTagDTO topicTag);
|
||||
TopicTagDTO unbindTopicTag(TopicTagDTO topicTag) throws ServiceException;
|
||||
|
||||
/**
|
||||
* 获取主题下标签列表
|
||||
*
|
||||
* @param topicUri
|
||||
* @param page
|
||||
* @param rows
|
||||
* @return
|
||||
*/
|
||||
Map findTagsByTopicUri(String topicUri, Integer page, Integer rows);
|
||||
List<TagDTO> findTagsByTopicUri(String topicUri);
|
||||
}
|
||||
|
@ -15,9 +15,8 @@ public interface TransactionRecordService extends Service<TransactionRecord> {
|
||||
* 交易
|
||||
* @param transactionRecord
|
||||
* @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 transactionType
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
TransactionRecord userTransfer(Long toUserId, Long formUserId, TransactionEnum transactionType) throws Exception;
|
||||
TransactionRecord userTransfer(Long toUserId, Long formUserId, TransactionEnum transactionType);
|
||||
|
||||
/**
|
||||
* 社区银行转账/奖励发放
|
||||
* @param idUser
|
||||
* @param transactionType
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
TransactionRecord bankTransfer(Long idUser, TransactionEnum transactionType) throws Exception;
|
||||
TransactionRecord bankTransfer(Long idUser, TransactionEnum transactionType);
|
||||
|
||||
/**
|
||||
* 发放新手奖励
|
||||
* @param transactionRecord
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
TransactionRecord newbieRewards(TransactionRecord transactionRecord) throws Exception;
|
||||
TransactionRecord newbieRewards(TransactionRecord transactionRecord);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.rymcu.forest.service;
|
||||
|
||||
import com.rymcu.forest.core.exception.ServiceException;
|
||||
import com.rymcu.forest.core.service.Service;
|
||||
import com.rymcu.forest.dto.*;
|
||||
import com.rymcu.forest.entity.User;
|
||||
@ -11,7 +12,6 @@ import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author CodeGenerator
|
||||
* @date 2018/05/29
|
||||
*/
|
||||
@ -19,84 +19,99 @@ public interface UserService extends Service<User> {
|
||||
|
||||
/**
|
||||
* 通过账号查询用户信息
|
||||
*
|
||||
* @param account
|
||||
* @throws TooManyResultsException
|
||||
* @return User
|
||||
* */
|
||||
* @throws TooManyResultsException
|
||||
*/
|
||||
User findByAccount(String account) throws TooManyResultsException;
|
||||
|
||||
/**
|
||||
* 注册接口
|
||||
*
|
||||
* @param email 邮箱
|
||||
* @param password 密码
|
||||
* @param code 验证码
|
||||
* @return Map
|
||||
* */
|
||||
Map register(String email, String password, String code);
|
||||
*/
|
||||
boolean register(String email, String password, String code);
|
||||
|
||||
/**
|
||||
* 登录接口
|
||||
*
|
||||
* @param account 邮箱
|
||||
* @param password 密码
|
||||
* @return Map
|
||||
* */
|
||||
TokenUser login(String account, String password);
|
||||
*/
|
||||
TokenUser login(String account, String password) throws ServiceException;
|
||||
|
||||
/**
|
||||
* 通过 account 获取用户信息接口
|
||||
*
|
||||
* @param account 昵称
|
||||
* @return UserDTO
|
||||
* */
|
||||
*/
|
||||
UserDTO findUserDTOByAccount(String account);
|
||||
|
||||
/**
|
||||
* 找回密码接口
|
||||
*
|
||||
* @param code 验证码
|
||||
* @param password 密码
|
||||
* @return Map
|
||||
* */
|
||||
Map forgetPassword(String code, String password);
|
||||
* @throws ServiceException
|
||||
*/
|
||||
boolean forgetPassword(String code, String password) throws ServiceException;
|
||||
|
||||
/**
|
||||
* 更新用户角色接口
|
||||
*
|
||||
* @param idUser 用户 id
|
||||
* @param idRole 角色 id
|
||||
* @return Map
|
||||
* */
|
||||
Map updateUserRole(Long idUser, Long idRole);
|
||||
* @throws ServiceException
|
||||
*/
|
||||
boolean updateUserRole(Long idUser, Long idRole) throws ServiceException;
|
||||
|
||||
/**
|
||||
* 更新用户状态
|
||||
*
|
||||
* @param idUser 用户 id
|
||||
* @param status 状态
|
||||
* @return Map
|
||||
* */
|
||||
Map updateStatus(Long idUser, String status);
|
||||
* @throws ServiceException
|
||||
*/
|
||||
boolean updateStatus(Long idUser, String status) throws ServiceException;
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
* @param idUser
|
||||
* @return
|
||||
*/
|
||||
Map findUserInfo(Long idUser);
|
||||
UserInfoDTO findUserInfo(Long idUser);
|
||||
|
||||
/**
|
||||
* 更新用户信息
|
||||
*
|
||||
* @param user
|
||||
* @return
|
||||
* @throws ServiceException
|
||||
*/
|
||||
Map updateUserInfo(UserInfoDTO user);
|
||||
UserInfoDTO updateUserInfo(UserInfoDTO user) throws ServiceException;
|
||||
|
||||
/**
|
||||
* 验证昵称是否重复
|
||||
*
|
||||
* @param idUser
|
||||
* @param nickname
|
||||
* @return
|
||||
*/
|
||||
Map checkNickname(Long idUser, String nickname);
|
||||
boolean checkNicknameByIdUser(Long idUser, String nickname);
|
||||
|
||||
/**
|
||||
* 获取用户权限
|
||||
*
|
||||
* @param idUser
|
||||
* @return
|
||||
*/
|
||||
@ -104,6 +119,7 @@ public interface UserService extends Service<User> {
|
||||
|
||||
/**
|
||||
* 查询作者信息
|
||||
*
|
||||
* @param idUser
|
||||
* @return
|
||||
*/
|
||||
@ -111,13 +127,15 @@ public interface UserService extends Service<User> {
|
||||
|
||||
/**
|
||||
* 更新用户扩展信息
|
||||
*
|
||||
* @param userExtend
|
||||
* @return
|
||||
*/
|
||||
Map updateUserExtend(UserExtend userExtend);
|
||||
UserExtend updateUserExtend(UserExtend userExtend) throws ServiceException;
|
||||
|
||||
/**
|
||||
* 获取用户扩展信息
|
||||
*
|
||||
* @param account
|
||||
* @return
|
||||
*/
|
||||
@ -125,29 +143,42 @@ public interface UserService extends Service<User> {
|
||||
|
||||
/**
|
||||
* 更换邮箱
|
||||
*
|
||||
* @param changeEmailDTO
|
||||
* @return
|
||||
* @throws ServiceException
|
||||
*/
|
||||
Map updateEmail(ChangeEmailDTO changeEmailDTO);
|
||||
boolean updateEmail(ChangeEmailDTO changeEmailDTO) throws ServiceException;
|
||||
|
||||
/**
|
||||
* 更新密码
|
||||
*
|
||||
* @param updatePasswordDTO
|
||||
* @return
|
||||
*/
|
||||
Map updatePassword(UpdatePasswordDTO updatePasswordDTO);
|
||||
boolean updatePassword(UpdatePasswordDTO updatePasswordDTO);
|
||||
|
||||
/**
|
||||
* 查询用户列表
|
||||
*
|
||||
* @param searchDTO
|
||||
* @return
|
||||
*/
|
||||
List<UserInfoDTO> findUsers(UserSearchDTO searchDTO);
|
||||
|
||||
/**
|
||||
* 通过邮箱查询用户信息
|
||||
* 通过邮箱更新用户最后登录时间
|
||||
*
|
||||
* @param email
|
||||
* @return
|
||||
*/
|
||||
Integer updateLastOnlineTimeByEmail(String email);
|
||||
|
||||
/**
|
||||
* 查询用户扩展信息
|
||||
*
|
||||
* @param idUser
|
||||
* @return
|
||||
*/
|
||||
UserExtend findUserExtendInfo(Long idUser);
|
||||
}
|
||||
|
@ -1,21 +1,17 @@
|
||||
package com.rymcu.forest.service.impl;
|
||||
|
||||
import com.rymcu.forest.core.exception.BusinessException;
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -31,40 +27,25 @@ public class ArticleThumbsUpServiceImpl extends AbstractService<ArticleThumbsUp>
|
||||
|
||||
@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;
|
||||
public int thumbsUp(ArticleThumbsUp articleThumbsUp) {
|
||||
int thumbsUpNumber = 1;
|
||||
Article article = articleService.findById(String.valueOf(articleThumbsUp.getIdArticle()));
|
||||
if (Objects.isNull(article)) {
|
||||
map.put("message", "数据异常,文章不存在!");
|
||||
map.put("success", false);
|
||||
throw new BusinessException("数据异常,文章不存在!");
|
||||
} 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 thumbsUpNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,10 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ronger
|
||||
|
@ -3,29 +3,25 @@ package com.rymcu.forest.service.impl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
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.UltraViresException;
|
||||
import com.rymcu.forest.core.service.AbstractService;
|
||||
import com.rymcu.forest.dto.*;
|
||||
import com.rymcu.forest.entity.Portfolio;
|
||||
import com.rymcu.forest.entity.User;
|
||||
import com.rymcu.forest.lucene.model.PortfolioLucene;
|
||||
import com.rymcu.forest.lucene.util.PortfolioIndexUtil;
|
||||
import com.rymcu.forest.mapper.PortfolioMapper;
|
||||
import com.rymcu.forest.service.ArticleService;
|
||||
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.util.XssUtils;
|
||||
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;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ronger
|
||||
@ -66,15 +62,12 @@ public class PortfolioServiceImpl extends AbstractService<Portfolio> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public Portfolio postPortfolio(Portfolio portfolio) throws BaseApiException {
|
||||
User user = UserUtils.getCurrentUserByToken();
|
||||
assert user != null;
|
||||
public Portfolio postPortfolio(Portfolio portfolio) {
|
||||
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());
|
||||
portfolio.setUpdatedTime(portfolio.getCreatedTime());
|
||||
portfolio.setPortfolioDescriptionHtml(XssUtils.filterHtmlCode(portfolio.getPortfolioDescription()));
|
||||
@ -99,80 +92,56 @@ public class PortfolioServiceImpl extends AbstractService<Portfolio> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map findUnbindArticles(Integer page, Integer rows, String searchText, Long idPortfolio) throws BaseApiException {
|
||||
Map map = new HashMap(1);
|
||||
User user = UserUtils.getCurrentUserByToken();
|
||||
public PageInfo<ArticleDTO> findUnbindArticles(Integer page, Integer rows, String searchText, Long idPortfolio, Long idUser) {
|
||||
Portfolio portfolio = portfolioMapper.selectByPrimaryKey(idPortfolio);
|
||||
if (portfolio == null) {
|
||||
map.put("message", "该作品集不存在或已被删除!");
|
||||
throw new BusinessException("该作品集不存在或已被删除!");
|
||||
} else {
|
||||
if (!user.getIdUser().equals(portfolio.getPortfolioAuthorId())) {
|
||||
map.put("message", "非法操作!");
|
||||
if (!idUser.equals(portfolio.getPortfolioAuthorId())) {
|
||||
throw new UltraViresException("非法操作!");
|
||||
} else {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<ArticleDTO> articles = articleService.selectUnbindArticles(idPortfolio, searchText, user.getIdUser());
|
||||
PageInfo<ArticleDTO> pageInfo = new PageInfo(articles);
|
||||
map = Utils.getArticlesGlobalResult(pageInfo);
|
||||
List<ArticleDTO> articles = articleService.selectUnbindArticles(idPortfolio, searchText, idUser);
|
||||
return new PageInfo<>(articles);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map bindArticle(PortfolioArticleDTO portfolioArticle) {
|
||||
Map map = new HashMap(1);
|
||||
public boolean bindArticle(PortfolioArticleDTO portfolioArticle) throws ServiceException {
|
||||
Integer count = portfolioMapper.selectCountPortfolioArticle(portfolioArticle.getIdArticle(), portfolioArticle.getIdPortfolio());
|
||||
if (count.equals(0)) {
|
||||
Integer maxSortNo = portfolioMapper.selectMaxSortNo(portfolioArticle.getIdPortfolio());
|
||||
portfolioMapper.insertPortfolioArticle(portfolioArticle.getIdArticle(), portfolioArticle.getIdPortfolio(), maxSortNo);
|
||||
map.put("message", "绑定成功!");
|
||||
} else {
|
||||
map.put("message", "该文章已经在作品集下!!");
|
||||
Integer result = portfolioMapper.insertPortfolioArticle(portfolioArticle.getIdArticle(), portfolioArticle.getIdPortfolio(), maxSortNo);
|
||||
if (result == 0) {
|
||||
throw new ServiceException("更新失败!");
|
||||
}
|
||||
return map;
|
||||
} else {
|
||||
throw new BusinessException("该文章已经在作品集下!!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map updateArticleSortNo(PortfolioArticleDTO portfolioArticle) {
|
||||
Map map = new HashMap(1);
|
||||
if (portfolioArticle.getIdPortfolio() == null || portfolioArticle.getIdPortfolio().equals(0)) {
|
||||
map.put("message", "作品集数据异常!");
|
||||
}
|
||||
if (portfolioArticle.getIdArticle() == null || portfolioArticle.getIdArticle().equals(0)) {
|
||||
map.put("message", "文章数据异常!");
|
||||
}
|
||||
if (portfolioArticle.getSortNo() == null) {
|
||||
map.put("message", "排序号不能为空!");
|
||||
}
|
||||
public boolean updateArticleSortNo(PortfolioArticleDTO portfolioArticle) throws ServiceException {
|
||||
Integer result = portfolioMapper.updateArticleSortNo(portfolioArticle.getIdPortfolio(), portfolioArticle.getIdArticle(), portfolioArticle.getSortNo());
|
||||
if (result > 0) {
|
||||
map.put("message", "更新成功!");
|
||||
} else {
|
||||
map.put("message", "更新失败!");
|
||||
if (result == 0) {
|
||||
throw new ServiceException("更新失败!");
|
||||
}
|
||||
return map;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map unbindArticle(Long idPortfolio, Long idArticle) {
|
||||
Map map = new HashMap(1);
|
||||
if (idPortfolio == null || idPortfolio.equals(0)) {
|
||||
map.put("message", "作品集数据异常");
|
||||
}
|
||||
if (idArticle == null || idArticle.equals(0)) {
|
||||
map.put("message", "文章数据异常");
|
||||
}
|
||||
public boolean unbindArticle(Long idPortfolio, Long idArticle) throws ServiceException {
|
||||
Integer result = portfolioMapper.unbindArticle(idPortfolio, idArticle);
|
||||
if (result > 0) {
|
||||
map.put("message", "操作成功!");
|
||||
} else {
|
||||
map.put("message", "操作失败!");
|
||||
if (result == 0) {
|
||||
throw new ServiceException("操作失败!");
|
||||
}
|
||||
return map;
|
||||
return true;
|
||||
}
|
||||
|
||||
@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) {
|
||||
throw new IllegalArgumentException("作品集数据异常!");
|
||||
}
|
||||
@ -180,7 +149,7 @@ public class PortfolioServiceImpl extends AbstractService<Portfolio> implements
|
||||
if (roleWeights > 2) {
|
||||
Portfolio portfolio = portfolioMapper.selectByPrimaryKey(idPortfolio);
|
||||
if (!idUser.equals(portfolio.getPortfolioAuthorId())) {
|
||||
throw new IllegalAccessException("非法访问!");
|
||||
throw new UltraViresException("非法访问!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.rymcu.forest.service.impl;
|
||||
|
||||
import com.rymcu.forest.core.exception.ServiceException;
|
||||
import com.rymcu.forest.core.service.AbstractService;
|
||||
import com.rymcu.forest.entity.Role;
|
||||
import com.rymcu.forest.entity.User;
|
||||
@ -10,9 +11,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@ -27,8 +26,7 @@ public class RoleServiceImpl extends AbstractService<Role> implements RoleServic
|
||||
|
||||
@Override
|
||||
public List<Role> selectRoleByUser(User sysUser) {
|
||||
List<Role> roles = roleMapper.selectRoleByIdUser(sysUser.getIdUser());
|
||||
return roles;
|
||||
return roleMapper.selectRoleByIdUser(sysUser.getIdUser());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -37,34 +35,30 @@ public class RoleServiceImpl extends AbstractService<Role> implements RoleServic
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Map updateStatus(Long idRole, String status) {
|
||||
Map map = new HashMap(1);
|
||||
Integer result = roleMapper.updateStatus(idRole,status);
|
||||
if(result == 0) {
|
||||
map.put("message","更新失败!");
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updateStatus(Long idRole, String status) throws ServiceException {
|
||||
Integer result = roleMapper.updateStatus(idRole, status);
|
||||
if (result == 0) {
|
||||
throw new ServiceException("更新失败");
|
||||
}
|
||||
return map;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map saveRole(Role role) {
|
||||
Integer result = 0;
|
||||
public boolean saveRole(Role role) throws ServiceException {
|
||||
Integer result;
|
||||
if (role.getIdRole() == null) {
|
||||
role.setCreatedTime(new Date());
|
||||
role.setUpdatedTime(role.getCreatedTime());
|
||||
result = roleMapper.insertSelective(role);
|
||||
} else {
|
||||
role.setCreatedTime(new Date());
|
||||
result = roleMapper.update(role.getIdRole(),role.getName(),role.getInputCode(),role.getWeights());
|
||||
result = roleMapper.update(role.getIdRole(), role.getName(), role.getInputCode(), role.getWeights());
|
||||
}
|
||||
Map map = new HashMap(1);
|
||||
if (result == 0) {
|
||||
map.put("message","操作失败!");
|
||||
} else {
|
||||
map.put("role", role);
|
||||
throw new ServiceException("操作失败!");
|
||||
}
|
||||
return map;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.rymcu.forest.service.impl;
|
||||
|
||||
|
||||
import com.rymcu.forest.core.exception.ServiceException;
|
||||
import com.rymcu.forest.core.exception.TransactionException;
|
||||
import com.rymcu.forest.core.service.AbstractService;
|
||||
import com.rymcu.forest.dto.ArticleDTO;
|
||||
@ -19,7 +20,8 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author ronger
|
||||
@ -36,32 +38,25 @@ public class SponsorServiceImpl extends AbstractService<Sponsor> implements Spon
|
||||
|
||||
@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 {
|
||||
TransactionEnum result = TransactionEnum.findTransactionEnum(sponsor.getDataType());
|
||||
BigDecimal money = BigDecimal.valueOf(result.getMoney());
|
||||
public boolean sponsorship(Sponsor sponsor) throws Exception {
|
||||
TransactionEnum transactionEnum = TransactionEnum.findTransactionEnum(sponsor.getDataType());
|
||||
BigDecimal money = BigDecimal.valueOf(transactionEnum.getMoney());
|
||||
sponsor.setSponsorshipMoney(money);
|
||||
User user = UserUtils.getCurrentUserByToken();
|
||||
sponsor.setSponsor(user.getIdUser());
|
||||
sponsor.setSponsorshipTime(new Date());
|
||||
sponsorMapper.insertSelective(sponsor);
|
||||
// 赞赏金额划转
|
||||
if (result.isArticleSponsor()) {
|
||||
if (transactionEnum.isArticleSponsor()) {
|
||||
ArticleDTO articleDTO = articleService.findArticleDTOById(sponsor.getDataId(), 1);
|
||||
TransactionRecord transactionRecord = transactionRecordService.userTransfer(articleDTO.getArticleAuthorId(), user.getIdUser(), result);
|
||||
TransactionRecord transactionRecord = transactionRecordService.userTransfer(articleDTO.getArticleAuthorId(), sponsor.getSponsor(), transactionEnum);
|
||||
if (Objects.isNull(transactionRecord.getIdTransactionRecord())) {
|
||||
throw new TransactionException(TransactionCode.InsufficientBalance);
|
||||
}
|
||||
// 更新文章赞赏数
|
||||
sponsorMapper.updateArticleSponsorCount(articleDTO.getIdArticle());
|
||||
int result = sponsorMapper.updateArticleSponsorCount(articleDTO.getIdArticle());
|
||||
if (result == 0) {
|
||||
throw new ServiceException("操作失败!");
|
||||
}
|
||||
map.put("success", true);
|
||||
map.put("message", "赞赏成功");
|
||||
}
|
||||
return map;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
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.service.AbstractService;
|
||||
import com.rymcu.forest.dto.ArticleTagDTO;
|
||||
import com.rymcu.forest.dto.LabelModel;
|
||||
@ -21,9 +23,7 @@ import javax.annotation.Resource;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ronger
|
||||
@ -101,47 +101,41 @@ public class TagServiceImpl extends AbstractService<Tag> implements TagService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map cleanUnusedTag() {
|
||||
Map map = new HashMap(1);
|
||||
tagMapper.deleteUnusedTag();
|
||||
return map;
|
||||
public boolean cleanUnusedTag() {
|
||||
return tagMapper.deleteUnusedTag() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map saveTag(Tag tag) {
|
||||
public Tag saveTag(Tag tag) throws Exception {
|
||||
Integer result;
|
||||
|
||||
Map map = new HashMap(1);
|
||||
tag.setTagDescription(XssUtils.filterHtmlCode(tag.getTagDescription()));
|
||||
if (tag.getIdTag() == null) {
|
||||
if (StringUtils.isBlank(tag.getTagTitle())) {
|
||||
map.put("message", "标签名不能为空!");
|
||||
return map;
|
||||
throw new IllegalArgumentException("标签名不能为空!");
|
||||
} else {
|
||||
Condition tagCondition = new Condition(Tag.class);
|
||||
tagCondition.createCriteria().andCondition("tag_title =", tag.getTagTitle());
|
||||
List<Tag> tags = tagMapper.selectByCondition(tagCondition);
|
||||
if (!tags.isEmpty()) {
|
||||
map.put("message", "标签 '" + tag.getTagTitle() + "' 已存在!");
|
||||
return map;
|
||||
throw new BusinessException("标签 '" + tag.getTagTitle() + "' 已存在!");
|
||||
}
|
||||
}
|
||||
Tag newTag = new Tag();
|
||||
newTag.setTagTitle(tag.getTagTitle());
|
||||
newTag.setTagUri(tag.getTagUri());
|
||||
tag = new Tag();
|
||||
tag.setTagTitle(tag.getTagTitle());
|
||||
tag.setTagUri(tag.getTagUri());
|
||||
if (StringUtils.isNotBlank(tag.getTagIconPath()) && tag.getTagIconPath().contains("base64")) {
|
||||
String tagIconPath = UploadController.uploadBase64File(tag.getTagIconPath(), 2);
|
||||
newTag.setTagIconPath(tagIconPath);
|
||||
tag.setTagIconPath(tagIconPath);
|
||||
} else {
|
||||
newTag.setTagIconPath(tag.getTagIconPath());
|
||||
tag.setTagIconPath(tag.getTagIconPath());
|
||||
}
|
||||
newTag.setTagStatus(tag.getTagStatus());
|
||||
newTag.setTagDescription(tag.getTagDescription());
|
||||
newTag.setTagReservation(tag.getTagReservation());
|
||||
newTag.setCreatedTime(new Date());
|
||||
newTag.setUpdatedTime(tag.getCreatedTime());
|
||||
result = tagMapper.insertSelective(newTag);
|
||||
tag.setTagStatus(tag.getTagStatus());
|
||||
tag.setTagDescription(tag.getTagDescription());
|
||||
tag.setTagReservation(tag.getTagReservation());
|
||||
tag.setCreatedTime(new Date());
|
||||
tag.setUpdatedTime(tag.getCreatedTime());
|
||||
result = tagMapper.insertSelective(tag);
|
||||
} else {
|
||||
tag.setUpdatedTime(new Date());
|
||||
if (StringUtils.isNotBlank(tag.getTagIconPath()) && tag.getTagIconPath().contains("base64")) {
|
||||
@ -151,11 +145,9 @@ public class TagServiceImpl extends AbstractService<Tag> implements TagService {
|
||||
result = tagMapper.update(tag.getIdTag(), tag.getTagUri(), tag.getTagIconPath(), tag.getTagStatus(), tag.getTagDescription(), tag.getTagReservation());
|
||||
}
|
||||
if (result == 0) {
|
||||
map.put("message", "操作失败!");
|
||||
} else {
|
||||
map.put("tag", tag);
|
||||
throw new ServiceException("操作失败!");
|
||||
}
|
||||
return map;
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,8 +1,9 @@
|
||||
package com.rymcu.forest.service.impl;
|
||||
|
||||
import cn.hutool.http.HtmlUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.rymcu.forest.core.exception.BusinessException;
|
||||
import com.rymcu.forest.core.exception.ServiceException;
|
||||
import com.rymcu.forest.core.service.AbstractService;
|
||||
import com.rymcu.forest.dto.admin.TagDTO;
|
||||
import com.rymcu.forest.dto.admin.TopicDTO;
|
||||
@ -20,9 +21,7 @@ import tk.mybatis.mapper.entity.Condition;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ronger
|
||||
@ -35,8 +34,7 @@ public class TopicServiceImpl extends AbstractService<Topic> implements TopicSer
|
||||
|
||||
@Override
|
||||
public List<Topic> findTopicNav() {
|
||||
List<Topic> topics = topicMapper.selectTopicNav();
|
||||
return topics;
|
||||
return topicMapper.selectTopicNav();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -48,40 +46,37 @@ public class TopicServiceImpl extends AbstractService<Topic> implements TopicSer
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map saveTopic(Topic topic) {
|
||||
public Topic saveTopic(Topic topic) throws ServiceException {
|
||||
Integer result;
|
||||
topic.setTopicDescriptionHtml(XssUtils.filterHtmlCode(topic.getTopicDescriptionHtml()));
|
||||
Map map = new HashMap(1);
|
||||
if (topic.getIdTopic() == null) {
|
||||
if (StringUtils.isBlank(topic.getTopicTitle())) {
|
||||
map.put("message","标签名不能为空!");
|
||||
return map;
|
||||
throw new IllegalArgumentException("标签名不能为空!");
|
||||
} else {
|
||||
Condition topicCondition = new Condition(Topic.class);
|
||||
topicCondition.createCriteria().andCondition("topic_title =", topic.getTopicTitle());
|
||||
List<Topic> topics = topicMapper.selectByCondition(topicCondition);
|
||||
if (!topics.isEmpty()) {
|
||||
map.put("message","专题 '" + topic.getTopicTitle() + "' 已存在!");
|
||||
return map;
|
||||
throw new BusinessException("专题 '" + topic.getTopicTitle() + "' 已存在!");
|
||||
}
|
||||
}
|
||||
Topic newTopic = new Topic();
|
||||
newTopic.setTopicTitle(topic.getTopicTitle());
|
||||
newTopic.setTopicUri(topic.getTopicUri());
|
||||
topic = new Topic();
|
||||
topic.setTopicTitle(topic.getTopicTitle());
|
||||
topic.setTopicUri(topic.getTopicUri());
|
||||
if (StringUtils.isNotBlank(topic.getTopicIconPath()) && topic.getTopicIconPath().contains("base64")) {
|
||||
String topicIconPath = UploadController.uploadBase64File(topic.getTopicIconPath(), 3);
|
||||
newTopic.setTopicIconPath(topicIconPath);
|
||||
topic.setTopicIconPath(topicIconPath);
|
||||
} else {
|
||||
newTopic.setTopicIconPath(topic.getTopicIconPath());
|
||||
topic.setTopicIconPath(topic.getTopicIconPath());
|
||||
}
|
||||
newTopic.setTopicNva(topic.getTopicNva());
|
||||
newTopic.setTopicStatus(topic.getTopicStatus());
|
||||
newTopic.setTopicSort(topic.getTopicSort());
|
||||
newTopic.setTopicDescription(topic.getTopicDescription());
|
||||
newTopic.setTopicDescriptionHtml(topic.getTopicDescriptionHtml());
|
||||
newTopic.setCreatedTime(new Date());
|
||||
newTopic.setUpdatedTime(topic.getCreatedTime());
|
||||
result = topicMapper.insertSelective(newTopic);
|
||||
topic.setTopicNva(topic.getTopicNva());
|
||||
topic.setTopicStatus(topic.getTopicStatus());
|
||||
topic.setTopicSort(topic.getTopicSort());
|
||||
topic.setTopicDescription(topic.getTopicDescription());
|
||||
topic.setTopicDescriptionHtml(topic.getTopicDescriptionHtml());
|
||||
topic.setCreatedTime(new Date());
|
||||
topic.setUpdatedTime(topic.getCreatedTime());
|
||||
result = topicMapper.insertSelective(topic);
|
||||
} else {
|
||||
if (StringUtils.isNotBlank(topic.getTopicIconPath()) && topic.getTopicIconPath().contains("base64")) {
|
||||
String topicIconPath = UploadController.uploadBase64File(topic.getTopicIconPath(), 3);
|
||||
@ -93,11 +88,9 @@ public class TopicServiceImpl extends AbstractService<Topic> implements TopicSer
|
||||
,topic.getTopicSort(),topic.getTopicDescription(),topic.getTopicDescriptionHtml());
|
||||
}
|
||||
if (result == 0) {
|
||||
map.put("message","操作失败!");
|
||||
} else {
|
||||
map.put("topic", topic);
|
||||
throw new ServiceException("操作失败!");
|
||||
}
|
||||
return map;
|
||||
return topic;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -110,46 +103,30 @@ public class TopicServiceImpl extends AbstractService<Topic> implements TopicSer
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map bindTopicTag(TopicTagDTO topicTag) {
|
||||
public TopicTagDTO bindTopicTag(TopicTagDTO topicTag) throws ServiceException {
|
||||
Integer result = topicMapper.insertTopicTag(topicTag.getIdTopic(), topicTag.getIdTag());
|
||||
Map map = new HashMap(1);
|
||||
if (result == 0) {
|
||||
map.put("message", "操作失败!");
|
||||
} else {
|
||||
map.put("topicTag", topicTag);
|
||||
throw new ServiceException("操作失败!");
|
||||
}
|
||||
return map;
|
||||
return topicTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map unbindTopicTag(TopicTagDTO topicTag) {
|
||||
public TopicTagDTO unbindTopicTag(TopicTagDTO topicTag) throws ServiceException {
|
||||
Integer result = topicMapper.deleteTopicTag(topicTag.getIdTopic(), topicTag.getIdTag());
|
||||
Map map = new HashMap(1);
|
||||
if (result == 0) {
|
||||
map.put("message", "操作失败!");
|
||||
} else {
|
||||
map.put("topicTag", topicTag);
|
||||
throw new ServiceException("操作失败!");
|
||||
}
|
||||
return map;
|
||||
return topicTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map findTagsByTopicUri(String topicUri, Integer page, Integer rows) {
|
||||
Map map = new HashMap(2);
|
||||
public List<TagDTO> findTagsByTopicUri(String topicUri) {
|
||||
TopicDTO topic = topicMapper.selectTopicByTopicUri(topicUri);
|
||||
if (topic == null) {
|
||||
return map;
|
||||
return null;
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<TagDTO> list = topicMapper.selectTopicTag(topic.getIdTopic());
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
map.put("tags", pageInfo.getList());
|
||||
Map pagination = new HashMap(3);
|
||||
pagination.put("pageSize",pageInfo.getPageSize());
|
||||
pagination.put("total",pageInfo.getTotal());
|
||||
pagination.put("currentPage",pageInfo.getPageNum());
|
||||
map.put("pagination", pagination);
|
||||
return map;
|
||||
return topicMapper.selectTopicTag(topic.getIdTopic());
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class TransactionRecordServiceImpl extends AbstractService<TransactionRec
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TransactionRecord transfer(TransactionRecord transactionRecord) throws Exception {
|
||||
public TransactionRecord transfer(TransactionRecord transactionRecord) {
|
||||
// 判断发起者账户状态
|
||||
boolean formAccountStatus = checkFormAccountStatus(transactionRecord.getFormBankAccount(), transactionRecord.getMoney());
|
||||
if (formAccountStatus) {
|
||||
@ -71,7 +71,7 @@ public class TransactionRecordServiceImpl extends AbstractService<TransactionRec
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransactionRecord userTransfer(Long toUserId, Long formUserId, TransactionEnum transactionType) throws Exception {
|
||||
public TransactionRecord userTransfer(Long toUserId, Long formUserId, TransactionEnum transactionType) {
|
||||
BankAccountDTO toBankAccount = bankAccountMapper.findPersonBankAccountByIdUser(toUserId);
|
||||
BankAccountDTO formBankAccount = bankAccountMapper.findPersonBankAccountByIdUser(formUserId);
|
||||
TransactionRecord transactionRecord = new TransactionRecord();
|
||||
@ -83,7 +83,7 @@ public class TransactionRecordServiceImpl extends AbstractService<TransactionRec
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransactionRecord bankTransfer(Long idUser, TransactionEnum transactionType) throws Exception {
|
||||
public TransactionRecord bankTransfer(Long idUser, TransactionEnum transactionType) {
|
||||
BankAccountDTO toBankAccount = bankAccountMapper.findPersonBankAccountByIdUser(idUser);
|
||||
Boolean isTrue;
|
||||
// 校验货币规则
|
||||
@ -116,7 +116,7 @@ public class TransactionRecordServiceImpl extends AbstractService<TransactionRec
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransactionRecord newbieRewards(TransactionRecord transactionRecord) throws Exception {
|
||||
public TransactionRecord newbieRewards(TransactionRecord transactionRecord) {
|
||||
// 判断是否重复发放
|
||||
Boolean result = transactionRecordMapper.existsWithNewbieRewards(transactionRecord.getToBankAccount());
|
||||
if (result) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.rymcu.forest.service.impl;
|
||||
|
||||
import com.rymcu.forest.core.exception.CaptchaException;
|
||||
import com.rymcu.forest.core.exception.ContentNotExistException;
|
||||
import com.rymcu.forest.core.exception.*;
|
||||
import com.rymcu.forest.core.service.AbstractService;
|
||||
import com.rymcu.forest.core.service.redis.RedisService;
|
||||
import com.rymcu.forest.dto.*;
|
||||
@ -60,15 +59,13 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map register(String email, String password, String code) {
|
||||
Map map = new HashMap(2);
|
||||
map.put("message", "验证码无效!");
|
||||
public boolean register(String email, String password, String code) {
|
||||
String vCode = redisService.get(email);
|
||||
if (StringUtils.isNotBlank(vCode)) {
|
||||
if (vCode.equals(code)) {
|
||||
User user = userMapper.findByAccount(email);
|
||||
if (user != null) {
|
||||
map.put("message", "该邮箱已被注册!");
|
||||
throw new AccountExistsException("该邮箱已被注册!");
|
||||
} else {
|
||||
user = new User();
|
||||
String nickname = email.split("@")[0];
|
||||
@ -88,13 +85,12 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
||||
.nickname(user.getNickname())
|
||||
.signature(user.getSignature())
|
||||
.build());
|
||||
map.put("message", "注册成功!");
|
||||
map.put("flag", 1);
|
||||
redisService.delete(email);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
throw new CaptchaException();
|
||||
}
|
||||
|
||||
private String checkNickname(String nickname) {
|
||||
@ -145,69 +141,55 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map forgetPassword(String code, String password) {
|
||||
Map map = new HashMap<>(2);
|
||||
public boolean forgetPassword(String code, String password) throws ServiceException {
|
||||
String email = redisService.get(code);
|
||||
if (StringUtils.isBlank(email)) {
|
||||
map.put("message", "链接已失效");
|
||||
throw new ServiceException("链接已失效");
|
||||
} else {
|
||||
userMapper.updatePasswordByEmail(email, Utils.entryptPassword(password));
|
||||
map.put("message", "修改成功,正在跳转登录登陆界面!");
|
||||
map.put("flag", 1);
|
||||
int result = userMapper.updatePasswordByEmail(email, Utils.entryptPassword(password));
|
||||
if (result == 0) {
|
||||
throw new ServiceException("密码修改失败!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map updateUserRole(Long idUser, Long idRole) {
|
||||
Map map = new HashMap(2);
|
||||
public boolean updateUserRole(Long idUser, Long idRole) throws ServiceException {
|
||||
Integer result = userMapper.updateUserRole(idUser, idRole);
|
||||
if (result == 0) {
|
||||
map.put("message", "更新失败!");
|
||||
throw new ServiceException("更新失败!");
|
||||
}
|
||||
return map;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map updateStatus(Long idUser, String status) {
|
||||
Map map = new HashMap(2);
|
||||
public boolean updateStatus(Long idUser, String status) throws ServiceException {
|
||||
Integer result = userMapper.updateStatus(idUser, status);
|
||||
if (result == 0) {
|
||||
map.put("message", "更新失败!");
|
||||
throw new ServiceException("更新失败!");
|
||||
}
|
||||
return map;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map findUserInfo(Long idUser) {
|
||||
Map map = new HashMap(2);
|
||||
public UserInfoDTO findUserInfo(Long idUser) {
|
||||
UserInfoDTO user = userMapper.selectUserInfo(idUser);
|
||||
if (user == null) {
|
||||
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
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map updateUserInfo(UserInfoDTO user) {
|
||||
Map map = new HashMap(2);
|
||||
public UserInfoDTO updateUserInfo(UserInfoDTO user) throws ServiceException {
|
||||
user.setNickname(formatNickname(user.getNickname()));
|
||||
Integer number = userMapper.checkNicknameByIdUser(user.getIdUser(), user.getNickname());
|
||||
if (number > 0) {
|
||||
map.put("message", "该昵称已使用!");
|
||||
return map;
|
||||
throw new NicknameOccupyException("该昵称已使用!");
|
||||
}
|
||||
if (StringUtils.isNotBlank(user.getAvatarType()) && AVATAR_SVG_TYPE.equals(user.getAvatarType())) {
|
||||
String avatarUrl = UploadController.uploadBase64File(user.getAvatarUrl(), 0);
|
||||
@ -221,25 +203,22 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
||||
.signature(user.getSignature())
|
||||
.build());
|
||||
if (result == 0) {
|
||||
map.put("message", "操作失败!");
|
||||
return map;
|
||||
throw new ServiceException("操作失败!");
|
||||
}
|
||||
map.put("user", user);
|
||||
return map;
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
private String formatNickname(String nickname) {
|
||||
return nickname.replaceAll("\\.", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map checkNickname(Long idUser, String nickname) {
|
||||
Map map = new HashMap(2);
|
||||
public boolean checkNicknameByIdUser(Long idUser, String nickname) {
|
||||
Integer number = userMapper.checkNicknameByIdUser(idUser, nickname);
|
||||
if (number > 0) {
|
||||
map.put("message", "该昵称已使用!");
|
||||
return false;
|
||||
}
|
||||
return map;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -253,15 +232,12 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map updateUserExtend(UserExtend userExtend) {
|
||||
Map map = new HashMap(2);
|
||||
int result = userExtendMapper.updateByPrimaryKeySelective(userExtend);
|
||||
public UserExtend updateUserExtend(UserExtend userExtend) throws ServiceException {
|
||||
int result = userExtendMapper.updateByPrimaryKey(userExtend);
|
||||
if (result == 0) {
|
||||
map.put("message", "操作失败!");
|
||||
return map;
|
||||
throw new ServiceException("操作失败!");
|
||||
}
|
||||
map.put("userExtend", userExtend);
|
||||
return map;
|
||||
return userExtend;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -270,29 +246,26 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map updateEmail(ChangeEmailDTO changeEmailDTO) {
|
||||
Map map = new HashMap(2);
|
||||
public boolean updateEmail(ChangeEmailDTO changeEmailDTO) throws ServiceException {
|
||||
Long idUser = changeEmailDTO.getIdUser();
|
||||
String email = changeEmailDTO.getEmail();
|
||||
String code = changeEmailDTO.getCode();
|
||||
String vCode = redisService.get(email);
|
||||
if (StringUtils.isNotBlank(vCode) && StringUtils.isNotBlank(code)) {
|
||||
if (vCode.equals(code)) {
|
||||
userMapper.updateEmail(idUser, email);
|
||||
map.put("message", "更新成功!");
|
||||
map.put("email", email);
|
||||
if (StringUtils.isNotBlank(vCode) && StringUtils.isNotBlank(code) && vCode.equals(code)) {
|
||||
int result = userMapper.updateEmail(idUser, email);
|
||||
if (result == 0) {
|
||||
throw new ServiceException("修改邮箱失败!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
throw new CaptchaException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map updatePassword(UpdatePasswordDTO updatePasswordDTO) {
|
||||
Map map = new HashMap(2);
|
||||
public boolean updatePassword(UpdatePasswordDTO updatePasswordDTO) {
|
||||
String password = Utils.entryptPassword(updatePasswordDTO.getPassword());
|
||||
userMapper.updatePasswordById(updatePasswordDTO.getIdUser(), password);
|
||||
map.put("message", "更新成功!");
|
||||
return map;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -316,4 +289,15 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
||||
public Integer updateLastOnlineTimeByEmail(String 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;
|
||||
}
|
||||
}
|
||||
|
@ -2,26 +2,25 @@ package com.rymcu.forest.web.api.admin;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
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.GlobalResultGenerator;
|
||||
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.UserRoleDTO;
|
||||
import com.rymcu.forest.entity.*;
|
||||
import com.rymcu.forest.service.*;
|
||||
import com.rymcu.forest.util.Utils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ronger
|
||||
* */
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/admin")
|
||||
public class AdminController {
|
||||
@ -44,7 +43,7 @@ public class AdminController {
|
||||
private ProductService productService;
|
||||
|
||||
@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);
|
||||
List<UserInfoDTO> list = userService.findUsers(searchDTO);
|
||||
PageInfo<UserInfoDTO> pageInfo = new PageInfo<>(list);
|
||||
@ -52,13 +51,13 @@ public class AdminController {
|
||||
}
|
||||
|
||||
@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);
|
||||
return GlobalResultGenerator.genSuccessResult(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);
|
||||
List<Role> list = roleService.findAll();
|
||||
PageInfo<Role> pageInfo = new PageInfo<>(list);
|
||||
@ -66,37 +65,37 @@ public class AdminController {
|
||||
}
|
||||
|
||||
@PatchMapping("/user/update-role")
|
||||
public GlobalResult<Map> updateUserRole(@RequestBody UserRoleDTO userRole){
|
||||
Map map = userService.updateUserRole(userRole.getIdUser(),userRole.getIdRole());
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult<Boolean> updateUserRole(@RequestBody UserRoleDTO userRole) throws ServiceException {
|
||||
boolean flag = userService.updateUserRole(userRole.getIdUser(), userRole.getIdRole());
|
||||
return GlobalResultGenerator.genSuccessResult(flag);
|
||||
}
|
||||
|
||||
@PatchMapping("/user/update-status")
|
||||
public GlobalResult<Map> updateUserStatus(@RequestBody User user){
|
||||
Map map = userService.updateStatus(user.getIdUser(),user.getStatus());
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult<Boolean> updateUserStatus(@RequestBody User user) throws ServiceException {
|
||||
boolean flag = userService.updateStatus(user.getIdUser(), user.getStatus());
|
||||
return GlobalResultGenerator.genSuccessResult(flag);
|
||||
}
|
||||
|
||||
@PatchMapping("/role/update-status")
|
||||
public GlobalResult<Map> updateRoleStatus(@RequestBody Role role){
|
||||
Map map = roleService.updateStatus(role.getIdRole(),role.getStatus());
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult<Boolean> updateRoleStatus(@RequestBody Role role) throws ServiceException {
|
||||
boolean flag = roleService.updateStatus(role.getIdRole(), role.getStatus());
|
||||
return GlobalResultGenerator.genSuccessResult(flag);
|
||||
}
|
||||
|
||||
@PostMapping("/role/post")
|
||||
public GlobalResult<Map> addRole(@RequestBody Role role){
|
||||
Map map = roleService.saveRole(role);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult<Boolean> addRole(@RequestBody Role role) throws ServiceException {
|
||||
boolean flag = roleService.saveRole(role);
|
||||
return GlobalResultGenerator.genSuccessResult(flag);
|
||||
}
|
||||
|
||||
@PutMapping("/role/post")
|
||||
public GlobalResult<Map> updateRole(@RequestBody Role role){
|
||||
Map map = roleService.saveRole(role);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult<Boolean> updateRole(@RequestBody Role role) throws Exception {
|
||||
boolean flag = roleService.saveRole(role);
|
||||
return GlobalResultGenerator.genSuccessResult(flag);
|
||||
}
|
||||
|
||||
@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);
|
||||
List<Topic> list = topicService.findAll();
|
||||
PageInfo<Topic> pageInfo = new PageInfo<>(list);
|
||||
@ -104,31 +103,33 @@ public class AdminController {
|
||||
}
|
||||
|
||||
@GetMapping("/topic/{topicUri}")
|
||||
public GlobalResult topic(@PathVariable String topicUri){
|
||||
public GlobalResult topic(@PathVariable String topicUri) {
|
||||
if (StringUtils.isBlank(topicUri)) {
|
||||
return GlobalResultGenerator.genErrorResult("数据异常!");
|
||||
throw new IllegalArgumentException("参数异常!");
|
||||
}
|
||||
Topic topic = topicService.findTopicByTopicUri(topicUri);
|
||||
return GlobalResultGenerator.genSuccessResult(topic);
|
||||
}
|
||||
|
||||
@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)) {
|
||||
return GlobalResultGenerator.genErrorResult("数据异常!");
|
||||
throw new IllegalArgumentException("参数异常!");
|
||||
}
|
||||
Map map = topicService.findTagsByTopicUri(topicUri,page,rows);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
PageHelper.startPage(page, rows);
|
||||
List<TagDTO> list = topicService.findTagsByTopicUri(topicUri);
|
||||
PageInfo<TagDTO> pageInfo = new PageInfo<>(list);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@GetMapping("/topic/detail/{idTopic}")
|
||||
public GlobalResult<Topic> topicDetail(@PathVariable Integer idTopic){
|
||||
public GlobalResult<Topic> topicDetail(@PathVariable Integer idTopic) {
|
||||
Topic topic = topicService.findById(idTopic.toString());
|
||||
return GlobalResultGenerator.genSuccessResult(topic);
|
||||
}
|
||||
|
||||
@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"));
|
||||
String tagTitle = request.getParameter("tagTitle");
|
||||
PageHelper.startPage(page, rows);
|
||||
@ -138,31 +139,31 @@ public class AdminController {
|
||||
}
|
||||
|
||||
@PostMapping("/topic/bind-topic-tag")
|
||||
public GlobalResult bindTopicTag(@RequestBody TopicTagDTO topicTag){
|
||||
Map map = topicService.bindTopicTag(topicTag);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult bindTopicTag(@RequestBody TopicTagDTO topicTag) throws Exception {
|
||||
TopicTagDTO newTopicTagDTO = topicService.bindTopicTag(topicTag);
|
||||
return GlobalResultGenerator.genSuccessResult(newTopicTagDTO);
|
||||
}
|
||||
|
||||
@DeleteMapping("/topic/unbind-topic-tag")
|
||||
public GlobalResult unbindTopicTag(@RequestBody TopicTagDTO topicTag){
|
||||
Map map = topicService.unbindTopicTag(topicTag);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult unbindTopicTag(@RequestBody TopicTagDTO topicTag) throws Exception {
|
||||
TopicTagDTO topicTagDTO = topicService.unbindTopicTag(topicTag);
|
||||
return GlobalResultGenerator.genSuccessResult(topicTagDTO);
|
||||
}
|
||||
|
||||
@PostMapping("/topic/post")
|
||||
public GlobalResult<Map> addTopic(@RequestBody Topic topic){
|
||||
Map map = topicService.saveTopic(topic);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult<Topic> addTopic(@RequestBody Topic topic) throws Exception {
|
||||
Topic newTopic = topicService.saveTopic(topic);
|
||||
return GlobalResultGenerator.genSuccessResult(newTopic);
|
||||
}
|
||||
|
||||
@PutMapping("/topic/post")
|
||||
public GlobalResult<Map> updateTopic(@RequestBody Topic topic){
|
||||
Map map = topicService.saveTopic(topic);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult<Topic> updateTopic(@RequestBody Topic topic) throws Exception {
|
||||
Topic newTopic = topicService.saveTopic(topic);
|
||||
return GlobalResultGenerator.genSuccessResult(newTopic);
|
||||
}
|
||||
|
||||
@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);
|
||||
List<Tag> list = tagService.findAll();
|
||||
PageInfo<Tag> pageInfo = new PageInfo<>(list);
|
||||
@ -170,27 +171,27 @@ public class AdminController {
|
||||
}
|
||||
|
||||
@DeleteMapping("/tag/clean-unused")
|
||||
public GlobalResult cleanUnusedTag(){
|
||||
Map map = tagService.cleanUnusedTag();
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult cleanUnusedTag() {
|
||||
boolean bool = tagService.cleanUnusedTag();
|
||||
return GlobalResultGenerator.genSuccessResult(bool);
|
||||
}
|
||||
|
||||
@GetMapping("/tag/detail/{idTag}")
|
||||
public GlobalResult<Tag> tagDetail(@PathVariable Integer idTag){
|
||||
public GlobalResult<Tag> tagDetail(@PathVariable Integer idTag) {
|
||||
Tag tag = tagService.findById(idTag.toString());
|
||||
return GlobalResultGenerator.genSuccessResult(tag);
|
||||
}
|
||||
|
||||
@PostMapping("/tag/post")
|
||||
public GlobalResult<Map> addTag(@RequestBody Tag tag){
|
||||
Map map = tagService.saveTag(tag);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult<Tag> addTag(@RequestBody Tag tag) throws Exception {
|
||||
Tag newTag = tagService.saveTag(tag);
|
||||
return GlobalResultGenerator.genSuccessResult(newTag);
|
||||
}
|
||||
|
||||
@PutMapping("/tag/post")
|
||||
public GlobalResult<Map> updateTag(@RequestBody Tag tag){
|
||||
Map map = tagService.saveTag(tag);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult<Tag> updateTag(@RequestBody Tag tag) throws Exception {
|
||||
Tag newTag = tagService.saveTag(tag);
|
||||
return GlobalResultGenerator.genSuccessResult(newTag);
|
||||
}
|
||||
|
||||
@GetMapping("/special-days")
|
||||
@ -226,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.PageInfo;
|
||||
import com.rymcu.forest.core.exception.BusinessException;
|
||||
import com.rymcu.forest.core.result.GlobalResult;
|
||||
import com.rymcu.forest.core.result.GlobalResultGenerator;
|
||||
import com.rymcu.forest.core.service.security.annotation.AuthorshipInterceptor;
|
||||
@ -24,7 +25,6 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@ -106,15 +106,24 @@ public class ArticleController {
|
||||
}
|
||||
|
||||
@PostMapping("/thumbs-up")
|
||||
public GlobalResult thumbsUp(@RequestBody ArticleThumbsUp articleThumbsUp) throws BaseApiException {
|
||||
Map map = articleThumbsUpService.thumbsUp(articleThumbsUp);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult<Integer> thumbsUp(@RequestBody ArticleThumbsUp articleThumbsUp) throws Exception {
|
||||
if (Objects.isNull(articleThumbsUp) || Objects.isNull(articleThumbsUp.getIdArticle())) {
|
||||
throw new BusinessException("数据异常,文章不存在!");
|
||||
}
|
||||
User user = UserUtils.getCurrentUserByToken();
|
||||
articleThumbsUp.setIdUser(user.getIdUser());
|
||||
return GlobalResultGenerator.genSuccessResult(articleThumbsUpService.thumbsUp(articleThumbsUp));
|
||||
}
|
||||
|
||||
@PostMapping("/sponsor")
|
||||
public GlobalResult sponsor(@RequestBody Sponsor sponsor) throws Exception {
|
||||
Map map = sponsorService.sponsorship(sponsor);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
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);
|
||||
return GlobalResultGenerator.genSuccessResult(flag);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,13 +22,13 @@ public class TransactionRecordController {
|
||||
private TransactionRecordService transactionRecordService;
|
||||
|
||||
@PostMapping("/transfer")
|
||||
public GlobalResult transfer(@RequestBody TransactionRecord transactionRecord) throws Exception {
|
||||
public GlobalResult transfer(@RequestBody TransactionRecord transactionRecord) {
|
||||
transactionRecord = transactionRecordService.transfer(transactionRecord);
|
||||
return GlobalResultGenerator.genSuccessResult(transactionRecord);
|
||||
}
|
||||
|
||||
@PostMapping("/newbie-rewards")
|
||||
public GlobalResult newbieRewards(@RequestBody TransactionRecord transactionRecord) throws Exception {
|
||||
public GlobalResult newbieRewards(@RequestBody TransactionRecord transactionRecord) {
|
||||
transactionRecord = transactionRecordService.newbieRewards(transactionRecord);
|
||||
return GlobalResultGenerator.genSuccessResult(transactionRecord);
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ package com.rymcu.forest.web.api.common;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.rymcu.forest.core.exception.AccountExistsException;
|
||||
import com.rymcu.forest.core.exception.ServiceException;
|
||||
import com.rymcu.forest.core.result.GlobalResult;
|
||||
import com.rymcu.forest.core.result.GlobalResultGenerator;
|
||||
import com.rymcu.forest.core.result.GlobalResultMessage;
|
||||
@ -9,6 +11,7 @@ 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.*;
|
||||
import org.apache.shiro.authc.UnknownAccountException;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -41,7 +44,7 @@ public class CommonApiController {
|
||||
map.put("message", GlobalResultMessage.SEND_SUCCESS.getMessage());
|
||||
User user = userService.findByAccount(email);
|
||||
if (user != null) {
|
||||
map.put("message", "该邮箱已被注册!");
|
||||
throw new AccountExistsException("该邮箱已被注册!");
|
||||
} else {
|
||||
Integer result = javaMailService.sendEmailCode(email);
|
||||
if (result == 0) {
|
||||
@ -52,29 +55,27 @@ public class CommonApiController {
|
||||
}
|
||||
|
||||
@GetMapping("/get-forget-password-email")
|
||||
public GlobalResult<Map<Object, Object>> getForgetPasswordEmail(@RequestParam("email") String email) throws MessagingException {
|
||||
Map<Object, Object> map = new HashMap<>(1);
|
||||
map.put("message", GlobalResultMessage.SEND_SUCCESS.getMessage());
|
||||
public GlobalResult getForgetPasswordEmail(@RequestParam("email") String email) throws MessagingException, ServiceException {
|
||||
User user = userService.findByAccount(email);
|
||||
if (user != null) {
|
||||
Integer result = javaMailService.sendForgetPasswordEmail(email);
|
||||
if (result == 0) {
|
||||
map.put("message", GlobalResultMessage.SEND_FAIL.getMessage());
|
||||
throw new ServiceException(GlobalResultMessage.SEND_FAIL.getMessage());
|
||||
}
|
||||
} else {
|
||||
map.put("message", "该邮箱未注册!");
|
||||
throw new UnknownAccountException("该邮箱未注册!");
|
||||
}
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(GlobalResultMessage.SEND_SUCCESS.getMessage());
|
||||
}
|
||||
|
||||
@PostMapping("/register")
|
||||
public GlobalResult<Map> register(@RequestBody UserRegisterInfoDTO registerInfo) {
|
||||
Map map = userService.register(registerInfo.getEmail(), registerInfo.getPassword(), registerInfo.getCode());
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult<Boolean> register(@RequestBody UserRegisterInfoDTO registerInfo) {
|
||||
boolean flag = userService.register(registerInfo.getEmail(), registerInfo.getPassword(), registerInfo.getCode());
|
||||
return GlobalResultGenerator.genSuccessResult(flag);
|
||||
}
|
||||
|
||||
@PostMapping("/login")
|
||||
public GlobalResult<TokenUser> login(@RequestBody User user) {
|
||||
public GlobalResult<TokenUser> login(@RequestBody User user) throws ServiceException {
|
||||
TokenUser tokenUser = userService.login(user.getAccount(), user.getPassword());
|
||||
return GlobalResultGenerator.genSuccessResult(tokenUser);
|
||||
}
|
||||
@ -89,7 +90,7 @@ public class CommonApiController {
|
||||
public GlobalResult<PageInfo<ArticleDTO>> articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, ArticleSearchDTO searchDTO) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<ArticleDTO> list = articleService.findArticles(searchDTO);
|
||||
PageInfo<ArticleDTO> pageInfo = new PageInfo(list);
|
||||
PageInfo<ArticleDTO> pageInfo = new PageInfo<>(list);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@ -97,7 +98,7 @@ public class CommonApiController {
|
||||
public GlobalResult<PageInfo<ArticleDTO>> announcements(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "5") Integer rows) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<ArticleDTO> list = articleService.findAnnouncements();
|
||||
PageInfo<ArticleDTO> pageInfo = new PageInfo(list);
|
||||
PageInfo<ArticleDTO> pageInfo = new PageInfo<>(list);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@ -109,9 +110,9 @@ public class CommonApiController {
|
||||
}
|
||||
|
||||
@PatchMapping("/forget-password")
|
||||
public GlobalResult<Map> forgetPassword(@RequestBody ForgetPasswordDTO forgetPassword) {
|
||||
Map map = userService.forgetPassword(forgetPassword.getCode(), forgetPassword.getPassword());
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult<Boolean> forgetPassword(@RequestBody ForgetPasswordDTO forgetPassword) throws ServiceException {
|
||||
boolean flag = userService.forgetPassword(forgetPassword.getCode(), forgetPassword.getPassword());
|
||||
return GlobalResultGenerator.genSuccessResult(flag);
|
||||
}
|
||||
|
||||
@GetMapping("/portfolio/{id}")
|
||||
@ -125,7 +126,7 @@ public class CommonApiController {
|
||||
public GlobalResult<PageInfo<ArticleDTO>> articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @PathVariable Long id) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<ArticleDTO> list = articleService.findArticlesByIdPortfolio(id);
|
||||
PageInfo<ArticleDTO> pageInfo = new PageInfo(list);
|
||||
PageInfo<ArticleDTO> pageInfo = new PageInfo<>(list);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@ -133,7 +134,7 @@ public class CommonApiController {
|
||||
public GlobalResult<PageInfo<PortfolioDTO>> portfolios(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<PortfolioDTO> list = portfolioService.findPortfolios();
|
||||
PageInfo<PortfolioDTO> pageInfo = new PageInfo(list);
|
||||
PageInfo<PortfolioDTO> pageInfo = new PageInfo<>(list);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
@ -141,7 +142,7 @@ public class CommonApiController {
|
||||
public GlobalResult<PageInfo<ProductDTO>> products(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows) {
|
||||
PageHelper.startPage(page, rows);
|
||||
List<ProductDTO> list = productService.findProducts();
|
||||
PageInfo<ProductDTO> pageInfo = new PageInfo(list);
|
||||
PageInfo<ProductDTO> pageInfo = new PageInfo<>(list);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.rymcu.forest.web.api.portfolio;
|
||||
|
||||
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.GlobalResultGenerator;
|
||||
import com.rymcu.forest.core.service.security.annotation.AuthorshipInterceptor;
|
||||
@ -31,62 +33,94 @@ public class PortfolioController {
|
||||
private UserService userService;
|
||||
|
||||
@GetMapping("/detail/{idPortfolio}")
|
||||
public GlobalResult detail(@PathVariable Long idPortfolio,@RequestParam(defaultValue = "0") Integer type) {
|
||||
PortfolioDTO portfolio = portfolioService.findPortfolioDTOById(idPortfolio, type);
|
||||
Map map = new HashMap<>(1);
|
||||
map.put("portfolio", portfolio);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult<PortfolioDTO> detail(@PathVariable Long idPortfolio, @RequestParam(defaultValue = "0") Integer type) {
|
||||
if (idPortfolio == null || idPortfolio == 0) {
|
||||
throw new IllegalArgumentException("作品集主键参数异常!");
|
||||
}
|
||||
return GlobalResultGenerator.genSuccessResult(portfolioService.findPortfolioDTOById(idPortfolio, type));
|
||||
}
|
||||
|
||||
@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);
|
||||
return GlobalResultGenerator.genSuccessResult(portfolio);
|
||||
}
|
||||
|
||||
@PutMapping("/post")
|
||||
@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);
|
||||
return GlobalResultGenerator.genSuccessResult(portfolio);
|
||||
}
|
||||
|
||||
@GetMapping("/{idPortfolio}/unbind-articles")
|
||||
@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 BaseApiException {
|
||||
Map map = portfolioService.findUnbindArticles(page, rows, searchText, idPortfolio);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult<PageInfo> unbindArticles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @RequestParam(defaultValue = "") String searchText, @PathVariable Long idPortfolio) throws BaseApiException {
|
||||
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);
|
||||
}
|
||||
|
||||
@PostMapping("/bind-article")
|
||||
@AuthorshipInterceptor(moduleName = Module.PORTFOLIO)
|
||||
public GlobalResult bindArticle(@RequestBody PortfolioArticleDTO portfolioArticle) {
|
||||
Map map = portfolioService.bindArticle(portfolioArticle);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult<Boolean> bindArticle(@RequestBody PortfolioArticleDTO portfolioArticle) throws ServiceException {
|
||||
if (portfolioArticle.getIdPortfolio() == null || portfolioArticle.getIdPortfolio() == 0) {
|
||||
throw new IllegalArgumentException("作品集主键参数异常!");
|
||||
}
|
||||
boolean flag = portfolioService.bindArticle(portfolioArticle);
|
||||
return GlobalResultGenerator.genSuccessResult(flag);
|
||||
}
|
||||
|
||||
@PutMapping("/update-article-sort-no")
|
||||
@AuthorshipInterceptor(moduleName = Module.PORTFOLIO)
|
||||
public GlobalResult updateArticleSortNo(@RequestBody PortfolioArticleDTO portfolioArticle) {
|
||||
Map map = portfolioService.updateArticleSortNo(portfolioArticle);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
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);
|
||||
return GlobalResultGenerator.genSuccessResult(flag);
|
||||
}
|
||||
|
||||
@DeleteMapping("/unbind-article")
|
||||
@AuthorshipInterceptor(moduleName = Module.PORTFOLIO)
|
||||
public GlobalResult unbindArticle(Long idArticle, Long idPortfolio) {
|
||||
Map map = portfolioService.unbindArticle(idPortfolio,idArticle);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
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);
|
||||
return GlobalResultGenerator.genSuccessResult(flag);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@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();
|
||||
Long idUser = user.getIdUser();
|
||||
Integer roleWeights = userService.findRoleWeightsByUser(idUser);
|
||||
boolean map = portfolioService.deletePortfolio(idPortfolio, idUser, roleWeights);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
boolean flag = portfolioService.deletePortfolio(idPortfolio, idUser, roleWeights);
|
||||
return GlobalResultGenerator.genSuccessResult(flag);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.rymcu.forest.web.api.user;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
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.GlobalResultGenerator;
|
||||
import com.rymcu.forest.core.service.security.annotation.SecurityInterceptor;
|
||||
@ -34,57 +35,59 @@ public class UserInfoController {
|
||||
|
||||
@GetMapping("/detail/{idUser}")
|
||||
@SecurityInterceptor
|
||||
public GlobalResult detail(@PathVariable Long idUser) {
|
||||
Map map = userService.findUserInfo(idUser);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult<UserInfoDTO> detail(@PathVariable Long idUser) {
|
||||
UserInfoDTO userInfo = userService.findUserInfo(idUser);
|
||||
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")
|
||||
@SecurityInterceptor
|
||||
public GlobalResult checkNickname(@RequestParam Long idUser, @RequestParam String nickname) {
|
||||
Map map = userService.checkNickname(idUser, nickname);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
boolean flag = userService.checkNicknameByIdUser(idUser, nickname);
|
||||
return GlobalResultGenerator.genSuccessResult(flag);
|
||||
}
|
||||
|
||||
@PatchMapping("/update")
|
||||
@SecurityInterceptor
|
||||
public GlobalResult updateUserInfo(@RequestBody UserInfoDTO user) {
|
||||
Map map = userService.updateUserInfo(user);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult<UserInfoDTO> updateUserInfo(@RequestBody UserInfoDTO user) throws ServiceException {
|
||||
user = userService.updateUserInfo(user);
|
||||
return GlobalResultGenerator.genSuccessResult(user);
|
||||
}
|
||||
|
||||
@PatchMapping("/update-extend")
|
||||
@SecurityInterceptor
|
||||
public GlobalResult updateUserExtend(@RequestBody UserExtend userExtend) {
|
||||
Map map = userService.updateUserExtend(userExtend);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult<UserExtend> updateUserExtend(@RequestBody UserExtend userExtend) throws ServiceException {
|
||||
userExtend = userService.updateUserExtend(userExtend);
|
||||
return GlobalResultGenerator.genSuccessResult(userExtend);
|
||||
}
|
||||
|
||||
@PatchMapping("/update-email")
|
||||
@SecurityInterceptor
|
||||
public GlobalResult updateEmail(@RequestBody ChangeEmailDTO changeEmailDTO) {
|
||||
Map map = userService.updateEmail(changeEmailDTO);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult<Boolean> updateEmail(@RequestBody ChangeEmailDTO changeEmailDTO) throws ServiceException {
|
||||
boolean flag = userService.updateEmail(changeEmailDTO);
|
||||
return GlobalResultGenerator.genSuccessResult(flag);
|
||||
}
|
||||
|
||||
@PatchMapping("/update-password")
|
||||
@SecurityInterceptor
|
||||
public GlobalResult updatePassword(@RequestBody UpdatePasswordDTO updatePasswordDTO) {
|
||||
Map map = userService.updatePassword(updatePasswordDTO);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
public GlobalResult<Boolean> updatePassword(@RequestBody UpdatePasswordDTO updatePasswordDTO) {
|
||||
boolean flag = userService.updatePassword(updatePasswordDTO);
|
||||
return GlobalResultGenerator.genSuccessResult(flag);
|
||||
}
|
||||
|
||||
@GetMapping("/login-records")
|
||||
@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);
|
||||
List<LoginRecord> list = loginRecordService.findLoginRecordByIdUser(idUser);
|
||||
PageInfo<LoginRecord> pageInfo = new PageInfo<>(list);
|
||||
Map<String, Object> map = new HashMap<String, Object>(2);
|
||||
map.put("records", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
return GlobalResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user