yfh пре 1 недеља
родитељ
комит
ab0107a709

+ 4 - 4
fs-admin/src/main/java/com/fs/course/controller/FsUserCourseController.java

@@ -82,10 +82,10 @@ public class FsUserCourseController extends BaseController {
     @GetMapping("/publicList")
     public TableDataInfo publicList(FsUserCourse fsUserCourse) {
         startPage();
-        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
-        Long userId = loginUser.getUser().getUserId();
-        String json = configService.selectConfigByKey("course.config");
-        CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
+//        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+//        Long userId = loginUser.getUser().getUserId();
+//        String json = configService.selectConfigByKey("course.config");
+//        CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
       /*  if (ObjectUtil.isNotEmpty(config.getIsBound()) && config.getIsBound()) {
             fsUserCourse.setUserId(userId);
         }*/

+ 5 - 0
fs-service/src/main/java/com/fs/his/config/AppConfig.java

@@ -13,4 +13,9 @@ public class AppConfig {
     private Long courseId;
     private List<FsUserCourseVideoVO> fsCourse;
     private Integer unbindLimit;
+
+    private String corpId; //APP客服配置 企业主体id
+    private String corpUrl; //APP客服配置 企业主体链接
+    private Integer addIntegral; //玩一局游戏加多少积分
+    private Integer defaultRewardGold; //看视频获取多少金币
 }

+ 39 - 0
fs-service/src/main/java/com/fs/his/domain/FsUserPlayer.java

@@ -0,0 +1,39 @@
+package com.fs.his.domain;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+import com.fs.common.core.domain.BaseEntity;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 用户游戏记录对象 fs_user_player
+ *
+ * @author fs
+ * @date 2026-02-25
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class FsUserPlayer extends BaseEntity{
+
+    /** 主键id */
+    @TableId
+    private Long id;
+
+    @Excel(name = "用户id")
+    private Long userId;
+
+    /** 游戏类型 */
+    @Excel(name = "游戏类型")
+    private Integer gameId;
+
+    /** 等级 */
+    @Excel(name = "等级")
+    private Integer level;
+
+    /** 星星数 */
+    @Excel(name = "星星数")
+    private String star;
+
+
+}

+ 67 - 0
fs-service/src/main/java/com/fs/his/mapper/FsUserPlayerMapper.java

@@ -0,0 +1,67 @@
+package com.fs.his.mapper;
+
+import java.util.List;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fs.his.domain.FsUserPlayer;
+import com.fs.his.vo.FsUserPlayerVo;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 用户游戏记录Mapper接口
+ *
+ * @author fs
+ * @date 2026-02-25
+ */
+public interface FsUserPlayerMapper extends BaseMapper<FsUserPlayer>{
+    /**
+     * 查询用户游戏记录
+     *
+     * @param id 用户游戏记录主键
+     * @return 用户游戏记录
+     */
+    FsUserPlayer selectFsUserPlayerById(Long id);
+
+    /**
+     * 查询用户游戏记录列表
+     *
+     * @param fsUserPlayer 用户游戏记录
+     * @return 用户游戏记录集合
+     */
+    List<FsUserPlayer> selectFsUserPlayerList(FsUserPlayer fsUserPlayer);
+
+    /**
+     * 新增用户游戏记录
+     *
+     * @param fsUserPlayer 用户游戏记录
+     * @return 结果
+     */
+    int insertFsUserPlayer(FsUserPlayer fsUserPlayer);
+
+    /**
+     * 修改用户游戏记录
+     *
+     * @param fsUserPlayer 用户游戏记录
+     * @return 结果
+     */
+    int updateFsUserPlayer(FsUserPlayer fsUserPlayer);
+
+    /**
+     * 删除用户游戏记录
+     *
+     * @param id 用户游戏记录主键
+     * @return 结果
+     */
+    int deleteFsUserPlayerById(Long id);
+
+    /**
+     * 批量删除用户游戏记录
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    int deleteFsUserPlayerByIds(Long[] ids);
+
+    FsUserPlayerVo selectFsUserByUserIdAndGameId(@Param("userId") Long userId,@Param("gameId") Integer gameId);
+
+    int updateFsUserPlayerByUserIdAndGameId(FsUserPlayer fsUserPlayer);
+}

+ 67 - 0
fs-service/src/main/java/com/fs/his/service/IFsUserPlayerService.java

@@ -0,0 +1,67 @@
+package com.fs.his.service;
+
+import java.util.List;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.fs.his.domain.FsUser;
+import com.fs.his.domain.FsUserPlayer;
+import com.fs.his.vo.FsUserPlayerVo;
+
+/**
+ * 用户游戏记录Service接口
+ *
+ * @author fs
+ * @date 2026-02-25
+ */
+public interface IFsUserPlayerService extends IService<FsUserPlayer>{
+    /**
+     * 查询用户游戏记录
+     *
+     * @param id 用户游戏记录主键
+     * @return 用户游戏记录
+     */
+    FsUserPlayer selectFsUserPlayerById(Long id);
+
+    /**
+     * 查询用户游戏记录列表
+     *
+     * @param fsUserPlayer 用户游戏记录
+     * @return 用户游戏记录集合
+     */
+    List<FsUserPlayer> selectFsUserPlayerList(FsUserPlayer fsUserPlayer);
+
+    /**
+     * 新增用户游戏记录
+     *
+     * @param fsUserPlayer 用户游戏记录
+     * @return 结果
+     */
+    int insertFsUserPlayer(FsUserPlayer fsUserPlayer);
+
+    /**
+     * 修改用户游戏记录
+     *
+     * @param fsUserPlayer 用户游戏记录
+     * @return 结果
+     */
+    int updateFsUserPlayer(FsUserPlayer fsUserPlayer);
+
+    /**
+     * 批量删除用户游戏记录
+     *
+     * @param ids 需要删除的用户游戏记录主键集合
+     * @return 结果
+     */
+    int deleteFsUserPlayerByIds(Long[] ids);
+
+    /**
+     * 删除用户游戏记录信息
+     *
+     * @param id 用户游戏记录主键
+     * @return 结果
+     */
+    int deleteFsUserPlayerById(Long id);
+
+    FsUserPlayerVo selectFsUserByUserIdAndGameId(Long userId,Integer gameId);
+
+    int updateFsUserPlayerByUserIdAndGameId(FsUserPlayer fsUserPlayer);
+}

+ 131 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsUserPlayerServiceImpl.java

@@ -0,0 +1,131 @@
+package com.fs.his.service.impl;
+
+import java.util.List;
+import com.fs.common.utils.DateUtils;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fs.his.domain.FsUser;
+import com.fs.his.domain.FsUserPlayer;
+import com.fs.his.mapper.FsUserMapper;
+import com.fs.his.mapper.FsUserPlayerMapper;
+import com.fs.his.service.IFsUserPlayerService;
+import com.fs.his.service.IFsUserService;
+import com.fs.his.vo.FsUserPlayerVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * 用户游戏记录Service业务层处理
+ *
+ * @author fs
+ * @date 2026-02-25
+ */
+@Service
+public class FsUserPlayerServiceImpl extends ServiceImpl<FsUserPlayerMapper, FsUserPlayer> implements IFsUserPlayerService {
+
+    @Autowired
+    private FsUserMapper fsUserMapper;
+
+
+    /**
+     * 查询用户游戏记录
+     *
+     * @param id 用户游戏记录主键
+     * @return 用户游戏记录
+     */
+    @Override
+    public FsUserPlayer selectFsUserPlayerById(Long id)
+    {
+        return baseMapper.selectFsUserPlayerById(id);
+    }
+
+    /**
+     * 查询用户游戏记录列表
+     *
+     * @param fsUserPlayer 用户游戏记录
+     * @return 用户游戏记录
+     */
+    @Override
+    public List<FsUserPlayer> selectFsUserPlayerList(FsUserPlayer fsUserPlayer)
+    {
+        return baseMapper.selectFsUserPlayerList(fsUserPlayer);
+    }
+
+    /**
+     * 新增用户游戏记录
+     *
+     * @param fsUserPlayer 用户游戏记录
+     * @return 结果
+     */
+    @Override
+    public int insertFsUserPlayer(FsUserPlayer fsUserPlayer)
+    {
+        fsUserPlayer.setCreateTime(DateUtils.getNowDate());
+        return baseMapper.insertFsUserPlayer(fsUserPlayer);
+    }
+
+    /**
+     * 修改用户游戏记录
+     *
+     * @param fsUserPlayer 用户游戏记录
+     * @return 结果
+     */
+    @Override
+    public int updateFsUserPlayer(FsUserPlayer fsUserPlayer)
+    {
+        fsUserPlayer.setUpdateTime(DateUtils.getNowDate());
+        return baseMapper.updateFsUserPlayer(fsUserPlayer);
+    }
+
+    /**
+     * 批量删除用户游戏记录
+     *
+     * @param ids 需要删除的用户游戏记录主键
+     * @return 结果
+     */
+    @Override
+    public int deleteFsUserPlayerByIds(Long[] ids)
+    {
+        return baseMapper.deleteFsUserPlayerByIds(ids);
+    }
+
+    /**
+     * 删除用户游戏记录信息
+     *
+     * @param id 用户游戏记录主键
+     * @return 结果
+     */
+    @Override
+    public int deleteFsUserPlayerById(Long id)
+    {
+        return baseMapper.deleteFsUserPlayerById(id);
+    }
+
+    @Override
+    public FsUserPlayerVo selectFsUserByUserIdAndGameId(Long userId,Integer gameId) {
+        if (userId == null || gameId == null) {
+            return null;
+        }
+        FsUserPlayerVo fsUserPlayerVo = baseMapper.selectFsUserByUserIdAndGameId(userId, gameId);
+        if(fsUserPlayerVo == null){
+            //查询用户是否存在
+            FsUser fsUser = fsUserMapper.selectFsUserByUserId(userId);
+            if(fsUser == null){
+                return null;
+            }
+            FsUserPlayer fsUserPlayer = new FsUserPlayer();
+            fsUserPlayer.setGameId(gameId);
+            fsUserPlayer.setUserId(userId);
+            fsUserPlayer.setLevel(1); //等级
+            fsUserPlayer.setStar("{}"); //星星数
+            insertFsUserPlayer(fsUserPlayer);
+            fsUserPlayerVo = baseMapper.selectFsUserByUserIdAndGameId(userId, gameId);
+        }
+        return fsUserPlayerVo;
+    }
+
+    @Override
+    public int updateFsUserPlayerByUserIdAndGameId(FsUserPlayer fsUserPlayer) {
+        fsUserPlayer.setUpdateTime(DateUtils.getNowDate());
+        return baseMapper.updateFsUserPlayerByUserIdAndGameId(fsUserPlayer);
+    }
+}

+ 12 - 0
fs-service/src/main/java/com/fs/his/vo/FsUserPlayerVo.java

@@ -0,0 +1,12 @@
+package com.fs.his.vo;
+
+import com.fs.his.domain.FsUserPlayer;
+import lombok.Data;
+
+@Data
+public class FsUserPlayerVo extends FsUserPlayer {
+    private String nickName;
+    private String avatar;
+    private Long integral;
+
+}

+ 96 - 0
fs-service/src/main/resources/mapper/his/FsUserPlayerMapper.xml

@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fs.his.mapper.FsUserPlayerMapper">
+
+    <resultMap type="FsUserPlayer" id="FsUserPlayerResult">
+        <result property="id"    column="id"    />
+        <result property="userId"    column="user_id"    />
+        <result property="gameId"    column="game_id"    />
+        <result property="level"    column="level"    />
+        <result property="star"    column="star"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateTime"    column="update_time"    />
+    </resultMap>
+
+    <sql id="selectFsUserPlayerVo">
+        select id, user_id, game_id, level, star, create_time, update_time from fs_user_player
+    </sql>
+
+    <select id="selectFsUserPlayerList" parameterType="FsUserPlayer" resultMap="FsUserPlayerResult">
+        <include refid="selectFsUserPlayerVo"/>
+        <where>
+            <if test="userId != null "> and user_id = #{userId}</if>
+            <if test="gameId != null "> and game_id = #{gameId}</if>
+            <if test="level != null "> and `level` = #{level}</if>
+            <if test="star != null "> and star = #{star}</if>
+        </where>
+    </select>
+
+    <select id="selectFsUserPlayerById" parameterType="Long" resultMap="FsUserPlayerResult">
+        <include refid="selectFsUserPlayerVo"/>
+        where id = #{id}
+    </select>
+    <select id="selectFsUserByUserIdAndGameId" resultType="com.fs.his.vo.FsUserPlayerVo">
+        select fup.id, fup.user_id, fup.game_id, fup.level, fup.star, fup.create_time, fup.update_time,fu.nick_name,
+               fu.avatar,fu.integral
+        from fs_user_player fup
+        inner join fs_user fu on fu.user_id = fup.user_id
+        WHERE
+            fup.user_id = #{userId} and fup.game_id = #{gameId}
+    </select>
+
+    <insert id="insertFsUserPlayer" parameterType="FsUserPlayer" useGeneratedKeys="true" keyProperty="id">
+        insert into fs_user_player
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="userId != null">user_id,</if>
+            <if test="gameId != null">game_id,</if>
+            <if test="level != null">`level`,</if>
+            <if test="star != null">star,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="userId != null">#{userId},</if>
+            <if test="gameId != null">#{gameId},</if>
+            <if test="level != null">#{level},</if>
+            <if test="star != null">#{star},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+         </trim>
+    </insert>
+
+    <update id="updateFsUserPlayer" parameterType="FsUserPlayer">
+        update fs_user_player
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="userId != null">user_id = #{userId},</if>
+            <if test="gameId != null">game_id = #{gameId},</if>
+            <if test="level != null">`level` = #{level},</if>
+            <if test="star != null">star = #{star},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+    <update id="updateFsUserPlayerByUserIdAndGameId">
+        update fs_user_player
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="level != null">`level` = #{level},</if>
+            <if test="star != null">star = #{star},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where user_Id = #{userId} and game_id = #{gameId}
+    </update>
+
+    <delete id="deleteFsUserPlayerById" parameterType="Long">
+        delete from fs_user_player where id = #{id}
+    </delete>
+
+    <delete id="deleteFsUserPlayerByIds" parameterType="String">
+        delete from fs_user_player where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 76 - 7
fs-user-app/src/main/java/com/fs/app/controller/game/PlayerController.java

@@ -1,32 +1,101 @@
 package com.fs.app.controller.game;
 
+import cn.hutool.json.JSONUtil;
 import com.fs.app.annotation.Login;
 import com.fs.app.controller.AppBaseController;
 import com.fs.common.core.domain.R;
+import com.fs.his.config.AppConfig;
+import com.fs.his.config.IntegralConfig;
+import com.fs.his.domain.FsUser;
+import com.fs.his.domain.FsUserPlayer;
 import com.fs.his.param.FsUserAddIntegralParam;
 import com.fs.his.service.IFsUserIntegralLogsService;
+import com.fs.his.service.IFsUserPlayerService;
+import com.fs.his.service.IFsUserService;
+import com.fs.his.vo.FsUserPlayerVo;
+import com.fs.system.service.ISysConfigService;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
+
+import static com.fs.his.utils.PhoneUtil.decryptPhoneMk;
 
 
 @RestController
-@RequestMapping("/player")
+@RequestMapping("/app/player")
 public class PlayerController extends AppBaseController {
 
     @Autowired
     private IFsUserIntegralLogsService userIntegralLogsService;
+    @Autowired
+    private IFsUserPlayerService userPlayerService;
+    @Autowired
+    private ISysConfigService configService;
 
-    @Login
     @PostMapping("/updateCurrency")
     @ApiOperation("玩家货币更新")
     public R updateCurrency(@RequestBody FsUserAddIntegralParam param){
-        param.setUserId(Long.parseLong(getUserId()));
+        param.setUserId(param.getUserId());
         param.setType(3);//游戏添加积分
         return userIntegralLogsService.addIntegral(param);
     }
 
+    /**
+     * 获取用户信息
+     * @param userId
+     * @return     */
+    @ApiOperation("获取用户信息")
+    @GetMapping("/getUserInfo")
+    public R getUserInfo(@RequestParam Long userId,@RequestParam Integer gameId){
+        try {
+            FsUserPlayerVo user=userPlayerService.selectFsUserByUserIdAndGameId(userId,gameId);
+            Map<String,Object> map=new HashMap<>();
+            map.put("user",user);
+            return R.ok(map);
+        } catch (Exception e){
+            return R.error("操作异常");
+        }
+    }
+
+    /**
+     * 获取游戏配置
+     * @param gameId
+     * @return
+     * */
+    @ApiOperation("获取游戏配置")
+    @GetMapping("/config")
+    public R config(@RequestParam Integer gameId){
+        String json = configService.selectConfigByKey("app.config");
+        AppConfig config = JSONUtil.toBean(json, AppConfig.class);
+        if (config == null) {
+            return R.error("游戏配置错误");
+        }else {
+            return R.ok().put("data",config);
+        }
+    }
+
+    /**
+     * 更新用户等级
+     * @param param
+     * @return
+    */
+    @ApiOperation("更新用户等级")
+    @PostMapping("/updateUserPlayer")
+    public R updateUserPlayer(@RequestBody FsUserPlayer param){
+        if (param.getUserId() == null) {
+            return R.error();
+        }
+        FsUserPlayer fsUserPlayer = new FsUserPlayer();
+        fsUserPlayer.setUserId(param.getUserId());
+        fsUserPlayer.setGameId(param.getGameId());
+        fsUserPlayer.setStar(param.getStar());
+        fsUserPlayer.setLevel(param.getLevel());
+        userPlayerService.updateFsUserPlayerByUserIdAndGameId(fsUserPlayer);
+        return R.ok();
+    }
+
 }