打开白名单

于相涌/mail
YXY 2 years ago committed by bob
parent 40afd5533f
commit 41faa8fe3e

@ -0,0 +1,107 @@
package com.ruoyi.flyingbook.consumer;
import cn.hutool.core.thread.ThreadFactoryBuilder;
import com.ruoyi.common.constant.RedisConstants;
import com.ruoyi.common.enums.EventOperateStatus;
import com.ruoyi.flyingbook.domain.Event;
import com.ruoyi.flyingbook.mapper.EventMapper;
import com.ruoyi.flyingbook.service.IEventService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* @author yuxiangyong
* @create 2023-03-12 23:04
*/
@Slf4j
@Component
public class LarkApplicationRunner implements ApplicationRunner {
/**
* 线
*/
private static final Integer CORE_POOL_SIZE = 1;
/**
* 线
*/
private static final Integer MAX_POOL_SIZE = 1;
/**
*
*/
private static final Integer KEEP_ALIVE_TIME = 30;
/**
*
*/
private static final Integer QUEUE_SIZE = 20;
/**
* 线
*/
private static final Integer WAIT_TIME = 5000;
@Autowired
private EventMapper eventMapper;
ThreadPoolExecutor threadPool = new ThreadPoolExecutor(CORE_POOL_SIZE, MAX_POOL_SIZE, KEEP_ALIVE_TIME,
TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(QUEUE_SIZE), new ThreadPoolExecutor.AbortPolicy());
@Override
public void run(ApplicationArguments args) throws Exception {
//这里用线程池,后续如果出现量大的情况下可以调整
// threadPool.execute(() -> {
//
// while (true) {
// List<String> statusList = Arrays.asList(EventOperateStatus.PENDING.getCode(),EventOperateStatus.FAIL.getCode());
// List<Event> eventList = eventMapper.queryListOperate(statusList);
// if (CollectionUtils.isEmpty(eventList)) {
// try {
// // 没有订单,休息一下
// Thread.sleep(WAIT_TIME);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// } else {
// try {
//
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
// });
}
private void operate(Event event){
if (StringUtils.isNotBlank(event.getMessage())){
queryAndOperate(event);
}else {
executeOperate(event);
}
}
private void queryAndOperate(Event event){
}
private void executeOperate(Event event){
}
}

