Explorar o código

1.新增分流配置基本的处理 2.白名单新增类型

王苗苗 hai 2 meses
pai
achega
3c9b708b26

+ 106 - 0
slibra-admin/src/main/java/com/slibra/web/controller/business/CBucketController.java

@@ -0,0 +1,106 @@
+package com.slibra.web.controller.business;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.slibra.common.annotation.Log;
+import com.slibra.common.core.controller.BaseController;
+import com.slibra.common.core.domain.AjaxResult;
+import com.slibra.common.enums.BusinessType;
+import com.slibra.business.domain.CBucket;
+import com.slibra.business.service.ICBucketService;
+import com.slibra.common.utils.poi.ExcelUtil;
+import com.slibra.common.core.page.TableDataInfo;
+
+/**
+ * 流量分桶Controller
+ * 
+ * @author slibra
+ * @date 2025-01-06
+ */
+@RestController
+@RequestMapping("/business/bucket")
+public class CBucketController extends BaseController
+{
+    @Autowired
+    private ICBucketService cBucketService;
+
+    /**
+     * 查询流量分桶列表
+     */
+    @PreAuthorize("@ss.hasPermi('business:bucket:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(CBucket cBucket)
+    {
+        startPage();
+        List<CBucket> list = cBucketService.selectCBucketList(cBucket);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出流量分桶列表
+     */
+    @PreAuthorize("@ss.hasPermi('business:bucket:export')")
+    @Log(title = "流量分桶", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, CBucket cBucket)
+    {
+        List<CBucket> list = cBucketService.selectCBucketList(cBucket);
+        ExcelUtil<CBucket> util = new ExcelUtil<CBucket>(CBucket.class);
+        util.exportExcel(response, list, "流量分桶数据");
+    }
+
+    /**
+     * 获取流量分桶详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('business:bucket:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") String id)
+    {
+        return success(cBucketService.selectCBucketById(id));
+    }
+
+    /**
+     * 新增流量分桶
+     */
+    @PreAuthorize("@ss.hasPermi('business:bucket:add')")
+    @Log(title = "流量分桶", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody CBucket cBucket)
+    {
+        cBucket.setCreateBy(getUsername());
+        return toAjax(cBucketService.insertCBucket(cBucket));
+    }
+
+    /**
+     * 修改流量分桶
+     */
+    @PreAuthorize("@ss.hasPermi('business:bucket:edit')")
+    @Log(title = "流量分桶", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody CBucket cBucket)
+    {
+        cBucket.setUpdateBy(getUsername());
+        return toAjax(cBucketService.updateCBucket(cBucket));
+    }
+
+    /**
+     * 删除流量分桶
+     */
+    @PreAuthorize("@ss.hasPermi('business:bucket:remove')")
+    @Log(title = "流量分桶", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable String[] ids)
+    {
+        return toAjax(cBucketService.deleteCBucketByIds(ids));
+    }
+}

+ 50 - 0
slibra-system/src/main/java/com/slibra/business/domain/CBucket.java

@@ -0,0 +1,50 @@
+package com.slibra.business.domain;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.slibra.common.annotation.Excel;
+import com.slibra.common.core.domain.BaseEntity;
+
+/**
+ * 流量分桶对象 c_bucket
+ * 
+ * @author slibra
+ * @date 2025-01-06
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class CBucket extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 主键 */
+    private String id;
+
+    /** 名称 */
+    @Excel(name = "名称")
+    private String name;
+
+    /** 实验id */
+    @Excel(name = "实验id")
+    private String eid;
+
+    /** 下限 */
+    @Excel(name = "下限")
+    private Integer lower;
+
+    /** 上限 */
+    @Excel(name = "上限")
+    private Integer upper;
+
+    /** 拓展配置 */
+    @Excel(name = "拓展配置")
+    private String config;
+
+
+}

+ 4 - 0
slibra-system/src/main/java/com/slibra/business/domain/TWhitelist.java

@@ -35,6 +35,10 @@ public class TWhitelist extends BaseEntity
     @Excel(name = "描述说明", readConverterExp = "备=注")
     private String description;
 
+    /** 类型(0人工白名单  1机器人白名单) */
+    @Excel(name = "类型", readConverterExp = "0=人工白名单,1=机器人白名单")
+    private Integer type;
+
     /** 删除标志(0代表存在 2代表删除) */
     private Long delFlag;
 

+ 61 - 0
slibra-system/src/main/java/com/slibra/business/mapper/CBucketMapper.java

@@ -0,0 +1,61 @@
+package com.slibra.business.mapper;
+
+import java.util.List;
+import com.slibra.business.domain.CBucket;
+
+/**
+ * 流量分桶Mapper接口
+ * 
+ * @author slibra
+ * @date 2025-01-06
+ */
+public interface CBucketMapper 
+{
+    /**
+     * 查询流量分桶
+     * 
+     * @param id 流量分桶主键
+     * @return 流量分桶
+     */
+    public CBucket selectCBucketById(String id);
+
+    /**
+     * 查询流量分桶列表
+     * 
+     * @param cBucket 流量分桶
+     * @return 流量分桶集合
+     */
+    public List<CBucket> selectCBucketList(CBucket cBucket);
+
+    /**
+     * 新增流量分桶
+     * 
+     * @param cBucket 流量分桶
+     * @return 结果
+     */
+    public int insertCBucket(CBucket cBucket);
+
+    /**
+     * 修改流量分桶
+     * 
+     * @param cBucket 流量分桶
+     * @return 结果
+     */
+    public int updateCBucket(CBucket cBucket);
+
+    /**
+     * 删除流量分桶
+     * 
+     * @param id 流量分桶主键
+     * @return 结果
+     */
+    public int deleteCBucketById(String id);
+
+    /**
+     * 批量删除流量分桶
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteCBucketByIds(String[] ids);
+}

+ 61 - 0
slibra-system/src/main/java/com/slibra/business/service/ICBucketService.java

@@ -0,0 +1,61 @@
+package com.slibra.business.service;
+
+import java.util.List;
+import com.slibra.business.domain.CBucket;
+
+/**
+ * 流量分桶Service接口
+ * 
+ * @author slibra
+ * @date 2025-01-06
+ */
+public interface ICBucketService 
+{
+    /**
+     * 查询流量分桶
+     * 
+     * @param id 流量分桶主键
+     * @return 流量分桶
+     */
+    public CBucket selectCBucketById(String id);
+
+    /**
+     * 查询流量分桶列表
+     * 
+     * @param cBucket 流量分桶
+     * @return 流量分桶集合
+     */
+    public List<CBucket> selectCBucketList(CBucket cBucket);
+
+    /**
+     * 新增流量分桶
+     * 
+     * @param cBucket 流量分桶
+     * @return 结果
+     */
+    public int insertCBucket(CBucket cBucket);
+
+    /**
+     * 修改流量分桶
+     * 
+     * @param cBucket 流量分桶
+     * @return 结果
+     */
+    public int updateCBucket(CBucket cBucket);
+
+    /**
+     * 批量删除流量分桶
+     * 
+     * @param ids 需要删除的流量分桶主键集合
+     * @return 结果
+     */
+    public int deleteCBucketByIds(String[] ids);
+
+    /**
+     * 删除流量分桶信息
+     * 
+     * @param id 流量分桶主键
+     * @return 结果
+     */
+    public int deleteCBucketById(String id);
+}

+ 96 - 0
slibra-system/src/main/java/com/slibra/business/service/impl/CBucketServiceImpl.java

@@ -0,0 +1,96 @@
+package com.slibra.business.service.impl;
+
+import java.util.List;
+import com.slibra.common.utils.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.slibra.business.mapper.CBucketMapper;
+import com.slibra.business.domain.CBucket;
+import com.slibra.business.service.ICBucketService;
+
+/**
+ * 流量分桶Service业务层处理
+ * 
+ * @author slibra
+ * @date 2025-01-06
+ */
+@Service
+public class CBucketServiceImpl implements ICBucketService 
+{
+    @Autowired
+    private CBucketMapper cBucketMapper;
+
+    /**
+     * 查询流量分桶
+     * 
+     * @param id 流量分桶主键
+     * @return 流量分桶
+     */
+    @Override
+    public CBucket selectCBucketById(String id)
+    {
+        return cBucketMapper.selectCBucketById(id);
+    }
+
+    /**
+     * 查询流量分桶列表
+     * 
+     * @param cBucket 流量分桶
+     * @return 流量分桶
+     */
+    @Override
+    public List<CBucket> selectCBucketList(CBucket cBucket)
+    {
+        return cBucketMapper.selectCBucketList(cBucket);
+    }
+
+    /**
+     * 新增流量分桶
+     * 
+     * @param cBucket 流量分桶
+     * @return 结果
+     */
+    @Override
+    public int insertCBucket(CBucket cBucket)
+    {
+        cBucket.setCreateTime(DateUtils.getNowDate());
+        return cBucketMapper.insertCBucket(cBucket);
+    }
+
+    /**
+     * 修改流量分桶
+     * 
+     * @param cBucket 流量分桶
+     * @return 结果
+     */
+    @Override
+    public int updateCBucket(CBucket cBucket)
+    {
+        cBucket.setUpdateTime(DateUtils.getNowDate());
+        return cBucketMapper.updateCBucket(cBucket);
+    }
+
+    /**
+     * 批量删除流量分桶
+     * 
+     * @param ids 需要删除的流量分桶主键
+     * @return 结果
+     */
+    @Override
+    public int deleteCBucketByIds(String[] ids)
+    {
+        return cBucketMapper.deleteCBucketByIds(ids);
+    }
+
+    /**
+     * 删除流量分桶信息
+     * 
+     * @param id 流量分桶主键
+     * @return 结果
+     */
+    @Override
+    public int deleteCBucketById(String id)
+    {
+        return cBucketMapper.deleteCBucketById(id);
+    }
+}

+ 88 - 0
slibra-system/src/main/resources/mapper/business/CBucketMapper.xml

@@ -0,0 +1,88 @@
+<?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.slibra.business.mapper.CBucketMapper">
+    
+    <resultMap type="CBucket" id="CBucketResult">
+        <result property="id"    column="id"    />
+        <result property="name"    column="name"    />
+        <result property="eid"    column="eid"    />
+        <result property="lower"    column="lower"    />
+        <result property="upper"    column="upper"    />
+        <result property="config"    column="config"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="createTime"    column="create_time"    />
+    </resultMap>
+
+    <sql id="selectCBucketVo">
+        select id, name, eid, lower, upper, config, update_time, create_time from c_bucket
+    </sql>
+
+    <select id="selectCBucketList" parameterType="CBucket" resultMap="CBucketResult">
+        <include refid="selectCBucketVo"/>
+        <where>
+            1 = 1
+            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
+            <if test="eid != null  and eid != ''"> and eid = #{eid}</if>
+            <if test="lower != null "> and lower = #{lower}</if>
+            <if test="upper != null "> and upper = #{upper}</if>
+            <if test="config != null  and config != ''"> and config = #{config}</if>
+        </where>
+        order by id desc
+    </select>
+    
+    <select id="selectCBucketById" parameterType="String" resultMap="CBucketResult">
+        <include refid="selectCBucketVo"/>
+        where id = #{id}
+    </select>
+        
+    <insert id="insertCBucket" parameterType="CBucket" useGeneratedKeys="true" keyProperty="id">
+        insert into c_bucket
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="name != null and name != ''">name,</if>
+            <if test="eid != null and eid != ''">eid,</if>
+            <if test="lower != null">lower,</if>
+            <if test="upper != null">upper,</if>
+            <if test="config != null and config != ''">config,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="createTime != null">create_time,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="name != null and name != ''">#{name},</if>
+            <if test="eid != null and eid != ''">#{eid},</if>
+            <if test="lower != null">#{lower},</if>
+            <if test="upper != null">#{upper},</if>
+            <if test="config != null and config != ''">#{config},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="createTime != null">#{createTime},</if>
+         </trim>
+    </insert>
+
+    <update id="updateCBucket" parameterType="CBucket">
+        update c_bucket
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="name != null and name != ''">name = #{name},</if>
+            <if test="eid != null and eid != ''">eid = #{eid},</if>
+            <if test="lower != null">lower = #{lower},</if>
+            <if test="upper != null">upper = #{upper},</if>
+            <if test="config != null and config != ''">config = #{config},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    
+
+    <delete id="deleteCBucketById" parameterType="String">
+        update c_bucket set del_flag = 2,revision = revision + 1 where del_flag = 0 and id = #{id}
+    </delete>
+
+    <delete id="deleteCBucketByIds" parameterType="String">
+        update c_bucket set del_flag = 2,revision = revision + 1 where del_flag = 0 and id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 6 - 1
slibra-system/src/main/resources/mapper/business/TWhitelistMapper.xml

@@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="id"    column="id"    />
         <result property="phone"    column="phone"    />
         <result property="description"    column="description"    />
+        <result property="type"    column="type"    />
         <result property="delFlag"    column="del_flag"    />
         <result property="revision"    column="revision"    />
         <result property="createBy"    column="create_by"    />
@@ -18,7 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectTWhitelistVo">
-        select id, phone, description, del_flag, revision, create_by, create_time, update_by, update_time, remark from t_whitelist
+        select id, phone, description, type, del_flag, revision, create_by, create_time, update_by, update_time, remark from t_whitelist
     </sql>
 
     <select id="selectTWhitelistList" parameterType="TWhitelist" resultMap="TWhitelistResult">
@@ -27,6 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             1 = 1
             <if test="phone != null  and phone != ''"> and phone like concat('%', #{phone}, '%')</if>
             <if test="description != null  and description != ''"> and description like concat('%', #{description}, '%')</if>
+            <if test="type != null "> and type = #{type}</if>
             <if test="revision != null "> and revision = #{revision}</if>
         </where>
         and del_flag = 0 order by id desc
@@ -42,6 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="phone != null and phone != ''">phone,</if>
             <if test="description != null">description,</if>
+            <if test="type != null">type,</if>
             <if test="delFlag != null">del_flag,</if>
             <if test="revision != null">revision,</if>
             <if test="createBy != null">create_by,</if>
@@ -53,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="phone != null and phone != ''">#{phone},</if>
             <if test="description != null">#{description},</if>
+            <if test="type != null">#{type},</if>
             <if test="delFlag != null">#{delFlag},</if>
             <if test="revision != null">#{revision},</if>
             <if test="createBy != null">#{createBy},</if>
@@ -68,6 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="SET" suffixOverrides=",">
             <if test="phone != null and phone != ''">phone = #{phone},</if>
             <if test="description != null">description = #{description},</if>
+            <if test="type != null">type = #{type},</if>
             <if test="delFlag != null">del_flag = #{delFlag},</if>
             <if test="revision != null">revision = #{revision},</if>
             <if test="createBy != null">create_by = #{createBy},</if>