Browse Source

达人管理功能(初版)

zhaoxian 2 years ago
parent
commit
0e1b123af5

File diff suppressed because it is too large
+ 32 - 28
ruixuan-admin/src/main/resources/application-dev.yml


File diff suppressed because it is too large
+ 5 - 0
ruixuan-admin/src/main/resources/application-prod.yml


+ 51 - 51
ruixuan-common/src/main/java/com/ruixuan/common/core/controller/BaseController.java

@@ -1,12 +1,5 @@
 package com.ruixuan.common.core.controller;
 package com.ruixuan.common.core.controller;
 
 
-import java.beans.PropertyEditorSupport;
-import java.util.Date;
-import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.web.bind.WebDataBinder;
-import org.springframework.web.bind.annotation.InitBinder;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
 import com.ruixuan.common.constant.HttpStatus;
 import com.ruixuan.common.constant.HttpStatus;
@@ -20,28 +13,32 @@ import com.ruixuan.common.utils.PageUtils;
 import com.ruixuan.common.utils.SecurityUtils;
 import com.ruixuan.common.utils.SecurityUtils;
 import com.ruixuan.common.utils.StringUtils;
 import com.ruixuan.common.utils.StringUtils;
 import com.ruixuan.common.utils.sql.SqlUtil;
 import com.ruixuan.common.utils.sql.SqlUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.WebDataBinder;
+import org.springframework.web.bind.annotation.InitBinder;
+
+import java.beans.PropertyEditorSupport;
+import java.util.Date;
+import java.util.List;
 
 
 /**
 /**
  * web层通用数据处理
  * web层通用数据处理
- * 
+ *
  * @author ruoyi
  * @author ruoyi
  */
  */
