Browse Source

晋级

master
zhizhi wu 5 years ago
parent
commit
563059cfff
  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"}) @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 { 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); List<TopicVo.QueryRanking> queryRankings = topicService.queryRanking(ranking);
return JsonResponse.newInstance().ok(queryRankings); return JsonResponse.newInstance().ok(queryRankings);
} }
@ -74,8 +74,8 @@ public class TopicController {
@ApiImplicitParams({ @ApiImplicitParams({
}) })
@RequestMapping(value = "/promoted", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RequestMapping(value = "/promoted", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse promoted(@RequestBody @ApiParam @Validated TopicDto.Promoted promoted) throws Exception { public JsonResponse promoted(@RequestBody @ApiParam @Validated List<TopicDto.Promoted> promoted) throws Exception {
log.info("查排名:{}",promoted.toString()); log.info("查排名:{}",promoted);
CodeEnum codeEnum = topicService.promoted(promoted); CodeEnum codeEnum = topicService.promoted(promoted);
return JsonResponse.newInstance().ok(codeEnum); 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) @Max(4)
private Byte linkTypes; private Byte linkTypes;
@ApiModelProperty("分组ID") @ApiModelProperty("分组ID")
private List<Long> groupIds; private Long groupId;
} }
@Data @Data

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

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

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

@ -113,6 +113,7 @@ public class TopicService implements ITopicService{
groupTopic.setScore(score); groupTopic.setScore(score);
groupTopicDao.insertSelective(groupTopic); groupTopicDao.insertSelective(groupTopic);
//修改分组的分数 //修改分组的分数
group.setScore(group.getScore() + score - groupTopicScore); group.setScore(group.getScore() + score - groupTopicScore);
groupDao.updateByPrimaryKeySelective(group); groupDao.updateByPrimaryKeySelective(group);
}); });
@ -230,11 +231,11 @@ public class TopicService implements ITopicService{
} }
@Override @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 mtGroup = new MtGroup();
mtGroup.setId(groupId); mtGroup.setId(promoted.getGroupId());
mtGroup.setAdvanceStatus(promoted.getLinkTypes()); mtGroup.setAdvanceStatus(promoted.getLinkTypes());
mtGroupMapper.updateByPrimaryKeySelective(mtGroup); mtGroupMapper.updateByPrimaryKeySelective(mtGroup);
}); });

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

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

Loading…
Cancel
Save