Browse Source

Merge branch 'pt' of gitee.com:ccsens_s/ccsenscloud into pt

master
zy_Java 5 years ago
parent
commit
4875fc1360
  1. 6
      mt/src/main/java/com/ccsens/mt/api/TopicController.java
  2. 2
      mt/src/main/java/com/ccsens/mt/bean/dto/TopicDto.java
  3. 2
      mt/src/main/java/com/ccsens/mt/service/ITopicService.java
  4. 7
      mt/src/main/java/com/ccsens/mt/service/TopicService.java
  5. 36
      mt/src/main/resources/mapper_dao/TopicDao.xml

6
mt/src/main/java/com/ccsens/mt/api/TopicController.java

@ -65,7 +65,7 @@ public class TopicController {
})
@RequestMapping(value = "/ranking", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<TopicVo.QueryRanking>> queryRanking(@RequestBody @ApiParam @Validated TopicDto.GetRankingByProjectId ranking) throws Exception {
log.info("查排名:{}",ranking.toString());
log.info("查排名:{}",ranking);
List<TopicVo.QueryRanking> queryRankings = topicService.queryRanking(ranking);
return JsonResponse.newInstance().ok(queryRankings);
}
@ -74,8 +74,8 @@ public class TopicController {
@ApiImplicitParams({
})
@RequestMapping(value = "/promoted", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse promoted(@RequestBody @ApiParam @Validated TopicDto.Promoted promoted) throws Exception {
log.info("查排名:{}",promoted.toString());
public JsonResponse promoted(@RequestBody @ApiParam @Validated List<TopicDto.Promoted> promoted) throws Exception {
log.info("查排名:{}",promoted);
CodeEnum codeEnum = topicService.promoted(promoted);
return JsonResponse.newInstance().ok(codeEnum);
}

2
mt/src/main/java/com/ccsens/mt/bean/dto/TopicDto.java

@ -80,7 +80,7 @@ public class TopicDto {
@Max(4)
private Byte linkTypes;
@ApiModelProperty("分组ID")
private List<Long> groupIds;
private Long groupId;
}
@Data

2
mt/src/main/java/com/ccsens/mt/service/ITopicService.java

@ -68,5 +68,5 @@ public interface ITopicService {
* @param promoted 晋级组信息
* @return 结果
*/
CodeEnum promoted(TopicDto.Promoted promoted);
CodeEnum promoted(List<TopicDto.Promoted> promoted);
}

7
mt/src/main/java/com/ccsens/mt/service/TopicService.java

@ -116,6 +116,7 @@ public class TopicService implements ITopicService{
groupTopic.setScore(score);
groupTopicDao.insertSelective(groupTopic);
//修改分组的分数
group.setScore(group.getScore() + score - groupTopicScore);
groupDao.updateByPrimaryKeySelective(group);
});
@ -239,11 +240,11 @@ public class TopicService implements ITopicService{
}
@Override
public CodeEnum promoted(TopicDto.Promoted promoted) {
public CodeEnum promoted(List<TopicDto.Promoted> promotes) {
promoted.getGroupIds().forEach(groupId -> {
promotes.forEach(promoted -> {
MtGroup mtGroup = new MtGroup();
mtGroup.setId(groupId);
mtGroup.setId(promoted.getGroupId());
mtGroup.setAdvanceStatus(promoted.getLinkTypes());
mtGroupMapper.updateByPrimaryKeySelective(mtGroup);
});

36
mt/src/main/resources/mapper_dao/TopicDao.xml

@ -45,23 +45,33 @@
SELECT
p.id AS topicId,
p.score AS topicScore,
p.description as description,
p.answers as answersTrue,
IF( gp.id IS NULL, 0, 1 ) as hasAnswers
p.description AS description,
p.answers AS answersTrue,
IF( gp2.id IS NULL, 0, 1 ) AS hasAnswers
FROM
t_mt_topic p
LEFT JOIN t_mt_group_topic gp ON p.id = gp.topic_id
LEFT JOIN t_mt_group g ON gp.group_id = g.id
LEFT JOIN (
SELECT
gp.topic_id,
gp.id
FROM
t_mt_group g,
t_mt_group_topic gp
WHERE
g.id = gp.group_id
AND g.project_id = #{projectId}
AND g.type = 0
AND g.rec_status = 0
AND gp.rec_status = 0
) gp2 ON p.id = gp2.topic_id
WHERE
p.link_type = #{linkType}
and p.rec_status = 0
and (g.project_id = #{projectId} or g.id is null)
and (g.type = 0 or g.id is null)
and (gp.rec_status = 0 or gp.id is null)
and (g.rec_status = 0 or gp.id is null)
GROUP BY p.id
order by p.score
LIMIT ${nums}
AND p.rec_status = 0
GROUP BY
p.id
ORDER BY
p.score
LIMIT ${nums}
</select>
<select id="queryOption" resultType="java.lang.String">
SELECT

Loading…
Cancel
Save