🎨 专题接口变更

🎨 专题接口变更
This commit is contained in:
ronger 2021-08-25 17:22:29 +08:00 committed by GitHub
commit fc8349d90e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 15 deletions

View File

@ -22,13 +22,11 @@ import org.springframework.web.servlet.HandlerMapping;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.Date; import java.util.*;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
/** /**
* 浏览 * 浏览
*
* @author ronger * @author ronger
*/ */
@Aspect @Aspect
@ -43,7 +41,8 @@ public class VisitAspect {
private VisitService visitService; private VisitService visitService;
@Pointcut("@annotation(com.rymcu.forest.core.service.log.annotation.VisitLogger)") @Pointcut("@annotation(com.rymcu.forest.core.service.log.annotation.VisitLogger)")
public void pointCut() {} public void pointCut() {
}
/** /**
* 保存系统操作日志 * 保存系统操作日志
@ -52,7 +51,7 @@ public class VisitAspect {
* @return 方法执行结果 * @return 方法执行结果
* @throws Throwable 调用出错 * @throws Throwable 调用出错
*/ */
@AfterReturning(value = "pointCut()", returning="obj") @AfterReturning(value = "pointCut()", returning = "obj")
public void save(JoinPoint joinPoint, Object obj) { public void save(JoinPoint joinPoint, Object obj) {
logger.info("保存访问记录 start ..."); logger.info("保存访问记录 start ...");
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
@ -69,10 +68,12 @@ public class VisitAspect {
visit.setVisitRefererUrl(referer); visit.setVisitRefererUrl(referer);
visit.setCreatedTime(new Date()); visit.setCreatedTime(new Date());
String authHeader = request.getHeader(JwtConstants.AUTHORIZATION); String authHeader = request.getHeader(JwtConstants.AUTHORIZATION);
if(StringUtils.isNotBlank(authHeader)){ if (StringUtils.isNotBlank(authHeader)) {
TokenUser tokenUser = UserUtils.getTokenUser(authHeader); TokenUser tokenUser = UserUtils.getTokenUser(authHeader);
if (Objects.nonNull(tokenUser)) {
visit.setVisitUserId(tokenUser.getIdUser()); visit.setVisitUserId(tokenUser.getIdUser());
} }
}
visitService.save(visit); visitService.save(visit);
String methodName = joinPoint.getSignature().getName(); String methodName = joinPoint.getSignature().getName();

View File

@ -78,5 +78,5 @@ public interface PortfolioMapper extends Mapper<Portfolio> {
* 获取作品集列表数据 * 获取作品集列表数据
* @return * @return
*/ */
List<Portfolio> selectPortfolios(); List<PortfolioDTO> selectPortfolios();
} }

View File

@ -82,5 +82,5 @@ public interface PortfolioService extends Service<Portfolio> {
* 获取作品集列表数据 * 获取作品集列表数据
* @return * @return
*/ */
List<Portfolio> findPortfolios(); List<PortfolioDTO> findPortfolios();
} }

View File

@ -45,6 +45,8 @@ public class PortfolioServiceImpl extends AbstractService<Portfolio> implements
Author author = userService.selectAuthor(userDTO.getIdUser()); Author author = userService.selectAuthor(userDTO.getIdUser());
list.forEach(portfolioDTO -> { list.forEach(portfolioDTO -> {
genPortfolioAuthor(portfolioDTO,author); genPortfolioAuthor(portfolioDTO,author);
Integer articleNumber = portfolioMapper.selectCountArticleNumber(portfolioDTO.getIdPortfolio());
portfolioDTO.setArticleNumber(articleNumber);
}); });
return list; return list;
} }
@ -199,7 +201,7 @@ public class PortfolioServiceImpl extends AbstractService<Portfolio> implements
} }
@Override @Override
public List<Portfolio> findPortfolios() { public List<PortfolioDTO> findPortfolios() {
return portfolioMapper.selectPortfolios(); return portfolioMapper.selectPortfolios();
} }

View File

@ -147,8 +147,8 @@ public class CommonApiController {
@GetMapping("/portfolios") @GetMapping("/portfolios")
public GlobalResult portfolios(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows) { public GlobalResult portfolios(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows) {
PageHelper.startPage(page, rows); PageHelper.startPage(page, rows);
List<Portfolio> list = portfolioService.findPortfolios(); List<PortfolioDTO> list = portfolioService.findPortfolios();
PageInfo<Portfolio> pageInfo = new PageInfo(list); PageInfo<PortfolioDTO> pageInfo = new PageInfo(list);
Map map = new HashMap(2); Map map = new HashMap(2);
map.put("portfolios", pageInfo.getList()); map.put("portfolios", pageInfo.getList());
Map pagination = Utils.getPagination(pageInfo); Map pagination = Utils.getPagination(pageInfo);

View File

@ -17,6 +17,7 @@
<result column="portfolio_author_id" property="portfolioAuthorId"></result> <result column="portfolio_author_id" property="portfolioAuthorId"></result>
<result column="portfolio_description" property="portfolioDescription"></result> <result column="portfolio_description" property="portfolioDescription"></result>
<result column="updated_time" property="updatedTime"></result> <result column="updated_time" property="updatedTime"></result>
<result column="numbers" property="articleNumber"></result>
</resultMap> </resultMap>
<insert id="insertPortfolioArticle"> <insert id="insertPortfolioArticle">
insert into forest_portfolio_article (id_portfolio, id_article, sort_no) values (#{idPortfolio}, #{idArticle}, #{maxSortNo}) insert into forest_portfolio_article (id_portfolio, id_article, sort_no) values (#{idPortfolio}, #{idArticle}, #{maxSortNo})
@ -51,8 +52,8 @@
<select id="selectMaxSortNo" resultType="java.lang.Integer"> <select id="selectMaxSortNo" resultType="java.lang.Integer">
select ifnull(max(sort_no),0) + 1 from forest_portfolio_article where id_portfolio = #{idPortfolio} select ifnull(max(sort_no),0) + 1 from forest_portfolio_article where id_portfolio = #{idPortfolio}
</select> </select>
<select id="selectPortfolios" resultMap="BaseResultMap"> <select id="selectPortfolios" resultMap="DTOResultMap">
select fp.* from forest_portfolio fp left join (select id_portfolio, count(id_portfolio) numbers from forest_portfolio_article group by id_portfolio) fpa select fp.*,fpa.numbers from forest_portfolio fp left join (select id_portfolio, count(id_portfolio) numbers from forest_portfolio_article group by id_portfolio) fpa
on fp.id = fpa.id_portfolio order by fpa.numbers desc, updated_time desc on fp.id = fpa.id_portfolio order by fpa.numbers desc, updated_time desc
</select> </select>
</mapper> </mapper>