-public class BaseController
-{
+public class BaseController {
     protected final Logger logger = LoggerFactory.getLogger(this.getClass());
     protected final Logger logger = LoggerFactory.getLogger(this.getClass());
 
 
     /**
     /**
      * 将前台传递过来的日期格式的字符串,自动转化为Date类型
      * 将前台传递过来的日期格式的字符串,自动转化为Date类型
      */
      */
     @InitBinder
     @InitBinder
-    public void initBinder(WebDataBinder binder)
-    {
+    public void initBinder(WebDataBinder binder) {
         // Date 类型转换
         // Date 类型转换
-        binder.registerCustomEditor(Date.class, new PropertyEditorSupport()
-        {
+        binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
             @Override
             @Override
-            public void setAsText(String text)
-            {
+            public void setAsText(String text) {
                 setValue(DateUtils.parseDate(text));
                 setValue(DateUtils.parseDate(text));
             }
             }
         });
         });
@@ -50,19 +47,16 @@ public class BaseController
     /**
     /**
      * 设置请求分页数据
      * 设置请求分页数据
      */
      */
-    protected void startPage()
-    {
+    protected void startPage() {
         PageUtils.startPage();
         PageUtils.startPage();
     }
     }
 
 
     /**
     /**
      * 设置请求排序数据
      * 设置请求排序数据
      */
      */
-    protected void startOrderBy()
-    {
+    protected void startOrderBy() {
         PageDomain pageDomain = TableSupport.buildPageRequest();
         PageDomain pageDomain = TableSupport.buildPageRequest();
-        if (StringUtils.isNotEmpty(pageDomain.getOrderBy()))
-        {
+        if (StringUtils.isNotEmpty(pageDomain.getOrderBy())) {
             String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
             String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
             PageHelper.orderBy(orderBy);
             PageHelper.orderBy(orderBy);
         }
         }
@@ -71,17 +65,15 @@ public class BaseController
     /**
     /**
      * 清理分页的线程变量
      * 清理分页的线程变量
      */
      */
-    protected void clearPage()
-    {
+    protected void clearPage() {
         PageUtils.clearPage();
         PageUtils.clearPage();
     }
     }
 
 
     /**
     /**
      * 响应请求分页数据
      * 响应请求分页数据
      */
      */
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    protected TableDataInfo getDataTable(List<?> list)
-    {
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    protected TableDataInfo getDataTable(List<?> list) {
         TableDataInfo rspData = new TableDataInfo();
         TableDataInfo rspData = new TableDataInfo();
         rspData.setCode(HttpStatus.SUCCESS);
         rspData.setCode(HttpStatus.SUCCESS);
         rspData.setMsg("查询成功");
         rspData.setMsg("查询成功");
@@ -93,94 +85,102 @@ public class BaseController
     /**
     /**
      * 返回成功
      * 返回成功
      */
      */
-    public AjaxResult success()
-    {
+    public AjaxResult success() {
         return AjaxResult.success();
         return AjaxResult.success();
     }
     }
 
 
     /**
     /**
      * 返回失败消息
      * 返回失败消息
      */
      */
-    public AjaxResult error()
-    {
+    public AjaxResult error() {
         return AjaxResult.error();
         return AjaxResult.error();
     }
     }
 
 
     /**
     /**
      * 返回成功消息
      * 返回成功消息
      */
      */
-    public AjaxResult success(String message)
-    {
+    public AjaxResult success(String message) {
         return AjaxResult.success(message);
         return AjaxResult.success(message);
     }
     }
 
 
     /**
     /**
      * 返回失败消息
      * 返回失败消息
      */
      */
-    public AjaxResult error(String message)
-    {
+    public AjaxResult error(String message) {
         return AjaxResult.error(message);
         return AjaxResult.error(message);
     }
     }
 
 
     /**
     /**
      * 响应返回结果
      * 响应返回结果
-     * 
+     *
      * @param rows 影响行数
      * @param rows 影响行数
      * @return 操作结果
      * @return 操作结果
      */
      */
-    protected AjaxResult toAjax(int rows)
-    {
+    protected AjaxResult toAjax(int rows) {
         return rows > 0 ? AjaxResult.success() : AjaxResult.error();
         return rows > 0 ? AjaxResult.success() : AjaxResult.error();
     }
     }
 
 
     /**
     /**
      * 响应返回结果
      * 响应返回结果
-     * 
+     *
+     * @param rows 影响行数
+     * @return 操作结果
+     */
+    protected AjaxResult toAjax2(int rows) {
+        AjaxResult result = null;
+        switch (rows) {
+            case 0:
+                result = result.error("该数据已存在,请重新输入");
+                break;
+            case 1:
+                result = AjaxResult.success();
+                break;
+        }
+        return result;
+    }
+
+    /**
+     * 响应返回结果
+     *
      * @param result 结果
      * @param result 结果
      * @return 操作结果
      * @return 操作结果
      */
      */
-    protected AjaxResult toAjax(boolean result)
-    {
+    protected AjaxResult toAjax(boolean result) {
         return result ? success() : error();
         return result ? success() : error();
     }
     }
 
 
     /**
     /**
      * 页面跳转
      * 页面跳转
      */
      */
-    public String redirect(String url)
-    {
+    public String redirect(String url) {
         return StringUtils.format("redirect:{}", url);
         return StringUtils.format("redirect:{}", url);
     }
     }
 
 
     /**
     /**
      * 获取用户缓存信息
      * 获取用户缓存信息
      */
      */
-    public LoginUser getLoginUser()
-    {
+    public LoginUser getLoginUser() {
         return SecurityUtils.getLoginUser();
         return SecurityUtils.getLoginUser();
     }
     }
 
 
     /**
     /**
      * 获取登录用户id
      * 获取登录用户id
      */
      */
-    public Long getUserId()
-    {
+    public Long getUserId() {
         return getLoginUser().getUserId();
         return getLoginUser().getUserId();
     }
     }
 
 
     /**
     /**
      * 获取登录部门id
      * 获取登录部门id
      */
      */
-    public Long getDeptId()
-    {
+    public Long getDeptId() {
         return getLoginUser().getDeptId();
         return getLoginUser().getDeptId();
     }
     }
 
 
     /**
     /**
      * 获取登录用户名
      * 获取登录用户名
      */
      */
-    public String getUsername()
-    {
+    public String getUsername() {
         return getLoginUser().getUsername();
         return getLoginUser().getUsername();
     }
     }
 }
 }

+ 4 - 2
ruixuan-framework/src/main/java/com/ruixuan/framework/config/SecurityConfig.java

@@ -1,6 +1,8 @@
 package com.ruixuan.framework.config;
 package com.ruixuan.framework.config;
 
 
 import com.ruixuan.framework.security.filter.JwtAuthenticationTokenFilter;
 import com.ruixuan.framework.security.filter.JwtAuthenticationTokenFilter;
+import com.ruixuan.framework.security.handle.AuthenticationEntryPointImpl;
+import com.ruixuan.framework.security.handle.LogoutSuccessHandlerImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.http.HttpMethod;
 import org.springframework.http.HttpMethod;
@@ -15,8 +17,6 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
 import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
 import org.springframework.security.web.authentication.logout.LogoutFilter;
 import org.springframework.security.web.authentication.logout.LogoutFilter;
 import org.springframework.web.filter.CorsFilter;
 import org.springframework.web.filter.CorsFilter;
-import com.ruixuan.framework.security.handle.AuthenticationEntryPointImpl;
-import com.ruixuan.framework.security.handle.LogoutSuccessHandlerImpl;
 
 
 /**
 /**
  * spring security配置
  * spring security配置
@@ -122,6 +122,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
                 .antMatchers("/itemCollectSamples/*").permitAll()
                 .antMatchers("/itemCollectSamples/*").permitAll()
                 .antMatchers("/item/*").permitAll()
                 .antMatchers("/item/*").permitAll()
                 .antMatchers("/system/user/*").permitAll()
                 .antMatchers("/system/user/*").permitAll()
+                .antMatchers("/kuaishou/promoter/*").permitAll()
+
                 // 除上面外的所有请求全部需要鉴权认证
                 // 除上面外的所有请求全部需要鉴权认证
                 .anyRequest().authenticated()
                 .anyRequest().authenticated()
                 .and()
                 .and()

+ 87 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/controller/KuaishouPromoterController.java

@@ -0,0 +1,87 @@
+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;
+import com.ruixuan.isc.entity.KuaishouPromoter;
+import com.ruixuan.isc.service.IKuaishouPromoterService;
+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;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 快手达人 信息Controller
+ *
+ * @author ruoyi
+ * @date 2023-02-03
+ */
+
+@Api(tags = "快手达人")
+@RestController
+@RequestMapping("/kuaishou/promoter")
+public class KuaishouPromoterController extends BaseController {
+    @Autowired
+    private IKuaishouPromoterService kuaishouPromoterService;
+
+    /**
+     * 查询快手达人 信息列表
+     */
+    @GetMapping("/list")
+    @ApiOperation(value = "查询快手达人")
+    public TableDataInfo list(@ApiParam("创建人ID") @RequestParam(value = "userId", required = true) Long userId,
+                              @ApiParam("达人ID") @RequestParam(value = "promoterId", required = false) Long promoterId,
+                              @ApiParam("达人名称") @RequestParam(value = "promoterNickName", required = false) String promoterNickName) {
+        startPage();
+        List<KuaishouPromoter> list = kuaishouPromoterService.selectKuaishouPromoterList(userId, promoterId, promoterNickName);
+        return getDataTable(list);
+    }
+
+    /**
+     * 获取快手达人 信息详细信息
+     */
+    @GetMapping(value = "/getById")
+    @ApiOperation(value = "获取快手达人信息详细信息")
+    public AjaxResult getById(@ApiParam("主键") @RequestParam(value = "id", required = true) Long id) {
+        return AjaxResult.success(kuaishouPromoterService.selectKuaishouPromoterById(id));
+    }
+
+
+    /**
+     * 新增快手达人 信息
+     */
+    @PostMapping(value = "/add")
+    @ApiOperation(value = "新增快手达人")
+    public AjaxResult add(@RequestBody KuaishouPromoter kuaishouPromoter) {
+        return toAjax2(kuaishouPromoterService.insertKuaishouPromoter(kuaishouPromoter));
+    }
+
+    /**
+     * 修改快手达人 信息
+     */
+    @PostMapping(value = "/edit")
+    @ApiOperation(value = "修改快手达人")
+    public AjaxResult edit(@RequestBody KuaishouPromoter kuaishouPromoter) {
+        return toAjax(kuaishouPromoterService.updateKuaishouPromoter(kuaishouPromoter));
+    }
+
+    /**
+     * 删除快手达人 信息
+     */
+    @DeleteMapping("/{ids}")
+//    @ApiOperation(value = "删除快手达人")
+    public AjaxResult remove(@PathVariable Long[] ids) {
+        return toAjax(kuaishouPromoterService.deleteKuaishouPromoterByIds(ids));
+    }
+}

+ 127 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/entity/KuaishouPromoter.java

@@ -0,0 +1,127 @@
+package com.ruixuan.isc.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 快手达人 信息对象 kuaishou_promoter
+ */
+@Data
+@ApiModel(value = "KuaishouPromoter", description = "快手达人")
+public class KuaishouPromoter {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    private Long id;
+
+    /**
+     * 创建人ID
+     */
+    @ApiModelProperty(name = "创建人ID")
+    private Long userId;
+
+    /**
+     * 创建人名称
+     */
+    @ApiModelProperty(name = "创建人名称")
+    private String userName;
+
+    /**
+     * 达人id(快手lD)
+     */
+    @ApiModelProperty(name = "达人id(快手lD)")
+    private Long promoterId;
+
+    /**
+     * 达人昵称
+     */
+    @ApiModelProperty(name = "达人昵称")
+    private String promoterNickName;
+
+    /**
+     * 达人状态:1-生效,0-无效
+     */
+    @ApiModelProperty(name = "达人状态:1-生效,0-无效")
+    private String state;
+
+    /**
+     * 省市
+     */
+    @ApiModelProperty(name = "省市")
+    private String province;
+
+    /**
+     * 佣金要求
+     */
+    @ApiModelProperty(name = "佣金要求")
+    private String commissionRequirement;
+
+    /**
+     * 品类要求
+     */
+    @ApiModelProperty(name = "品类要求")
+    private String categoryRequirement;
+    /**
+     * 收货人
+     */
+    @ApiModelProperty(name = "收货人")
+    private String consignee;
+
+    /**
+     * 联系电话
+     */
+    @ApiModelProperty(name = "联系电话")
+    private String phone;
+    /**
+     * 总销售额
+     */
+    @ApiModelProperty(name = "总销售额")
+    private String totalSale;
+    /**
+     * 粉丝数
+     */
+    @ApiModelProperty(name = "粉丝数")
+    private String fansNumber;
+
+    /**
+     * 发货地址
+     */
+    @ApiModelProperty(name = "发货地址")
+    private String promoterAddress;
+
+    /**
+     * 达人头像链接
+     */
+    @ApiModelProperty(name = "达人头像")
+    private String promoterUrl;
+
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    public KuaishouPromoter() {
+    }
+
+    public KuaishouPromoter(Long id, String promoterNickName, String province, String promoterUrl, String fansNumber, String totalSale) {
+        this.id = id;
+        this.promoterNickName = promoterNickName;
+        this.province = province;
+        this.promoterUrl = promoterUrl;
+        this.fansNumber = fansNumber;
+        this.totalSale = totalSale;
+    }
+}

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

@@ -0,0 +1,58 @@
+package com.ruixuan.isc.mapper;
+
+import com.ruixuan.isc.entity.KuaishouPromoter;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface KuaishouPromoterMapper {
+    /**
+     * 查询快手达人 信息
+     *
+     * @param id 快手达人 信息主键
+     * @return 快手达人 信息
+     */
+    public KuaishouPromoter selectKuaishouPromoterById(Long id);
+
+    /**
+     * 查询快手达人 信息列表
+     *
+     * @param kuaishouPromoter 快手达人 信息
+     * @return 快手达人 信息集合
+     */
+    public List<KuaishouPromoter> selectKuaishouPromoterList(@Param("userList") List<Long> userList, @Param("promoterId") Long promoterId, @Param("promoterNickName") String promoterNickName);
+
+    /**
+     * 新增快手达人 信息
+     *
+     * @param kuaishouPromoter 快手达人 信息
+     * @return 结果
+     */
+    public int insertKuaishouPromoter(KuaishouPromoter kuaishouPromoter);
+
+    /**
+     * 修改快手达人 信息
+     *
+     * @param kuaishouPromoter 快手达人 信息
+     * @return 结果
+     */
+    public int updateKuaishouPromoter(KuaishouPromoter kuaishouPromoter);
+
+    /**
+     * 删除快手达人 信息
+     *
+     * @param id 快手达人 信息主键
+     * @return 结果
+     */
+    public int deleteKuaishouPromoterById(Long id);
+
+    /**
+     * 批量删除快手达人 信息
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteKuaishouPromoterByIds(Long[] ids);
+
+    KuaishouPromoter getOneByIdAndPromoterId(@Param("userId") Long userId, @Param("promoterId") Long promoterId);
+}

+ 63 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/IKuaishouPromoterService.java

@@ -0,0 +1,63 @@
+package com.ruixuan.isc.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.ruixuan.isc.entity.KuaishouPromoter;
+
+import java.util.List;
+
+/**
+ * 快手达人 信息Service接口
+ *
+ * @author ruoyi
+ * @date 2023-02-03
+ */
+public interface IKuaishouPromoterService {
+    /**
+     * 查询快手达人 信息
+     *
+     * @param id 快手达人 信息主键
+     * @return 快手达人 信息
+     */
+    public JSONObject selectKuaishouPromoterById(Long id);
+
+    /**
+     * 查询快手达人 信息列表
+     *
+     * @param kuaishouPromoter 快手达人 信息
+     * @return 快手达人 信息集合
+     */
+    public List<KuaishouPromoter> selectKuaishouPromoterList(Long userId, Long promoterId, String promoterNickName);
+
+    /**
+     * 新增快手达人 信息
+     *
+     * @param kuaishouPromoter 快手达人 信息
+     * @return 结果
+     */
+    public int insertKuaishouPromoter(KuaishouPromoter kuaishouPromoter);
+
+    /**
+     * 修改快手达人 信息
+     *
+     * @param kuaishouPromoter 快手达人 信息
+     * @return 结果
+     */
+    public int updateKuaishouPromoter(KuaishouPromoter kuaishouPromoter);
+
+    /**
+     * 批量删除快手达人 信息
+     *
+     * @param ids 需要删除的快手达人 信息主键集合
+     * @return 结果
+     */
+    public int deleteKuaishouPromoterByIds(Long[] ids);
+
+    /**
+     * 删除快手达人 信息信息
+     *
+     * @param id 快手达人 信息主键
+     * @return 结果
+     */
+    public int deleteKuaishouPromoterById(Long id);
+
+}

+ 209 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouPromoterServiceImpl.java

@@ -0,0 +1,209 @@
+package com.ruixuan.isc.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.ruixuan.common.core.domain.entity.SysUser;
+import com.ruixuan.common.utils.Check;
+import com.ruixuan.common.utils.DateUtils;
+import com.ruixuan.common.utils.RedisUtil;
+import com.ruixuan.common.utils.http.HttpUtil;
+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.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.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 快手达人 信息Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2023-02-03
+ */
+@Slf4j
+@Service
+public class KuaishouPromoterServiceImpl implements IKuaishouPromoterService {
+
+    @Value("${promoter.start_ip_path}")
+    private String startIpPath;
+    @Value("${promoter.internal_ip_path}")
+    private String internalIpPath;
+
+    @Autowired
+    private ISysUserService sysUserService;
+
+    @Autowired
+    private KuaishouPromoterMapper kuaishouPromoterMapper;
+
+    @Autowired
+    private ISysDeptService deptService;
+
+    @Autowired
+    private RedisUtil redisUtil;
+
+    /**
+     * 查询快手达人 信息列表
+     *
+     * @param kuaishouPromoter 快手达人 信息
+     * @return 快手达人 信息
+     */
+    @Override
+    public List<KuaishouPromoter> selectKuaishouPromoterList(Long userId, Long promoterId, String promoterNickName) {
+        String roleKey = sysUserService.getRoleKeyByUserId(userId + "");
+        List<Long> userList = null;
+        //角色:供应链管理员、招商、招商经理可以看到所有的达人信息
+        if (roleKey.contains("courtship") || "supplyChainAdmin".equals(roleKey)) {
+
+        } else if ("bdManager".equals(roleKey) || "associationManager".equals(roleKey)) {
+            // 渠道经理、社群经理 可以看到自己创建的以及自己部门人员的达人信息
+            Long deptId = deptService.getDeptIdByUserId(userId);
+            userList = deptService.getDeptUserListByDeptId(deptId);
+        } else if ("bd".equals(roleKey) || "association".equals(roleKey)) {
+            // 渠道、社群 可以看到自己创建的达人信息
+            userList = Arrays.asList(userId);
+//        } else {
+//            return Collections.emptyList();
+        }
+
+        List<KuaishouPromoter> list = kuaishouPromoterMapper.selectKuaishouPromoterList(userList, promoterId, promoterNickName);
+        return list;
+    }
+
+    /**
+     * 查询快手达人 信息
+     *
+     * @param id 快手达人 信息主键
+     * @return 快手达人 信息
+     */
+    @Override
+    public JSONObject selectKuaishouPromoterById(Long id) {
+        JSONObject data = new JSONObject();
+        JSONObject result = null;
+        try {
+            KuaishouPromoter promoter = kuaishouPromoterMapper.selectKuaishouPromoterById(id);
+            if (Check.isNotNull(promoter)) {
+                Thread thread = new Thread() {
+                    @Override
+                    public void run() {
+                        try {
+                            //              demo:PromoterId:1424128656
+                            editPromoter(promoter.getId(), promoter.getPromoterId());
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
+                };
+                thread.start();
+
+                Long startTime = System.currentTimeMillis();
+                String content = HttpUtil.httpGetRequest(internalIpPath + "kuaiShou/promoter/getPromoterInfo?promoterId=" + promoter.getPromoterId());
+                result = JSONObject.parseObject(content);
+                log.info("获取达人详情数据,用时:{}s", (System.currentTimeMillis() - startTime) / 1000);
+                data.put("promoterInfo", promoter);
+                data.put("result", result);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("获取达人详情数据异常,{}", result);
+        }
+        return data;
+    }
+
+
+    /**
+     * 新增快手达人 信息
+     *
+     * @param kuaishouPromoter 快手达人 信息
+     */
+    @Override
+    public int insertKuaishouPromoter(KuaishouPromoter promoter) {
+        KuaishouPromoter one = kuaishouPromoterMapper.getOneByIdAndPromoterId(promoter.getUserId(), promoter.getPromoterId());
+        if (Check.isNotNull(one)) {
+            return 0;
+        }
+        SysUser sysUser = sysUserService.selectUserById(promoter.getUserId());
+        if (Check.isNotNull(sysUser)) {
+            promoter.setUserName(sysUser.getNickName());
+        }
+        int i = kuaishouPromoterMapper.insertKuaishouPromoter(promoter);
+        //              demoPromoterId:1424128656
+        editPromoter(promoter.getId(), promoter.getPromoterId());
+        return i;
+    }
+
+    /**
+     * 同步更新数据
+     */
+    private void editPromoter(Long id, Long promoterId) {
+        try {
+            /*缓存标记,每日第一次访问调用该接口,更新达人部分(昵称,省市,粉丝,总销售,头像等)数据*/
+            String key = DateUtils.getDate() + "_" + id + "_" + promoterId;
+            String value = (String) redisUtil.get(key);
+            if (Check.isNotNull(value) && "1".equals(value)) {
+                return;
+            }
+            redisUtil.set(key, "1", 60 * 60 * 24);
+
+            /*更新达人数据*/
+            Map<String, Object> param = new HashMap<>();
+            param.put("promoterId", promoterId);
+            Long startTime = System.currentTimeMillis();
+            String content = HttpUtil.httpPostRequest(startIpPath + "promoterInfo/getPromoterId", param, null);
+            JSONObject result = JSONObject.parseObject(content);
+            log.info("更新达人信息,用时:{}s,返回结果:{}", (System.currentTimeMillis() - startTime) / 1000, result);
+            if (Check.isNotNull(result)) {
+                KuaishouPromoter kuaishouPromoter = new KuaishouPromoter(
+                        id, result.getString("promoterNickName"),
+                        result.getString("province").concat("-").concat(result.getString("city")),
+                        result.getString("promoterHeadImgUrl"),
+                        result.getString("fanNum"),
+                        result.getString("totalSale"));
+                kuaishouPromoterMapper.updateKuaishouPromoter(kuaishouPromoter);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("更新达人信息异常", e);
+        }
+    }
+
+    /**
+     * 修改快手达人 信息
+     *
+     * @param kuaishouPromoter 快手达人 信息
+     * @return 结果
+     */
+    @Override
+    public int updateKuaishouPromoter(KuaishouPromoter kuaishouPromoter) {
+        return kuaishouPromoterMapper.updateKuaishouPromoter(kuaishouPromoter);
+    }
+
+    /**
+     * 批量删除快手达人 信息
+     *
+     * @param ids 需要删除的快手达人 信息主键
+     * @return 结果
+     */
+    @Override
+    public int deleteKuaishouPromoterByIds(Long[] ids) {
+        return kuaishouPromoterMapper.deleteKuaishouPromoterByIds(ids);
+    }
+
+    /**
+     * 删除快手达人 信息信息
+     *
+     * @param id 快手达人 信息主键
+     * @return 结果
+     */
+    @Override
+    public int deleteKuaishouPromoterById(Long id) {
+        return kuaishouPromoterMapper.deleteKuaishouPromoterById(id);
+    }
+
+}

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

@@ -0,0 +1,155 @@
+<?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.ruixuan.isc.mapper.KuaishouPromoterMapper">
+
+    <resultMap type="com.ruixuan.isc.entity.KuaishouPromoter" id="KuaishouPromoterResult">
+        <result property="id" column="id"/>
+        <result property="userId" column="user_id"/>
+        <result property="userName" column="user_name"/>
+        <result property="promoterId" column="promoter_id"/>
+        <result property="promoterNickName" column="promoter_nick_name"/>
+        <result property="state" column="state"/>
+        <result property="province" column="province"/>
+        <result property="commissionRequirement" column="commission_requirement"/>
+        <result property="categoryRequirement" column="category_requirement"/>
+        <result property="createTime" column="create_time"/>
+        <result property="promoterUrl" column="promoter_url"/>
+        <result property="totalSale" column="total_sale"/>
+        <result property="fansNumber" column="fans_number"/>
+        <result property="phone" column="phone"/>
+        <result property="consignee" column="consignee"/>
+        <result property="promoterAddress" column="promoter_address"/>
+        <result property="updateTime" column="update_time"/>
+    </resultMap>
+
+    <sql id="selectKuaishouPromoterVo">
+        select id,
+               user_id,
+               user_name,
+               promoter_id,
+               promoter_nick_name,
+               `state`,
+               province,
+               commission_requirement,
+               category_requirement,
+               promoter_url,
+               phone,
+               consignee,
+               promoter_address,
+               total_sale,
+               fans_number,
+               create_time,
+               update_time
+        from kuaishou_promoter
+    </sql>
+
+    <select id="selectKuaishouPromoterList" resultMap="KuaishouPromoterResult">
+        <include refid="selectKuaishouPromoterVo"/>
+        <where>
+            <if test="userList != null and userList.size() > 0  ">
+                and user_id in
+                <foreach collection="userList" item="userId" open="(" separator="," close=")">
+                    #{userId}
+                </foreach>
+            </if>
+            <if test="promoterId != null ">
+                and promoter_id = #{promoterId}
+            </if>
+            <if test="promoterNickName != null  and promoterNickName != ''">
+                and promoter_nick_name like concat('%', #{promoterNickName}, '%')
+            </if>
+        </where>
+    </select>
+
+    <select id="selectKuaishouPromoterById" parameterType="Long" resultMap="KuaishouPromoterResult">
+        <include refid="selectKuaishouPromoterVo"/>
+        where id = #{id}
+    </select>
+
+    <select id="getOneByIdAndPromoterId" resultMap="KuaishouPromoterResult">
+        <include refid="selectKuaishouPromoterVo"/>
+        where user_id = #{userId}
+        AND promoter_id = #{promoterId}
+    </select>
+
+    <insert id="insertKuaishouPromoter" parameterType="com.ruixuan.isc.entity.KuaishouPromoter" useGeneratedKeys="true"
+            keyProperty="id">
+        insert into kuaishou_promoter
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="userId != null">user_id,</if>
+            <if test="userName != null">user_name,</if>
+            <if test="promoterId != null">promoter_id,</if>
+            <if test="promoterNickName != null">promoter_nick_name,</if>
+            <if test="state != null">state,</if>
+            <if test="province != null">province,</if>
+            <if test="commissionRequirement != null">commission_requirement,</if>
+            <if test="categoryRequirement != null">category_requirement,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="totalSale != null">total_sale,</if>
+            <if test="fansNumber != null">fans_number,</if>
+            <if test="promoterUrl != null">promoter_url,</if>
+            <if test="phone != null">phone,</if>
+            <if test="consignee != null">consignee,</if>
+            <if test="promoterAddress != null">promoter_address,</if>
+
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="userId != null">#{userId},</if>
+            <if test="userName != null">#{userName},</if>
+            <if test="promoterId != null">#{promoterId},</if>
+            <if test="promoterNickName != null">#{promoterNickName},</if>
+            <if test="state != null">#{state},</if>
+            <if test="province != null">#{province},</if>
+            <if test="commissionRequirement != null">#{commissionRequirement},</if>
+            <if test="categoryRequirement != null">#{categoryRequirement},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="totalSale != null">#{totalSale},</if>
+            <if test="fansNumber != null">#{fansNumber},</if>
+            <if test="promoterUrl != null">#{promoterUrl},</if>
+            <if test="phone != null">#{phone},</if>
+            <if test="consignee != null">#{consignee},</if>
+            <if test="promoterAddress != null">#{promoterAddress},</if>
+        </trim>
+    </insert>
+
+    <update id="updateKuaishouPromoter" parameterType="com.ruixuan.isc.entity.KuaishouPromoter">
+        update kuaishou_promoter
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="userId != null">user_id = #{userId},</if>
+            <if test="userName != null">user_name = #{userName},</if>
+            <if test="promoterId != null">promoter_id = #{promoterId},</if>
+            <if test="promoterNickName != null">promoter_nick_name = #{promoterNickName},</if>
+            <if test="totalSale != null">total_sale = #{totalSale},</if>
+            <if test="fansNumber != null">fans_number = #{fansNumber},</if>
+            <if test="promoterUrl != null">promoter_url = #{promoterUrl},</if>
+            <if test="phone != null">phone = #{phone},</if>
+            <if test="consignee != null">consignee = #{consignee},</if>
+            <if test="promoterAddress != null">promoter_address = #{promoterAddress},</if>
+            <if test="state != null">state = #{state},</if>
+            <if test="province != null">province = #{province},</if>
+            <if test="commissionRequirement != null">commission_requirement = #{commissionRequirement},</if>
+            <if test="categoryRequirement != null">category_requirement = #{categoryRequirement},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteKuaishouPromoterById" parameterType="Long">
+        delete
+        from kuaishou_promoter
+        where id = #{id}
+    </delete>
+
+    <delete id="deleteKuaishouPromoterByIds" parameterType="String">
+        delete from kuaishou_promoter where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+
+</mapper>