Browse Source

用户是否关注项目

master
zhangye 5 years ago
parent
commit
21e5deaf1b
  1. 2
      cloudutil/src/main/java/com/ccsens/cloudutil/feign/TallFeignClient.java
  2. 14
      game/src/main/java/com/ccsens/game/api/ClientController.java
  3. 2
      game/src/main/java/com/ccsens/game/api/ScreenController.java
  4. 4
      game/src/main/java/com/ccsens/game/netty/wsserver/WebSocketHandler.java
  5. 80
      game/src/main/java/com/ccsens/game/service/ClientService.java
  6. 2
      game/src/main/java/com/ccsens/game/service/IScreenService.java
  7. 34
      game/src/main/java/com/ccsens/game/service/ScreenService.java
  8. 9
      game/src/main/java/com/ccsens/game/util/GameConstant.java
  9. 7
      game/src/main/java/com/ccsens/game/util/SendMsg.java
  10. 33
      mt/src/main/java/com/ccsens/mt/api/ScoreController.java
  11. 12
      mt/src/main/java/com/ccsens/mt/bean/dto/ScoreDto.java
  12. 7
      mt/src/main/java/com/ccsens/mt/service/IScoreService.java
  13. 74
      mt/src/main/java/com/ccsens/mt/service/ScoreService.java
  14. 6
      tall/src/main/java/com/ccsens/tall/service/IUserService.java
  15. 85
      tall/src/main/java/com/ccsens/tall/service/TaskDeliverService.java
  16. 12
      tall/src/main/java/com/ccsens/tall/service/TaskSubTimeService.java
  17. 56
      tall/src/main/java/com/ccsens/tall/service/UserService.java
  18. 28
      tall/src/main/java/com/ccsens/tall/web/UserController.java
  19. 3
      util/src/main/java/com/ccsens/util/CodeEnum.java

2
cloudutil/src/main/java/com/ccsens/cloudutil/feign/TallFeignClient.java

