Bladeren bron

企业黑名单

yaodaoseng 2 weken geleden
bovenliggende
commit
9c6b1397d0

+ 78 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/dao/mapper/QywxCorpBlacklistUserMapper.java

@@ -0,0 +1,78 @@
+package com.tzld.piaoquan.risk.control.dao.mapper;
+
+import com.tzld.piaoquan.risk.control.model.po.QywxCorpBlacklistUser;
+import com.tzld.piaoquan.risk.control.model.po.QywxCorpBlacklistUserExample;
+import java.util.Date;
+import java.util.List;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 企业微信客户主体黑名单用户数据访问接口
+ * 
+ * @author MyBatis Generator
+ * @since 1.0.0
+ */
+public interface QywxCorpBlacklistUserMapper {
+    
+    /**
+     * 根据查询条件统计记录数量
+     */
+    long countByExample(QywxCorpBlacklistUserExample example);
+
+    /**
+     * 根据查询条件批量删除记录
+     */
+    int deleteByExample(QywxCorpBlacklistUserExample example);
+
+    /**
+     * 根据主键删除单条记录
+     */
+    int deleteByPrimaryKey(Long id);
+
+    /**
+     * 插入完整记录
+     */
+    int insert(QywxCorpBlacklistUser record);
+
+    /**
+     * 选择性插入记录
+     */
+    int insertSelective(QywxCorpBlacklistUser record);
+
+    /**
+     * 根据查询条件查询记录列表
+     */
+    List<QywxCorpBlacklistUser> selectByExample(QywxCorpBlacklistUserExample example);
+
+    /**
+     * 根据主键查询单条记录
+     */
+    QywxCorpBlacklistUser selectByPrimaryKey(Long id);
+
+    /**
+     * 根据条件选择性更新记录
+     */
+    int updateByExampleSelective(@Param("record") QywxCorpBlacklistUser record, 
+                                @Param("example") QywxCorpBlacklistUserExample example);
+
+    /**
+     * 根据条件完整更新记录
+     */
+    int updateByExample(@Param("record") QywxCorpBlacklistUser record, 
+                       @Param("example") QywxCorpBlacklistUserExample example);
+
+    /**
+     * 根据主键选择性更新记录
+     */
+    int updateByPrimaryKeySelective(QywxCorpBlacklistUser record);
+
+    /**
+     * 根据主键完整更新记录
+     */
+    int updateByPrimaryKey(QywxCorpBlacklistUser record);
+
+    /**
+     * 根据vid和corpId查询拉黑时间
+     */
+    Date selectBlackTimeByVidAndCorpId(@Param("vid") Long vid, @Param("corpId") Long corpId);
+}

+ 107 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/po/QywxCorpBlacklistUser.java

