Merge remote-tracking branch 'origin/master'

This commit is contained in:
ronger 2020-09-25 13:59:32 +08:00
commit 6f0ca32273
42 changed files with 478 additions and 3730 deletions

View File

@ -23,6 +23,8 @@ import java.util.Map;
/** /**
* 全局异常处理器 * 全局异常处理器
*
* @author ronger
* */ * */
@RestControllerAdvice @RestControllerAdvice
public class BaseExceptionHandler { public class BaseExceptionHandler {
@ -46,7 +48,8 @@ public class BaseExceptionHandler {
result.setCode(1000002); result.setCode(1000002);
result.setMessage("用户无权限"); result.setMessage("用户无权限");
logger.info("用户无权限"); logger.info("用户无权限");
}else if (ex instanceof ServiceException) {//业务失败的异常账号或密码错误 }else if (ex instanceof ServiceException) {
//业务失败的异常账号或密码错误
result.setCode(((ServiceException) ex).getCode()); result.setCode(((ServiceException) ex).getCode());
result.setMessage(ex.getMessage()); result.setMessage(ex.getMessage());
logger.info(ex.getMessage()); logger.info(ex.getMessage());
@ -88,7 +91,8 @@ public class BaseExceptionHandler {
} else if (ex instanceof UnauthorizedException) { } else if (ex instanceof UnauthorizedException) {
attributes.put("code", "1000002"); attributes.put("code", "1000002");
attributes.put("message", "用户无权限"); attributes.put("message", "用户无权限");
} else if (ex instanceof ServiceException) {//业务失败的异常账号或密码错误 } else if (ex instanceof ServiceException) {
//业务失败的异常账号或密码错误
attributes.put("code",((ServiceException) ex).getCode()); attributes.put("code",((ServiceException) ex).getCode());
attributes.put("message",ex.getMessage()); attributes.put("message",ex.getMessage());
logger.info(ex.getMessage()); logger.info(ex.getMessage());

View File

@ -42,8 +42,6 @@ public class BaseShiroRealm extends AuthorizingRealm {
@Override @Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
//Principal principal = (Principal) getAvailablePrincipal(principals);
// System.out.println("权限配置-->MyShiroRealm.doGetAuthorizationInfo()");
SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo(); SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
Principal principal = (Principal)principals.getPrimaryPrincipal(); Principal principal = (Principal)principals.getPrimaryPrincipal();
User user = new User(); User user = new User();
@ -55,7 +53,7 @@ public class BaseShiroRealm extends AuthorizingRealm {
authorizationInfo.addRole(role.getInputCode()); authorizationInfo.addRole(role.getInputCode());
} }
} }
List<Permission> permissions = permissionService.selectMenuByUser(user); List<Permission> permissions = permissionService.selectPermissionByUser(user);
for (Permission perm : permissions) { for (Permission perm : permissions) {
if (perm.getPermissionCategory() != null) { if (perm.getPermissionCategory() != null) {
authorizationInfo.addStringPermission(perm.getPermissionCategory()); authorizationInfo.addStringPermission(perm.getPermissionCategory());

View File

@ -55,6 +55,7 @@ public class ShiroConfig implements EnvironmentAware {
filterChainDefinitionMap.put("/api/**", "anon"); filterChainDefinitionMap.put("/api/**", "anon");
filterChainDefinitionMap.put("/ws/**", "anon"); filterChainDefinitionMap.put("/ws/**", "anon");
filterChainDefinitionMap.put("/wx/**", "anon");
filterChainDefinitionMap.put("/**", "auth"); filterChainDefinitionMap.put("/**", "auth");
//配置shiro默认登录界面地址前后端分离中登录界面跳转应由前端路由控制后台仅返回json数据 //配置shiro默认登录界面地址前后端分离中登录界面跳转应由前端路由控制后台仅返回json数据
shiroFilterFactoryBean.setLoginUrl("/login"); shiroFilterFactoryBean.setLoginUrl("/login");

View File

@ -23,6 +23,7 @@ import java.util.List;
/** /**
* Spring MVC 配置 * Spring MVC 配置
*
* @author ronger * @author ronger
*/ */
@Configuration @Configuration
@ -49,7 +50,7 @@ public class WebMvcConfigurer extends WebMvcConfigurationSupport {
/** /**
* 解决跨域问题 * 解决跨域问题
* */ */
@Override @Override
public void addCorsMappings(CorsRegistry registry) { public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**") registry.addMapping("/**")
@ -65,17 +66,18 @@ public class WebMvcConfigurer extends WebMvcConfigurationSupport {
/** /**
* 添加拦截器 * 添加拦截器
* */ */
@Override @Override
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(restAuthTokenInterceptor()).addPathPatterns("/api/**") registry.addInterceptor(restAuthTokenInterceptor()).addPathPatterns("/api/**")
.excludePathPatterns("/api/v1/console/**","/api/v1/article/articles/**","/api/v1/article/detail/**","/api/v1/topic/**","/api/v1/user/**"); .excludePathPatterns("/api/v1/console/**", "/api/v1/article/articles/**", "/api/v1/article/detail/**"
, "/api/v1/topic/**", "/api/v1/user/**", "/api/v1/article/*/comments");
} }
/** /**
* 访问静态资源 * 访问静态资源
* */ */
@Override @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
/** /**
@ -89,7 +91,7 @@ public class WebMvcConfigurer extends WebMvcConfigurationSupport {
registry.addResourceHandler("/webjars/**") registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/"); .addResourceLocations("classpath:/META-INF/resources/webjars/");
//将所有/static/** 访问都映射到classpath:/static/ 目录下 //将所有/static/** 访问都映射到classpath:/static/ 目录下
registry.addResourceHandler("/static/**").addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX +"/static/"); registry.addResourceHandler("/static/**").addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX + "/static/");
super.addResourceHandlers(registry); super.addResourceHandlers(registry);
} }
} }

View File

@ -50,8 +50,6 @@ public class ArticleDTO {
private List<ArticleTagDTO> tags; private List<ArticleTagDTO> tags;
private List<CommentDTO> articleComments;
private List<PortfolioArticleDTO> portfolios; private List<PortfolioArticleDTO> portfolios;
private Integer sortNo; private Integer sortNo;

View File

@ -0,0 +1,17 @@
package com.rymcu.vertical.dto;
import lombok.Data;
/**
* @author ronger
*/
@Data
public class ArticleSearchDTO {
private String searchText;
private String topicUri;
private String tag;
}

View File

@ -0,0 +1,22 @@
package com.rymcu.vertical.dto;
import com.rymcu.vertical.entity.Notification;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author ronger
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class NotificationDTO extends Notification {
private Integer idNotification;
private String dataTitle;
private String dataUrl;
private Author author;
}

View File

@ -43,7 +43,7 @@ public class Notification implements Serializable,Cloneable {
* 数据摘要 * 数据摘要
*/ */
@Column(name = "data_summary") @Column(name = "data_summary")
private String dataSummary ; private String dataSummary;
/** /**
* 是否已读 * 是否已读
*/ */

View File

@ -44,4 +44,6 @@ public class Tag implements Serializable,Cloneable {
private Date updatedTime; private Date updatedTime;
/** 保留标签 */ /** 保留标签 */
private String tagReservation; private String tagReservation;
/** 描述 */
private String tagDescriptionHtml;
} }

View File

@ -42,5 +42,7 @@ public class Topic {
private Date createdTime; private Date createdTime;
/** 更新时间 */ /** 更新时间 */
private Date updatedTime; private Date updatedTime;
/** 专题描述 Html */
private String topicDescriptionHtml;
} }

View File

@ -19,9 +19,10 @@ public interface ArticleMapper extends Mapper<Article> {
* 获取文章列表 * 获取文章列表
* @param searchText * @param searchText
* @param tag * @param tag
* @param topicUri
* @return * @return
*/ */
List<ArticleDTO> selectArticles(@Param("searchText") String searchText, @Param("tag") String tag); List<ArticleDTO> selectArticles(@Param("searchText") String searchText, @Param("tag") String tag, @Param("topicUri") String topicUri);
/** /**
* 根据文章 ID 查询文章 * 根据文章 ID 查询文章
@ -135,4 +136,26 @@ public interface ArticleMapper extends Mapper<Article> {
* @return * @return
*/ */
List<PortfolioArticleDTO> selectPortfolioArticles(@Param("idArticle") Integer idArticle); List<PortfolioArticleDTO> selectPortfolioArticles(@Param("idArticle") Integer idArticle);
/**
* 更新文章标签
* @param idArticle
* @param tags
* @return
*/
Integer updateArticleTags(@Param("idArticle") Integer idArticle, @Param("tags") String tags);
/**
* 判断是否有评论
* @param id
* @return
*/
boolean existsCommentWithPrimaryKey(@Param("id") Integer id);
/**
* 删除关联作品集数据
* @param id
* @return
*/
Integer deleteLinkedPortfolioData(@Param("id") Integer id);
} }

View File

@ -32,6 +32,7 @@ public interface TopicMapper extends Mapper<Topic> {
List<TagDTO> selectTopicTag(@Param("idTopic") Integer idTopic); List<TagDTO> selectTopicTag(@Param("idTopic") Integer idTopic);
/** /**
* 更新
* @param idTopic * @param idTopic
* @param topicTitle * @param topicTitle
* @param topicUri * @param topicUri
@ -40,9 +41,10 @@ public interface TopicMapper extends Mapper<Topic> {
* @param topicStatus * @param topicStatus
* @param topicSort * @param topicSort
* @param topicDescription * @param topicDescription
* @param topicDescriptionHtml
* @return * @return
*/ */
Integer update(@Param("idTopic") Integer idTopic, @Param("topicTitle") String topicTitle, @Param("topicUri") String topicUri, @Param("topicIconPath") String topicIconPath, @Param("topicNva") String topicNva, @Param("topicStatus") String topicStatus, @Param("topicSort") Integer topicSort, @Param("topicDescription") String topicDescription); Integer update(@Param("idTopic") Integer idTopic, @Param("topicTitle") String topicTitle, @Param("topicUri") String topicUri, @Param("topicIconPath") String topicIconPath, @Param("topicNva") String topicNva, @Param("topicStatus") String topicStatus, @Param("topicSort") Integer topicSort, @Param("topicDescription") String topicDescription, @Param("topicDescriptionHtml") String topicDescriptionHtml);
/** /**
* @param idTopic * @param idTopic

View File

@ -113,4 +113,11 @@ public interface UserMapper extends Mapper<User> {
* @return * @return
*/ */
Author selectAuthor(@Param("id") Integer id); Author selectAuthor(@Param("id") Integer id);
/**
* 更新用户最后登录时间
* @param idUser
* @return
*/
Integer updateLastLoginTime(@Param("idUser") Integer idUser);
} }

View File

@ -2,6 +2,7 @@ package com.rymcu.vertical.service;
import com.rymcu.vertical.core.service.Service; import com.rymcu.vertical.core.service.Service;
import com.rymcu.vertical.dto.ArticleDTO; import com.rymcu.vertical.dto.ArticleDTO;
import com.rymcu.vertical.dto.ArticleSearchDTO;
import com.rymcu.vertical.entity.Article; import com.rymcu.vertical.entity.Article;
import com.rymcu.vertical.web.api.exception.BaseApiException; import com.rymcu.vertical.web.api.exception.BaseApiException;
@ -17,11 +18,10 @@ public interface ArticleService extends Service<Article> {
/** /**
* 根据检索内容/标签查询文章列表 * 根据检索内容/标签查询文章列表
* @param searchText * @param searchDTO
* @param tag
* @return * @return
* */ * */
List<ArticleDTO> findArticles(String searchText, String tag); List<ArticleDTO> findArticles(ArticleSearchDTO searchDTO);
/** /**
* 查询文章详情信息 * 查询文章详情信息
@ -105,4 +105,12 @@ public interface ArticleService extends Service<Article> {
* @return * @return
*/ */
List<ArticleDTO> selectUnbindArticles(Integer idPortfolio, String searchText, Integer idUser); List<ArticleDTO> selectUnbindArticles(Integer idPortfolio, String searchText, Integer idUser);
/**
* 更新文章标签
* @param idArticle
* @param tags
* @return
*/
Map updateTags(Integer idArticle, String tags) throws UnsupportedEncodingException, BaseApiException;
} }

View File

@ -8,6 +8,9 @@ import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
/**
* @author ronger
*/
public interface CommentService extends Service<Comment> { public interface CommentService extends Service<Comment> {
List<CommentDTO> getArticleComments(Integer idArticle); List<CommentDTO> getArticleComments(Integer idArticle);

View File

@ -1,8 +1,8 @@
package com.rymcu.vertical.service; package com.rymcu.vertical.service;
import com.rymcu.vertical.core.service.Service; import com.rymcu.vertical.core.service.Service;
import com.rymcu.vertical.dto.NotificationDTO;
import com.rymcu.vertical.entity.Notification; import com.rymcu.vertical.entity.Notification;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -23,7 +23,7 @@ public interface NotificationService extends Service<Notification> {
* @param idUser * @param idUser
* @return * @return
*/ */
List<Notification> findNotifications(Integer idUser); List<NotificationDTO> findNotifications(Integer idUser);
/** /**
* 获取消息数据 * 获取消息数据
@ -48,5 +48,5 @@ public interface NotificationService extends Service<Notification> {
* 标记消息已读 * 标记消息已读
* @param id * @param id
*/ */
void readNotification(Integer id); Integer readNotification(Integer id);
} }

View File

@ -14,5 +14,10 @@ import java.util.List;
*/ */
public interface PermissionService extends Service<Permission> { public interface PermissionService extends Service<Permission> {
List<Permission> selectMenuByUser(User sysUser); /**
* 获取用户权限
* @param sysUser
* @return
*/
List<Permission> selectPermissionByUser(User sysUser);
} }

View File

@ -22,11 +22,9 @@ public interface TopicService extends Service<Topic> {
/** /**
* 根据 topicUri 获取主题信息及旗下标签数据 * 根据 topicUri 获取主题信息及旗下标签数据
* @param topicUri 主题 URI * @param topicUri 主题 URI
* @param page
* @param rows
* @return * @return
* */ * */
Map findTopicByTopicUri(String topicUri, Integer page, Integer rows); Topic findTopicByTopicUri(String topicUri);
/** /**
* 新增/更新主题信息 * 新增/更新主题信息
@ -56,4 +54,13 @@ public interface TopicService extends Service<Topic> {
* @return * @return
*/ */
Map unbindTopicTag(TopicTagDTO topicTag); Map unbindTopicTag(TopicTagDTO topicTag);
/**
* 获取主题下标签列表
* @param topicUri
* @param page
* @param rows
* @return
*/
Map findTagsByTopicUri(String topicUri, Integer page, Integer rows);
} }

View File

@ -25,10 +25,7 @@ import tk.mybatis.mapper.entity.Condition;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* @author ronger * @author ronger
@ -52,23 +49,29 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
private static final int MAX_PREVIEW = 200; private static final int MAX_PREVIEW = 200;
private static final String defaultStatus = "0"; private static final String defaultStatus = "0";
private static final String defaultTopicUri = "news";
@Override @Override
public List<ArticleDTO> findArticles(String searchText, String tag) { public List<ArticleDTO> findArticles(ArticleSearchDTO searchDTO) {
List<ArticleDTO> list = articleMapper.selectArticles(searchText, tag); List<ArticleDTO> list;
list.forEach(article->{ if (StringUtils.isNotBlank(searchDTO.getTopicUri()) && !defaultTopicUri.equals(searchDTO.getTopicUri())) {
genArticle(article,0); list = articleMapper.selectArticlesByTopicUri(searchDTO.getTopicUri());
} else {
list = articleMapper.selectArticles(searchDTO.getSearchText(), searchDTO.getTag(), searchDTO.getTopicUri());
}
list.forEach(article -> {
genArticle(article, 0);
}); });
return list; return list;
} }
@Override @Override
public ArticleDTO findArticleDTOById(Integer id, Integer type) { public ArticleDTO findArticleDTOById(Integer id, Integer type) {
ArticleDTO articleDTO = articleMapper.selectArticleDTOById(id,type); ArticleDTO articleDTO = articleMapper.selectArticleDTOById(id, type);
if (articleDTO == null) { if (articleDTO == null) {
return null; return null;
} }
articleDTO = genArticle(articleDTO,type); articleDTO = genArticle(articleDTO, type);
return articleDTO; return articleDTO;
} }
@ -76,7 +79,7 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
public List<ArticleDTO> findArticlesByTopicUri(String name) { public List<ArticleDTO> findArticlesByTopicUri(String name) {
List<ArticleDTO> articleDTOS = articleMapper.selectArticlesByTopicUri(name); List<ArticleDTO> articleDTOS = articleMapper.selectArticlesByTopicUri(name);
articleDTOS.forEach(articleDTO -> { articleDTOS.forEach(articleDTO -> {
genArticle(articleDTO,0); genArticle(articleDTO, 0);
}); });
return articleDTOS; return articleDTOS;
} }
@ -90,29 +93,30 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
@Override @Override
public List<ArticleDTO> findUserArticlesByIdUser(Integer idUser) { public List<ArticleDTO> findUserArticlesByIdUser(Integer idUser) {
List<ArticleDTO> list = articleMapper.selectUserArticles(idUser); List<ArticleDTO> list = articleMapper.selectUserArticles(idUser);
list.forEach(article->{ list.forEach(article -> {
genArticle(article,0); genArticle(article, 0);
}); });
return list; return list;
} }
@Override @Override
@Transactional(rollbackFor = { UnsupportedEncodingException.class, BaseApiException.class }) @Transactional(rollbackFor = {UnsupportedEncodingException.class, BaseApiException.class})
public Map postArticle(ArticleDTO article, HttpServletRequest request) throws UnsupportedEncodingException, BaseApiException { public Map postArticle(ArticleDTO article, HttpServletRequest request) throws UnsupportedEncodingException, BaseApiException {
Map map = new HashMap(1); Map map = new HashMap(1);
if(StringUtils.isBlank(article.getArticleTitle())){ if (StringUtils.isBlank(article.getArticleTitle())) {
map.put("message","标题不能为空!"); map.put("message", "标题不能为空!");
return map; return map;
} }
if(StringUtils.isBlank(article.getArticleContent())){ if (StringUtils.isBlank(article.getArticleContent())) {
map.put("message","正文不能为空!"); map.put("message", "正文不能为空!");
return map; return map;
} }
boolean isUpdate = false;
String articleTitle = article.getArticleTitle(); String articleTitle = article.getArticleTitle();
String articleTags = article.getArticleTags(); String articleTags = article.getArticleTags();
String articleContent = article.getArticleContent(); String articleContent = article.getArticleContent();
String articleContentHtml = article.getArticleContentHtml(); String articleContentHtml = article.getArticleContentHtml();
User user = UserUtils.getWxCurrentUser(); User user = UserUtils.getCurrentUserByToken();
String reservedTag = checkTags(articleTags); String reservedTag = checkTags(articleTags);
boolean notification = false; boolean notification = false;
if (StringUtils.isNotBlank(reservedTag)) { if (StringUtils.isNotBlank(reservedTag)) {
@ -125,7 +129,7 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
} }
} }
Article newArticle; Article newArticle;
if(article.getIdArticle() == null || article.getIdArticle() == 0){ if (article.getIdArticle() == null || article.getIdArticle() == 0) {
newArticle = new Article(); newArticle = new Article();
newArticle.setArticleTitle(articleTitle); newArticle.setArticleTitle(articleTitle);
newArticle.setArticleAuthorId(user.getIdUser()); newArticle.setArticleAuthorId(user.getIdUser());
@ -134,24 +138,19 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
newArticle.setUpdatedTime(newArticle.getCreatedTime()); newArticle.setUpdatedTime(newArticle.getCreatedTime());
newArticle.setArticleStatus(article.getArticleStatus()); newArticle.setArticleStatus(article.getArticleStatus());
articleMapper.insertSelective(newArticle); articleMapper.insertSelective(newArticle);
articleMapper.insertArticleContent(newArticle.getIdArticle(),articleContent,articleContentHtml); articleMapper.insertArticleContent(newArticle.getIdArticle(), articleContent, articleContentHtml);
if (!ProjectConstant.ENV.equals(env) && defaultStatus.equals(newArticle.getArticleStatus())) {
BaiDuUtils.sendSEOData(newArticle.getArticlePermalink());
}
} else { } else {
isUpdate = true;
newArticle = articleMapper.selectByPrimaryKey(article.getIdArticle()); newArticle = articleMapper.selectByPrimaryKey(article.getIdArticle());
if(!user.getIdUser().equals(newArticle.getArticleAuthorId())){ if (!user.getIdUser().equals(newArticle.getArticleAuthorId())) {
map.put("message","非法访问!"); map.put("message", "非法访问!");
return map; return map;
} }
newArticle.setArticleTitle(articleTitle); newArticle.setArticleTitle(articleTitle);
newArticle.setArticleTags(articleTags); newArticle.setArticleTags(articleTags);
newArticle.setArticleStatus(article.getArticleStatus()); newArticle.setArticleStatus(article.getArticleStatus());
newArticle.setUpdatedTime(new Date()); newArticle.setUpdatedTime(new Date());
articleMapper.updateArticleContent(newArticle.getIdArticle(),articleContent,articleContentHtml); articleMapper.updateArticleContent(newArticle.getIdArticle(), articleContent, articleContentHtml);
if (!ProjectConstant.ENV.equals(env) && defaultStatus.equals(newArticle.getArticleStatus())) {
BaiDuUtils.sendUpdateSEOData(newArticle.getArticlePermalink());
}
} }
if (notification && defaultStatus.equals(newArticle.getArticleStatus())) { if (notification && defaultStatus.equals(newArticle.getArticleStatus())) {
@ -168,23 +167,34 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
newArticle.setArticleLink("/draft/" + newArticle.getIdArticle()); newArticle.setArticleLink("/draft/" + newArticle.getIdArticle());
} }
if(StringUtils.isNotBlank(articleContentHtml)){ if (StringUtils.isNotBlank(articleContentHtml)) {
Integer length = articleContentHtml.length(); Integer length = articleContentHtml.length();
if(length > MAX_PREVIEW){ if (length > MAX_PREVIEW) {
length = MAX_PREVIEW; length = MAX_PREVIEW;
} }
String articlePreviewContent = articleContentHtml.substring(0,length); String articlePreviewContent = articleContentHtml.substring(0, length);
newArticle.setArticlePreviewContent(Html2TextUtil.getContent(articlePreviewContent)); newArticle.setArticlePreviewContent(Html2TextUtil.getContent(articlePreviewContent));
} }
articleMapper.updateByPrimaryKeySelective(newArticle); articleMapper.updateByPrimaryKeySelective(newArticle);
// 推送百度 SEO
if (!ProjectConstant.ENV.equals(env)
&& defaultStatus.equals(newArticle.getArticleStatus())
&& articleContent.length() >= MAX_PREVIEW) {
if (isUpdate) {
BaiDuUtils.sendUpdateSEOData(newArticle.getArticlePermalink());
} else {
BaiDuUtils.sendSEOData(newArticle.getArticlePermalink());
}
}
map.put("id", newArticle.getIdArticle()); map.put("id", newArticle.getIdArticle());
return map; return map;
} }
private String checkTags(String articleTags) { private String checkTags(String articleTags) {
// 判断文章是否有标签 // 判断文章是否有标签
if(StringUtils.isBlank(articleTags)){ if (StringUtils.isBlank(articleTags)) {
return ""; return "";
} }
// 判断是否存在系统配置的保留标签词 // 判断是否存在系统配置的保留标签词
@ -200,7 +210,7 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
continue; continue;
} }
for (String articleTag: articleTagArr) { for (String articleTag : articleTagArr) {
if (StringUtils.isBlank(articleTag)) { if (StringUtils.isBlank(articleTag)) {
continue; continue;
} }
@ -217,21 +227,31 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Map delete(Integer id) { public Map delete(Integer id) {
Map<String,String> map = new HashMap(1); Map<String, String> map = new HashMap(1);
Integer result; Integer result;
// 删除引用标签记录 // 判断是否有评论
result = articleMapper.deleteTagArticle(id); boolean isHavComment = articleMapper.existsCommentWithPrimaryKey(id);
if (result > 0){ if (isHavComment) {
map.put("message", "已有评论的文章不允许删除!");
} else {
// 删除关联数据(作品集关联关系,标签关联关系)
deleteLinkedData(id);
// 删除文章
result = articleMapper.deleteByPrimaryKey(id); result = articleMapper.deleteByPrimaryKey(id);
if (result < 1){ if (result < 1) {
map.put("message", "删除失败!"); map.put("message", "删除失败!");
} }
} else {
map.put("message", "删除失败!");
} }
return map; return map;
} }
private void deleteLinkedData(Integer id) {
// 删除关联作品集
articleMapper.deleteLinkedPortfolioData(id);
// 删除引用标签记录
articleMapper.deleteTagArticle(id);
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void incrementArticleViewCount(Integer id) { public void incrementArticleViewCount(Integer id) {
@ -243,7 +263,7 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
@Override @Override
public Map share(Integer id) throws BaseApiException { public Map share(Integer id) throws BaseApiException {
Article article = articleMapper.selectByPrimaryKey(id); Article article = articleMapper.selectByPrimaryKey(id);
User user = UserUtils.getWxCurrentUser(); User user = UserUtils.getCurrentUserByToken();
StringBuilder shareUrl = new StringBuilder(article.getArticlePermalink()); StringBuilder shareUrl = new StringBuilder(article.getArticlePermalink());
shareUrl.append("?s=").append(user.getNickname()); shareUrl.append("?s=").append(user.getNickname());
Map map = new HashMap(1); Map map = new HashMap(1);
@ -253,10 +273,10 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
@Override @Override
public List<ArticleDTO> findDrafts() throws BaseApiException { public List<ArticleDTO> findDrafts() throws BaseApiException {
User user = UserUtils.getWxCurrentUser(); User user = UserUtils.getCurrentUserByToken();
List<ArticleDTO> list = articleMapper.selectDrafts(user.getIdUser()); List<ArticleDTO> list = articleMapper.selectDrafts(user.getIdUser());
list.forEach(article->{ list.forEach(article -> {
genArticle(article,0); genArticle(article, 0);
}); });
return list; return list;
} }
@ -264,21 +284,38 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
@Override @Override
public List<ArticleDTO> findArticlesByIdPortfolio(Integer idPortfolio) { public List<ArticleDTO> findArticlesByIdPortfolio(Integer idPortfolio) {
List<ArticleDTO> list = articleMapper.selectArticlesByIdPortfolio(idPortfolio); List<ArticleDTO> list = articleMapper.selectArticlesByIdPortfolio(idPortfolio);
list.forEach(article->{ list.forEach(article -> {
genArticle(article,0); genArticle(article, 0);
}); });
return list; return list;
} }
@Override @Override
public List<ArticleDTO> selectUnbindArticles(Integer idPortfolio, String searchText, Integer idUser) { public List<ArticleDTO> selectUnbindArticles(Integer idPortfolio, String searchText, Integer idUser) {
List<ArticleDTO> list = articleMapper.selectUnbindArticlesByIdPortfolio(idPortfolio,searchText,idUser); List<ArticleDTO> list = articleMapper.selectUnbindArticlesByIdPortfolio(idPortfolio, searchText, idUser);
list.forEach(article->{ list.forEach(article -> {
genArticle(article,0); genArticle(article, 0);
}); });
return list; return list;
} }
@Override
@Transactional(rollbackFor = Exception.class)
public Map updateTags(Integer idArticle, String tags) throws UnsupportedEncodingException, BaseApiException {
Map map = new HashMap(2);
Article article = articleMapper.selectByPrimaryKey(idArticle);
if (Objects.nonNull(article)) {
article.setArticleTags(tags);
articleMapper.updateArticleTags(idArticle, tags);
tagService.saveTagArticle(article);
map.put("success", true);
} else {
map.put("success", false);
map.put("message", "更新失败,文章不存在!");
}
return map;
}
private ArticleDTO genArticle(ArticleDTO article, Integer type) { private ArticleDTO genArticle(ArticleDTO article, Integer type) {
Integer ARTICLE_LIST = 0; Integer ARTICLE_LIST = 0;
Integer ARTICLE_VIEW = 1; Integer ARTICLE_VIEW = 1;
@ -290,16 +327,15 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
article.setTags(tags); article.setTags(tags);
if (!type.equals(ARTICLE_LIST)) { if (!type.equals(ARTICLE_LIST)) {
ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle()); ArticleContent articleContent = articleMapper.selectArticleContent(article.getIdArticle());
if (type.equals(ARTICLE_VIEW)){ if (type.equals(ARTICLE_VIEW)) {
article.setArticleContent(articleContent.getArticleContentHtml()); article.setArticleContent(articleContent.getArticleContentHtml());
// 获取评论列表数据
List<CommentDTO> commentDTOList = commentService.getArticleComments(article.getIdArticle());
article.setArticleComments(commentDTOList);
// 获取所属作品集列表数据 // 获取所属作品集列表数据
List<PortfolioArticleDTO> portfolioArticleDTOList = articleMapper.selectPortfolioArticles(article.getIdArticle()); List<PortfolioArticleDTO> portfolioArticleDTOList = articleMapper.selectPortfolioArticles(article.getIdArticle());
article.setPortfolios(portfolioArticleDTOList); article.setPortfolios(portfolioArticleDTOList);
} else if (type.equals(ARTICLE_EDIT)) { } else if (type.equals(ARTICLE_EDIT)) {
article.setArticleContent(articleContent.getArticleContent()); article.setArticleContent(articleContent.getArticleContent());
} else {
article.setArticleContent(articleContent.getArticleContentHtml());
} }
} }
return article; return article;

View File

@ -83,7 +83,7 @@ public class CommentServiceImpl extends AbstractService<Comment> implements Comm
comment.setCreatedTime(new Date()); comment.setCreatedTime(new Date());
commentMapper.insertSelective(comment); commentMapper.insertSelective(comment);
StringBuilder commentSharpUrl = new StringBuilder(article.getArticlePermalink()); StringBuilder commentSharpUrl = new StringBuilder(article.getArticlePermalink());
commentSharpUrl.append("/comment/").append(comment.getIdComment()); commentSharpUrl.append("#comment-").append(comment.getIdComment());
commentMapper.updateCommentSharpUrl(comment.getIdComment(), commentSharpUrl.toString()); commentMapper.updateCommentSharpUrl(comment.getIdComment(), commentSharpUrl.toString());
String commentContent = comment.getCommentContent(); String commentContent = comment.getCommentContent();

View File

@ -1,13 +1,24 @@
package com.rymcu.vertical.service.impl; package com.rymcu.vertical.service.impl;
import com.rymcu.vertical.core.service.AbstractService; import com.rymcu.vertical.core.service.AbstractService;
import com.rymcu.vertical.dto.ArticleDTO;
import com.rymcu.vertical.dto.Author;
import com.rymcu.vertical.dto.NotificationDTO;
import com.rymcu.vertical.entity.Comment;
import com.rymcu.vertical.entity.Follow;
import com.rymcu.vertical.entity.Notification; import com.rymcu.vertical.entity.Notification;
import com.rymcu.vertical.entity.User;
import com.rymcu.vertical.mapper.NotificationMapper; import com.rymcu.vertical.mapper.NotificationMapper;
import com.rymcu.vertical.service.NotificationService; import com.rymcu.vertical.service.*;
import com.rymcu.vertical.util.BeanCopierUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* @author ronger * @author ronger
@ -17,31 +28,108 @@ public class NotificationServiceImpl extends AbstractService<Notification> imple
@Resource @Resource
private NotificationMapper notificationMapper; private NotificationMapper notificationMapper;
@Resource
private ArticleService articleService;
@Resource
private CommentService commentService;
@Resource
private UserService userService;
@Resource
private FollowService followService;
@Value("${resource.domain}")
private String domain;
@Override @Override
public List<Notification> findUnreadNotifications(Integer idUser){ public List<Notification> findUnreadNotifications(Integer idUser) {
List<Notification> list = notificationMapper.selectUnreadNotifications(idUser); List<Notification> list = notificationMapper.selectUnreadNotifications(idUser);
return list; return list;
} }
@Override @Override
public List<Notification> findNotifications(Integer idUser) { public List<NotificationDTO> findNotifications(Integer idUser) {
List<Notification> list = notificationMapper.selectNotifications(idUser); List<Notification> list = notificationMapper.selectNotifications(idUser);
return list; List<NotificationDTO> notifications = new ArrayList<>();
list.forEach(notification -> {
NotificationDTO notificationDTO = genNotification(notification);
notifications.add(notificationDTO);
});
return notifications;
}
private NotificationDTO genNotification(Notification notification) {
NotificationDTO notificationDTO = new NotificationDTO();
BeanCopierUtil.copy(notification, notificationDTO);
ArticleDTO article;
Comment comment;
User user;
Follow follow;
switch (notification.getDataType()) {
case "0":
// 系统公告/帖子
article = articleService.findArticleDTOById(notification.getDataId(), 0);
notificationDTO.setDataTitle("系统公告");
notificationDTO.setDataUrl(article.getArticlePermalink());
user = userService.findById(article.getArticleAuthorId().toString());
notificationDTO.setAuthor(genAuthor(user));
break;
case "1":
// 关注
follow = followService.findById(notification.getDataId().toString());
notificationDTO.setDataTitle("关注提醒");
user = userService.findById(follow.getFollowerId().toString());
notificationDTO.setDataUrl(getFollowLink(follow.getFollowingType(), user.getNickname()));
notificationDTO.setAuthor(genAuthor(user));
break;
case "2":
// 回帖
comment = commentService.findById(notification.getDataId().toString());
article = articleService.findArticleDTOById(comment.getCommentArticleId(), 0);
notificationDTO.setDataTitle(article.getArticleTitle());
notificationDTO.setDataUrl(comment.getCommentSharpUrl());
user = userService.findById(comment.getCommentAuthorId().toString());
notificationDTO.setAuthor(genAuthor(user));
break;
default:
break;
}
return notificationDTO;
}
private String getFollowLink(String followingType, String id) {
StringBuilder url = new StringBuilder();
url.append(domain);
switch (followingType) {
case "0":
url = url.append("/user/").append(id);
break;
default:
url.append("/notification");
}
return url.toString();
}
private Author genAuthor(User user) {
Author author = new Author();
author.setUserNickname(user.getNickname());
author.setUserAvatarURL(user.getAvatarUrl());
author.setIdUser(user.getIdUser());
return author;
} }
@Override @Override
public Notification findNotification(Integer idUser, Integer dataId, String dataType) { public Notification findNotification(Integer idUser, Integer dataId, String dataType) {
return notificationMapper.selectNotification(idUser,dataId,dataType); return notificationMapper.selectNotification(idUser, dataId, dataType);
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public Integer save(Integer idUser, Integer dataId, String dataType, String dataSummary) { public Integer save(Integer idUser, Integer dataId, String dataType, String dataSummary) {
return notificationMapper.insertNotification(idUser,dataId,dataType,dataSummary); return notificationMapper.insertNotification(idUser, dataId, dataType, dataSummary);
} }
@Override @Override
public void readNotification(Integer id) { @Transactional(rollbackFor = Exception.class)
notificationMapper.readNotification(id); public Integer readNotification(Integer id) {
return notificationMapper.readNotification(id);
} }
} }

View File

@ -17,10 +17,11 @@ import java.util.List;
/** /**
* Created by CodeGenerator on 2018/05/29. *
* @author CodeGenerator
* @date 2018/05/29
*/ */
@Service @Service
@Transactional
public class PermissionServiceImpl extends AbstractService<Permission> implements PermissionService { public class PermissionServiceImpl extends AbstractService<Permission> implements PermissionService {
@Resource @Resource
private PermissionMapper permissionMapper; private PermissionMapper permissionMapper;
@ -29,7 +30,7 @@ public class PermissionServiceImpl extends AbstractService<Permission> implement
private RoleService roleService; private RoleService roleService;
@Override @Override
public List<Permission> selectMenuByUser(User sysUser) { public List<Permission> selectPermissionByUser(User sysUser) {
List<Permission> list = new ArrayList<Permission>(); List<Permission> list = new ArrayList<Permission>();
List<Role> roles = roleService.selectRoleByUser(sysUser); List<Role> roles = roleService.selectRoleByUser(sysUser);
roles.forEach(role -> list.addAll(permissionMapper.selectMenuByIdRole(role.getIdRole()))); roles.forEach(role -> list.addAll(permissionMapper.selectMenuByIdRole(role.getIdRole())));

View File

@ -62,7 +62,7 @@ public class PortfolioServiceImpl extends AbstractService<Portfolio> implements
@Override @Override
public Portfolio postPortfolio(Portfolio portfolio) throws BaseApiException { public Portfolio postPortfolio(Portfolio portfolio) throws BaseApiException {
User user = UserUtils.getWxCurrentUser(); User user = UserUtils.getCurrentUserByToken();
if (portfolio.getIdPortfolio() == null || portfolio.getIdPortfolio() == 0) { if (portfolio.getIdPortfolio() == null || portfolio.getIdPortfolio() == 0) {
portfolio.setPortfolioAuthorId(user.getIdUser()); portfolio.setPortfolioAuthorId(user.getIdUser());
portfolio.setCreatedTime(new Date()); portfolio.setCreatedTime(new Date());
@ -78,7 +78,7 @@ public class PortfolioServiceImpl extends AbstractService<Portfolio> implements
@Override @Override
public Map findUnbindArticles(Integer page, Integer rows, String searchText, Integer idPortfolio) throws BaseApiException { public Map findUnbindArticles(Integer page, Integer rows, String searchText, Integer idPortfolio) throws BaseApiException {
Map map = new HashMap(1); Map map = new HashMap(1);
User user = UserUtils.getWxCurrentUser(); User user = UserUtils.getCurrentUserByToken();
Portfolio portfolio = portfolioMapper.selectByPrimaryKey(idPortfolio); Portfolio portfolio = portfolioMapper.selectByPrimaryKey(idPortfolio);
if (portfolio == null) { if (portfolio == null) {
map.put("message", "该作品集不存在或已被删除!"); map.put("message", "该作品集不存在或已被删除!");

View File

@ -37,11 +37,11 @@ public class TagServiceImpl extends AbstractService<Tag> implements TagService {
private ArticleMapper articleMapper; private ArticleMapper articleMapper;
@Override @Override
@Transactional(rollbackFor = { UnsupportedEncodingException.class,BaseApiException.class }) @Transactional(rollbackFor = {UnsupportedEncodingException.class, BaseApiException.class})
public Integer saveTagArticle(Article article) throws UnsupportedEncodingException, BaseApiException { public Integer saveTagArticle(Article article) throws UnsupportedEncodingException, BaseApiException {
User user = UserUtils.getWxCurrentUser(); User user = UserUtils.getCurrentUserByToken();
String articleTags = article.getArticleTags(); String articleTags = article.getArticleTags();
if(StringUtils.isNotBlank(articleTags)){ if (StringUtils.isNotBlank(articleTags)) {
String[] tags = articleTags.split(","); String[] tags = articleTags.split(",");
List<ArticleTagDTO> articleTagDTOList = articleMapper.selectTags(article.getIdArticle()); List<ArticleTagDTO> articleTagDTOList = articleMapper.selectTags(article.getIdArticle());
for (int i = 0; i < tags.length; i++) { for (int i = 0; i < tags.length; i++) {
@ -50,10 +50,10 @@ public class TagServiceImpl extends AbstractService<Tag> implements TagService {
Tag tag = new Tag(); Tag tag = new Tag();
tag.setTagTitle(tags[i]); tag.setTagTitle(tags[i]);
tag = tagMapper.selectOne(tag); tag = tagMapper.selectOne(tag);
if(tag == null){ if (tag == null) {
tag = new Tag(); tag = new Tag();
tag.setTagTitle(tags[i]); tag.setTagTitle(tags[i]);
tag.setTagUri(URLEncoder.encode(tag.getTagTitle(),"UTF-8")); tag.setTagUri(URLEncoder.encode(tag.getTagTitle(), "UTF-8"));
tag.setCreatedTime(new Date()); tag.setCreatedTime(new Date());
tag.setUpdatedTime(tag.getCreatedTime()); tag.setUpdatedTime(tag.getCreatedTime());
tag.setTagArticleCount(1); tag.setTagArticleCount(1);
@ -61,31 +61,34 @@ public class TagServiceImpl extends AbstractService<Tag> implements TagService {
addTagArticle = true; addTagArticle = true;
addUserTag = true; addUserTag = true;
} else { } else {
for(int m=0,n=articleTagDTOList.size()-1;m<n; m++) { int n = articleTagDTOList.size();
for (int m = 0; m < n; m++) {
ArticleTagDTO articleTag = articleTagDTOList.get(m); ArticleTagDTO articleTag = articleTagDTOList.get(m);
if (articleTag.getIdTag().equals(tag.getIdTag())) { if (articleTag.getIdTag().equals(tag.getIdTag())) {
articleTagDTOList.remove(articleTag); articleTagDTOList.remove(articleTag);
m--;
n--;
} }
} }
Integer count = tagMapper.selectCountTagArticleById(tag.getIdTag(),article.getIdArticle()); Integer count = tagMapper.selectCountTagArticleById(tag.getIdTag(), article.getIdArticle());
if(count == 0){ if (count == 0) {
tag.setTagArticleCount(tag.getTagArticleCount() + 1); tag.setTagArticleCount(tag.getTagArticleCount() + 1);
tagMapper.updateByPrimaryKeySelective(tag); tagMapper.updateByPrimaryKeySelective(tag);
addTagArticle = true; addTagArticle = true;
} }
Integer countUserTag = tagMapper.selectCountUserTagById(user.getIdUser(),tag.getIdTag()); Integer countUserTag = tagMapper.selectCountUserTagById(user.getIdUser(), tag.getIdTag());
if(countUserTag == 0){ if (countUserTag == 0) {
addUserTag = true; addUserTag = true;
} }
} }
articleTagDTOList.forEach(articleTagDTO -> { articleTagDTOList.forEach(articleTagDTO -> {
articleMapper.deleteUnusedArticleTag(articleTagDTO.getIdArticleTag()); articleMapper.deleteUnusedArticleTag(articleTagDTO.getIdArticleTag());
}); });
if(addTagArticle){ if (addTagArticle) {
tagMapper.insertTagArticle(tag.getIdTag(),article.getIdArticle()); tagMapper.insertTagArticle(tag.getIdTag(), article.getIdArticle());
} }
if(addUserTag){ if (addUserTag) {
tagMapper.insertUserTag(tag.getIdTag(),user.getIdUser(),1); tagMapper.insertUserTag(tag.getIdTag(), user.getIdUser(), 1);
} }
} }
return 1; return 1;
@ -109,14 +112,14 @@ public class TagServiceImpl extends AbstractService<Tag> implements TagService {
Map map = new HashMap(1); Map map = new HashMap(1);
if (tag.getIdTag() == null) { if (tag.getIdTag() == null) {
if (StringUtils.isBlank(tag.getTagTitle())) { if (StringUtils.isBlank(tag.getTagTitle())) {
map.put("message","标签名不能为空!"); map.put("message", "标签名不能为空!");
return map; return map;
} 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()) {
map.put("message","标签 '" + tag.getTagTitle() + "' 已存在!"); map.put("message", "标签 '" + tag.getTagTitle() + "' 已存在!");
return map; return map;
} }
} }
@ -132,10 +135,10 @@ public class TagServiceImpl extends AbstractService<Tag> implements TagService {
result = tagMapper.insertSelective(newTag); result = tagMapper.insertSelective(newTag);
} else { } else {
tag.setUpdatedTime(new Date()); tag.setUpdatedTime(new Date());
result = tagMapper.update(tag.getIdTag(),tag.getTagUri(),tag.getTagIconPath(),tag.getTagStatus(),tag.getTagDescription(),tag.getTagReservation()); result = tagMapper.update(tag.getIdTag(), tag.getTagUri(), tag.getTagIconPath(), tag.getTagStatus(), tag.getTagDescription(), tag.getTagReservation());
} }
if (result == 0) { if (result == 0) {
map.put("message","操作失败!"); map.put("message", "操作失败!");
} else { } else {
map.put("tag", tag); map.put("tag", tag);
} }

View File

@ -37,23 +37,10 @@ public class TopicServiceImpl extends AbstractService<Topic> implements TopicSer
} }
@Override @Override
public Map findTopicByTopicUri(String topicUri, Integer page, Integer rows) { public Topic findTopicByTopicUri(String topicUri) {
Map map = new HashMap(2); Topic searchTopic = new Topic();
TopicDTO topic = topicMapper.selectTopicByTopicUri(topicUri); searchTopic.setTopicUri(topicUri);
if (topic == null) { return topicMapper.selectOne(searchTopic);
return map;
}
PageHelper.startPage(page, rows);
List<TagDTO> list = topicMapper.selectTopicTag(topic.getIdTopic());
PageInfo pageInfo = new PageInfo(list);
topic.setTags(pageInfo.getList());
map.put("topic", topic);
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;
} }
@Override @Override
@ -82,6 +69,7 @@ public class TopicServiceImpl extends AbstractService<Topic> implements TopicSer
newTopic.setTopicStatus(topic.getTopicStatus()); newTopic.setTopicStatus(topic.getTopicStatus());
newTopic.setTopicSort(topic.getTopicSort()); newTopic.setTopicSort(topic.getTopicSort());
newTopic.setTopicDescription(topic.getTopicDescription()); newTopic.setTopicDescription(topic.getTopicDescription());
newTopic.setTopicDescriptionHtml(topic.getTopicDescriptionHtml());
newTopic.setCreatedTime(new Date()); newTopic.setCreatedTime(new Date());
newTopic.setUpdatedTime(topic.getCreatedTime()); newTopic.setUpdatedTime(topic.getCreatedTime());
result = topicMapper.insertSelective(newTopic); result = topicMapper.insertSelective(newTopic);
@ -89,7 +77,7 @@ public class TopicServiceImpl extends AbstractService<Topic> implements TopicSer
topic.setCreatedTime(new Date()); topic.setCreatedTime(new Date());
result = topicMapper.update(topic.getIdTopic(),topic.getTopicTitle(),topic.getTopicUri() result = topicMapper.update(topic.getIdTopic(),topic.getTopicTitle(),topic.getTopicUri()
,topic.getTopicIconPath(),topic.getTopicNva(),topic.getTopicStatus() ,topic.getTopicIconPath(),topic.getTopicNva(),topic.getTopicStatus()
,topic.getTopicSort(),topic.getTopicDescription()); ,topic.getTopicSort(),topic.getTopicDescription(),topic.getTopicDescriptionHtml());
} }
if (result == 0) { if (result == 0) {
map.put("message","操作失败!"); map.put("message","操作失败!");
@ -132,4 +120,23 @@ public class TopicServiceImpl extends AbstractService<Topic> implements TopicSer
} }
return map; return map;
} }
@Override
public Map findTagsByTopicUri(String topicUri, Integer page, Integer rows) {
Map map = new HashMap(2);
TopicDTO topic = topicMapper.selectTopicByTopicUri(topicUri);
if (topic == null) {
return map;
}
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;
}
} }

View File

@ -100,8 +100,7 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
user = userMapper.selectOne(user); user = userMapper.selectOne(user);
if(user != null){ if(user != null){
if(Utils.comparePwd(password, user.getPassword())){ if(Utils.comparePwd(password, user.getPassword())){
user.setLastLoginTime(new Date()); userMapper.updateLastLoginTime(user.getIdUser());
userMapper.updateByPrimaryKeySelective(user);
TokenUser tokenUser = new TokenUser(); TokenUser tokenUser = new TokenUser();
BeanCopierUtil.copy(user, tokenUser); BeanCopierUtil.copy(user, tokenUser);
tokenUser.setToken(tokenManager.createToken(account)); tokenUser.setToken(tokenManager.createToken(account));
@ -183,6 +182,7 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
if (StringUtils.isNotBlank(user.getAvatarType()) && avatarSvgType.equals(user.getAvatarType())) { if (StringUtils.isNotBlank(user.getAvatarType()) && avatarSvgType.equals(user.getAvatarType())) {
String avatarUrl = UploadController.uploadBase64File(user.getAvatarUrl(), 0); String avatarUrl = UploadController.uploadBase64File(user.getAvatarUrl(), 0);
user.setAvatarUrl(avatarUrl); user.setAvatarUrl(avatarUrl);
user.setAvatarType("0");
} }
Integer result = userMapper.updateUserInfo(user.getIdUser(), user.getNickname(), user.getAvatarType(),user.getAvatarUrl(), Integer result = userMapper.updateUserInfo(user.getIdUser(), user.getNickname(), user.getAvatarType(),user.getAvatarUrl(),
user.getEmail(),user.getPhone(),user.getSignature(), user.getSex()); user.getEmail(),user.getPhone(),user.getSignature(), user.getSex());

View File

@ -80,6 +80,7 @@ public class BaiDuUtils {
} }
public static void main(String[] args){ public static void main(String[] args){
sendUpdateSEOData("https://rymcu.com"); // sendUpdateSEOData("https://rymcu.com");
sendSEOData("https://rymcu.com/article/98");
} }
} }

View File

@ -25,7 +25,7 @@ public class UserUtils {
* 通过token获取当前用户的信息 * 通过token获取当前用户的信息
* @return * @return
*/ */
public static User getWxCurrentUser() throws BaseApiException { public static User getCurrentUserByToken() throws BaseApiException {
String authHeader = ContextHolderUtils.getRequest().getHeader(JwtConstants.AUTHORIZATION); String authHeader = ContextHolderUtils.getRequest().getHeader(JwtConstants.AUTHORIZATION);
if (authHeader == null) { if (authHeader == null) {
return null; return null;

View File

@ -2,6 +2,7 @@ package com.rymcu.vertical.util;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.rymcu.vertical.dto.ArticleDTO; import com.rymcu.vertical.dto.ArticleDTO;
import com.rymcu.vertical.dto.NotificationDTO;
import com.rymcu.vertical.entity.Notification; import com.rymcu.vertical.entity.Notification;
import com.rymcu.vertical.entity.User; import com.rymcu.vertical.entity.User;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
@ -182,4 +183,15 @@ public class Utils {
return ip; return ip;
} }
public static Map getNotificationDTOsGlobalResult(PageInfo<NotificationDTO> pageInfo) {
Map map = new HashMap(2);
map.put("notifications", pageInfo.getList());
Map pagination = new HashMap(4);
pagination.put("pageSize",pageInfo.getPageSize());
pagination.put("total",pageInfo.getTotal());
pagination.put("currentPage",pageInfo.getPageNum());
map.put("pagination", pagination);
return map;
}
} }

View File

@ -109,11 +109,20 @@ public class AdminController {
} }
@GetMapping("/topic/{topicUri}") @GetMapping("/topic/{topicUri}")
public GlobalResult topic(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows,@PathVariable String topicUri){ public GlobalResult topic(@PathVariable String topicUri){
if (StringUtils.isBlank(topicUri)) { if (StringUtils.isBlank(topicUri)) {
return GlobalResultGenerator.genErrorResult("数据异常!"); return GlobalResultGenerator.genErrorResult("数据异常!");
} }
Map map = topicService.findTopicByTopicUri(topicUri,page,rows); 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){
if (StringUtils.isBlank(topicUri)) {
return GlobalResultGenerator.genErrorResult("数据异常!");
}
Map map = topicService.findTagsByTopicUri(topicUri,page,rows);
return GlobalResultGenerator.genSuccessResult(map); return GlobalResultGenerator.genSuccessResult(map);
} }

View File

@ -6,6 +6,7 @@ import com.rymcu.vertical.core.result.GlobalResult;
import com.rymcu.vertical.core.result.GlobalResultGenerator; import com.rymcu.vertical.core.result.GlobalResultGenerator;
import com.rymcu.vertical.dto.ArticleDTO; import com.rymcu.vertical.dto.ArticleDTO;
import com.rymcu.vertical.dto.CommentDTO; import com.rymcu.vertical.dto.CommentDTO;
import com.rymcu.vertical.entity.Article;
import com.rymcu.vertical.service.ArticleService; import com.rymcu.vertical.service.ArticleService;
import com.rymcu.vertical.service.CommentService; import com.rymcu.vertical.service.CommentService;
import com.rymcu.vertical.util.Utils; import com.rymcu.vertical.util.Utils;
@ -80,4 +81,10 @@ public class ArticleController {
return GlobalResultGenerator.genSuccessResult(map); return GlobalResultGenerator.genSuccessResult(map);
} }
@PostMapping("/{id}/update-tags")
public GlobalResult updateTags(@PathVariable Integer id, @RequestBody Article article) throws BaseApiException, UnsupportedEncodingException {
Map map = articleService.updateTags(id, article.getArticleTags());
return GlobalResultGenerator.genSuccessResult(map);
}
} }

View File

@ -43,14 +43,14 @@ public class CommonApiController {
@GetMapping("/get-email-code") @GetMapping("/get-email-code")
public GlobalResult<Map<String, String>> getEmailCode(@RequestParam("email") String email) throws MessagingException { public GlobalResult<Map<String, String>> getEmailCode(@RequestParam("email") String email) throws MessagingException {
Map<String, String> map = new HashMap<>(1); Map<String, String> map = new HashMap<>(1);
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","该邮箱已被注册!"); map.put("message","该邮箱已被注册!");
} else { } else {
Integer result = javaMailService.sendEmailCode(email); Integer result = javaMailService.sendEmailCode(email);
if(result == 0){ if(result == 0){
map.put("message",GlobalResultMessage.SEND_FAIL.getMessage()); map.put("message", GlobalResultMessage.SEND_FAIL.getMessage());
} }
} }
return GlobalResultGenerator.genSuccessResult(map); return GlobalResultGenerator.genSuccessResult(map);
@ -60,12 +60,12 @@ 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<Map<Object, Object>> getForgetPasswordEmail(@RequestParam("email") String email) throws MessagingException {
Map<Object, Object> map = new HashMap<>(1); Map<Object, Object> map = new HashMap<>(1);
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) {
Integer result = javaMailService.sendForgetPasswordEmail(email); Integer result = javaMailService.sendForgetPasswordEmail(email);
if(result == 0){ if(result == 0){
map.put("message",GlobalResultMessage.SEND_FAIL.getMessage()); map.put("message", GlobalResultMessage.SEND_FAIL.getMessage());
} }
} else { } else {
map.put("message","该邮箱未注册!"); map.put("message","该邮箱未注册!");
@ -92,9 +92,9 @@ public class CommonApiController {
@GetMapping("/articles") @GetMapping("/articles")
@VisitLogger @VisitLogger
public GlobalResult<Map> articles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, @RequestParam(defaultValue = "") String searchText, @RequestParam(defaultValue = "") String tag){ public GlobalResult<Map> 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(searchText,tag); List<ArticleDTO> list = articleService.findArticles(searchDTO);
PageInfo<ArticleDTO> pageInfo = new PageInfo(list); PageInfo<ArticleDTO> pageInfo = new PageInfo(list);
Map map = Utils.getArticlesGlobalResult(pageInfo); Map map = Utils.getArticlesGlobalResult(pageInfo);
return GlobalResultGenerator.genSuccessResult(map); return GlobalResultGenerator.genSuccessResult(map);

View File

@ -25,6 +25,7 @@ import java.util.Set;
/** /**
* 文件上传控制器 * 文件上传控制器
*
* @author ronger * @author ronger
*/ */
@RestController @RestController
@ -33,25 +34,25 @@ public class UploadController {
private final static String UPLOAD_SIMPLE_URL = "/api/upload/file"; private final static String UPLOAD_SIMPLE_URL = "/api/upload/file";
private final static String UPLOAD_URL = "/api/upload/file/batch"; private final static String UPLOAD_URL = "/api/upload/file/batch";
public static final String ctxHeadPicPath = "/usr/local/src/tomcat-hp/webapps/vertical"; public static final String ctxHeadPicPath = "/usr/local/src/nebula/static";
@PostMapping("/file") @PostMapping("/file")
public GlobalResult uploadPicture(@RequestParam(value = "file", required = false) MultipartFile multipartFile,@RequestParam(defaultValue = "1")Integer type, HttpServletRequest request){ public GlobalResult uploadPicture(@RequestParam(value = "file", required = false) MultipartFile multipartFile, @RequestParam(defaultValue = "1") Integer type, HttpServletRequest request) {
if (multipartFile == null) { if (multipartFile == null) {
return GlobalResultGenerator.genErrorResult("请选择要上传的文件"); return GlobalResultGenerator.genErrorResult("请选择要上传的文件");
} }
String typePath = getTypePath(type); String typePath = getTypePath(type);
//图片存储路径 //图片存储路径
String dir = ctxHeadPicPath+"/"+typePath; String dir = ctxHeadPicPath + "/" + typePath;
File file = new File(dir); File file = new File(dir);
if (!file.exists()) { if (!file.exists()) {
file.mkdirs();// 创建文件根目录 file.mkdirs();// 创建文件根目录
} }
String localPath = Utils.getProperty("resource.file-path")+"/"+typePath+"/"; String localPath = Utils.getProperty("resource.file-path") + "/" + typePath + "/";
String orgName = multipartFile.getOriginalFilename(); String orgName = multipartFile.getOriginalFilename();
String fileName = System.currentTimeMillis()+"."+ FileUtils.getExtend(orgName).toLowerCase(); String fileName = System.currentTimeMillis() + "." + FileUtils.getExtend(orgName).toLowerCase();
String savePath = file.getPath() + File.separator + fileName; String savePath = file.getPath() + File.separator + fileName;
@ -59,7 +60,7 @@ public class UploadController {
File saveFile = new File(savePath); File saveFile = new File(savePath);
try { try {
FileCopyUtils.copy(multipartFile.getBytes(), saveFile); FileCopyUtils.copy(multipartFile.getBytes(), saveFile);
data.put("url", localPath+fileName); data.put("url", localPath + fileName);
} catch (IOException e) { } catch (IOException e) {
data.put("message", "上传失败!"); data.put("message", "上传失败!");
} }
@ -68,43 +69,43 @@ public class UploadController {
} }
@PostMapping("/file/batch") @PostMapping("/file/batch")
public GlobalResult batchFileUpload(@RequestParam(value = "file[]", required = false)MultipartFile[] multipartFiles,@RequestParam(defaultValue = "1")Integer type,HttpServletRequest request){ public GlobalResult batchFileUpload(@RequestParam(value = "file[]", required = false) MultipartFile[] multipartFiles, @RequestParam(defaultValue = "1") Integer type, HttpServletRequest request) {
String typePath = getTypePath(type); String typePath = getTypePath(type);
//图片存储路径 //图片存储路径
String dir = ctxHeadPicPath+"/"+typePath; String dir = ctxHeadPicPath + "/" + typePath;
File file = new File(dir); File file = new File(dir);
if (!file.exists()) { if (!file.exists()) {
file.mkdirs();// 创建文件根目录 file.mkdirs();// 创建文件根目录
} }
String localPath = Utils.getProperty("resource.file-path")+"/"+typePath+"/"; String localPath = Utils.getProperty("resource.file-path") + "/" + typePath + "/";
Map succMap = new HashMap(10); Map succMap = new HashMap(10);
Set errFiles = new HashSet(); Set errFiles = new HashSet();
for(int i=0,len=multipartFiles.length;i<len;i++){ for (int i = 0, len = multipartFiles.length; i < len; i++) {
MultipartFile multipartFile = multipartFiles[i]; MultipartFile multipartFile = multipartFiles[i];
String orgName = multipartFile.getOriginalFilename(); String orgName = multipartFile.getOriginalFilename();
String fileName = System.currentTimeMillis()+"."+FileUtils.getExtend(orgName).toLowerCase(); String fileName = System.currentTimeMillis() + "." + FileUtils.getExtend(orgName).toLowerCase();
String savePath = file.getPath() + File.separator + fileName; String savePath = file.getPath() + File.separator + fileName;
File saveFile = new File(savePath); File saveFile = new File(savePath);
try { try {
FileCopyUtils.copy(multipartFile.getBytes(), saveFile); FileCopyUtils.copy(multipartFile.getBytes(), saveFile);
succMap.put(orgName,localPath+fileName); succMap.put(orgName, localPath + fileName);
} catch (IOException e) { } catch (IOException e) {
errFiles.add(orgName); errFiles.add(orgName);
} }
} }
Map data = new HashMap(2); Map data = new HashMap(2);
data.put("errFiles",errFiles); data.put("errFiles", errFiles);
data.put("succMap",succMap); data.put("succMap", succMap);
return GlobalResultGenerator.genSuccessResult(data); return GlobalResultGenerator.genSuccessResult(data);
} }
private static String getTypePath(Integer type) { private static String getTypePath(Integer type) {
String typePath; String typePath;
switch (type){ switch (type) {
case 0: case 0:
typePath = "avatar"; typePath = "avatar";
break; break;
@ -123,7 +124,7 @@ public class UploadController {
@GetMapping("/simple/token") @GetMapping("/simple/token")
public GlobalResult uploadSimpleToken(HttpServletRequest request) throws BaseApiException { public GlobalResult uploadSimpleToken(HttpServletRequest request) throws BaseApiException {
String authHeader = request.getHeader(JwtConstants.AUTHORIZATION); String authHeader = request.getHeader(JwtConstants.AUTHORIZATION);
if(StringUtils.isBlank(authHeader)){ if (StringUtils.isBlank(authHeader)) {
throw new BaseApiException(ErrorCode.UNAUTHORIZED); throw new BaseApiException(ErrorCode.UNAUTHORIZED);
} }
TokenUser tokenUser = UserUtils.getTokenUser(authHeader); TokenUser tokenUser = UserUtils.getTokenUser(authHeader);
@ -136,7 +137,7 @@ public class UploadController {
@GetMapping("/token") @GetMapping("/token")
public GlobalResult uploadToken(HttpServletRequest request) throws BaseApiException { public GlobalResult uploadToken(HttpServletRequest request) throws BaseApiException {
String authHeader = request.getHeader(JwtConstants.AUTHORIZATION); String authHeader = request.getHeader(JwtConstants.AUTHORIZATION);
if(StringUtils.isBlank(authHeader)){ if (StringUtils.isBlank(authHeader)) {
throw new BaseApiException(ErrorCode.UNAUTHORIZED); throw new BaseApiException(ErrorCode.UNAUTHORIZED);
} }
TokenUser tokenUser = UserUtils.getTokenUser(authHeader); TokenUser tokenUser = UserUtils.getTokenUser(authHeader);
@ -152,19 +153,19 @@ public class UploadController {
} }
String typePath = getTypePath(type); String typePath = getTypePath(type);
//图片存储路径 //图片存储路径
String dir = ctxHeadPicPath+"/"+typePath; String dir = ctxHeadPicPath + "/" + typePath;
File file = new File(dir); File file = new File(dir);
if (!file.exists()) { if (!file.exists()) {
file.mkdirs();// 创建文件根目录 file.mkdirs();// 创建文件根目录
} }
String localPath = Utils.getProperty("resource.file-path")+"/"+typePath+"/"; String localPath = Utils.getProperty("resource.file-path") + "/" + typePath + "/";
String fileName = System.currentTimeMillis()+".png"; String fileName = System.currentTimeMillis() + ".png";
String savePath = file.getPath() + File.separator + fileName; String savePath = file.getPath() + File.separator + fileName;
File saveFile = new File(savePath); File saveFile = new File(savePath);
try { try {
FileCopyUtils.copy(Base64.decodeBase64(fileStr.substring(fileStr.indexOf(",") + 1)), saveFile); FileCopyUtils.copy(Base64.decodeBase64(fileStr.substring(fileStr.indexOf(",") + 1)), saveFile);
fileStr = localPath+fileName; fileStr = localPath + fileName;
} catch (IOException e) { } catch (IOException e) {
fileStr = "上传失败!"; fileStr = "上传失败!";
} }

View File

@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.rymcu.vertical.core.result.GlobalResult; import com.rymcu.vertical.core.result.GlobalResult;
import com.rymcu.vertical.core.result.GlobalResultGenerator; import com.rymcu.vertical.core.result.GlobalResultGenerator;
import com.rymcu.vertical.dto.NotificationDTO;
import com.rymcu.vertical.entity.Notification; import com.rymcu.vertical.entity.Notification;
import com.rymcu.vertical.entity.User; import com.rymcu.vertical.entity.User;
import com.rymcu.vertical.service.NotificationService; import com.rymcu.vertical.service.NotificationService;
@ -29,17 +30,17 @@ public class NotificationController {
@GetMapping("/all") @GetMapping("/all")
public GlobalResult notifications(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) throws BaseApiException { public GlobalResult notifications(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) throws BaseApiException {
User user = UserUtils.getWxCurrentUser(); User user = UserUtils.getCurrentUserByToken();
PageHelper.startPage(page, rows); PageHelper.startPage(page, rows);
List<Notification> list = notificationService.findNotifications(user.getIdUser()); List<NotificationDTO> list = notificationService.findNotifications(user.getIdUser());
PageInfo<Notification> pageInfo = new PageInfo(list); PageInfo<NotificationDTO> pageInfo = new PageInfo(list);
Map map = Utils.getNotificationsGlobalResult(pageInfo); Map map = Utils.getNotificationDTOsGlobalResult(pageInfo);
return GlobalResultGenerator.genSuccessResult(map); return GlobalResultGenerator.genSuccessResult(map);
} }
@GetMapping("/unread") @GetMapping("/unread")
public GlobalResult unreadNotification(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) throws BaseApiException { public GlobalResult unreadNotification(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) throws BaseApiException {
User user = UserUtils.getWxCurrentUser(); User user = UserUtils.getCurrentUserByToken();
PageHelper.startPage(page, rows); PageHelper.startPage(page, rows);
List<Notification> list = notificationService.findUnreadNotifications(user.getIdUser()); List<Notification> list = notificationService.findUnreadNotifications(user.getIdUser());
PageInfo<Notification> pageInfo = new PageInfo(list); PageInfo<Notification> pageInfo = new PageInfo(list);
@ -48,8 +49,12 @@ public class NotificationController {
} }
@PutMapping("/read/{id}") @PutMapping("/read/{id}")
public void read(@PathVariable Integer id) { public GlobalResult read(@PathVariable Integer id) {
notificationService.readNotification(id); Integer result = notificationService.readNotification(id);
if (result == 0) {
return GlobalResultGenerator.genErrorResult("标记已读失败");
}
return GlobalResultGenerator.genSuccessResult("标记已读成功");
} }
} }

View File

@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.rymcu.vertical.core.result.GlobalResult; import com.rymcu.vertical.core.result.GlobalResult;
import com.rymcu.vertical.core.result.GlobalResultGenerator; import com.rymcu.vertical.core.result.GlobalResultGenerator;
import com.rymcu.vertical.core.service.log.annotation.VisitLogger;
import com.rymcu.vertical.dto.ArticleDTO; import com.rymcu.vertical.dto.ArticleDTO;
import com.rymcu.vertical.dto.PortfolioDTO; import com.rymcu.vertical.dto.PortfolioDTO;
import com.rymcu.vertical.dto.UserDTO; import com.rymcu.vertical.dto.UserDTO;
@ -33,6 +34,7 @@ public class UserController {
private PortfolioService portfolioService; private PortfolioService portfolioService;
@GetMapping("/{nickname}") @GetMapping("/{nickname}")
@VisitLogger
public GlobalResult detail(@PathVariable String nickname){ public GlobalResult detail(@PathVariable String nickname){
UserDTO userDTO = userService.findUserDTOByNickname(nickname); UserDTO userDTO = userService.findUserDTOByNickname(nickname);
return GlobalResultGenerator.genSuccessResult(userDTO); return GlobalResultGenerator.genSuccessResult(userDTO);

View File

@ -71,14 +71,25 @@
<update id="updateArticleViewCount"> <update id="updateArticleViewCount">
update vertical_article set article_view_count = #{articleViewCount} where id = #{id} update vertical_article set article_view_count = #{articleViewCount} where id = #{id}
</update> </update>
<update id="updateArticleTags">
update vertical_article set article_tags = #{tags} where id = #{idArticle}
</update>
<delete id="deleteTagArticle"> <delete id="deleteTagArticle">
delete from vertical_tag_article where id_article = #{id} delete from vertical_tag_article where id_article = #{id}
</delete> </delete>
<delete id="deleteUnusedArticleTag"> <delete id="deleteUnusedArticleTag">
delete from vertical_tag_article where id = #{idArticleTag} delete from vertical_tag_article where id = #{idArticleTag}
</delete> </delete>
<delete id="deleteLinkedPortfolioData">
delete from vertical_portfolio_article where id_vertical_article = #{id}
</delete>
<select id="selectArticles" resultMap="DTOResultMap"> <select id="selectArticles" resultMap="DTOResultMap">
select art.*,su.nickname,su.avatar_url from vertical_article art join vertical_user su on art.article_author_id = su.id where article_status = '0' order by updated_time desc select art.*,su.nickname,su.avatar_url from vertical_article art join vertical_user su on art.article_author_id = su.id
where article_status = '0'
<if test="topicUri != 'news'">
and FIND_IN_SET("划水",art.article_tags) = 0
</if>
order by updated_time desc
</select> </select>
<select id="selectArticleDTOById" resultMap="DTOResultMap"> <select id="selectArticleDTOById" resultMap="DTOResultMap">
select art.*,su.nickname,su.avatar_url from vertical_article art join vertical_user su on art.article_author_id = su.id where art.id = #{id} select art.*,su.nickname,su.avatar_url from vertical_article art join vertical_user su on art.article_author_id = su.id where art.id = #{id}
@ -106,7 +117,7 @@
select vta.id, vta.id_tag, vta.id_article, vt.tag_title, vt.tag_icon_path, vt.tag_uri, vt.tag_description from vertical_tag vt join vertical_tag_article vta on vt.id = vta.id_tag where vta.id_article = #{idArticle} select vta.id, vta.id_tag, vta.id_article, vt.tag_title, vt.tag_icon_path, vt.tag_uri, vt.tag_description from vertical_tag vt join vertical_tag_article vta on vt.id = vta.id_tag where vta.id_article = #{idArticle}
</select> </select>
<select id="selectDrafts" resultMap="DTOResultMap"> <select id="selectDrafts" resultMap="DTOResultMap">
select art.*,su.nickname,su.avatar_url from vertical_article art join vertical_user su on art.article_author_id = su.id where article_status = '1' and art.article_author_id = #{idUser} order by updated_time desc select art.*,su.nickname,su.avatar_url from vertical_article asdfasd art join vertical_user su on art.article_author_id = su.id where article_status = '1' and art.article_author_id = #{idUser} order by updated_time desc
</select> </select>
<select id="selectArticlesByIdPortfolio" resultMap="DTOResultMap"> <select id="selectArticlesByIdPortfolio" resultMap="DTOResultMap">
select art.*,su.nickname,su.avatar_url,vpa.sort_no from vertical_article art join vertical_portfolio_article vpa on vpa.id_vertical_article = art.id and vpa.id_vertical_portfolio = #{idPortfolio} select art.*,su.nickname,su.avatar_url,vpa.sort_no from vertical_article art join vertical_portfolio_article vpa on vpa.id_vertical_article = art.id and vpa.id_vertical_portfolio = #{idPortfolio}
@ -119,4 +130,7 @@
<select id="selectPortfolioArticles" resultMap="PortfolioArticleResultMap"> <select id="selectPortfolioArticles" resultMap="PortfolioArticleResultMap">
select vp.portfolio_title,vp.portfolio_head_img_url,vpa.id_vertical_portfolio,vpa.id_vertical_article from vertical_portfolio vp join vertical_portfolio_article vpa on vp.id = vpa.id_vertical_portfolio where vpa.id_vertical_article = #{idArticle} select vp.portfolio_title,vp.portfolio_head_img_url,vpa.id_vertical_portfolio,vpa.id_vertical_article from vertical_portfolio vp join vertical_portfolio_article vpa on vp.id = vpa.id_vertical_portfolio where vpa.id_vertical_article = #{idArticle}
</select> </select>
<select id="existsCommentWithPrimaryKey" resultType="java.lang.Boolean">
select exists (select * from vertical_comment where comment_article_id = #{id})
</select>
</mapper> </mapper>

View File

@ -9,26 +9,23 @@
select count(*) from vertical_user select count(*) from vertical_user
</select> </select>
<select id="selectNewUserCount" resultType="java.lang.Integer"> <select id="selectNewUserCount" resultType="java.lang.Integer">
select count(*) from vertical_user where created_time between date_sub(sysdate(),interval 1 day) select count(*) from vertical_user where created_time > str_to_date(date_format(sysdate(),'%Y-%m-%d'),'%Y-%m-%d')
and date_sub(sysdate(),interval - 1 day)
</select> </select>
<select id="selectArticleCount" resultType="java.lang.Integer"> <select id="selectArticleCount" resultType="java.lang.Integer">
select count(*) from vertical_article select count(*) from vertical_article
</select> </select>
<select id="selectNewArticleCount" resultType="java.lang.Integer"> <select id="selectNewArticleCount" resultType="java.lang.Integer">
select count(*) from vertical_article where created_time between date_sub(sysdate(),interval 1 day) select count(*) from vertical_article where created_time > str_to_date(date_format(sysdate(),'%Y-%m-%d'),'%Y-%m-%d') and article_status = 0
and date_sub(sysdate(),interval - 1 day)
</select> </select>
<select id="selectCountViewNum" resultType="java.lang.Integer"> <select id="selectCountViewNum" resultType="java.lang.Integer">
select count(*) from vertical_visit select count(*) from vertical_visit
</select> </select>
<select id="selectTodayViewNum" resultType="java.lang.Integer"> <select id="selectTodayViewNum" resultType="java.lang.Integer">
select count(*) from vertical_visit where created_time between str_to_date(date_format(sysdate(),'%Y-%m-%d'),'%Y-%m-%d') select count(*) from vertical_visit where created_time > str_to_date(date_format(sysdate(),'%Y-%m-%d'),'%Y-%m-%d')
and str_to_date(date_format(date_sub(sysdate(),interval - 1 day),'%Y-%m-%d'),'%Y-%m-%d')
</select> </select>
<select id="selectLastThirtyDaysArticleData" resultMap="DashboardDataResultMap"> <select id="selectLastThirtyDaysArticleData" resultMap="DashboardDataResultMap">
select COUNT(*) as value, date_format(created_time, '%Y-%m-%d') as label from vertical_article select COUNT(*) as value, date_format(created_time, '%Y-%m-%d') as label from vertical_article
where created_time > str_to_date(date_format(date_sub(sysdate(),interval + 30 day),'%Y-%m-%d'),'%Y-%m-%d') GROUP BY date_format(created_time, '%Y-%m-%d') where created_time > str_to_date(date_format(date_sub(sysdate(),interval + 30 day),'%Y-%m-%d'),'%Y-%m-%d') and article_status = 0 GROUP BY date_format(created_time, '%Y-%m-%d')
</select> </select>
<select id="selectLastThirtyDaysUserData" resultMap="DashboardDataResultMap"> <select id="selectLastThirtyDaysUserData" resultMap="DashboardDataResultMap">
select COUNT(*) as value, date_format(created_time, '%Y-%m-%d') as label from vertical_user select COUNT(*) as value, date_format(created_time, '%Y-%m-%d') as label from vertical_user
@ -40,7 +37,7 @@
</select> </select>
<select id="selectHistoryArticleData" resultMap="DashboardDataResultMap"> <select id="selectHistoryArticleData" resultMap="DashboardDataResultMap">
select COUNT(*) as value, date_format(created_time, '%Y-%m') as label from vertical_article select COUNT(*) as value, date_format(created_time, '%Y-%m') as label from vertical_article
where created_time > str_to_date(date_format(date_sub(sysdate(),interval + 1 year),'%Y-%m-%d'),'%Y-%m-%d') GROUP BY date_format(created_time, '%Y-%m') where created_time > str_to_date(date_format(date_sub(sysdate(),interval + 1 year),'%Y-%m-%d'),'%Y-%m-%d') and article_status = 0 GROUP BY date_format(created_time, '%Y-%m')
</select> </select>
<select id="selectHistoryUserData" resultMap="DashboardDataResultMap"> <select id="selectHistoryUserData" resultMap="DashboardDataResultMap">
select COUNT(*) as value, date_format(created_time, '%Y-%m') as label from vertical_user select COUNT(*) as value, date_format(created_time, '%Y-%m') as label from vertical_user

View File

@ -54,8 +54,8 @@
insert into vertical_topic_tag (id_topic, id_tag, created_time, updated_time) values (#{idTopic}, #{idTag}, sysdate(), sysdate()) insert into vertical_topic_tag (id_topic, id_tag, created_time, updated_time) values (#{idTopic}, #{idTag}, sysdate(), sysdate())
</insert> </insert>
<update id="update"> <update id="update">
update vertical_topic set topic_title = #{topicTitle},topic_uri = #{topicUri},topic_icon_path = #{topicIconPath} update vertical_topic set topic_title = #{topicTitle},topic_uri = #{topicUri},topic_icon_path = #{topicIconPath}, updated_time = sysdate(),
,topic_nva = #{topicNva},topic_status = #{topicStatus},topic_sort = #{topicSort},topic_description = #{topicDescription} topic_nva = #{topicNva},topic_status = #{topicStatus},topic_sort = #{topicSort},topic_description = #{topicDescription},topic_description_html = #{topicDescriptionHtml}
where id = #{idTopic} where id = #{idTopic}
</update> </update>
<delete id="deleteTopicTag"> <delete id="deleteTopicTag">
@ -73,7 +73,7 @@
<select id="selectUnbindTagsById" resultMap="TagResultMap"> <select id="selectUnbindTagsById" resultMap="TagResultMap">
select * from vertical_tag vt where not exists(select * from vertical_topic_tag vtt where vtt.id_topic = #{idTopic} and vtt.id_tag = vt.id) select * from vertical_tag vt where not exists(select * from vertical_topic_tag vtt where vtt.id_topic = #{idTopic} and vtt.id_tag = vt.id)
<if test="tagTitle != '' and tagTitle != null"> <if test="tagTitle != '' and tagTitle != null">
and vt.tag_title = #{tagTitle} and LOCATE(#{tagTitle}, vt.tag_title) > 0
</if> </if>
order by vt.created_time desc order by vt.created_time desc
</select> </select>

View File

@ -65,6 +65,9 @@
</if> </if>
where id = #{idUser} where id = #{idUser}
</update> </update>
<update id="updateLastLoginTime">
update vertical_user set last_login_time = sysdate() where id = #{idUser}
</update>
<select id="findByAccount" resultMap="BaseResultMap"> <select id="findByAccount" resultMap="BaseResultMap">
select id, nickname, account, password, status from vertical_user where account = #{account} and status = 0 select id, nickname, account, password, status from vertical_user where account = #{account} and status = 0

View File

@ -1,6 +1,6 @@
spring: spring:
# profiles: # profiles:
# active: pord # active: dev
thymeleaf: thymeleaf:
prefix: classpath:/templates/ prefix: classpath:/templates/
suffix: .html suffix: .html
@ -22,6 +22,7 @@ spring:
max-idle: 500 max-idle: 500
min-idle: 0 min-idle: 0
datasource: datasource:
druid:
url: jdbc:mysql://localhost:3306/vertical?characterEncoding=UTF-8&autoReconnect=true&useSSL=false url: jdbc:mysql://localhost:3306/vertical?characterEncoding=UTF-8&autoReconnect=true&useSSL=false
username: root username: root
password: # 数据库密码 password: # 数据库密码

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

File diff suppressed because it is too large Load Diff