소스 검색

总后台直播红包控制台

chenguo 2 일 전
부모
커밋
cebfac7bc8

+ 2 - 1
fs-admin/src/main/java/com/fs/live/controller/LiveLotteryConfController.java

@@ -91,7 +91,8 @@ public class LiveLotteryConfController extends BaseController
     @PutMapping
     public R edit(@RequestBody LiveLotteryConf liveLotteryConf)
     {
-        return R.ok(liveLotteryConfService.updateLiveLotteryConf(liveLotteryConf));
+        liveLotteryConfService.updateLiveLotteryConf(liveLotteryConf);
+        return R.ok(liveLotteryConf.getLotteryStatus());
     }
 
     /**

+ 4 - 7
fs-admin/src/main/java/com/fs/live/controller/LiveRedConfController.java

@@ -2,6 +2,7 @@ package com.fs.live.controller;
 
 import java.util.List;
 
+import com.fs.common.core.domain.R;
 import com.fs.live.param.RedPO;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -80,9 +81,10 @@ public class LiveRedConfController extends BaseController
     @PreAuthorize("@ss.hasPermi('live:liveRedConf:edit')")
     @Log(title = "直播红包记录配置", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody LiveRedConf liveRedConf)
+    public R edit(@RequestBody LiveRedConf liveRedConf)
     {
-        return toAjax(liveRedConfService.updateLiveRedConf(liveRedConf));
+        liveRedConfService.updateLiveRedConf(liveRedConf);
+        return R.ok(liveRedConf.getRedStatus().toString());
     }
 
     /**
@@ -96,11 +98,6 @@ public class LiveRedConfController extends BaseController
         return toAjax(liveRedConfService.deleteLiveRedConfByRedIds(redIds));
     }
 
-    @GetMapping("/{id}")
-    public LiveRedConf getById(@PathVariable Long id) {
-        return liveRedConfService.getById(id);
-    }
-
     @GetMapping("/live/{liveId}")
     public List<LiveRedConf> getByLiveId(@PathVariable Long liveId) {
         return liveRedConfService.getByLiveId(liveId);

+ 8 - 0
fs-live-app/src/main/java/com/fs/app/websocket/service/WebSocketServer.java

@@ -209,6 +209,14 @@ public class WebSocketServer {
                     // 广播消息
                     broadcastMessage(liveId, JSONObject.toJSONString(R.ok().put("data", msg)));
                     break;
+                case "sendGift":
+                    break;
+                case "red":
+                    System.out.println("红包");
+                    break;
+                case "lottery":
+                    System.out.println("抽奖");
+                    break;
             }
         } catch (Exception e) {
             log.error("webSocket 消息处理失败 msg: {}", e.getMessage(), e);

+ 1 - 1
fs-service/src/main/java/com/fs/live/domain/LiveLotteryRecord.java

@@ -27,7 +27,7 @@ public class LiveLotteryRecord extends BaseEntity{
 
     /** 抽奖状态 0:未开始 1:进行中 2:已结束 */
     @Excel(name = "抽奖状态 0:未开始 1:进行中 2:已结束")
-    private Long lotteryStauts;
+    private Long lotterystatus;
 
 
 

+ 2 - 2
fs-service/src/main/java/com/fs/live/mapper/LiveRedConfMapper.java

