parent
0a527e83a9
commit
fe8f41044a
@ -0,0 +1,26 @@
|
||||
package com.xjs.business.english;
|
||||
|
||||
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.xjs.business.english.domain.EnglishWordDTO;
|
||||
import com.xjs.business.english.factory.RemoteEnglishFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 调用openapi服务AreaController feign
|
||||
*
|
||||
* @author xiejs
|
||||
* @since 2022-03-23
|
||||
*/
|
||||
@FeignClient(contextId = "remoteEnglishFeign",
|
||||
value = ServiceNameConstants.BUSINESS_ENGLISH_SERVICE,
|
||||
fallbackFactory = RemoteEnglishFactory.class)
|
||||
public interface RemoteEnglishFeign {
|
||||
|
||||
@GetMapping("/word/getEnglishWordForRpc")
|
||||
R<List<EnglishWordDTO>> getEnglishWordByRandom();
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.xjs.business.english.domain;
|
||||
|
||||
import com.ruoyi.common.core.annotation.Excel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 英语单词对象 english_word
|
||||
*
|
||||
* @author xjs
|
||||
* @since 2021-12-29
|
||||
*/
|
||||
@Data
|
||||
public class EnglishWordDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 英语单词
|
||||
*/
|
||||
private String englishWord;
|
||||
|
||||
/**
|
||||
* 对应的中文
|
||||
*/
|
||||
private String chineseWord;
|
||||
|
||||
/**
|
||||
* 查看次数
|
||||
*/
|
||||
private Long lookCount;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.xjs.business.english.factory;
|
||||
|
||||
import com.xjs.business.english.RemoteEnglishFeign;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
*英语服务降级处理
|
||||
* @author xiejs
|
||||
* @since 2022-06-15
|
||||
*/
|
||||
@Component
|
||||
public class RemoteEnglishFactory implements FallbackFactory<RemoteEnglishFeign> {
|
||||
|
||||
@Override
|
||||
public RemoteEnglishFeign create(Throwable cause) {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,82 +1,105 @@
|
||||
<?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">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.system.mapper.SysOperLogMapper">
|
||||
|
||||
<resultMap type="SysOperLog" id="SysOperLogResult">
|
||||
<id property="operId" column="oper_id" />
|
||||
<result property="title" column="title" />
|
||||
<result property="businessType" column="business_type" />
|
||||
<result property="method" column="method" />
|
||||
<result property="requestMethod" column="request_method" />
|
||||
<result property="operatorType" column="operator_type" />
|
||||
<result property="operName" column="oper_name" />
|
||||
<result property="deptName" column="dept_name" />
|
||||
<result property="operUrl" column="oper_url" />
|
||||
<result property="operIp" column="oper_ip" />
|
||||
<result property="operParam" column="oper_param" />
|
||||
<result property="jsonResult" column="json_result" />
|
||||
<result property="status" column="status" />
|
||||
<result property="errorMsg" column="error_msg" />
|
||||
<result property="operTime" column="oper_time" />
|
||||
</resultMap>
|
||||
<resultMap type="SysOperLog" id="SysOperLogResult">
|
||||
<id property="operId" column="oper_id"/>
|
||||
<result property="title" column="title"/>
|
||||
<result property="businessType" column="business_type"/>
|
||||
<result property="method" column="method"/>
|
||||
<result property="requestMethod" column="request_method"/>
|
||||
<result property="operatorType" column="operator_type"/>
|
||||
<result property="operName" column="oper_name"/>
|
||||
<result property="deptName" column="dept_name"/>
|
||||
<result property="operUrl" column="oper_url"/>
|
||||
<result property="operIp" column="oper_ip"/>
|
||||
<result property="operParam" column="oper_param"/>
|
||||
<result property="jsonResult" column="json_result"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="errorMsg" column="error_msg"/>
|
||||
<result property="operTime" column="oper_time"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectOperLogVo">
|
||||
select oper_id, title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_param, json_result, status, error_msg, oper_time
|
||||
<sql id="selectOperLogVo">
|
||||
select oper_id,
|
||||
title,
|
||||
business_type,
|
||||
method,
|
||||
request_method,
|
||||
operator_type,
|
||||
oper_name,
|
||||
dept_name,
|
||||
oper_url,
|
||||
oper_ip,
|
||||
oper_param,
|
||||
json_result,
|
||||
status,
|
||||
error_msg,
|
||||
oper_time
|
||||
from sys_oper_log
|
||||
</sql>
|
||||
|
||||
<insert id="insertOperlog" parameterType="SysOperLog">
|
||||
insert into sys_oper_log(title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_param, json_result, status, error_msg, oper_time)
|
||||
values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, sysdate())
|
||||
</insert>
|
||||
|
||||
<select id="selectOperLogList" parameterType="SysOperLog" resultMap="SysOperLogResult">
|
||||
<include refid="selectOperLogVo"/>
|
||||
<where>
|
||||
<if test="title != null and title != ''">
|
||||
AND title like concat('%', #{title}, '%')
|
||||
</if>
|
||||
<if test="businessType != null and businessType != ''">
|
||||
AND business_type = #{businessType}
|
||||
</if>
|
||||
<if test="businessTypes != null and businessTypes.length > 0">
|
||||
AND business_type in
|
||||
<foreach collection="businessTypes" item="businessType" open="(" separator="," close=")">
|
||||
#{businessType}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="operName != null and operName != ''">
|
||||
AND oper_name like concat('%', #{operName}, '%')
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
and date_format(oper_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(oper_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
</where>
|
||||
order by oper_id desc
|
||||
</select>
|
||||
|
||||
<delete id="deleteOperLogByIds" parameterType="Long">
|
||||
delete from sys_oper_log where oper_id in
|
||||
<foreach collection="array" item="operId" open="(" separator="," close=")">
|
||||
#{operId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectOperLogById" parameterType="Long" resultMap="SysOperLogResult">
|
||||
<include refid="selectOperLogVo"/>
|
||||
where oper_id = #{operId}
|
||||
</select>
|
||||
|
||||
<update id="cleanOperLog">
|
||||
|
||||
<insert id="insertOperlog" parameterType="SysOperLog">
|
||||
insert into sys_oper_log(title, business_type, method, request_method, operator_type, oper_name, dept_name,
|
||||
oper_url, oper_ip, oper_param, json_result, status, error_msg, oper_time)
|
||||
values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName},
|
||||
#{operUrl}, #{operIp}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, sysdate())
|
||||
</insert>
|
||||
|
||||
<select id="selectOperLogList" parameterType="SysOperLog" resultMap="SysOperLogResult">
|
||||
<include refid="selectOperLogVo"/>
|
||||
<where>
|
||||
<if test="title != null and title != ''">
|
||||
AND title like concat('%', #{title}, '%')
|
||||
</if>
|
||||
<if test="businessType != null and businessType != ''">
|
||||
AND business_type = #{businessType}
|
||||
</if>
|
||||
<if test="businessTypes != null and businessTypes.length > 0">
|
||||
AND business_type in
|
||||
<foreach collection="businessTypes" item="businessType" open="(" separator="," close=")">
|
||||
#{businessType}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="operName != null and operName != ''">
|
||||
AND oper_name like concat('%', #{operName}, '%')
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
and date_format(oper_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(oper_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
</where>
|
||||
order by oper_id desc
|
||||
</select>
|
||||
|
||||
<delete id="deleteOperLogByIds" parameterType="Long">
|
||||
delete from sys_oper_log where oper_id in
|
||||
<foreach collection="array" item="operId" open="(" separator="," close=")">
|
||||
#{operId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectOperLogById" parameterType="Long" resultMap="SysOperLogResult">
|
||||
<include refid="selectOperLogVo"/>
|
||||
where oper_id = #{operId}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectNewOperLog" resultMap="SysOperLogResult">
|
||||
select oper_id, title, business_type, request_method, oper_name,oper_ip
|
||||
from sys_oper_log
|
||||
order by oper_time desc limit 5
|
||||
</select>
|
||||
|
||||
<update id="cleanOperLog">
|
||||
truncate table sys_oper_log
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.xjs.consts;
|
||||
|
||||
/**
|
||||
* 通用常量
|
||||
* @author xiejs
|
||||
* @since 2022-06-15
|
||||
*/
|
||||
public class CommonConst {
|
||||
|
||||
public static final String TODAY_START = "00:00:00";
|
||||
public static final String TODAY_END = "23:59:59";
|
||||
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package com.xjs;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.xjs.apilog.service.IApiLogService;
|
||||
import com.xjs.maillog.service.MailLogService;
|
||||
import com.xjs.other.LogNumberVo;
|
||||
import com.xjs.reptileLog.service.WebmagicLogService;
|
||||
import com.xjs.tasklog.service.TaskLogService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/**
|
||||
* 通用日志控制器
|
||||
* @author xiejs
|
||||
* @since 2022-06-15
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("log")
|
||||
@Api(tags = "业务模块-通用日志")
|
||||
public class CommonLogController {
|
||||
private final ExecutorService executor = Executors.newFixedThreadPool(5);
|
||||
|
||||
@Autowired
|
||||
private IApiLogService apiLogService;
|
||||
@Autowired
|
||||
private MailLogService mailLogService;
|
||||
@Autowired
|
||||
private WebmagicLogService webmagicLogService;
|
||||
@Autowired
|
||||
private TaskLogService taskLogService;
|
||||
|
||||
//---------------------------内部调用----------------------------------------------
|
||||
|
||||
@GetMapping("groupLogNumberForRPC")
|
||||
@ApiOperation("聚合日志次数")
|
||||
public R<Map<Object, Object>> groupLogNumber() throws ExecutionException, InterruptedException {
|
||||
CompletableFuture<LogNumberVo> apiLogFuture = CompletableFuture.supplyAsync(() ->
|
||||
apiLogService.getCount(), executor);
|
||||
|
||||
CompletableFuture<LogNumberVo> mailLogFuture = CompletableFuture.supplyAsync(() ->
|
||||
mailLogService.getCount(), executor);
|
||||
|
||||
CompletableFuture<LogNumberVo> webmagicLogFuture = CompletableFuture.supplyAsync(() ->
|
||||
webmagicLogService.getCount(), executor);
|
||||
|
||||
CompletableFuture<LogNumberVo> taskLogFuture = CompletableFuture.supplyAsync(() ->
|
||||
taskLogService.getCount(), executor);
|
||||
|
||||
CompletableFuture.allOf(apiLogFuture,mailLogFuture,webmagicLogFuture,taskLogFuture).get();
|
||||
|
||||
Map<Object, Object> map = MapUtil.builder()
|
||||
.put("apiLog",apiLogFuture.get())
|
||||
.put("mailLog",mailLogFuture.get())
|
||||
.put("webmagicLog",webmagicLogFuture.get())
|
||||
.put("taskLog",taskLogFuture.get())
|
||||
.build();
|
||||
return R.ok(map);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.xjs.other;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 日志次数vo
|
||||
* @author xiejs
|
||||
* @since 2022-06-15
|
||||
*/
|
||||
@Data
|
||||
public class LogNumberVo {
|
||||
|
||||
/**
|
||||
* 今日次数
|
||||
*/
|
||||
private Long todayNumber;
|
||||
|
||||
/**
|
||||
* 总次数
|
||||
*/
|
||||
private Long total;
|
||||
}
|
Loading…
Reference in new issue