@ -16,7 +16,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/event/test1")
public class EventController extends BaseController { public class EventController extends BaseController {
@Autowired @Autowired
@ -30,6 +29,7 @@ public class EventController extends BaseController {
log.error("没有值"); log.error("没有值");
return result; return result;
} }
log.info("/event/test1/approval request:{} encrypt:{}", jsonObject.toJSONString(), result);
if (jsonObject.containsKey("encrypt")) { if (jsonObject.containsKey("encrypt")) {
result = DecryptUtil.decrypt(jsonObject.getString("encrypt")); result = DecryptUtil.decrypt(jsonObject.getString("encrypt"));
log.info("/event/test1/approval request:{} encrypt:{}", jsonObject.toJSONString(), result); log.info("/event/test1/approval request:{} encrypt:{}", jsonObject.toJSONString(), result);

@ -31,7 +31,6 @@ import java.util.Map;
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/event/test2")
public class EventControllers { public class EventControllers {
@ -174,7 +173,7 @@ public class EventControllers {
private ServletAdapter servletAdapter; private ServletAdapter servletAdapter;
//3. 创建路由处理器 //3. 创建路由处理器
@PostMapping("/approval") @PostMapping("/approval2")
public void event(HttpServletRequest request, HttpServletResponse response) public void event(HttpServletRequest request, HttpServletResponse response)
throws Throwable { throws Throwable {
//3.1 回调扩展包提供的事件回调处理器 //3.1 回调扩展包提供的事件回调处理器

@ -17,7 +17,8 @@ public class Event extends BaseEntity
/** $column.columnComment */ /** $column.columnComment */
private Long id; private Long id;
private Integer numbers;
private String eventCode;
/** $column.columnComment */ /** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String message; private String message;
@ -26,6 +27,14 @@ public class Event extends BaseEntity
@Excel(name = "pendingsuccessfaild") @Excel(name = "pendingsuccessfaild")
private String flag; private String flag;
public Integer getNumbers() {
return numbers;
}
public void setNumbers(Integer numbers) {
this.numbers = numbers;
}
public void setId(Long id) public void setId(Long id)
{ {
this.id = id; this.id = id;
@ -59,6 +68,7 @@ public class Event extends BaseEntity
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId()) .append("id", getId())
.append("message", getMessage()) .append("message", getMessage())
.append("numbers", getMessage())
.append("createBy", getCreateBy()) .append("createBy", getCreateBy())
.append("createTime", getCreateTime()) .append("createTime", getCreateTime())
.append("updateBy", getUpdateBy()) .append("updateBy", getUpdateBy())

@ -2,6 +2,7 @@ package com.ruoyi.flyingbook.mapper;
import com.ruoyi.flyingbook.domain.Event; import com.ruoyi.flyingbook.domain.Event;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -60,4 +61,9 @@ public interface EventMapper
* @return * @return
*/ */
public int deleteEventByIds(Long[] ids); public int deleteEventByIds(Long[] ids);
/**
*
*/
public List<Event> queryListOperate(@Param("statusList") List<String> statusList);
} }

@ -6,7 +6,9 @@
<resultMap type="Event" id="EventResult"> <resultMap type="Event" id="EventResult">
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="event_code" column="eventCode"/>
<result property="message" column="message"/> <result property="message" column="message"/>
<result property="numbers" column="numbers"/>
<result property="createBy" column="create_by"/> <result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/> <result property="updateBy" column="update_by"/>
@ -17,7 +19,9 @@
<sql id="selectEventVo"> <sql id="selectEventVo">
select id, select id,
event_code,
message, message,
numbers,
create_by, create_by,
create_time, create_time,
update_by, update_by,
@ -43,7 +47,9 @@
<insert id="insertEvent" parameterType="Event" useGeneratedKeys="true" keyProperty="id"> <insert id="insertEvent" parameterType="Event" useGeneratedKeys="true" keyProperty="id">
insert into event insert into event
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="eventCode != null">event_code,</if>
<if test="message != null">message,</if> <if test="message != null">message,</if>
<if test="numbers != null">numbers,</if>
<if test="createBy != null and createBy != ''">create_by,</if> <if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if> <if test="updateBy != null">update_by,</if>
@ -52,7 +58,9 @@
<if test="remark != null">remark,</if> <if test="remark != null">remark,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="eventCode != null">#{event_code},</if>
<if test="message != null">#{message},</if> <if test="message != null">#{message},</if>
<if test="numbers != null">#{numbers},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if> <if test="updateBy != null">#{updateBy},</if>
@ -65,7 +73,9 @@
<update id="updateEvent" parameterType="Event"> <update id="updateEvent" parameterType="Event">
update event update event
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="message != null">message = #{message},</if> <if test="eventCode != null and eventCode != ''">message = #{event_code},</if>
<if test="message != null and message != ''">message = #{message},</if>
<if test="numbers != null">message = #{numbers},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if> <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
@ -88,4 +98,13 @@
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
<select id="queryListOperate" resultMap="EventResult">
<include refid="selectEventVo"/>
where 3 > numbers
and flag in
<foreach collection="statusList" item="status" open="(" close=")" separator=",">
#{status}
</foreach>
</select>
</mapper> </mapper>

@ -97,7 +97,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
// 过滤请求 // 过滤请求
.authorizeRequests() .authorizeRequests()
// 对于登录login 验证码captchaImage 允许匿名访问 // 对于登录login 验证码captchaImage 允许匿名访问
.antMatchers("/login", "/captchaImage").anonymous() .antMatchers("/login", "/captchaImage", "/approval", "/approval2").anonymous()
.antMatchers( .antMatchers(
HttpMethod.GET, HttpMethod.GET,
"/*.html", "/*.html",
@ -115,7 +115,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.antMatchers("/druid/**").anonymous() .antMatchers("/druid/**").anonymous()
.antMatchers("/flowable/**").permitAll() .antMatchers("/flowable/**").permitAll()
.antMatchers("/socket/**").permitAll() .antMatchers("/socket/**").permitAll()
.antMatchers("/event/**").permitAll() .antMatchers("//event/**").permitAll()
// 除上面外的所有请求全部需要鉴权认证 // 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated() .anyRequest().authenticated()
.and() .and()

Loading…
Cancel
Save