@@ -68,7 +68,7 @@ public interface LiveRedConfMapper extends BaseMapper<LiveRedConf>{
     List<LiveRedConf> selectByLiveId(Long liveId);
 
     @Insert({
-            "INSERT INTO live_red_conf (red_stauts, duration, red_type, live_id, red_num,"+
+            "INSERT INTO live_red_conf (red_status, duration, red_type, live_id, red_num,"+
             "total_lots, total_send, `desc`, create_time, update_time, create_by, update_by)"+
             "VALUES (#{redStatus}, #{duration}, #{redType}, #{liveId}, #{redNum},"+
             "#{totalLots}, #{totalSend}, #{desc}, NOW(), null, null, null)"
@@ -77,7 +77,7 @@ public interface LiveRedConfMapper extends BaseMapper<LiveRedConf>{
     int insert(LiveRedConf conf);
 
     @Update({
-            "UPDATE live_red_conf SET red_stauts = #{redStatus}, duration = #{duration},"+
+            "UPDATE live_red_conf SET red_status = #{redStatus}, duration = #{duration},"+
             "red_type = #{redType}, live_id = #{liveId}, red_num = #{redNum},"+
             "total_lots = #{totalLots}, total_send = #{totalSend}, `desc` = #{desc},"+
             "update_time = NOW()"+

+ 1 - 1
fs-service/src/main/java/com/fs/live/service/ILiveLotteryConfService.java

@@ -43,7 +43,7 @@ public interface ILiveLotteryConfService extends IService<LiveLotteryConf>{
      * @param liveLotteryConf 直播抽奖配置
      * @return 结果
      */
-    String updateLiveLotteryConf(LiveLotteryConf liveLotteryConf);
+    int updateLiveLotteryConf(LiveLotteryConf liveLotteryConf);
 
     /**
      * 批量删除直播抽奖配置

+ 4 - 6
fs-service/src/main/java/com/fs/live/service/impl/LiveLotteryConfServiceImpl.java

@@ -74,17 +74,15 @@ public class LiveLotteryConfServiceImpl extends ServiceImpl<LiveLotteryConfMappe
      * @return 结果
      */
     @Override
-    public String updateLiveLotteryConf(LiveLotteryConf liveLotteryConf)
+    public int updateLiveLotteryConf(LiveLotteryConf liveLotteryConf)
     {
         if("1".equals(liveLotteryConf.getLotteryStatus())){
             List<LiveLotteryProduct> prizes = productMapper.selectLiveLotteryProductConfByLotteryId(liveLotteryConf.getLotteryId());
-            if (prizes != null && !prizes.isEmpty()){
-                return baseMapper.updateLiveLotteryConf(liveLotteryConf)+"";
-            }else{
-                return "请先添加奖品";
+            if (prizes == null || prizes.isEmpty()){
+                throw new RuntimeException("请先添加奖品");
             }
         }
-        return "1";
+        return baseMapper.updateLiveLotteryConf(liveLotteryConf);
 
     }
 

+ 6 - 6
fs-service/src/main/resources/mapper/live/LiveLotteryRecordMapper.xml

@@ -7,7 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <resultMap type="LiveLotteryRecord" id="LiveLotteryRecordResult">
         <result property="lotteryId"    column="lottery_id"    />
         <result property="liveId"    column="live_id"    />
-        <result property="lotteryStauts"    column="lottery_stauts"    />
+        <result property="lotterystatus"    column="lottery_status"    />
         <result property="createTime"    column="create_time"    />
         <result property="updateTime"    column="update_time"    />
         <result property="createBy"    column="create_by"    />
@@ -15,14 +15,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectLiveLotteryRecordVo">
-        select lottery_id, live_id, lottery_stauts, create_time, update_time, create_by, update_by from live_lottery_record
+        select lottery_id, live_id, lottery_status, create_time, update_time, create_by, update_by from live_lottery_record
     </sql>
 
     <select id="selectLiveLotteryRecordList" parameterType="LiveLotteryRecord" resultMap="LiveLotteryRecordResult">
         <include refid="selectLiveLotteryRecordVo"/>
         <where>
             <if test="liveId != null "> and live_id = #{liveId}</if>
-            <if test="lotteryStauts != null "> and lottery_stauts = #{lotteryStauts}</if>
+            <if test="lotterystatus != null "> and lottery_status = #{lotterystatus}</if>
             <if test="updateTime != null "> and update_time = #{updateTime}</if>
         </where>
     </select>
@@ -36,7 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         insert into live_lottery_record
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="liveId != null">live_id,</if>
-            <if test="lotteryStauts != null">lottery_stauts,</if>
+            <if test="lotterystatus != null">lottery_status,</if>
             <if test="createTime != null">create_time,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="createBy != null">create_by,</if>
@@ -44,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="liveId != null">#{liveId},</if>
-            <if test="lotteryStauts != null">#{lotteryStauts},</if>
+            <if test="lotterystatus != null">#{lotterystatus},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="createBy != null">#{createBy},</if>
@@ -56,7 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         update live_lottery_record
         <trim prefix="SET" suffixOverrides=",">
             <if test="liveId != null">live_id = #{liveId},</if>
-            <if test="lotteryStauts != null">lottery_stauts = #{lotteryStauts},</if>
+            <if test="lotterystatus != null">lottery_status = #{lotterystatus},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="createBy != null">create_by = #{createBy},</if>

+ 5 - 5
fs-service/src/main/resources/mapper/live/LiveRedConfMapper.xml

@@ -6,7 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <resultMap type="LiveRedConf" id="LiveRedConfResult">
         <result property="redId"    column="red_id"    />
-        <result property="redStatus"    column="red_stauts"    />
+        <result property="redStatus"    column="red_status"    />
         <result property="duration"    column="duration"    />
         <result property="redType"    column="red_type"    />
         <result property="liveId"    column="live_id"    />
@@ -21,13 +21,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectLiveRedConfVo">
-        select red_id, red_stauts, duration, red_type, live_id, red_num, total_lots, total_send, `desc`, create_time, update_time, create_by, update_by from live_red_conf
+        select red_id, red_status, duration, red_type, live_id, red_num, total_lots, total_send, `desc`, create_time, update_time, create_by, update_by from live_red_conf
     </sql>
 
     <select id="selectLiveRedConfList" parameterType="LiveRedConf" resultMap="LiveRedConfResult">
         <include refid="selectLiveRedConfVo"/>
         <where>
-            <if test="redStatus != null "> and red_stauts = #{redStatus}</if>
+            <if test="redStatus != null "> and red_status = #{redStatus}</if>
             <if test="redType != null "> and red_type = #{redType}</if>
             <if test="liveId != null "> and live_id = #{liveId}</if>
             <if test="desc != null  and desc != ''"> and `desc` = #{desc}</if>
@@ -44,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <insert id="insertLiveRedConf" parameterType="LiveRedConf" useGeneratedKeys="true" keyProperty="redId">
         insert into live_red_conf
         <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test="redStatus != null">red_stauts,</if>
+            <if test="redStatus != null">red_status,</if>
             <if test="duration != null">duration,</if>
             <if test="redType != null">red_type,</if>
             <if test="liveId != null">live_id,</if>
@@ -76,7 +76,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <update id="updateLiveRedConf" parameterType="LiveRedConf">
         update live_red_conf
         <trim prefix="SET" suffixOverrides=",">
-            <if test="redStatus != null">red_stauts = #{redStatus},</if>
+            <if test="redStatus != null">red_status = #{redStatus},</if>
             <if test="duration != null">duration = #{duration},</if>
             <if test="redType != null">red_type = #{redType},</if>
             <if test="liveId != null">live_id = #{liveId},</if>