瀏覽代碼

Merge remote-tracking branch 'origin/master'

yumeng 2 年之前
父節點
當前提交
03a1eda55c

+ 16 - 8
ruixuan-live/src/main/java/com/ruixuan/isc/controller/KuaishouPromoterController.java

@@ -1,6 +1,5 @@
 package com.ruixuan.isc.controller;
 
-import com.alibaba.fastjson.JSONObject;
 import com.ruixuan.common.core.controller.BaseController;
 import com.ruixuan.common.core.domain.AjaxResult;
 import com.ruixuan.common.core.page.TableDataInfo;
@@ -10,9 +9,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -60,13 +57,22 @@ public class KuaishouPromoterController extends BaseController {
      * 获取快手达人信息
      */
     @GetMapping(value = "/getPromoterInfo")
-    @ApiOperation(value = "获取快手达人信息")
+    @ApiOperation(value = "获取快手达人短视频信息")
     public AjaxResult getPromoterInfo(@ApiParam("达人ID") @RequestParam(value = "promoterId", required = true) Long promoterId) {
         return kuaishouPromoterService.getPromoterInfo(promoterId);
     }
 
 
     /**
+     * 获取快手达人信息
+     */
+    @GetMapping(value = "/getOnlyPromoterInfo")
+    @ApiOperation(value = "只获取达人信息")
+    public AjaxResult getOnlyPromoterInfo(@ApiParam("达人ID") @RequestParam(value = "promoterId", required = true) Long promoterId) {
+        return AjaxResult.success(kuaishouPromoterService.getOnlyPromoterInfo(promoterId));
+    }
+
+    /**
      * 新增快手达人 信息
      */
     @PostMapping(value = "/add")
@@ -87,9 +93,11 @@ public class KuaishouPromoterController extends BaseController {
     /**
      * 删除快手达人 信息
      */
-    @DeleteMapping("/{ids}")
-//    @ApiOperation(value = "删除快手达人")
-    public AjaxResult remove(@PathVariable Long[] ids) {
-        return toAjax(kuaishouPromoterService.deleteKuaishouPromoterByIds(ids));
+    @GetMapping("/deleteById")
+    @ApiOperation(value = "删除快手达人")
+    public AjaxResult deleteById(@ApiParam("主键") @RequestParam(value = "id", required = true) Long id,
+                                 @ApiParam("操作人ID") @RequestParam(value = "userId", required = true) Long userId
+    ) {
+        return toAjax(kuaishouPromoterService.deleteKuaishouPromoterById(id, userId));
     }
 }

+ 2 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/KuaishouPromoterMapper.java

@@ -58,4 +58,6 @@ public interface KuaishouPromoterMapper {
     KuaishouPromoter getOneByIdAndPromoterId(@Param("userId") Long userId, @Param("promoterId") Long promoterId);
 
     JSONObject getNearlyMonthGmv(@Param("promoterId") Long promoterId, @Param("start") String start, @Param("end") String end);
+
+    void insertKuaishouPromoterRecord(JSONObject record);
 }

+ 3 - 9
ruixuan-live/src/main/java/com/ruixuan/isc/service/IKuaishouPromoterService.java

@@ -46,20 +46,14 @@ public interface IKuaishouPromoterService {
     public int updateKuaishouPromoter(KuaishouPromoter kuaishouPromoter);
 
     /**
-     * 批量删除快手达人 信息
-     *
-     * @param ids 需要删除的快手达人 信息主键集合
-     * @return 结果
-     */
-    public int deleteKuaishouPromoterByIds(Long[] ids);
-
-    /**
      * 删除快手达人 信息信息
      *
      * @param id 快手达人 信息主键
      * @return 结果
      */
-    public int deleteKuaishouPromoterById(Long id);
+    public int deleteKuaishouPromoterById(Long id, Long userId);
 
     AjaxResult getPromoterInfo(Long promoterId);
+
+    KuaishouPromoter getOnlyPromoterInfo(Long promoterId);
 }

+ 23 - 14
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouPromoterServiceImpl.java

@@ -12,12 +12,14 @@ import com.ruixuan.isc.entity.KuaishouPromoter;
 import com.ruixuan.isc.mapper.KuaishouPromoterMapper;
 import com.ruixuan.isc.service.IKuaishouPromoterService;
 import com.ruixuan.system.service.ISysDeptService;
+import com.ruixuan.system.service.ISysRoleService;
 import com.ruixuan.system.service.ISysUserService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Date;
@@ -50,6 +52,9 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
     private ISysDeptService deptService;
 
     @Autowired
+    private ISysRoleService roleService;
+
+    @Autowired
     private RedisUtil redisUtil;
 
     /**
@@ -69,9 +74,12 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
             // 渠道经理、社群经理 可以看到自己创建的以及自己部门人员的达人信息
             Long deptId = deptService.getDeptIdByUserId(userId);
             userList = deptService.getDeptUserListByDeptId(deptId);
-        } else if ("bd".equals(roleKey) || "association".equals(roleKey)) {
-            // 渠道、社群 可以看到自己创建的达人信息
+        } else if ("bd".equals(roleKey)) {
+            // 渠道可以看到自己创建的达人信息
             userList = Arrays.asList(userId);
+        } else if ("association".equals(roleKey)) {
+            // 社群可以看到所有社群的达人信息
+            userList = sysUserService.getUserIdByRoleKey(roleKey);
         } else {
             return Collections.emptyList();
         }
@@ -189,24 +197,21 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
     }
 
     /**
-     * 批量删除快手达人 信息
-     *
-     * @param ids 需要删除的快手达人 信息主键
-     * @return 结果
-     */
-    @Override
-    public int deleteKuaishouPromoterByIds(Long[] ids) {
-        return kuaishouPromoterMapper.deleteKuaishouPromoterByIds(ids);
-    }
-
-    /**
      * 删除快手达人 信息信息
      *
      * @param id 快手达人 信息主键
      * @return 结果
      */
     @Override
-    public int deleteKuaishouPromoterById(Long id) {
+    public int deleteKuaishouPromoterById(Long id, Long userId) {
+        KuaishouPromoter promoter = kuaishouPromoterMapper.selectKuaishouPromoterById(id);
+        if (Check.isNotNull(promoter)) {
+            JSONObject record = new JSONObject();
+            record.put("promoterId", promoter.getPromoterId());
+            record.put("userId", promoter.getUserId());
+            record.put("operatorId", userId);
+            kuaishouPromoterMapper.insertKuaishouPromoterRecord(record);
+        }
         return kuaishouPromoterMapper.deleteKuaishouPromoterById(id);
     }
 
@@ -257,4 +262,8 @@ public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
         return ajaxResult;
     }
 
+    @Override
+    public KuaishouPromoter getOnlyPromoterInfo(Long promoterId) {
+            return kuaishouPromoterMapper.getOneByIdAndPromoterId(null, promoterId);
+    }
 }

+ 17 - 0
ruixuan-live/src/main/resources/mapper/isc/KuaishouPromoterMapper.xml

@@ -170,4 +170,21 @@
           AND FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') >= #{start}
           AND FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') <= #{end}
     </select>
+
+
+    <insert id="insertKuaishouPromoterRecord" parameterType="com.alibaba.fastjson.JSONObject" useGeneratedKeys="true"
+            keyProperty="id">
+        insert into kuaishou_promoter_record
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="promoterId != null">promoter_id,</if>
+            <if test="userId != null">user_id,</if>
+            <if test="operatorId != null">operator_id,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="promoterId != null">#{promoterId},</if>
+            <if test="userId != null">#{userId},</if>
+            <if test="operatorId != null">#{operatorId},</if>
+        </trim>
+    </insert>
+
 </mapper>

+ 2 - 0
ruixuan-system/src/main/java/com/ruixuan/system/mapper/SysUserMapper.java

@@ -163,4 +163,6 @@ public interface SysUserMapper {
 
 
     String getRoleKeyByUserId(@Param("userId") String userId);
+
+    List<Long> getUserIdByRoleKey(@Param("roleKey")  String roleKey);
 }

+ 2 - 0
ruixuan-system/src/main/java/com/ruixuan/system/service/ISysUserService.java

@@ -227,4 +227,6 @@ public interface ISysUserService {
     List<JSONObject> getUserByRoleName(List<String> roleCodeList);
 
     String getRoleKeyByUserId(String userId);
+
+    List<Long> getUserIdByRoleKey(String roleKey);
 }

+ 5 - 0
ruixuan-system/src/main/java/com/ruixuan/system/service/impl/SysUserServiceImpl.java

@@ -545,4 +545,9 @@ public class SysUserServiceImpl implements ISysUserService {
         return userMapper.getRoleKeyByUserId(userId);
     }
 
+    @Override
+    public List<Long> getUserIdByRoleKey(String roleKey) {
+        return userMapper.getUserIdByRoleKey(roleKey);
+    }
+
 }