@ -29,7 +29,7 @@ import java.util.Map;
*/ */
@FeignClient(name = "tall", path = "v1.0", fallbackFactory = TallFeignClientFallBack.class) @FeignClient(name = "tall", path = "v1.0", fallbackFactory = TallFeignClientFallBack.class)
public interface TallFeignClient { public interface TallFeignClient {
/** /**
* 获取 * 获取
* @param map * @param map

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

@ -4,6 +4,7 @@ import com.ccsens.cloudutil.annotation.MustLogin;
import com.ccsens.game.bean.dto.ClientDto; import com.ccsens.game.bean.dto.ClientDto;
import com.ccsens.game.bean.dto.ScreenDto; import com.ccsens.game.bean.dto.ScreenDto;
import com.ccsens.game.bean.vo.ClientVo; import com.ccsens.game.bean.vo.ClientVo;
import com.ccsens.game.bean.vo.ScreenVo;
import com.ccsens.game.service.IClientService; import com.ccsens.game.service.IClientService;
import com.ccsens.game.service.IScreenService; import com.ccsens.game.service.IScreenService;
import com.ccsens.util.JsonResponse; import com.ccsens.util.JsonResponse;
@ -66,7 +67,7 @@ public class ClientController {
}) })
@RequestMapping(value = "activityPrize", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) @RequestMapping(value = "activityPrize", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<String>> getGameActivityPrize(@ApiParam @RequestParam Long recordId) throws Exception { public JsonResponse<List<String>> getGameActivityPrize(@ApiParam @RequestParam Long recordId) throws Exception {
log.info("获取游戏规则:{}",recordId); log.info("查询游戏奖品:{}",recordId);
List<String> gameActivityRule = screenService.getGameActivityPrize(screenService.getGameTypeId(recordId)); List<String> gameActivityRule = screenService.getGameActivityPrize(screenService.getGameTypeId(recordId));
return JsonResponse.newInstance().ok(gameActivityRule); return JsonResponse.newInstance().ok(gameActivityRule);
} }
@ -76,9 +77,18 @@ public class ClientController {
}) })
@RequestMapping(value = "prizeInstructions", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) @RequestMapping(value = "prizeInstructions", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<String>> getGamePrizeInstructions(@ApiParam @RequestParam Long recordId) throws Exception { public JsonResponse<List<String>> getGamePrizeInstructions(@ApiParam @RequestParam Long recordId) throws Exception {
log.info("获取游戏规则:{}",recordId); log.info("查询奖券使用说明:{}",recordId);
List<String> gameActivityRule = screenService.getGamePrizeInstructions(screenService.getGameTypeId(recordId)); List<String> gameActivityRule = screenService.getGamePrizeInstructions(screenService.getGameTypeId(recordId));
return JsonResponse.newInstance().ok(gameActivityRule); return JsonResponse.newInstance().ok(gameActivityRule);
} }
@ApiOperation(value = "根据游戏id获取分组信息", notes = "")
@ApiImplicitParams({
})
@RequestMapping(value = "group", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<ScreenVo.Group>> getGroupByRecordId(@ApiParam @RequestParam Long recordId) throws Exception {
log.info("根据游戏id获取分组信息:{}",recordId);
List<ScreenVo.Group> groupList = screenService.getGroupByRecordId(recordId);
return JsonResponse.newInstance().ok(groupList);
}
} }

2
game/src/main/java/com/ccsens/game/api/ScreenController.java

@ -71,7 +71,7 @@ public class ScreenController {
}) })
@RequestMapping(value = "startAgain", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RequestMapping(value = "startAgain", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<String> startAgain(@ApiParam @Validated @RequestBody QueryDto<ScreenDto.MemberRecord> params) throws Exception { public JsonResponse<String> startAgain(@ApiParam @Validated @RequestBody QueryDto<ScreenDto.MemberRecord> params) throws Exception {
log.info("开始游戏:{}",params); log.info("再玩一次:{}",params);
String url = screenService.startAgain(params); String url = screenService.startAgain(params);
return JsonResponse.newInstance().ok(url); return JsonResponse.newInstance().ok(url);
} }

4
game/src/main/java/com/ccsens/game/netty/wsserver/WebSocketHandler.java

@ -76,6 +76,7 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<BaseMessageDto
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, BaseMessageDto baseMessage) throws Exception { protected void channelRead0(ChannelHandlerContext ctx, BaseMessageDto baseMessage) throws Exception {
log.info("接受到消息的时间+++++++++++++++++++++++:{}",System.currentTimeMillis());
MessageConstant.GameClientMessageType gameClientMessageType = MessageConstant.GameClientMessageType.valueOf(baseMessage.getType()); MessageConstant.GameClientMessageType gameClientMessageType = MessageConstant.GameClientMessageType.valueOf(baseMessage.getType());
System.out.println(baseMessage); System.out.println(baseMessage);
@ -104,12 +105,15 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<BaseMessageDto
doAuthMessage(ctx, theMessage); doAuthMessage(ctx, theMessage);
break; break;
case Count: case Count:
Long receiveTime = System.currentTimeMillis();
String userId = ChannelManager.getUserIdByChannel(ctx.channel()); String userId = ChannelManager.getUserIdByChannel(ctx.channel());
String recordId = ChannelManager.getRecordIdByChannel(ctx.channel()); String recordId = ChannelManager.getRecordIdByChannel(ctx.channel());
log.info("统计分数:{},{}",userId, recordId); log.info("统计分数:{},{}",userId, recordId);
GameMessageCountOut gameMessageCountOut = clientService.clientAddTimes(userId,recordId); GameMessageCountOut gameMessageCountOut = clientService.clientAddTimes(userId,recordId);
log.info("统计分数返回结果:{}", gameMessageCountOut); log.info("统计分数返回结果:{}", gameMessageCountOut);
ChannelManager.sendTo(ctx.channel(), gameMessageCountOut); ChannelManager.sendTo(ctx.channel(), gameMessageCountOut);
Long sendTime = System.currentTimeMillis();
log.info("消耗的时长:{}", sendTime - receiveTime);
break; break;
case ChangeStatus: case ChangeStatus:
GameMessageWithChangeStatusOut gameMessage = (GameMessageWithChangeStatusOut) baseMessage; GameMessageWithChangeStatusOut gameMessage = (GameMessageWithChangeStatusOut) baseMessage;

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

@ -57,10 +57,10 @@ public class ClientService implements IClientService {
@Override @Override
public ClientVo.Join join(ClientDto.Join join, Long userId){ public ClientVo.Join join(ClientDto.Join join, Long userId) {
log.info("加入游戏:{}, userId:{}", join, userId); log.info("加入游戏:{}, userId:{}", join, userId);
int timeMore = (int)(join.getLocalTime() - System.currentTimeMillis()); int timeMore = (int) (join.getLocalTime() - System.currentTimeMillis());
log.info("{}时间差:{}", userId, timeMore); log.info("{}时间差:{}", userId, timeMore);
//获取游戏信息 //获取游戏信息
GameRecord gameRecord = screenService.getGameRecord(join.getUrlId()); GameRecord gameRecord = screenService.getGameRecord(join.getUrlId());
@ -83,7 +83,7 @@ public class ClientService implements IClientService {
// 已加入 // 已加入
if (CollectionUtil.isNotEmpty(gameUserJoins)) { if (CollectionUtil.isNotEmpty(gameUserJoins)) {
//查询结果,返回对应的信息 //查询结果,返回对应的信息
return joinResult(gameUserJoins.get(0), gameRecord,isGroup,join.getGroupId()); return joinResult(gameUserJoins.get(0), gameRecord, isGroup, join.getGroupId());
} }
//游戏已结束 //游戏已结束
@ -113,38 +113,38 @@ public class ClientService implements IClientService {
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, join.getProjectId());
if(memberInfo.getData() == null){ if (memberInfo.getData() == null) {
memberInfo = tallFeignClient.getUserByUserId(userId); memberInfo = tallFeignClient.getUserByUserId(userId);
} }
if (memberInfo.getCode().intValue() == CodeEnum.SUCCESS.getCode() && memberInfo.getData() != null) { if (memberInfo.getCode().intValue() == CodeEnum.SUCCESS.getCode() && memberInfo.getData() != null) {
userJoin.setAvatarUrl(memberInfo.getData().getAvatarUrl()); userJoin.setAvatarUrl(memberInfo.getData().getAvatarUrl());
userJoin.setNickname(memberInfo.getData().getNickname()); userJoin.setNickname(memberInfo.getData().getNickname());
if(StrUtil.isNotEmpty(memberInfo.getData().getNickname())){ if (StrUtil.isNotEmpty(memberInfo.getData().getNickname())) {
userJoin.setNickname(memberInfo.getData().getNickname()); userJoin.setNickname(memberInfo.getData().getNickname());
}else { } else {
if(StrUtil.isNotEmpty(memberInfo.getData().getPhone())){ if (StrUtil.isNotEmpty(memberInfo.getData().getPhone())) {
String phone = memberInfo.getData().getPhone(); String phone = memberInfo.getData().getPhone();
String phoneNumber = phone.substring(0, 3) + "****" + phone.substring(7, phone.length()); String phoneNumber = phone.substring(0, 3) + "****" + phone.substring(7, phone.length());
userJoin.setNickname(phoneNumber); userJoin.setNickname(phoneNumber);
}else { } else {
userJoin.setNickname(""); userJoin.setNickname("");
} }
} }
if(StrUtil.isNotEmpty(memberInfo.getData().getAvatarUrl())){ if (StrUtil.isNotEmpty(memberInfo.getData().getAvatarUrl())) {
userJoin.setAvatarUrl(memberInfo.getData().getAvatarUrl()); userJoin.setAvatarUrl(memberInfo.getData().getAvatarUrl());
}else { } else {
userJoin.setAvatarUrl(""); userJoin.setAvatarUrl("");
} }
}else{ } else {
userJoin.setAvatarUrl(""); userJoin.setAvatarUrl("");
userJoin.setNickname(""); userJoin.setNickname("");
} }
gameUserJoinDao.insertSelective(userJoin); gameUserJoinDao.insertSelective(userJoin);
//如果是分组游戏,则添加用户与组的关联表 //如果是分组游戏,则添加用户与组的关联表并添加redis
if(isGroup){ if (isGroup) {
if(ObjectUtil.isNotNull(join.getGroupId())){ if (ObjectUtil.isNull(join.getGroupId())) {
log.info("分组信息为空"); log.info("分组信息为空");
throw new BaseException(CodeEnum.PARAM_ERROR); throw new BaseException(CodeEnum.PARAM_ERROR);
} }
@ -153,16 +153,15 @@ public class ClientService implements IClientService {
userJoinGroup.setUserJoinId(userJoin.getId()); userJoinGroup.setUserJoinId(userJoin.getId());
userJoinGroup.setGameGroupId(join.getGroupId()); userJoinGroup.setGameGroupId(join.getGroupId());
userJoinGroupDao.insertSelective(userJoinGroup); userJoinGroupDao.insertSelective(userJoinGroup);
} }
// 3.更新redis(sort set key:分数 value:头像,姓名) // 3.更新redis(sort set key:分数 value:头像,姓名)
if (prepare || processing) { if (prepare || processing) {
ClientDto.RedisUser user = ClientDto.RedisUser.getInstance(userJoin); ClientDto.RedisUser user = ClientDto.RedisUser.getInstance(userJoin);
redisUtil.zsSet(GameConstant.generateGameKey(gameRecord.getId()), JSON.toJSONString(user), 0, GameConstant.REDIS_TIME); redisUtil.zsSet(GameConstant.generateGameKey(gameRecord.getId()), JSON.toJSONString(user), 0, GameConstant.REDIS_TIME);
} }
//5.返回状态
return joinResult(userJoin, gameRecord,isGroup,join.getGroupId()); //5.返回状态
return joinResult(userJoin, gameRecord, isGroup, join.getGroupId());
} }
// private ClientVo.Join joinResultWithGroup(ClientDto.Join join, Long userId, GameRecord gameRecord ){ // private ClientVo.Join joinResultWithGroup(ClientDto.Join join, Long userId, GameRecord gameRecord ){
@ -178,11 +177,14 @@ public class ClientService implements IClientService {
// //
// } // }
private ClientVo.Join joinResult(GameUserJoin join, GameRecord gameRecord,Boolean isGroup,Long groupId){ private ClientVo.Join joinResult(GameUserJoin join, GameRecord gameRecord, Boolean isGroup, Long groupId) {
ClientVo.Join joinVo = initStatusAndCount(gameRecord); ClientVo.Join joinVo = initStatusAndCount(gameRecord);
if(isGroup && ObjectUtil.isNotNull(groupId)){ if (isGroup && ObjectUtil.isNotNull(groupId)) {
//获取分组的信息 //获取分组的信息
GameGroup gameGroup = gameGroupDao.selectByPrimaryKey(groupId); GameGroup gameGroup = gameGroupDao.selectByPrimaryKey(groupId);
if (ObjectUtil.isNull(gameGroup)) {
throw new BaseException(CodeEnum.PARAM_ERROR);
}
ClientVo.Group group = new ClientVo.Group(); ClientVo.Group group = new ClientVo.Group();
group.setGroupId(gameGroup.getId()); group.setGroupId(gameGroup.getId());
group.setGroupName(gameGroup.getName()); group.setGroupName(gameGroup.getName());
@ -191,49 +193,52 @@ public class ClientService implements IClientService {
} }
switch (gameRecord.getGameStatus()) { switch (gameRecord.getGameStatus()) {
case GameConstant.GAME_PENDING : case GameConstant.GAME_PENDING:
// 未开始 // 未开始
joinVo.setPendingData(new ClientVo.PendingData()); joinVo.setPendingData(new ClientVo.PendingData());
break; break;
case GameConstant.GAME_PREPARATION : case GameConstant.GAME_PREPARATION:
// 准备中 // 准备中
ClientVo.PreparingData preparingData = new ClientVo.PreparingData(); ClientVo.PreparingData preparingData = new ClientVo.PreparingData();
preparingData.setStartLocalTime(join.getLocalStartTime() + join.getTimeDifference()); preparingData.setStartLocalTime(join.getLocalStartTime() + join.getTimeDifference());
preparingData.setEndLocalTime(join.getLocalEndTime() + join.getTimeDifference()); preparingData.setEndLocalTime(join.getLocalEndTime() + join.getTimeDifference());
joinVo.setPreparingData(preparingData); joinVo.setPreparingData(preparingData);
break; break;
case GameConstant.GAME_PROCESSING : case GameConstant.GAME_PROCESSING:
// 进行中 // 进行中
ClientVo.ProcessingData processingData = new ClientVo.ProcessingData(); ClientVo.ProcessingData processingData = new ClientVo.ProcessingData();
processingData.setStartLocalTime(join.getLocalStartTime()); processingData.setStartLocalTime(join.getLocalStartTime());
processingData.setEndLocalTime(join.getLocalEndTime()); processingData.setEndLocalTime(join.getLocalEndTime());
joinVo.setProcessingData(processingData); joinVo.setProcessingData(processingData);
break; break;
case GameConstant.GAME_COMPLETED : case GameConstant.GAME_COMPLETED:
//已结束 //已结束
ClientVo.CompletedData completedData = new ClientVo.CompletedData(); ClientVo.CompletedData completedData = new ClientVo.CompletedData();
completedData.setTimes(join.getTimes()); completedData.setTimes(join.getTimes());
completedData.setScore(join.getScore()); completedData.setScore(join.getScore());
Integer sort = gameUserJoinDao.getRanking(join.getUserId(), gameRecord.getId()); Integer sort = gameUserJoinDao.getRanking(join.getUserId(), gameRecord.getId());
if(ObjectUtil.isNotNull(sort)){ if (ObjectUtil.isNotNull(sort)) {
completedData.setSort(sort); completedData.setSort(sort);
}else { } else {
completedData.setSort(1); completedData.setSort(1);
} }
int low = gameUserJoinDao.overNum(gameRecord.getId(), join.getScore()); int low = gameUserJoinDao.overNum(gameRecord.getId(), join.getScore());
GameUserJoinExample joinExample = new GameUserJoinExample(); GameUserJoinExample joinExample = new GameUserJoinExample();
joinExample.createCriteria().andRecordIdEqualTo(gameRecord.getId()); joinExample.createCriteria().andRecordIdEqualTo(gameRecord.getId());
long count = gameUserJoinDao.countByExample(joinExample); long count = gameUserJoinDao.countByExample(joinExample);
completedData.setOver((int) (low * 100/count)); completedData.setOver((int) (low * 100 / count));
joinVo.setCompletedData(completedData); joinVo.setCompletedData(completedData);
break; break;
default: break; default:
break;
} }
log.info("参加游戏:{}", joinVo); log.info("参加游戏:{}", joinVo);
return joinVo; return joinVo;
} }
/** /**
* 设置状态和总人数 * 设置状态和总人数
*
* @param gameRecord * @param gameRecord
*/ */
private ClientVo.Join initStatusAndCount(GameRecord gameRecord) { private ClientVo.Join initStatusAndCount(GameRecord gameRecord) {
@ -289,8 +294,10 @@ public class ClientService implements IClientService {
// //
// return rankingAll; // return rankingAll;
// } // }
/** /**
* 查询总排名表 * 查询总排名表
*
* @param params * @param params
* @return * @return
*/ */
@ -306,7 +313,7 @@ public class ClientService implements IClientService {
GameUserJoinExample userJoinExample = new GameUserJoinExample(); GameUserJoinExample userJoinExample = new GameUserJoinExample();
userJoinExample.createCriteria().andRecordIdEqualTo(gatRanking.getRecordId()); userJoinExample.createCriteria().andRecordIdEqualTo(gatRanking.getRecordId());
List<GameUserJoin> userJoinList = gameUserJoinDao.selectByExample(userJoinExample); List<GameUserJoin> userJoinList = gameUserJoinDao.selectByExample(userJoinExample);
totalMembers = userJoinList == null ? 0 : (long)userJoinList.size(); totalMembers = userJoinList == null ? 0 : (long) userJoinList.size();
} }
rankingAll.setTotalMembers(totalMembers.intValue()); rankingAll.setTotalMembers(totalMembers.intValue());
@ -318,13 +325,13 @@ public class ClientService implements IClientService {
if (CollectionUtil.isNotEmpty(typedTuples)) { if (CollectionUtil.isNotEmpty(typedTuples)) {
List<ClientVo.MemberInfo> finalMemberInfo = memberInfo; List<ClientVo.MemberInfo> finalMemberInfo = memberInfo;
typedTuples.forEach(type -> { typedTuples.forEach(type -> {
ClientDto.RedisUser user = JSON.parseObject((String)type.getValue(), ClientDto.RedisUser.class); ClientDto.RedisUser user = JSON.parseObject((String) type.getValue(), ClientDto.RedisUser.class);
ClientVo.MemberInfo info = new ClientVo.MemberInfo(); ClientVo.MemberInfo info = new ClientVo.MemberInfo();
info.setId(user.getId()); info.setId(user.getId());
info.setHeadImgUrl(user.getAvatarUrl()); info.setHeadImgUrl(user.getAvatarUrl());
info.setNickname(user.getNickname()); info.setNickname(user.getNickname());
info.setScore(type.getScore().intValue()); info.setScore(type.getScore().intValue());
info.setTimes(type.getScore().intValue()/100); info.setTimes(type.getScore().intValue() / 100);
Long sort = redisUtil.zsReverseRank(userKey, type.getValue()); Long sort = redisUtil.zsReverseRank(userKey, type.getValue());
info.setSort(sort == null ? 1 : sort.intValue()); info.setSort(sort == null ? 1 : sort.intValue());
finalMemberInfo.add(info); finalMemberInfo.add(info);
@ -344,20 +351,21 @@ public class ClientService implements IClientService {
/** /**
* 滑动时添加记录 * 滑动时添加记录
*
* @param userId * @param userId
* @param recordId * @param recordId
* @return * @return
*/ */
@Override @Override
public GameMessageCountOut clientAddTimes(String userId,String recordId) { public GameMessageCountOut clientAddTimes(String userId, String recordId) {
GameMessageCountOut gameMessageCountOut = new GameMessageCountOut(); GameMessageCountOut gameMessageCountOut = new GameMessageCountOut();
log.info("userId:{}", userId); log.info("userId:{}", userId);
if(ObjectUtil.isNotNull(userId)){ if (ObjectUtil.isNotNull(userId)) {
GameUserJoinExample gameUserJoinExample = new GameUserJoinExample(); GameUserJoinExample gameUserJoinExample = new GameUserJoinExample();
gameUserJoinExample.createCriteria().andUserIdEqualTo(Long.valueOf(userId)).andRecordIdEqualTo(Long.valueOf(recordId)); gameUserJoinExample.createCriteria().andUserIdEqualTo(Long.valueOf(userId)).andRecordIdEqualTo(Long.valueOf(recordId));
List<GameUserJoin> userJoinList = gameUserJoinDao.selectByExample(gameUserJoinExample); List<GameUserJoin> userJoinList = gameUserJoinDao.selectByExample(gameUserJoinExample);
log.info("游戏对象:{}", userJoinList); log.info("游戏对象:{}", userJoinList);
if(CollectionUtil.isNotEmpty(userJoinList)){ if (CollectionUtil.isNotEmpty(userJoinList)) {
GameUserJoin userJoin = userJoinList.get(0); GameUserJoin userJoin = userJoinList.get(0);
userJoin.setTimes(userJoin.getTimes() + 1); userJoin.setTimes(userJoin.getTimes() + 1);
userJoin.setScore(userJoin.getScore() + 100); userJoin.setScore(userJoin.getScore() + 100);
@ -365,9 +373,9 @@ public class ClientService implements IClientService {
gameUserJoinDao.updateByPrimaryKeySelective(userJoin); gameUserJoinDao.updateByPrimaryKeySelective(userJoin);
//更新redis //更新redis
ClientDto.RedisUser user = ClientDto.RedisUser.getInstance(userJoin); ClientDto.RedisUser user = ClientDto.RedisUser.getInstance(userJoin);
log.info("游戏id:{}, 对象:{}, 分数:{}", recordId, user,userJoin.getScore()); log.info("游戏id:{}, 对象:{}, 分数:{}", recordId, user, userJoin.getScore());
redisUtil.zsSet(GameConstant.generateGameKey(Long.parseLong(recordId)), JSON.toJSONString(user), userJoin.getScore(), GameConstant.REDIS_TIME); redisUtil.zsSet(GameConstant.generateGameKey(Long.parseLong(recordId)), JSON.toJSONString(user), userJoin.getScore(), GameConstant.REDIS_TIME);
gameMessageCountOut = new GameMessageCountOut(userJoin.getTimes(),userJoin.getScore()); gameMessageCountOut = new GameMessageCountOut(userJoin.getTimes(), userJoin.getScore());
} }
} }
return gameMessageCountOut; return gameMessageCountOut;

2
game/src/main/java/com/ccsens/game/service/IScreenService.java

@ -37,4 +37,6 @@ public interface IScreenService {
List<String> getGamePrizeInstructions(Long gameTypeId); List<String> getGamePrizeInstructions(Long gameTypeId);
Long getGameTypeId(Long recordId); Long getGameTypeId(Long recordId);
List<ScreenVo.Group> getGroupByRecordId(Long recordId);
} }

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

@ -122,10 +122,12 @@ public class ScreenService implements IScreenService{
gameGroupBlue.setId(snowflake.nextId()); gameGroupBlue.setId(snowflake.nextId());
gameGroupBlue.setRecordId(gameRecord.getId()); gameGroupBlue.setRecordId(gameRecord.getId());
gameGroupBlue.setName("蓝队"); gameGroupBlue.setName("蓝队");
gameGroupDao.insertSelective(gameGroupBlue);
GameGroup gameGroupRed = new GameGroup(); GameGroup gameGroupRed = new GameGroup();
gameGroupRed.setId(snowflake.nextId()); gameGroupRed.setId(snowflake.nextId());
gameGroupRed.setRecordId(gameRecord.getId()); gameGroupRed.setRecordId(gameRecord.getId());
gameGroupRed.setName("红队"); gameGroupRed.setName("红队");
gameGroupDao.insertSelective(gameGroupRed);
} }
//5、查询该游戏的规则 //5、查询该游戏的规则
@ -336,13 +338,16 @@ public class ScreenService implements IScreenService{
List<GameGroup> gameGroupList = gameGroupDao.selectByExample(gameGroupExample); List<GameGroup> gameGroupList = gameGroupDao.selectByExample(gameGroupExample);
if(CollectionUtil.isNotEmpty(gameGroupList)){ if(CollectionUtil.isNotEmpty(gameGroupList)){
for(GameGroup gameGroup : gameGroupList){ for(GameGroup gameGroup : gameGroupList){
Map<String,Object> group = getGroupTotalScore(gameGroup.getId());
List<GameUserJoin> userJoinList = (List<GameUserJoin>) group.get("userJoinList");
ScreenVo.GroupVo groupVo = new ScreenVo.GroupVo(); ScreenVo.GroupVo groupVo = new ScreenVo.GroupVo();
groupVo.setGroupId(gameGroup.getId()); groupVo.setGroupId(gameGroup.getId());
groupVo.setGroupName(gameGroup.getName()); groupVo.setGroupName(gameGroup.getName());
groupVo.setScore((Integer) group.get("totalScore"));
groupVo.setTotalMembers(userJoinList.size()); Map<String,Object> group = getGroupTotalScore(gameGroup.getId());
if(CollectionUtil.isNotEmpty(group)){
List<GameUserJoin> userJoinList = (List<GameUserJoin>) group.get("userJoinList");
groupVo.setScore((Integer) group.get("totalScore"));
groupVo.setTotalMembers(userJoinList.size());
}
groupVoList.add(groupVo); groupVoList.add(groupVo);
} }
} }
@ -740,7 +745,7 @@ public class ScreenService implements IScreenService{
joinExample.createCriteria().andRecordIdEqualTo(gameRecord.getId()); joinExample.createCriteria().andRecordIdEqualTo(gameRecord.getId());
List<GameUserJoin> userJoins = gameUserJoinDao.selectByExample(joinExample); List<GameUserJoin> userJoins = gameUserJoinDao.selectByExample(joinExample);
if (CollectionUtil.isEmpty(userJoins)) { if (CollectionUtil.isNotEmpty(userJoins)) {
userJoins.forEach( userJoin -> { userJoins.forEach( userJoin -> {
ClientDto.RedisUser user = ClientDto.RedisUser.getInstance(userJoin); ClientDto.RedisUser user = ClientDto.RedisUser.getInstance(userJoin);
redisUtil.zsSet(GameConstant.generateGameKey(gameRecord.getId()), JSON.toJSONString(user), 0, GameConstant.REDIS_TIME); redisUtil.zsSet(GameConstant.generateGameKey(gameRecord.getId()), JSON.toJSONString(user), 0, GameConstant.REDIS_TIME);
@ -822,4 +827,23 @@ public class ScreenService implements IScreenService{
} }
return gameTypeId; return gameTypeId;
} }
@Override
public List<ScreenVo.Group> getGroupByRecordId(Long recordId) {
List<ScreenVo.Group> groupList = null;
//获取分组信息
GameGroupExample gameGroupExample = new GameGroupExample();
gameGroupExample.createCriteria().andRecordIdEqualTo(recordId);
List<GameGroup> gameGroupList = gameGroupDao.selectByExample(gameGroupExample);
if(CollectionUtil.isNotEmpty(gameGroupList)){
groupList = new ArrayList<>();
for(GameGroup gameGroup:gameGroupList){
ScreenVo.Group group = new ScreenVo.Group();
group.setGroupId(gameGroup.getId());
group.setGroupName(gameGroup.getName());
groupList.add(group);
}
}
return groupList;
}
} }

9
game/src/main/java/com/ccsens/game/util/GameConstant.java

@ -36,6 +36,15 @@ public class GameConstant {
return recordId + GAME_SCORE_KEY; return recordId + GAME_SCORE_KEY;
} }
/**
* 生成分组游戏key
* @param recordId
* @return
*/
public static String generateGameGroupKey(Long recordId,Long groupId) {
return recordId + "_" + groupId + GAME_SCORE_KEY;
}
/** /**
* 游戏状态key * 游戏状态key
* @param recordId * @param recordId

7
game/src/main/java/com/ccsens/game/util/SendMsg.java

@ -5,7 +5,10 @@ import com.alibaba.fastjson.JSON;
import com.ccsens.game.bean.dto.ClientDto; import com.ccsens.game.bean.dto.ClientDto;
import com.ccsens.game.bean.dto.message.ChangeStatusMessageDto; import com.ccsens.game.bean.dto.message.ChangeStatusMessageDto;
import com.ccsens.game.bean.dto.message.GameMessageWithChangeStatusOut; import com.ccsens.game.bean.dto.message.GameMessageWithChangeStatusOut;
import com.ccsens.game.bean.po.GameGroup;
import com.ccsens.game.bean.po.GameGroupExample;
import com.ccsens.game.bean.po.GameRecord; import com.ccsens.game.bean.po.GameRecord;
import com.ccsens.game.persist.dao.GameGroupDao;
import com.ccsens.game.persist.dao.GameUserJoinDao; import com.ccsens.game.persist.dao.GameUserJoinDao;
import com.ccsens.util.JacksonUtil; import com.ccsens.util.JacksonUtil;
import com.ccsens.util.RedisUtil; import com.ccsens.util.RedisUtil;
@ -18,6 +21,7 @@ import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
@ -34,6 +38,8 @@ public class SendMsg {
@Autowired @Autowired
private GameUserJoinDao gameUserJoinDao; private GameUserJoinDao gameUserJoinDao;
@Autowired @Autowired
private GameGroupDao gameGroupDao;
@Autowired
private AmqpTemplate rabbitTemplate; private AmqpTemplate rabbitTemplate;
@Autowired @Autowired
private RedisUtil redisUtil; private RedisUtil redisUtil;
@ -103,6 +109,7 @@ public class SendMsg {
} }
public List<ClientDto.RedisUser> getAllScore(GameRecord gameRecord) { public List<ClientDto.RedisUser> getAllScore(GameRecord gameRecord) {
String userKey = GameConstant.generateGameKey(gameRecord.getId()); String userKey = GameConstant.generateGameKey(gameRecord.getId());
Set<ZSetOperations.TypedTuple<Object>> typedTuples = redisUtil.zsRevGetWithScore(userKey, 0, -1); Set<ZSetOperations.TypedTuple<Object>> typedTuples = redisUtil.zsRevGetWithScore(userKey, 0, -1);
if (CollectionUtil.isNotEmpty(typedTuples)) { if (CollectionUtil.isNotEmpty(typedTuples)) {

33
mt/src/main/java/com/ccsens/mt/api/ScoreController.java

@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
@Api(tags = "评分插件相关" , description = "") @Api(tags = "评分插件相关" , description = "")
@ -54,6 +55,19 @@ public class ScoreController {
return JsonResponse.newInstance().ok(); return JsonResponse.newInstance().ok();
} }
@ApiOperation(value = "提交单项评分",notes = "")
@ApiImplicitParams({
})
@RequestMapping(value = "/oneScore", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse submitScore(HttpServletRequest request,
@ApiParam @RequestBody ScoreDto.SubmitOnlyOneScore submitOnlyOneScore) throws Exception {
//获取userId
Long userId = userService.getUserIdByToken(request);
scoreService.submitOnlyOneScore(userId,submitOnlyOneScore);
return JsonResponse.newInstance().ok();
}
@ApiOperation(value = "获取评分",notes = "") @ApiOperation(value = "获取评分",notes = "")
@ApiImplicitParams({ @ApiImplicitParams({
@ -119,4 +133,23 @@ public class ScoreController {
return JsonResponse.newInstance().ok(); return JsonResponse.newInstance().ok();
} }
/**
* 普通成员获取自己给任务的评分
*/
@RequestMapping(value = "/memberScore", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
public BigDecimal getMemberScore(Long taskId,Long userId) throws Exception {
BigDecimal memberScore = scoreService.getMemberScore(taskId,userId);
return memberScore;
}
/**
* 项目经理获取任务的平均分
*/
@RequestMapping(value = "/adminScore", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
public BigDecimal getAdminScore(Long projectId,Long taskId) throws Exception {
BigDecimal adminScore = scoreService.getAdminScore(projectId,taskId);
return adminScore;
}
} }

12
mt/src/main/java/com/ccsens/mt/bean/dto/ScoreDto.java

@ -80,4 +80,16 @@ public class ScoreDto {
@ApiModelProperty("最小值") @ApiModelProperty("最小值")
private BigDecimal minScore; private BigDecimal minScore;
} }
@Getter
@Setter
@ApiModel
public static class SubmitOnlyOneScore{
@ApiModelProperty("角色id")
private Long roleId;
@ApiModelProperty("任务Id")
private Long playerId;
@ApiModelProperty("分数")
private BigDecimal score;
}
} }

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

@ -3,6 +3,7 @@ package com.ccsens.mt.service;
import com.ccsens.mt.bean.dto.ScoreDto; import com.ccsens.mt.bean.dto.ScoreDto;
import com.ccsens.mt.bean.vo.ScoreVo; import com.ccsens.mt.bean.vo.ScoreVo;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
public interface IScoreService { public interface IScoreService {
@ -19,4 +20,10 @@ public interface IScoreService {
void backScore(Long roleId, Long playerId); void backScore(Long roleId, Long playerId);
void backScoreAll(Long playerId); void backScoreAll(Long playerId);
void submitOnlyOneScore(Long userId, ScoreDto.SubmitOnlyOneScore submitOnlyOneScore);
BigDecimal getMemberScore(Long taskId, Long userId);
BigDecimal getAdminScore(Long projectId,Long taskId);
} }

74
mt/src/main/java/com/ccsens/mt/service/ScoreService.java

@ -155,6 +155,49 @@ public class ScoreService implements IScoreService{
} }
} }
/**
* 提交单项评分
* @param userId
* @param submitOnlyOneScore
*/
@Override
public void submitOnlyOneScore(Long userId, ScoreDto.SubmitOnlyOneScore submitOnlyOneScore) {
if(ObjectUtil.isNull(userId)){
throw new BaseException(CodeEnum.NOT_LOGIN);
}
TaskVo.TaskInfoWithFeign taskInfo = tallFeignClient.getProjectId(submitOnlyOneScore.getPlayerId());
if(ObjectUtil.isNull(taskInfo)){
throw new BaseException(CodeEnum.NOT_TASK);
}
JsonResponse<MemberVo.MemberInfo> jMemberInfo = tallFeignClient.getMemberByUserId(userId,taskInfo.getProjectId());
if(ObjectUtil.isNull(jMemberInfo)){
throw new BaseException(CodeEnum.NOT_MEMBER);
}
MemberVo.MemberInfo memberInfo = jMemberInfo.getData();
if(ObjectUtil.isNull(memberInfo)){
throw new BaseException(CodeEnum.NOT_MEMBER);
}
//添加评委
addJudge(memberInfo);
MtScoreExample scoreExample = new MtScoreExample();
scoreExample.createCriteria().andTaskIdEqualTo(taskInfo.getId()).andJudgeUserIdEqualTo(memberInfo.getId());
List<MtScore> scoreList = scoreDao.selectByExample(scoreExample);
if (CollectionUtil.isEmpty(scoreList)) {
MtScore score = new MtScore();
score.setId(snowflake.nextId());
score.setJudgeUserId(memberInfo.getId());
score.setTaskId(taskInfo.getId());
score.setTaskName(taskInfo.getName());
score.setScore(submitOnlyOneScore.getScore());
//0已评分,1被退回
score.setIsScore(0);
scoreDao.insertSelective(score);
} else {
throw new BaseException(CodeEnum.SCORE_REPEAT);
}
}
/** /**
* 查看评分 * 查看评分
* @param userId * @param userId
@ -381,4 +424,35 @@ public class ScoreService implements IScoreService{
} }
} }
} }
/*=====================================================*/
@Override
public BigDecimal getMemberScore(Long taskId, Long userId) {
BigDecimal score = null;
BigDecimal scoreSum = scoreDao.sumScoreByJudgeId(userId, taskId);
if(ObjectUtil.isNotNull(scoreSum)){
score = scoreSum;
}
return score;
}
@Override
public BigDecimal getAdminScore(Long projectId,Long taskId) {
BigDecimal aveScore = null;
//获取每个评委对此任务的评分
List<ScoreVo.JudgeScore> judgeScoreList = findJudgeScore(projectId,taskId);
if(CollectionUtil.isNotEmpty(judgeScoreList)){
aveScore = BigDecimal.valueOf(0);
for(ScoreVo.JudgeScore judgeScore : judgeScoreList){
//获取此任务的总分
if(ObjectUtil.isNotNull(judgeScore.getScore())){
aveScore = aveScore.add(judgeScore.getScore());
}
}
//平均分
aveScore = aveScore.divide(BigDecimal.valueOf(judgeScoreList.size()), 2, ROUND_HALF_UP);
}
return aveScore;
}
} }

6
tall/src/main/java/com/ccsens/tall/service/IUserService.java

@ -3,6 +3,7 @@ package com.ccsens.tall.service;
import com.ccsens.tall.bean.dto.ProjectDto;
import com.ccsens.tall.bean.dto.UserDto; import com.ccsens.tall.bean.dto.UserDto;
import com.ccsens.tall.bean.po.SysUser; import com.ccsens.tall.bean.po.SysUser;
import com.ccsens.tall.bean.vo.UserVo; import com.ccsens.tall.bean.vo.UserVo;
@ -49,6 +50,9 @@ public interface IUserService {
List<Long> selectUserIdByRoleId(Long roleId)throws Exception; List<Long> selectUserIdByRoleId(Long roleId)throws Exception;
Boolean getIsAttention(Long currentUserId, Long projectId);
void userAttentionProject(Long currentUserId, ProjectDto.ProjectIdDto projectIdDto);
//默认注册 //默认注册
/** /**
@ -68,4 +72,6 @@ public interface IUserService {
void relievePhone(Long userId,String phone); void relievePhone(Long userId,String phone);
UserVo.UserSign changePhoneNotPassword(Long userId,UserDto.WxBindingPhone phoneInfo) throws Exception; UserVo.UserSign changePhoneNotPassword(Long userId,UserDto.WxBindingPhone phoneInfo) throws Exception;
} }

85
tall/src/main/java/com/ccsens/tall/service/TaskDeliverService.java

@ -193,38 +193,69 @@ public class TaskDeliverService implements ITaskDeliverService {
} }
} }
//添加PostLog //添加PostLog
ProTaskDeliverPostLog deliverPostLog = new ProTaskDeliverPostLog();
deliverPostLog.setId(snowflake.nextId());
deliverPostLog.setDeliverId(uploadDeliver.getDeliverId());
deliverPostLog.setTaskSubTimeId(subTimeId);
//如果有文件则添加,没有不添加
if (CollectionUtil.isNotEmpty(uploadDeliver.getFileInfo())) { if (CollectionUtil.isNotEmpty(uploadDeliver.getFileInfo())) {
for (DeliverDto.fileInfo fileInfo : uploadDeliver.getFileInfo()) { for (DeliverDto.fileInfo fileInfo : uploadDeliver.getFileInfo()) {
SysCommitedFile file = commitedFileDao.selectByPrimaryKey(fileInfo.getId()); SysCommitedFile file = commitedFileDao.selectByPrimaryKey(fileInfo.getId());
if (ObjectUtil.isNotNull(file)) { deliverPostLog.setFileId(fileInfo.getId());
ProTaskDeliverPostLog deliverPostLog = new ProTaskDeliverPostLog();
deliverPostLog.setId(snowflake.nextId());
deliverPostLog.setDeliverId(uploadDeliver.getDeliverId());
deliverPostLog.setTaskSubTimeId(subTimeId);
deliverPostLog.setFileId(fileInfo.getId());
deliverPostLog.setUserId(currentUserId);
deliverPostLog.setDescription(uploadDeliver.getDescription());
deliverPostLog.setTime(System.currentTimeMillis());
deliverPostLog.setIsHistory(0);
deliverPostLogDao.insertSelective(deliverPostLog);
//添加交付物检查人表
if (CollectionUtil.isNotEmpty(uploadDeliver.getCheckerIdList())) {
ProTaskDeliverPostLogChecker postLogChecker = null;
for (Long checkerId : uploadDeliver.getCheckerIdList()) {
postLogChecker = new ProTaskDeliverPostLogChecker();
postLogChecker.setId(snowflake.nextId());
postLogChecker.setDeliverPostLogId(deliverPostLog.getId());
postLogChecker.setCheckerId(checkerId);
postLogCheckerDao.insertSelective(postLogChecker);
}
} else {
throw new BaseException(CodeEnum.NOT_CHECKER);
}
} else {
throw new BaseException(CodeEnum.NOT_DELIVER_FILE);
}
} }
} }
deliverPostLog.setUserId(currentUserId);
deliverPostLog.setDescription(uploadDeliver.getDescription());
deliverPostLog.setTime(System.currentTimeMillis());
deliverPostLog.setIsHistory(0);
deliverPostLogDao.insertSelective(deliverPostLog);
//添加交付物检查人表
if (CollectionUtil.isNotEmpty(uploadDeliver.getCheckerIdList())) {
ProTaskDeliverPostLogChecker postLogChecker = null;
for (Long checkerId : uploadDeliver.getCheckerIdList()) {
postLogChecker = new ProTaskDeliverPostLogChecker();
postLogChecker.setId(snowflake.nextId());
postLogChecker.setDeliverPostLogId(deliverPostLog.getId());
postLogChecker.setCheckerId(checkerId);
postLogCheckerDao.insertSelective(postLogChecker);
}
} else {
throw new BaseException(CodeEnum.NOT_CHECKER);
}
// if (CollectionUtil.isNotEmpty(uploadDeliver.getFileInfo())) {
// for (DeliverDto.fileInfo fileInfo : uploadDeliver.getFileInfo()) {
//
// SysCommitedFile file = commitedFileDao.selectByPrimaryKey(fileInfo.getId());
//// if (ObjectUtil.isNotNull(file)) {
// ProTaskDeliverPostLog deliverPostLog = new ProTaskDeliverPostLog();
// deliverPostLog.setId(snowflake.nextId());
// deliverPostLog.setDeliverId(uploadDeliver.getDeliverId());
// deliverPostLog.setTaskSubTimeId(subTimeId);
// deliverPostLog.setFileId(fileInfo.getId());
// deliverPostLog.setUserId(currentUserId);
// deliverPostLog.setDescription(uploadDeliver.getDescription());
// deliverPostLog.setTime(System.currentTimeMillis());
// deliverPostLog.setIsHistory(0);
// deliverPostLogDao.insertSelective(deliverPostLog);
// //添加交付物检查人表
// if (CollectionUtil.isNotEmpty(uploadDeliver.getCheckerIdList())) {
// ProTaskDeliverPostLogChecker postLogChecker = null;
// for (Long checkerId : uploadDeliver.getCheckerIdList()) {
// postLogChecker = new ProTaskDeliverPostLogChecker();
// postLogChecker.setId(snowflake.nextId());
// postLogChecker.setDeliverPostLogId(deliverPostLog.getId());
// postLogChecker.setCheckerId(checkerId);
// postLogCheckerDao.insertSelective(postLogChecker);
// }
// } else {
// throw new BaseException(CodeEnum.NOT_CHECKER);
// }
//// } else {
//// throw new BaseException(CodeEnum.NOT_DELIVER_FILE);
//// }
// }
// }
//修改交付物状态 //修改交付物状态
ProTaskDeliver deliver = new ProTaskDeliver(); ProTaskDeliver deliver = new ProTaskDeliver();

12
tall/src/main/java/com/ccsens/tall/service/TaskSubTimeService.java

@ -306,6 +306,18 @@ public class TaskSubTimeService implements ITaskSubTimeService {
detail.setEndTime(addTask.getEndTime()); detail.setEndTime(addTask.getEndTime());
} }
taskDetailDao.insertSelective(detail); taskDetailDao.insertSelective(detail);
if(ObjectUtil.isNotNull(addTask.getProjectId())){
SysProject project = sysProjectDao.selectByPrimaryKey(addTask.getProjectId());
if(ObjectUtil.isNotNull(project)) {
if (detail.getBeginTime() < project.getBeginTime()) {
project.setBeginTime(detail.getBeginTime());
}
if (detail.getEndTime() > project.getEndTime()) {
project.setEndTime(detail.getEndTime());
}
sysProjectDao.updateByPrimaryKeySelective(project);
}
}
//TaskSubTime //TaskSubTime
List<ProTaskSubTime> proTaskSubTimeList = new ArrayList<>(); List<ProTaskSubTime> proTaskSubTimeList = new ArrayList<>();
if(ObjectUtil.isNotNull(detail.getProjectId())){ if(ObjectUtil.isNotNull(detail.getProjectId())){

56
tall/src/main/java/com/ccsens/tall/service/UserService.java

@ -7,6 +7,7 @@ import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.ccsens.tall.bean.dto.ProjectDto;
import com.ccsens.tall.bean.dto.UserDto; import com.ccsens.tall.bean.dto.UserDto;
import com.ccsens.tall.bean.po.*; import com.ccsens.tall.bean.po.*;
import com.ccsens.tall.bean.vo.UserVo; import com.ccsens.tall.bean.vo.UserVo;
@ -24,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.xhtmlrenderer.css.parser.property.PrimitivePropertyBuilders;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -51,6 +53,10 @@ public class UserService implements IUserService {
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Autowired @Autowired
private SysWxDao sysWxDao; private SysWxDao sysWxDao;
@Autowired
private SysProjectDao sysProjectDao;
@Autowired
private UserAttentionDao userAttentionDao;
/** /**
@ -936,7 +942,55 @@ public class UserService implements IUserService {
return userIdList; return userIdList;
} }
// @Override /**
* 查询用户是否关注此项目
* @param currentUserId
* @param projectId
* @return
*/
@Override
public Boolean getIsAttention(Long currentUserId, Long projectId) {
Boolean isAttention = false;
if(ObjectUtil.isNotNull(sysProjectDao.selectByPrimaryKey(projectId))){
UserAttentionExample attentionExample = new UserAttentionExample();
attentionExample.createCriteria().andProjectIdEqualTo(projectId).andUserIdEqualTo(currentUserId);
List<UserAttention> attentionList = userAttentionDao.selectByExample(attentionExample);
if(CollectionUtil.isNotEmpty(attentionList)){
isAttention = true;
}
}else {
throw new BaseException(CodeEnum.NOT_PROJECT);
}
return isAttention;
}
/**
* 用户关注某个项目
* @param currentUserId
* @param projectIdDto
*/
@Override
public void userAttentionProject(Long currentUserId, ProjectDto.ProjectIdDto projectIdDto) {
//查找项目
SysProject project = sysProjectDao.selectByPrimaryKey(projectIdDto.getProjectId());
if(ObjectUtil.isNotNull(project)){
UserAttentionExample attentionExample = new UserAttentionExample();
attentionExample.createCriteria().andProjectIdEqualTo(projectIdDto.getProjectId()).andUserIdEqualTo(currentUserId);
List<UserAttention> attentionList = userAttentionDao.selectByExample(attentionExample);
if(CollectionUtil.isNotEmpty(attentionList)){
throw new BaseException(CodeEnum.ALREADY_ATTENTION);
}
UserAttention attention = new UserAttention();
attention.setId(snowflake.nextId());
attention.setUserId(currentUserId);
attention.setProjectId(projectIdDto.getProjectId());
userAttentionDao.insertSelective(attention);
}else {
throw new BaseException(CodeEnum.NOT_PROJECT);
}
}
// @Override
// public UserVo.TokenBean userManageSignin(UserDto.UserSginin dto){ // public UserVo.TokenBean userManageSignin(UserDto.UserSginin dto){
// UserVo.TokenBean tokenBean = null; // UserVo.TokenBean tokenBean = null;
// JsonResponse<UserVo.TokenBean> tokenBeanJsonResponse = userManageFeign.userSignin(dto); // JsonResponse<UserVo.TokenBean> tokenBeanJsonResponse = userManageFeign.userSignin(dto);

28
tall/src/main/java/com/ccsens/tall/web/UserController.java

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.servlet.ServletUtil; import cn.hutool.extra.servlet.ServletUtil;
import com.ccsens.tall.bean.dto.ProjectDto;
import com.ccsens.tall.bean.dto.UserDto; import com.ccsens.tall.bean.dto.UserDto;
import com.ccsens.tall.bean.po.SysUser; import com.ccsens.tall.bean.po.SysUser;
import com.ccsens.tall.bean.vo.MemberVo; import com.ccsens.tall.bean.vo.MemberVo;
@ -273,7 +274,32 @@ public class UserController {
return JsonResponse.newInstance().ok(tokenBean); return JsonResponse.newInstance().ok(tokenBean);
} }
/*===============================================================================================*/ @ApiOperation(value = "查询用户是否关注某个项目",notes = "")
@ApiImplicitParams({
@ApiImplicitParam(name="projectId",value = "projectId",required = true,paramType = "query")
})
@RequestMapping(value = "/attention",method = RequestMethod.GET,produces = {"application/json;charset=UTF-8"})
public JsonResponse<UserVo.TokenToUserId> getIsAttention(HttpServletRequest request,
@RequestParam(required = true) Long projectId) throws Exception {
Long currentUserId = Long.valueOf(((Claims) request.getAttribute(WebConstant.REQUEST_KEY_CLAIMS)).getSubject());
Boolean isAttention = userService.getIsAttention(currentUserId,projectId);
return JsonResponse.newInstance().ok(isAttention);
}
@ApiOperation(value = "用户关注项目",notes = "")
@ApiImplicitParams({
@ApiImplicitParam(name="projectId",value = "projectId",required = true,paramType = "query")
})
@RequestMapping(value = "/attention",method = RequestMethod.POST,produces = {"application/json;charset=UTF-8"})
public JsonResponse<UserVo.TokenToUserId> userAttentionProject(HttpServletRequest request,
@ApiParam @Validated @RequestBody ProjectDto.ProjectIdDto projectIdDto) throws Exception {
Long currentUserId = Long.valueOf(((Claims) request.getAttribute(WebConstant.REQUEST_KEY_CLAIMS)).getSubject());
userService.userAttentionProject(currentUserId,projectIdDto);
return JsonResponse.newInstance().ok();
}
/*===============================================================================================*/
@ApiOperation(value = "根据token获取userId",notes = "") @ApiOperation(value = "根据token获取userId",notes = "")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name="token",value = "token",required = true,paramType = "query") @ApiImplicitParam(name="token",value = "token",required = true,paramType = "query")

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

@ -92,7 +92,8 @@ public enum CodeEnum {
MERGE_WX_PHONE(75,"该手机号已经注册过账号,是否将账号合并",true), MERGE_WX_PHONE(75,"该手机号已经注册过账号,是否将账号合并",true),
ALREADY_EXIST_ACCOUNT(76,"该账号已存在",true), ALREADY_EXIST_ACCOUNT(76,"该账号已存在",true),
NOT_SIGN_FIELD(77,"签到的字段不可用",true), NOT_SIGN_FIELD(77,"签到的字段不可用",true),
ALREADY_SIGN(78,"您已经签到过了,请勿重复签到",true) ALREADY_SIGN(78,"您已经签到过了,请勿重复签到",true),
ALREADY_ATTENTION(78,"您已经关注了这个项目",true)
; ;
public CodeEnum addMsg(String msg){ public CodeEnum addMsg(String msg){

Loading…
Cancel
Save