2 Achegas ecd14426dd ... b96cda231d

Autor SHA1 Mensaxe Data
  小杜 b96cda231d Merge remote-tracking branch 'origin/master' hai 4 meses
  小杜 bec1628ae0 渠道类型接口 hai 4 meses

+ 71 - 0
yt-agent/agent-service/src/main/java/com/ytpm/controller/AgentDitchController.java

@@ -0,0 +1,71 @@
+package com.ytpm.controller;
+
+import com.ytpm.agent.model.YtDitch;
+import com.ytpm.agent.param.AgentDitchParam;
+import com.ytpm.agent.param.DitchListParam;
+import com.ytpm.agent.view.AgentDitchView;
+import com.ytpm.agent.view.AgentUserInfo;
+import com.ytpm.general.Result;
+import com.ytpm.general.ResultTable;
+import com.ytpm.service.AgentDitchService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.core.annotation.AuthenticationPrincipal;
+import org.springframework.web.bind.annotation.*;
+import springfox.documentation.annotations.ApiIgnore;
+
+import javax.annotation.Resource;
+import java.util.Date;
+
+@Api(tags = "渠道类型管理模块")
+@RestController
+@RequestMapping("/ditch")
+public class AgentDitchController {
+
+    @Resource
+    private AgentDitchService agentDitchService;
+
+    /**
+     * 获取渠道类型列表
+     */
+    @ApiOperation("获取渠道类型列表")
+    @PostMapping("/list")
+    public ResultTable<AgentDitchView> list(@RequestBody DitchListParam param, @ApiIgnore @AuthenticationPrincipal AgentUserInfo userInfo) {
+        return agentDitchService.ditchList(param);
+    }
+
+    /**
+     * 新增渠道类型
+     */
+    @ApiOperation("新增渠道类型")
+    @PostMapping("/addOne")
+    public Result<?> addOne(@RequestBody AgentDitchParam param, @ApiIgnore @AuthenticationPrincipal AgentUserInfo userInfo){
+        YtDitch ytDitch = new YtDitch();
+        ytDitch.setDitchName(param.getDitchName());
+        ytDitch.setCreateTime(new Date());
+        ytDitch.setUserId(userInfo.getUserId());
+        return agentDitchService.addOne(ytDitch);
+    }
+
+    /**
+     * 修改渠道类型
+     */
+    @ApiOperation("修改渠道类型")
+    @PostMapping("/updateOne")
+    public Result<?> updateOne(@RequestBody AgentDitchParam param){
+        YtDitch ytDitch = new YtDitch();
+        ytDitch.setDitchName(param.getDitchName());
+        ytDitch.setDitchId(param.getDitchId());
+        return agentDitchService.updateOne(ytDitch);
+    }
+
+    /**
+     * 删除渠道类型
+     */
+    @ApiOperation("删除渠道类型")
+    @GetMapping("/deleteOne")
+    public Result<?> deleteOne(@RequestParam("ditchId")Long ditchId){
+        return agentDitchService.deleteOne(ditchId);
+    }
+
+}

+ 17 - 0
yt-agent/agent-service/src/main/java/com/ytpm/dao/AgentDitchMapper.java

@@ -0,0 +1,17 @@
+package com.ytpm.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ytpm.agent.model.YtDitch;
+import com.ytpm.agent.param.DitchListParam;
+import com.ytpm.agent.view.AgentDitchView;
+
+import java.util.List;
+
+public interface AgentDitchMapper extends BaseMapper<YtDitch> {
+    List<AgentDitchView> ditchList(DitchListParam param);
+
+    void update(YtDitch ytDitch);
+
+    void insertOne(YtDitch ytDitch);
+
+}

+ 38 - 0
yt-agent/agent-service/src/main/java/com/ytpm/service/AgentDitchService.java

@@ -0,0 +1,38 @@
+package com.ytpm.service;
+
+import com.ytpm.agent.model.YtDitch;
+import com.ytpm.agent.param.DitchListParam;
+import com.ytpm.agent.view.AgentDitchView;
+import com.ytpm.general.Result;
+import com.ytpm.general.ResultTable;
+
+/**
+ * 渠道类型service
+ */
+public interface AgentDitchService {
+    /**
+     * 获取渠道类型列表
+     */
+    ResultTable<AgentDitchView> ditchList(DitchListParam param);
+
+    /**
+     * 新增
+     * @param param
+     * @return
+     */
+    Result<?> addOne(YtDitch param);
+
+    /**
+     * 修改
+     * @param param
+     * @return
+     */
+    Result<?> updateOne(YtDitch param);
+
+    /**
+     * 假删除
+     * @param ditchId
+     * @return
+     */
+    Result<?> deleteOne(Long ditchId);
+}

+ 51 - 0
yt-agent/agent-service/src/main/java/com/ytpm/service/impl/AgentDitchServiceImpl.java