+ 23 - 14
ruixuan-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -323,16 +323,13 @@
 
     <!-- 根据用户id 查询用户和角色信息-->
     <select id="getUserRoleByUserId" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-            u.*,
-            r.role_name,
-            r.role_key
-        FROM
-            sys_user u
-                LEFT JOIN sys_user_role ur ON ur.user_id = u.user_id
-                LEFT JOIN sys_role r ON r.role_id = ur.role_id
-        WHERE
-            r.del_flag = 0
+        SELECT u.*,
+               r.role_name,
+               r.role_key
+        FROM sys_user u
+                 LEFT JOIN sys_user_role ur ON ur.user_id = u.user_id
+                 LEFT JOIN sys_role r ON r.role_id = ur.role_id
+        WHERE r.del_flag = 0
           AND u.del_flag = 0
           AND u.STATUS = 0
           AND u.user_id = #{userId}
@@ -362,12 +359,24 @@
         </if>
 
     </select>
+
     <select id="getRoleKeyByUserId" resultType="java.lang.String" parameterType="java.lang.String">
-         select t2.role_key
-         from sys_user_role t1
-         left join sys_role t2 on t1.role_id = t2.role_id
-         where t1.user_id = #{userId}
+        select t2.role_key
+        from sys_user_role t1
+                 left join sys_role t2 on t1.role_id = t2.role_id
+        where t1.user_id = #{userId}
     </select>
 
 
+    <select id="getUserIdByRoleKey" resultType="java.lang.Long">
+        SELECT u.user_id
+        FROM sys_user u
+                 LEFT JOIN sys_user_role ur ON ur.user_id = u.user_id
+                 LEFT JOIN sys_role r ON r.role_id = ur.role_id
+        WHERE r.del_flag = 0
+          AND u.del_flag = 0
+          AND u.STATUS = 0
+          and r.role_key like concat('%', #{roleKey}, '%')
+    </select>
+
 </mapper>