Browse Source

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

master
zy_Java 5 years ago
parent
commit
70e97f36df
  1. 10
      game/src/main/java/com/ccsens/game/api/ClientController.java
  2. 6
      game/src/main/java/com/ccsens/game/bean/dto/ClientDto.java
  3. 2
      game/src/main/java/com/ccsens/game/bean/vo/ScreenVo.java
  4. 27
      game/src/main/java/com/ccsens/game/service/ClientService.java
  5. 6
      game/src/main/java/com/ccsens/game/service/ScreenService.java
  6. 2
      util/src/main/java/com/ccsens/util/CodeEnum.java

10
game/src/main/java/com/ccsens/game/api/ClientController.java

@ -35,9 +35,10 @@ public class ClientController {
@ApiImplicitParams({ @ApiImplicitParams({
}) })
@RequestMapping(value = "groupMembers", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RequestMapping(value = "groupMembers", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<ClientVo.RankingAll> groupMembers(@ApiParam @Validated @RequestBody QueryDto<ClientDto.GroupRanking> params) throws Exception { public JsonResponse<PageInfo<ClientVo.MemberInfo>> groupMembers(@ApiParam @Validated @RequestBody QueryDto<ClientDto.GroupRanking> params) throws Exception {
log.info("查看组内排行榜:{}",params); log.info("查看组内排行榜:{}",params);
PageInfo<ClientVo.MemberInfo> rankingAll = clientService.groupMembers(params.getParam()); PageInfo<ClientVo.MemberInfo> rankingAll = clientService.groupMembers(params.getParam());
log.info("查询组内排行榜结束");
return JsonResponse.newInstance().ok(rankingAll); return JsonResponse.newInstance().ok(rankingAll);
} }
@ -48,6 +49,7 @@ public class ClientController {
public JsonResponse<ClientVo.RankingAll> members(@ApiParam @Validated @RequestBody QueryDto<ClientDto.GatRanking> params) throws Exception { public JsonResponse<ClientVo.RankingAll> members(@ApiParam @Validated @RequestBody QueryDto<ClientDto.GatRanking> params) throws Exception {
log.info("查看全部排行榜:{}",params); log.info("查看全部排行榜:{}",params);
ClientVo.RankingAll rankingAll = clientService.getRankingAll(params); ClientVo.RankingAll rankingAll = clientService.getRankingAll(params);
log.info("查询排行榜结束");
return JsonResponse.newInstance().ok(rankingAll); return JsonResponse.newInstance().ok(rankingAll);
} }
@ -59,6 +61,7 @@ public class ClientController {
public JsonResponse<ClientVo.Join> joinGame(@ApiParam @Validated @RequestBody QueryDto<ClientDto.Join> params) throws Exception { public JsonResponse<ClientVo.Join> joinGame(@ApiParam @Validated @RequestBody QueryDto<ClientDto.Join> params) throws Exception {
log.info("参加游戏:{}",params); log.info("参加游戏:{}",params);
ClientVo.Join join = clientService.join(params.getParam(), params.getUserId()); ClientVo.Join join = clientService.join(params.getParam(), params.getUserId());
log.info("参加游戏结果:{}", join);
return JsonResponse.newInstance().ok(join); return JsonResponse.newInstance().ok(join);
} }
@ -68,7 +71,6 @@ public class ClientController {
@RequestMapping(value = "activityRule", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) @RequestMapping(value = "activityRule", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<String>> getGameActivityRule(@ApiParam @RequestParam Long recordId) throws Exception { public JsonResponse<List<String>> getGameActivityRule(@ApiParam @RequestParam Long recordId) throws Exception {
log.info("获取游戏规则:{}",recordId); log.info("获取游戏规则:{}",recordId);
List<String> gameActivityRule = screenService.getGameActivityRule(screenService.getGameTypeId(recordId)); List<String> gameActivityRule = screenService.getGameActivityRule(screenService.getGameTypeId(recordId));
return JsonResponse.newInstance().ok(gameActivityRule); return JsonResponse.newInstance().ok(gameActivityRule);
} }
@ -100,6 +102,7 @@ public class ClientController {
public JsonResponse<List<ScreenVo.Group>> getGroupByRecordId(@ApiParam @RequestParam Long recordId) throws Exception { public JsonResponse<List<ScreenVo.Group>> getGroupByRecordId(@ApiParam @RequestParam Long recordId) throws Exception {
log.info("根据游戏id获取分组信息:{}",recordId); log.info("根据游戏id获取分组信息:{}",recordId);
List<ScreenVo.Group> groupList = screenService.getGroupByRecordId(recordId); List<ScreenVo.Group> groupList = screenService.getGroupByRecordId(recordId);
log.info("分组查询结束");
return JsonResponse.newInstance().ok(groupList); return JsonResponse.newInstance().ok(groupList);
} }
@ -108,8 +111,9 @@ public class ClientController {
}) })
@RequestMapping(value = "task", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) @RequestMapping(value = "task", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
public JsonResponse<ScreenVo.RecordInfo> getRecordByTaskId(@ApiParam @RequestParam Long taskId,String gameType) throws Exception { public JsonResponse<ScreenVo.RecordInfo> getRecordByTaskId(@ApiParam @RequestParam Long taskId,String gameType) throws Exception {
log.info("根据游戏id获取分组信息:{}",taskId); log.info("根据任务id获取游戏记录id:{}",taskId);
ScreenVo.RecordInfo recordInfo = screenService.getRecordByTaskId(taskId,gameType); ScreenVo.RecordInfo recordInfo = screenService.getRecordByTaskId(taskId,gameType);
log.info("游戏信息:{}", recordInfo);
return JsonResponse.newInstance().ok(recordInfo); return JsonResponse.newInstance().ok(recordInfo);
} }
} }

6
game/src/main/java/com/ccsens/game/bean/dto/ClientDto.java

@ -23,9 +23,9 @@ public class ClientDto {
@NotNull(message = "请选择的时间") @NotNull(message = "请选择的时间")
@ApiModelProperty("本地时间") @ApiModelProperty("本地时间")
private Long localTime; private Long localTime;
@ApiModelProperty // @ApiModelProperty("不再传参")
@NotNull(message = "请选择项目") // @NotNull(message = "请选择项目")
private Long projectId; // private Long projectId;
@ApiModelProperty("分组id,不是分组游戏则为空") @ApiModelProperty("分组id,不是分组游戏则为空")
private Long groupId; private Long groupId;
} }

2
game/src/main/java/com/ccsens/game/bean/vo/ScreenVo.java

@ -53,6 +53,8 @@ public class ScreenVo {
private Long groupId ; private Long groupId ;
@ApiModelProperty("分组名称") @ApiModelProperty("分组名称")
private String groupName ; private String groupName ;
@ApiModelProperty("头像")
private String headPortraitUrl;
@ApiModelProperty("该组参赛总人数") @ApiModelProperty("该组参赛总人数")
private int totalGroupMembers ; private int totalGroupMembers ;
} }

27
game/src/main/java/com/ccsens/game/service/ClientService.java

@ -76,7 +76,7 @@ public class ClientService implements IClientService {
//获取游戏的购买记录和类型 //获取游戏的购买记录和类型
// TODO 暂时没有购买相关的,先不查询 // TODO 暂时没有购买相关的,先不查询
// GameUserPay gameUserPay = gameUserPayDao.selectByPrimaryKey(gameRecord.getUserPayId()); // GameUserPay gameUserPay = gameUserPayDao.selectByPrimaryKey(gameRecord.getUserPayId());
Boolean isGroup = gameRecord.getGameGroup() == GameConstant.GAME_GROUP; boolean isGroup = gameRecord.getGameGroup() == GameConstant.GAME_GROUP;
//根据游戏ID和用户ID查询用户是否加入 //根据游戏ID和用户ID查询用户是否加入
GameUserJoinExample example = new GameUserJoinExample(); GameUserJoinExample example = new GameUserJoinExample();
@ -87,6 +87,12 @@ public class ClientService implements IClientService {
//查询结果,返回对应的信息 //查询结果,返回对应的信息
return joinResult(gameUserJoins.get(0), gameRecord, isGroup, join.getGroupId()); return joinResult(gameUserJoins.get(0), gameRecord, isGroup, join.getGroupId());
} }
if (isGroup) {
if (ObjectUtil.isNull(join.getGroupId())) {
log.info("分组信息为空");
throw new BaseException(CodeEnum.GROUP_NOT_CHOICE);
}
}
//游戏已结束 //游戏已结束
if (gameRecord.getGameStatus().byteValue() == GameConstant.GAME_COMPLETED) { if (gameRecord.getGameStatus().byteValue() == GameConstant.GAME_COMPLETED) {
@ -105,6 +111,19 @@ public class ClientService implements IClientService {
joinVo.setCompletedData(completedData); joinVo.setCompletedData(completedData);
return joinVo; return joinVo;
} }
// 判断是否达到组内上限
if (isGroup) {
GameUserJoinGroupExample groupExample = new GameUserJoinGroupExample();
groupExample.createCriteria().andGameGroupIdEqualTo(join.getGroupId());
long count = gameUserJoinGroupDao.countByExample(groupExample);
log.info("组内人数:{},上限:{}", count, gameRecord.getMemberLimit());
if (count >= gameRecord.getMemberLimit()) {
throw new BaseException(CodeEnum.GROUP_MEMBER_LIMIT);
}
}
//准备中 //准备中
boolean prepare = gameRecord.getGameStatus().byteValue() == GameConstant.GAME_PREPARATION; boolean prepare = gameRecord.getGameStatus().byteValue() == GameConstant.GAME_PREPARATION;
//进行中 //进行中
@ -120,7 +139,7 @@ public class ClientService implements IClientService {
userJoin.setLocalStartTime(prepare || processing ? gameRecord.getStartTime() + timeMore : 0); userJoin.setLocalStartTime(prepare || processing ? gameRecord.getStartTime() + timeMore : 0);
userJoin.setLocalEndTime(prepare || processing ? gameRecord.getEndTime() + timeMore : 0); userJoin.setLocalEndTime(prepare || processing ? gameRecord.getEndTime() + timeMore : 0);
// 获取头像和用户名 // 获取头像和用户名
JsonResponse<MemberVo.MemberInfo> memberInfo = tallFeignClient.getMemberByUserId(userId, join.getProjectId()); JsonResponse<MemberVo.MemberInfo> memberInfo = tallFeignClient.getMemberByUserId(userId, gameRecord.getTaskId());
if (memberInfo.getData() == null) { if (memberInfo.getData() == null) {
memberInfo = tallFeignClient.getUserByUserId(userId); memberInfo = tallFeignClient.getUserByUserId(userId);
} }
@ -152,10 +171,6 @@ public class ClientService implements IClientService {
gameUserJoinDao.insertSelective(userJoin); gameUserJoinDao.insertSelective(userJoin);
//如果是分组游戏,则添加用户与组的关联表 //如果是分组游戏,则添加用户与组的关联表
if (isGroup) { if (isGroup) {
if (ObjectUtil.isNull(join.getGroupId())) {
log.info("分组信息为空");
throw new BaseException(CodeEnum.PARAM_ERROR);
}
GameUserJoinGroup userJoinGroup = new GameUserJoinGroup(); GameUserJoinGroup userJoinGroup = new GameUserJoinGroup();
userJoinGroup.setId(snowflake.nextId()); userJoinGroup.setId(snowflake.nextId());
userJoinGroup.setUserJoinId(userJoin.getId()); userJoinGroup.setUserJoinId(userJoin.getId());

6
game/src/main/java/com/ccsens/game/service/ScreenService.java

@ -557,7 +557,7 @@ public class ScreenService implements IScreenService {
break; break;
case GameConstant.GAME_PROCESSING: case GameConstant.GAME_PROCESSING:
//查询游戏是否有分组 //查询游戏是否有分组
if (gameType.getIsGroup() == 0) { if (gameRecord.getGameGroup() == GameConstant.GAME_SINGLE) {
//普通游戏返回前十名的信息 //普通游戏返回前十名的信息
ScreenVo.ProcessingData processingData = new ScreenVo.ProcessingData(); ScreenVo.ProcessingData processingData = new ScreenVo.ProcessingData();
// 查询前十名(列表顺序即前十名顺序) // 查询前十名(列表顺序即前十名顺序)
@ -566,7 +566,8 @@ public class ScreenService implements IScreenService {
gameStatusVo.setProcessingData(processingData); gameStatusVo.setProcessingData(processingData);
} else { } else {
//分组游戏则返回每个分组的信息 //分组游戏则返回每个分组的信息
List<ScreenVo.GroupVo> groupVoList = getGroupScore(gameRecord); // List<ScreenVo.GroupVo> groupVoList = getGroupScore(gameRecord);
List<ScreenVo.GroupVo> groupVoList = groupVo;
gameStatusVo.setProcessingData(groupVoList); gameStatusVo.setProcessingData(groupVoList);
} }
break; break;
@ -1186,6 +1187,7 @@ public class ScreenService implements IScreenService {
ScreenVo.Group group = new ScreenVo.Group(); ScreenVo.Group group = new ScreenVo.Group();
group.setGroupId(gameGroup.getId()); group.setGroupId(gameGroup.getId());
group.setGroupName(gameGroup.getName()); group.setGroupName(gameGroup.getName());
group.setHeadPortraitUrl(gameGroup.getHeadPortraitUrl());
groupList.add(group); groupList.add(group);
} }
} }

2
util/src/main/java/com/ccsens/util/CodeEnum.java

@ -138,6 +138,8 @@ public enum CodeEnum {
VOTE_COMPLETED(116,"投票已结束",true), VOTE_COMPLETED(116,"投票已结束",true),
VOTE_NOT_START(117,"投票未开始",true), VOTE_NOT_START(117,"投票未开始",true),
NOT_CONFIG_OR_ERR(118,"缺少配置信息,或配置信息异常",true), NOT_CONFIG_OR_ERR(118,"缺少配置信息,或配置信息异常",true),
GROUP_MEMBER_LIMIT(119,"当前组内人员已满,请选择其他组",true),
GROUP_NOT_CHOICE(120,"请选择要加入的队伍",true),
; ;

Loading…
Cancel
Save