@@ -0,0 +1,107 @@
+package com.tzld.piaoquan.risk.control.model.po;
+
+import java.util.Date;
+
+/**
+ * 企业微信客户主体黑名单用户实体类
+ * 
+ * 对应数据库表: qywx_corp_blacklist_user
+ * 
+ * @author 系统生成
+ * @since 1.0.0
+ */
+public class QywxCorpBlacklistUser {
+    
+    /**
+     * 主键ID
+     */
+    private Long id;
+
+    /**
+     * 企业微信用户VID
+     */
+    private Long vid;
+
+    /**
+     * 企业ID
+     */
+    private Long corpId;
+
+    /**
+     * 拉黑时间
+     */
+    private Date blackTime;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getVid() {
+        return vid;
+    }
+
+    public void setVid(Long vid) {
+        this.vid = vid;
+    }
+
+    public Long getCorpId() {
+        return corpId;
+    }
+
+    public void setCorpId(Long corpId) {
+        this.corpId = corpId;
+    }
+
+    public Date getBlackTime() {
+        return blackTime;
+    }
+
+    public void setBlackTime(Date blackTime) {
+        this.blackTime = blackTime;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    @Override
+    public String toString() {
+        return "QywxCorpBlacklistUser{" +
+                "id=" + id +
+                ", vid=" + vid +
+                ", corpId=" + corpId +
+                ", blackTime=" + blackTime +
+                ", createTime=" + createTime +
+                '}';
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+        QywxCorpBlacklistUser that = (QywxCorpBlacklistUser) obj;
+        return vid != null && vid.equals(that.vid) && corpId != null && corpId.equals(that.corpId);
+    }
+
+    @Override
+    public int hashCode() {
+        return vid != null && corpId != null ? (vid.toString() + corpId.toString()).hashCode() : 0;
+    }
+}

+ 223 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/po/QywxCorpBlacklistUserExample.java

@@ -0,0 +1,223 @@
+package com.tzld.piaoquan.risk.control.model.po;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 企业微信客户主体黑名单用户查询条件构建类
+ * 
+ * @author MyBatis Generator
+ * @since 1.0.0
+ */
+public class QywxCorpBlacklistUserExample {
+    
+    protected String orderByClause;
+    protected boolean distinct;
+    protected List<Criteria> oredCriteria;
+
+    public QywxCorpBlacklistUserExample() {
+        oredCriteria = new ArrayList<>();
+    }
+
+    public void setOrderByClause(String orderByClause) {
+        this.orderByClause = orderByClause;
+    }
+
+    public String getOrderByClause() {
+        return orderByClause;
+    }
+
+    public void setDistinct(boolean distinct) {
+        this.distinct = distinct;
+    }
+
+    public boolean isDistinct() {
+        return distinct;
+    }
+
+    public List<Criteria> getOredCriteria() {
+        return oredCriteria;
+    }
+
+    public void or(Criteria criteria) {
+        oredCriteria.add(criteria);
+    }
+
+    public Criteria or() {
+        Criteria criteria = createCriteriaInternal();
+        oredCriteria.add(criteria);
+        return criteria;
+    }
+
+    public Criteria createCriteria() {
+        Criteria criteria = createCriteriaInternal();
+        if (oredCriteria.size() == 0) {
+            oredCriteria.add(criteria);
+        }
+        return criteria;
+    }
+
+    protected Criteria createCriteriaInternal() {
+        Criteria criteria = new Criteria();
+        return criteria;
+    }
+
+    public void clear() {
+        oredCriteria.clear();
+        orderByClause = null;
+        distinct = false;
+    }
+
+    protected abstract static class GeneratedCriteria {
+        protected List<Criterion> criteria;
+
+        protected GeneratedCriteria() {
+            super();
+            criteria = new ArrayList<>();
+        }
+
+        public boolean isValid() {
+            return criteria.size() > 0;
+        }
+
+        public List<Criterion> getAllCriteria() {
+            return criteria;
+        }
+
+        public List<Criterion> getCriteria() {
+            return criteria;
+        }
+
+        protected void addCriterion(String condition) {
+            if (condition == null) {
+                throw new RuntimeException("Value for condition cannot be null");
+            }
+            criteria.add(new Criterion(condition));
+        }
+
+        protected void addCriterion(String condition, Object value, String property) {
+            if (value == null) {
+                throw new RuntimeException("Value for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value));
+        }
+
+        protected void addCriterion(String condition, Object value1, Object value2, String property) {
+            if (value1 == null || value2 == null) {
+                throw new RuntimeException("Between values for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value1, value2));
+        }
+
+        public Criteria andIdEqualTo(Long value) {
+            addCriterion("id =", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andVidEqualTo(Long value) {
+            addCriterion("vid =", value, "vid");
+            return (Criteria) this;
+        }
+
+        public Criteria andCorpIdEqualTo(Long value) {
+            addCriterion("corp_id =", value, "corpId");
+            return (Criteria) this;
+        }
+
+        public Criteria andBlackTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("black_time >=", value, "blackTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("create_time >=", value, "createTime");
+            return (Criteria) this;
+        }
+    }
+
+    public static class Criteria extends GeneratedCriteria {
+        protected Criteria() {
+            super();
+        }
+    }
+
+    public static class Criterion {
+        private String condition;
+        private Object value;
+        private Object secondValue;
+        private boolean noValue;
+        private boolean singleValue;
+        private boolean betweenValue;
+        private boolean listValue;
+        private String typeHandler;
+
+        public String getCondition() {
+            return condition;
+        }
+
+        public Object getValue() {
+            return value;
+        }
+
+        public Object getSecondValue() {
+            return secondValue;
+        }
+
+        public boolean isNoValue() {
+            return noValue;
+        }
+
+        public boolean isSingleValue() {
+            return singleValue;
+        }
+
+        public boolean isBetweenValue() {
+            return betweenValue;
+        }
+
+        public boolean isListValue() {
+            return listValue;
+        }
+
+        public String getTypeHandler() {
+            return typeHandler;
+        }
+
+        protected Criterion(String condition) {
+            super();
+            this.condition = condition;
+            this.typeHandler = null;
+            this.noValue = true;
+        }
+
+        protected Criterion(String condition, Object value, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.typeHandler = typeHandler;
+            if (value instanceof List<?>) {
+                this.listValue = true;
+            } else {
+                this.singleValue = true;
+            }
+        }
+
+        protected Criterion(String condition, Object value) {
+            this(condition, value, null);
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.secondValue = secondValue;
+            this.typeHandler = typeHandler;
+            this.betweenValue = true;
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue) {
+            this(condition, value, secondValue, null);
+        }
+    }
+}

+ 58 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/service/CorpBlacklistService.java

@@ -0,0 +1,58 @@
+package com.tzld.piaoquan.risk.control.service;
+
+import com.tzld.piaoquan.risk.control.model.po.QywxCorpBlacklistUser;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 企业微信客户主体黑名单管理服务接口
+ * 
+ * @author 风控系统开发团队
+ * @since 1.0.0
+ */
+public interface CorpBlacklistService {
+    
+    /**
+     * 根据vid和corpId查询拉黑时间
+     * 
+     * @param vid 企业微信用户VID
+     * @param corpId 企业ID
+     * @return 拉黑时间,如果不存在则返回null
+     */
+    Date getBlackTimeByVidAndCorpId(Long vid, Long corpId);
+    
+    /**
+     * 添加用户到企业黑名单
+     * 
+     * @param vid 企业微信用户VID
+     * @param corpId 企业ID
+     * @throws RuntimeException 当用户已在该企业黑名单中时抛出
+     */
+    void addToCorpBlacklist(Long vid, Long corpId);
+    
+    /**
+     * 根据企业ID查询该企业的所有黑名单用户
+     * 
+     * @param corpId 企业ID
+     * @return 该企业的黑名单用户列表
+     */
+    List<QywxCorpBlacklistUser> getBlacklistByCorpId(Long corpId);
+    
+    /**
+     * 检查用户是否在指定企业的黑名单中
+     * 
+     * @param vid 企业微信用户VID
+     * @param corpId 企业ID
+     * @return true表示在黑名单中,false表示不在黑名单中
+     */
+    boolean isInCorpBlacklist(Long vid, Long corpId);
+    
+    /**
+     * 从企业黑名单中移除用户
+     * 
+     * @param vid 企业微信用户VID
+     * @param corpId 企业ID
+     * @return true表示移除成功,false表示用户不在黑名单中
+     */
+    boolean removeFromCorpBlacklist(Long vid, Long corpId);
+}

+ 182 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/service/impl/CorpBlacklistServiceImpl.java

@@ -0,0 +1,182 @@
+package com.tzld.piaoquan.risk.control.service.impl;
+
+import com.tzld.piaoquan.risk.control.dao.mapper.QywxCorpBlacklistUserMapper;
+import com.tzld.piaoquan.risk.control.model.po.QywxCorpBlacklistUser;
+import com.tzld.piaoquan.risk.control.model.po.QywxCorpBlacklistUserExample;
+import com.tzld.piaoquan.risk.control.service.CorpBlacklistService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 企业微信客户主体黑名单管理服务实现类
+ * 
+ * @author 风控系统开发团队
+ * @since 1.0.0
+ */
+@Service
+public class CorpBlacklistServiceImpl implements CorpBlacklistService {
+    
+    private static final Logger log = LoggerFactory.getLogger(CorpBlacklistServiceImpl.class);
+    
+    @Autowired
+    private QywxCorpBlacklistUserMapper corpBlacklistUserMapper;
+    
+    /**
+     * 根据vid和corpId查询拉黑时间
+     */
+    @Override
+    public Date getBlackTimeByVidAndCorpId(Long vid, Long corpId) {
+        if (vid == null || corpId == null) {
+            log.warn("getBlackTimeByVidAndCorpId called with null parameters: vid={}, corpId={}", vid, corpId);
+            return null;
+        }
+        
+        try {
+            Date blackTime = corpBlacklistUserMapper.selectBlackTimeByVidAndCorpId(vid, corpId);
+            log.debug("Query black time for vid: {}, corpId: {}, result: {}", vid, corpId, blackTime);
+            return blackTime;
+        } catch (Exception e) {
+            log.error("Failed to query black time for vid: {}, corpId: {}", vid, corpId, e);
+            throw new RuntimeException("查询拉黑时间失败", e);
+        }
+    }
+    
+    /**
+     * 添加用户到企业黑名单
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void addToCorpBlacklist(Long vid, Long corpId) {
+        if (vid == null || corpId == null) {
+            throw new IllegalArgumentException("用户VID和企业ID不能为空");
+        }
+        
+        if (vid <= 0 || corpId <= 0) {
+            throw new IllegalArgumentException("用户VID和企业ID必须是有效的正数");
+        }
+        
+        try {
+            // 检查是否已存在
+            if (isInCorpBlacklist(vid, corpId)) {
+                throw new RuntimeException("用户已在该企业黑名单中,VID: " + vid + ", CorpId: " + corpId);
+            }
+            
+            // 创建黑名单记录
+            QywxCorpBlacklistUser record = new QywxCorpBlacklistUser();
+            record.setVid(vid);
+            record.setCorpId(corpId);
+            record.setBlackTime(new Date());
+            record.setCreateTime(new Date());
+            
+            int result = corpBlacklistUserMapper.insertSelective(record);
+            
+            if (result > 0) {
+                log.info("Successfully added user to corp blacklist, vid: {}, corpId: {}, id: {}", 
+                        vid, corpId, record.getId());
+            } else {
+                throw new RuntimeException("添加用户到企业黑名单失败,数据库操作无效");
+            }
+            
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            log.error("Unexpected error while adding user to corp blacklist, vid: {}, corpId: {}", vid, corpId, e);
+            throw new RuntimeException("添加用户到企业黑名单时发生系统异常", e);
+        }
+    }
+    
+    /**
+     * 根据企业ID查询该企业的所有黑名单用户
+     */
+    @Override
+    public List<QywxCorpBlacklistUser> getBlacklistByCorpId(Long corpId) {
+        if (corpId == null) {
+            throw new IllegalArgumentException("企业ID不能为空");
+        }
+        
+        try {
+            QywxCorpBlacklistUserExample example = new QywxCorpBlacklistUserExample();
+            example.createCriteria().andCorpIdEqualTo(corpId);
+            example.setOrderByClause("black_time DESC");
+            
+            List<QywxCorpBlacklistUser> users = corpBlacklistUserMapper.selectByExample(example);
+            
+            log.info("Retrieved corp blacklist users for corpId: {}, count: {}", corpId, users.size());
+            
+            if (users.size() > 1000) {
+                log.warn("Large corp blacklist dataset retrieved: {} records for corpId: {}", users.size(), corpId);
+            }
+            
+            return users;
+            
+        } catch (Exception e) {
+            log.error("Failed to retrieve corp blacklist users for corpId: {}", corpId, e);
+            throw new RuntimeException("获取企业黑名单用户失败", e);
+        }
+    }
+    
+    /**
+     * 检查用户是否在指定企业的黑名单中
+     */
+    @Override
+    public boolean isInCorpBlacklist(Long vid, Long corpId) {
+        if (vid == null || corpId == null) {
+            log.warn("isInCorpBlacklist called with null parameters, returning false");
+            return false;
+        }
+        
+        try {
+            QywxCorpBlacklistUserExample example = new QywxCorpBlacklistUserExample();
+            example.createCriteria().andVidEqualTo(vid).andCorpIdEqualTo(corpId);
+            
+            long count = corpBlacklistUserMapper.countByExample(example);
+            
+            if (log.isDebugEnabled()) {
+                log.debug("Corp blacklist check for vid: {}, corpId: {}, result: {}", vid, corpId, count > 0);
+            }
+            
+            return count > 0;
+            
+        } catch (Exception e) {
+            log.error("Failed to check corp blacklist for vid: {}, corpId: {}", vid, corpId, e);
+            throw new RuntimeException("企业黑名单检查失败", e);
+        }
+    }
+    
+    /**
+     * 从企业黑名单中移除用户
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean removeFromCorpBlacklist(Long vid, Long corpId) {
+        if (vid == null || corpId == null) {
+            throw new IllegalArgumentException("用户VID和企业ID不能为空");
+        }
+        
+        try {
+            QywxCorpBlacklistUserExample example = new QywxCorpBlacklistUserExample();
+            example.createCriteria().andVidEqualTo(vid).andCorpIdEqualTo(corpId);
+            
+            int result = corpBlacklistUserMapper.deleteByExample(example);
+            
+            if (result > 0) {
+                log.info("Successfully removed user from corp blacklist, vid: {}, corpId: {}, deleted count: {}", 
+                        vid, corpId, result);
+                return true;
+            } else {
+                log.info("User not found in corp blacklist, no removal needed, vid: {}, corpId: {}", vid, corpId);
+                return false;
+            }
+            
+        } catch (Exception e) {
+            log.error("Failed to remove user from corp blacklist, vid: {}, corpId: {}", vid, corpId, e);
+            throw new RuntimeException("从企业黑名单移除用户失败", e);
+        }
+    }
+}

+ 218 - 0
risk-control-core/src/main/resources/mapper/QywxCorpBlacklistUserMapper.xml

@@ -0,0 +1,218 @@
+<?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">
+
+<!-- 企业微信客户主体黑名单用户MyBatis映射文件 -->
+<mapper namespace="com.tzld.piaoquan.risk.control.dao.mapper.QywxCorpBlacklistUserMapper">
+  
+  <!-- 基础结果映射 -->
+  <resultMap id="BaseResultMap" type="com.tzld.piaoquan.risk.control.model.po.QywxCorpBlacklistUser">
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="vid" jdbcType="BIGINT" property="vid" />
+    <result column="corp_id" jdbcType="BIGINT" property="corpId" />
+    <result column="black_time" jdbcType="TIMESTAMP" property="blackTime" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+  </resultMap>
+  
+  <!-- 动态WHERE条件构建 -->
+  <sql id="Example_Where_Clause">
+    <where>
+      <foreach collection="oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  
+  <!-- 基础字段列表 -->
+  <sql id="Base_Column_List">
+    id, vid, corp_id, black_time, create_time
+  </sql>
+  
+  <!-- 根据条件查询记录列表 -->
+  <select id="selectByExample" parameterType="com.tzld.piaoquan.risk.control.model.po.QywxCorpBlacklistUserExample" resultMap="BaseResultMap">
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from qywx_corp_blacklist_user
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+    <if test="orderByClause != null">
+      order by ${orderByClause}
+    </if>
+  </select>
+  
+  <!-- 根据主键查询单条记录 -->
+  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
+    select 
+    <include refid="Base_Column_List" />
+    from qywx_corp_blacklist_user
+    where id = #{id,jdbcType=BIGINT}
+  </select>
+  
+  <!-- 根据vid和corpId查询拉黑时间 -->
+  <select id="selectBlackTimeByVidAndCorpId" resultType="java.util.Date">
+    select black_time
+    from qywx_corp_blacklist_user
+    where vid = #{vid,jdbcType=BIGINT} and corp_id = #{corpId,jdbcType=BIGINT}
+  </select>
+  
+  <!-- 根据主键删除记录 -->
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+    delete from qywx_corp_blacklist_user
+    where id = #{id,jdbcType=BIGINT}
+  </delete>
+  
+  <!-- 根据条件批量删除记录 -->
+  <delete id="deleteByExample" parameterType="com.tzld.piaoquan.risk.control.model.po.QywxCorpBlacklistUserExample">
+    delete from qywx_corp_blacklist_user
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  
+  <!-- 插入完整记录 -->
+  <insert id="insert" parameterType="com.tzld.piaoquan.risk.control.model.po.QywxCorpBlacklistUser">
+    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
+      SELECT LAST_INSERT_ID()
+    </selectKey>
+    insert into qywx_corp_blacklist_user (vid, corp_id, black_time, create_time)
+    values (#{vid,jdbcType=BIGINT}, #{corpId,jdbcType=BIGINT}, #{blackTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP})
+  </insert>
+  
+  <!-- 选择性插入记录 -->
+  <insert id="insertSelective" parameterType="com.tzld.piaoquan.risk.control.model.po.QywxCorpBlacklistUser">
+    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
+      SELECT LAST_INSERT_ID()
+    </selectKey>
+    insert into qywx_corp_blacklist_user
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="vid != null">
+        vid,
+      </if>
+      <if test="corpId != null">
+        corp_id,
+      </if>
+      <if test="blackTime != null">
+        black_time,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="vid != null">
+        #{vid,jdbcType=BIGINT},
+      </if>
+      <if test="corpId != null">
+        #{corpId,jdbcType=BIGINT},
+      </if>
+      <if test="blackTime != null">
+        #{blackTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  
+  <!-- 根据条件统计记录数 -->
+  <select id="countByExample" parameterType="com.tzld.piaoquan.risk.control.model.po.QywxCorpBlacklistUserExample" resultType="java.lang.Long">
+    select count(*) from qywx_corp_blacklist_user
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  
+  <!-- 根据条件选择性更新记录 -->
+  <update id="updateByExampleSelective" parameterType="map">
+    update qywx_corp_blacklist_user
+    <set>
+      <if test="record.id != null">
+        id = #{record.id,jdbcType=BIGINT},
+      </if>
+      <if test="record.vid != null">
+        vid = #{record.vid,jdbcType=BIGINT},
+      </if>
+      <if test="record.corpId != null">
+        corp_id = #{record.corpId,jdbcType=BIGINT},
+      </if>
+      <if test="record.blackTime != null">
+        black_time = #{record.blackTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="record.createTime != null">
+        create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </update>
+  
+  <!-- 根据条件完整更新记录 -->
+  <update id="updateByExample" parameterType="map">
+    update qywx_corp_blacklist_user
+    set id = #{record.id,jdbcType=BIGINT},
+      vid = #{record.vid,jdbcType=BIGINT},
+      corp_id = #{record.corpId,jdbcType=BIGINT},
+      black_time = #{record.blackTime,jdbcType=TIMESTAMP},
+      create_time = #{record.createTime,jdbcType=TIMESTAMP}
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </update>
+  
+  <!-- 根据主键选择性更新记录 -->
+  <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.risk.control.model.po.QywxCorpBlacklistUser">
+    update qywx_corp_blacklist_user
+    <set>
+      <if test="vid != null">
+        vid = #{vid,jdbcType=BIGINT},
+      </if>
+      <if test="corpId != null">
+        corp_id = #{corpId,jdbcType=BIGINT},
+      </if>
+      <if test="blackTime != null">
+        black_time = #{blackTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+  
+  <!-- 根据主键完整更新记录 -->
+  <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.risk.control.model.po.QywxCorpBlacklistUser">
+    update qywx_corp_blacklist_user
+    set vid = #{vid,jdbcType=BIGINT},
+      corp_id = #{corpId,jdbcType=BIGINT},
+      black_time = #{blackTime,jdbcType=TIMESTAMP},
+      create_time = #{createTime,jdbcType=TIMESTAMP}
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+  
+</mapper>

+ 69 - 0
risk-control-server/src/main/java/com/tzld/piaoquan/risk/control/controller/CorpBlacklistController.java

@@ -0,0 +1,69 @@
+package com.tzld.piaoquan.risk.control.controller;
+
+import com.tzld.piaoquan.risk.control.common.base.CommonResponse;
+import com.tzld.piaoquan.risk.control.model.po.QywxCorpBlacklistUser;
+import com.tzld.piaoquan.risk.control.service.CorpBlacklistService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 企业微信客户主体黑名单管理控制器
+ * 
+ * @author 风控系统开发团队
+ * @since 1.0.0
+ */
+@RestController
+@RequestMapping("/corp-blacklist")
+public class CorpBlacklistController {
+    
+    private static final Logger log = LoggerFactory.getLogger(CorpBlacklistController.class);
+    
+    @Autowired
+    private CorpBlacklistService corpBlacklistService;
+    
+    /**
+     * 根据企业ID查询黑名单用户(全量,不分页)
+     * 
+     * @param corpId 企业ID
+     * @return 该企业的所有黑名单用户
+     */
+    @GetMapping("/corp/{corpId}")
+    public CommonResponse<List<QywxCorpBlacklistUser>> getBlacklistByCorpId(@PathVariable Long corpId) {
+        try {
+            log.info("Request to get corp blacklist users for corpId: {}", corpId);
+            
+            // 参数校验
+            if (corpId == null) {
+                log.warn("Get corp blacklist request with null corpId");
+                return CommonResponse.create(-1, "企业ID不能为空");
+            }
+            if (corpId <= 0) {
+                log.warn("Get corp blacklist request with invalid corpId: {}", corpId);
+                return CommonResponse.create(-1, "企业ID必须是有效的正数");
+            }
+            
+            // 调用业务服务获取企业黑名单用户
+            List<QywxCorpBlacklistUser> users = corpBlacklistService.getBlacklistByCorpId(corpId);
+            
+            log.info("Retrieved corp blacklist users for corpId: {}, count: {}", corpId, users.size());
+            
+            // 数据量警告
+            if (users.size() > 1000) {
+                log.warn("Large corp blacklist dataset returned: {} records for corpId: {}", users.size(), corpId);
+            }
+            
+            return CommonResponse.success(users);
+            
+        } catch (IllegalArgumentException e) {
+            log.warn("Parameter validation failed for get corp blacklist, corpId: {}", corpId, e);
+            return CommonResponse.create(-1, "参数错误: " + e.getMessage());
+        } catch (Exception e) {
+            log.error("Failed to get corp blacklist users for corpId: {}", corpId, e);
+            return CommonResponse.create(-1, "获取企业黑名单用户失败,请稍后重试");
+        }
+    }
+}