@@ -0,0 +1,51 @@
+package com.ytpm.service.impl;
+
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.ytpm.agent.model.YtDitch;
+import com.ytpm.agent.param.DitchListParam;
+import com.ytpm.agent.view.AgentDitchView;
+import com.ytpm.dao.AgentDitchMapper;
+import com.ytpm.general.RepMessage;
+import com.ytpm.general.Result;
+import com.ytpm.general.ResultTable;
+import com.ytpm.service.AgentDitchService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+@Service
+public class AgentDitchServiceImpl implements AgentDitchService {
+
+    @Resource
+    private AgentDitchMapper agentDitchMapper;
+
+    @Override
+    public ResultTable<AgentDitchView> ditchList(DitchListParam param) {
+        PageHelper.startPage(param.getPage(), param.getLimit());
+        List<AgentDitchView> agentDitchViews = agentDitchMapper.ditchList(param);
+        return ResultTable.resultTableOk(new PageInfo<>(agentDitchViews));
+    }
+
+    @Override
+    public Result<?> addOne(YtDitch param) {
+        param.setIsDelete(0);
+        agentDitchMapper.insertOne(param);
+        return Result.resultOk(RepMessage.SAVE_SUCCESS);
+    }
+
+    @Override
+    public Result<?> updateOne(YtDitch param) {
+        agentDitchMapper.update(param);
+        return Result.resultOk(RepMessage.MODIFY_SUCCESS);
+    }
+
+    @Override
+    public Result<?> deleteOne(Long ditchId) {
+        YtDitch ytDitch = new YtDitch();
+        ytDitch.setIsDelete(1);
+        ytDitch.setDitchId(ditchId);
+        agentDitchMapper.update(ytDitch);
+        return Result.resultOk(RepMessage.DELETE_SUCCESS);
+    }
+}

+ 48 - 0
yt-agent/agent-service/src/main/resources/mapper/AgentDitchMapper.xml

@@ -0,0 +1,48 @@
+<?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.ytpm.dao.AgentDitchMapper">
+    <insert id="insertOne">
+        insert into yt_ditch
+        (
+            ditch_id,
+            ditch_name,
+            user_id,
+            is_delete,
+            create_time
+        )
+        values
+            (
+                #{ditchId},
+                #{ditchName},
+                #{userId},
+                #{isDelete},
+                #{createTime}
+            )
+    </insert>
+
+    <update id="update">
+        update yt_ditch
+        <set>
+            <if test="ditchName !=null">
+                ditch_name = #{ditchName},
+            </if>
+            <if test="isDelete !=null">
+                is_delete = #{isDelete}
+            </if>
+        </set>
+        where ditch_id = #{ditchId}
+    </update>
+
+    <select id="ditchList" resultType="com.ytpm.agent.view.AgentDitchView">
+        select
+        ditch_id, ditch_name, create_time
+        from yt_ditch
+        <where>
+            <if test="ditchName != null and ditchName != ''">
+                AND ditch_name LIKE CONCAT('%', #{ditchName}, '%')
+            </if>
+            and is_delete=0
+        </where>
+    </select>
+
+</mapper>

+ 29 - 0
yt-common/src/main/java/com/ytpm/agent/model/YtDitch.java

@@ -0,0 +1,29 @@
+package com.ytpm.agent.model;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class YtDitch {
+    /**
+     * id
+     */
+    private Long ditchId;
+    /**
+     * 渠道类型名称
+     */
+    private String ditchName;
+    /**
+     * 用户id
+     */
+    private String userId;
+    /**
+     * 是否删除 0-正常 1-已删除
+     */
+    private Integer isDelete;
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+}

+ 12 - 0
yt-common/src/main/java/com/ytpm/agent/param/AgentDitchParam.java

@@ -0,0 +1,12 @@
+package com.ytpm.agent.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class AgentDitchParam {
+    @ApiModelProperty("渠道类型名称")
+    private String ditchName;
+    @ApiModelProperty("id")
+    private Long ditchId;
+}

+ 17 - 0
yt-common/src/main/java/com/ytpm/agent/param/DitchListParam.java

@@ -0,0 +1,17 @@
+package com.ytpm.agent.param;
+
+import com.ytpm.general.PageMeta;
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+@Data
+@EqualsAndHashCode(callSuper = false)
+@NoArgsConstructor
+@AllArgsConstructor
+@ApiModel("渠道类型管理列表入参")
+public class DitchListParam extends PageMeta {
+    private String ditchName;
+}

+ 15 - 0
yt-common/src/main/java/com/ytpm/agent/view/AgentDitchView.java

@@ -0,0 +1,15 @@
+package com.ytpm.agent.view;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+@ApiModel("渠道列表")
+public class AgentDitchView {
+    private Long ditchId;
+    private String ditchName;
+    private Date createTime;
+
+}