瀏覽代碼

修改bug

hurixing 1 年之前
父節點
當前提交
a4e31f3b02

+ 2 - 2
hcp-app/src/main/java/com/yingyangfly/app/controller/MedicalConsultationController.java

@@ -117,8 +117,8 @@ public class MedicalConsultationController {
     public ResultResponse<List<MedicalConsultationAppVo>> myList() {
         List<MedicalConsultationAppVo> appMyList = medicalConsultationService.getAppMyList();
 
-        List<ConsultationDetailsVo> consultationDetailsVos = EntityConverter.convertList(appMyList, ConsultationDetailsVo.class);
-        return ResultResponse.success(consultationDetailsVos);
+//        List<ConsultationDetailsVo> consultationDetailsVos = EntityConverter.convertList(appMyList, ConsultationDetailsVo.class);
+        return ResultResponse.success(appMyList);
     }
 
     @Log(title = "取消咨询订单",operatorType = OperatorType.MOBILE)

+ 7 - 4
hcp-app/src/main/java/com/yingyangfly/app/controller/UploadFileController.java

@@ -8,10 +8,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.Arrays;
@@ -62,4 +59,10 @@ public class UploadFileController {
     }
 
 
+    @GetMapping("/hertz/audio")
+    public ResultResponse getHertzAudioUrl(){
+        return ResultResponse.success("https://yaorongoss.yaorongmedical.com/dabeizhou_40hz.mp3");
+    }
+
+
 }

+ 3 - 0
hcp-core/src/main/java/com/yingyangfly/core/domain/Game.java

@@ -51,6 +51,9 @@ public class Game extends BaseEntity {
     @ApiModelProperty(value = "边框地址")
     private String frameImg;
 
+    @ApiModelProperty("科学原理")
+    private String scientificPrinciple;
+
 }
 
 

+ 3 - 0
hcp-core/src/main/java/com/yingyangfly/core/domain/GamePastRecords.java

@@ -47,4 +47,7 @@ public class GamePastRecords extends BaseEntity {
     private String fullFlag;
     @ApiModelProperty(value = "边框地址")
     private String frameImg;
+
+    @ApiModelProperty("科学原理")
+    private String scientificPrinciple;
 }

+ 5 - 0
hcp-core/src/main/java/com/yingyangfly/core/dto/GameDto.java

@@ -108,5 +108,10 @@ public class GameDto  implements Serializable{
      */
     private String frameImg;
 
+    /**
+     * 科学原理
+     */
+    private String scientificPrinciple;
+
 
 }

+ 14 - 4
hcp-core/src/main/java/com/yingyangfly/core/recommend/RecommendFacade.java

@@ -82,9 +82,19 @@ public class RecommendFacade {
         recommendUserBorCByRule(ruleB, appUser);
         log.info("<<<<<<<<<<<推荐蓝豚开始>>>>>>>>>>>>>");
         GameRecommendRule ruleC = getRule("C");
-        recommendUserBorCByRule(ruleC, appUser);
+        recommendUserBorCByRuleC(ruleC,appUser);
     }
 
+
+    @Transactional(rollbackFor = Exception.class)
+    public void recommendUserBorCByRuleC(GameRecommendRule ruleC,AppUser appUser){
+        // 查询所有游戏
+        List<Game> gameList = gameService.list();
+        List<GameUser> gameUsers = buildGameUsers(gameList, appUser, ruleC);
+        boolean saveBath = gameUserService.saveBatch(gameUsers);
+    }
+
+
     /**
      * 定时任务推荐A B C
      *
@@ -111,9 +121,9 @@ public class RecommendFacade {
                log.info("<<<<<<<<<<<<<<<推荐首页推荐开始>>>>>>>>>>>>>>");
                recommendBorCByRule(ruleB);
                log.info("<<<<<<<<<<<<<<<推荐首页推荐结束>>>>>>>>>>>>>>");
-               log.info("<<<<<<<<<<<<<<<推荐自由训练开始>>>>>>>>>>>>>>");
-               recommendBorCByRule(ruleC);
-               log.info("<<<<<<<<<<<<<<<推荐自由训练结束>>>>>>>>>>>>>>");
+//               log.info("<<<<<<<<<<<<<<<推荐自由训练开始>>>>>>>>>>>>>>");
+//               recommendBorCByRule(ruleC);
+//               log.info("<<<<<<<<<<<<<<<推荐自由训练结束>>>>>>>>>>>>>>");
            }finally {
                if (!isGetLock){
                    redisClient.unlock(date);

+ 64 - 5
hcp-core/src/main/java/com/yingyangfly/core/service/impl/GameServiceImpl.java

@@ -1,4 +1,5 @@
 package com.yingyangfly.core.service.impl;
+import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
@@ -10,13 +11,12 @@ import com.yingyangfly.core.dto.AppCurrentLoginUser;
 import com.yingyangfly.core.dto.CurrentLoginUser;
 import com.yingyangfly.core.dto.GameDto;
 import com.yingyangfly.core.enums.StatusEnums;
+import com.yingyangfly.core.mapper.AppUserMapper;
 import com.yingyangfly.core.mapper.GameMapper;
 import com.yingyangfly.core.mapper.GameTaskDetailMapper;
 import com.yingyangfly.core.mapper.GameUserMapper;
 import com.yingyangfly.core.security.util.TokenUtil;
-import com.yingyangfly.core.service.GamePastRecordsService;
-import com.yingyangfly.core.service.GamePlayRecordService;
-import com.yingyangfly.core.service.GameService;
+import com.yingyangfly.core.service.*;
 import com.yingyangfly.redis.client.RedisClient;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
@@ -25,8 +25,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 游戏表(Game)表服务实现类
@@ -55,6 +54,15 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements Ga
     @Resource
     private GamePastRecordsService gamePastRecordsService;
 
+    @Resource
+    private AppUserService appUserService;
+
+    @Resource
+    private GameUserService gameUserService;
+
+    @Resource
+    private GameTaskDetailService gameTaskDetailService;
+
     @Override
     public Game selectByGameCode(String gameCode) {
         CurrentLoginUser currentUser = tokenUtil.getCurrentUser();
@@ -104,6 +112,8 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements Ga
         gameDto.setFullFlag(game.getFullFlag());
         //边框
         gameDto.setFrameImg(game.getFrameImg());
+        // 科学原理
+        gameDto.setScientificPrinciple(game.getScientificPrinciple());
         //游戏标签
         SysDictData sysDictData = sysDictDataService.selectByDictTypeAndValue("game_type", game.getGameType());
         gameDto.setGameType(sysDictData.getDictLabel());
@@ -136,10 +146,15 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements Ga
             Integer gamecode = Integer.parseInt(gameDb.getGameCode())+1;
             game.setGameCode(String.valueOf(gamecode));
             game.setStatus(StatusEnums.OK.getIntCode());
+            // 新增给所有用户加上游戏
+            List<AppUser> appUsers = appUserService.list();
+            List<GameUser> gameUsers = buildGameUsers(game, appUsers);
+            gameUserService.saveBatch(gameUsers);
             return save(game);
         }
         Game gameUpdate = this.getById(game.getId());
         if (ObjectUtils.isNotNull(gameUpdate)){
+            // 修改游戏 同步数据给用户游戏
             GameUser gameUser = new GameUser();
             gameUser.setTotalNum(game.getTotalNum());
             gameUser.setGameType(game.getGameType());
@@ -152,6 +167,15 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements Ga
             LambdaQueryWrapper<GameUser> wrapper = new LambdaQueryWrapper<>();
             wrapper.eq(GameUser::getGameCode,gameUpdate.getGameCode());
             gameUserMapper.update(gameUser,wrapper);
+            // 修改游戏 同步数据给专属任务游戏
+            GameTaskDetail gameTaskDetail = new GameTaskDetail();
+            gameTaskDetail.setGameName(game.getGameName());
+            gameTaskDetail.setGameType(game.getGameType());
+            gameTaskDetail.setGameUrl(game.getGameUrl());
+            LambdaQueryWrapper<GameTaskDetail> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+            lambdaQueryWrapper.eq(GameTaskDetail::getGameCode,gameUpdate.getGameCode());
+            lambdaQueryWrapper.eq(GameTaskDetail::getStatus,"1");
+            gameTaskDetailService.update(gameTaskDetail,lambdaQueryWrapper);
 
         }
         return saveOrUpdate(game);
@@ -170,10 +194,45 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements Ga
         LambdaQueryWrapper<GameUser> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(GameUser::getGameCode,game.getGameCode());
         gameUserMapper.delete(wrapper);
+        // 删除理疗任务游戏
+        LambdaQueryWrapper<GameTaskDetail> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(GameTaskDetail::getGameCode,game.getGameCode());
+        lambdaQueryWrapper.eq(GameTaskDetail::getStatus,"1");
+        gameTaskDetailService.remove(lambdaQueryWrapper);
         // 删除游戏
         return removeById(gameId);
     }
 
+    private List<GameUser> buildGameUsers(Game game, List<AppUser> appUsers){
+        Date current = DateUtil.date();
+        List<GameUser> gameUsers = new ArrayList<>();
+        for (AppUser appUser : appUsers) {
+            GameUser gameUser = new GameUser();
+            gameUser.setId(IdWorker.getId());
+            gameUser.setGameCode(game.getGameCode());
+            gameUser.setGameName(game.getGameName());
+            gameUser.setGameUrl(game.getGameUrl());
+            gameUser.setGameType(game.getGameType());
+            gameUser.setUserId(appUser.getId());
+            gameUser.setUserName(appUser.getName());
+            gameUser.setPlayClass("C");
+            gameUser.setStatus("1");
+            gameUser.setCurrentLevel(1);
+            gameUser.setTotalNum(game.getTotalNum());
+            gameUser.setCreateTime(current);
+            gameUser.setUpdateTime(current);
+            gameUser.setOrgCode(game.getOrgCode());
+            gameUser.setOrgName(game.getOrgName());
+            gameUser.setGameDifficulty(game.getGameDifficulty());
+            gameUser.setGameDifficultyRate(game.getGameDifficultyRate());
+            gameUser.setGameDuration(game.getGameDuration());
+            gameUser.setGameCoverImage(game.getGameCoverImage());
+            gameUsers.add(gameUser);
+        }
+        return gameUsers;
+    }
+
+
 }
 
 

+ 2 - 2
hcp-core/src/main/java/com/yingyangfly/core/service/impl/QuestionRecordServiceImpl.java

@@ -139,8 +139,8 @@ public class QuestionRecordServiceImpl  extends ServiceImpl<QuestionMapper, Ques
         }
         examinationPage.setRecords(returnList);
 
-        IPage questionVoPage = EntityConverter.convertPage(examinationPage, QuestionVo.class);
-        return ResultResponse.success(questionVoPage);
+//        IPage questionVoPage = EntityConverter.convertPage(examinationPage, QuestionVo.class);
+        return ResultResponse.success(examinationPage);
     }
 
     @Override

+ 14 - 1
hcp-core/src/main/java/com/yingyangfly/core/util/EntityConverter.java

@@ -16,10 +16,23 @@ public class EntityConverter {
     }
 
     public static <S, T> T convertToTarget(S source, Class<T> targetClass) {
+        if (source == null) {
+            // 如果source为null,则直接返回null
+            return null;
+        }
+
         try {
-            T target = targetClass.getDeclaredConstructor().newInstance();
+            // 检查是否存在无参构造函数
+            java.lang.reflect.Constructor<T> constructor = targetClass.getDeclaredConstructor();
+            constructor.setAccessible(true); // 设置为可访问,以防构造函数是私有的
+            T target = constructor.newInstance();
+
+            // 使用BeanUtils复制属性
             BeanUtils.copyProperties(source, target);
+
             return target;
+        } catch (NoSuchMethodException e) {
+            throw new IllegalArgumentException("Target class does not have a no-arg constructor", e);
         } catch (Exception e) {
             throw new RuntimeException("Failed to convert source to target", e);
         }

+ 3 - 0
hcp-core/src/main/java/com/yingyangfly/core/vo/GamePastRecordsVo.java

@@ -47,6 +47,9 @@ public class GamePastRecordsVo {
     @ApiModelProperty(value = "边框地址")
     private String frameImg;
 
+    @ApiModelProperty("科学原理")
+    private String scientificPrinciple;
+
 
     private Date createTime;
 

+ 3 - 0
hcp-core/src/main/java/com/yingyangfly/core/vo/GameVo.java

@@ -49,6 +49,9 @@ public class GameVo {
     @ApiModelProperty(value = "边框地址")
     private String frameImg;
 
+    @ApiModelProperty("科学原理")
+    private String scientificPrinciple;
+
 
     private Date createTime;
     private Date updateTime;

+ 1 - 0
hcp-core/src/main/java/com/yingyangfly/core/vo/QuestionVo.java

@@ -29,6 +29,7 @@ public class QuestionVo {
 
     private Date createTime;
 
+
     @com.baomidou.mybatisplus.annotation.TableField(exist = false)
     private java.lang.Integer page;
     @com.baomidou.mybatisplus.annotation.TableField(exist = false)

+ 1 - 1
hcp-platform/src/main/java/com/yingyangfly/platform/sys/controller/UploadFileController.java

@@ -32,7 +32,7 @@ public class UploadFileController {
     private FileClient fileClient;
 
     // 允许上传的文件类型
-    private static final List<String> ALLOWED_FILE_TYPES = Arrays.asList("png", "jpg", "jpeg", "doc", "xls", "ppt", "mp4", "pdf");
+    private static final List<String> ALLOWED_FILE_TYPES = Arrays.asList("png", "jpg", "jpeg", "doc", "xls", "ppt", "mp4", "pdf", "apk");
 
     /**
      * 通用上传