前端主页页面实现

pull/254/head
xjs 3 years ago
parent 0a527e83a9
commit fe8f41044a

@ -1,6 +1,7 @@
package com.ruoyi.system.api;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
@ -11,6 +12,8 @@ import com.ruoyi.system.api.domain.SysLogininfor;
import com.ruoyi.system.api.domain.SysOperLog;
import com.ruoyi.system.api.factory.RemoteLogFallbackFactory;
import java.util.List;
/**
*
*
@ -38,4 +41,7 @@ public interface RemoteLogService
*/
@PostMapping("/logininfor")
public R<Boolean> saveLogininfor(@RequestBody SysLogininfor sysLogininfor, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
@GetMapping("/operlog/selectNewOperLog")
R<List<SysOperLog>> selectNewOperLog(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}

@ -9,6 +9,8 @@ import com.ruoyi.system.api.RemoteLogService;
import com.ruoyi.system.api.domain.SysLogininfor;
import com.ruoyi.system.api.domain.SysOperLog;
import java.util.List;
/**
*
*
@ -36,6 +38,11 @@ public class RemoteLogFallbackFactory implements FallbackFactory<RemoteLogServic
{
return null;
}
@Override
public R<List<SysOperLog>> selectNewOperLog(String source) {
return null;
}
};
}

@ -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;
/**
* openapiAreaController 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;
}
}

@ -41,4 +41,7 @@ public interface RemoteLogFeign {
@PostMapping("maillog/saveForRPC")
R<Object> saveMailLog(@RequestBody MailLog mailLog);
@GetMapping("log/groupLogNumberForRPC")
R<Map<Object, Object>> groupLogNumber();
}

@ -55,6 +55,12 @@ public class RemoteLogFactory implements FallbackFactory<RemoteLogFeign> {
log.error("日志模块邮件日志服务添加调用失败");
return R.fail("日志模块邮件日志服务添加调用失败" + cause.getMessage());
}
@Override
public R<Map<Object, Object>> groupLogNumber() {
log.error("日志模块获取日志次数调用失败");
return R.fail("日志模块获取日志次数调用失败" + cause.getMessage());
}
};
}
}

@ -6,6 +6,8 @@ import com.xjs.business.webmagic.factory.RemoteWebmagicSinaFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.Map;
/**
*
* @author xiejs
@ -18,4 +20,7 @@ public interface RemoteWebmagicSinaFeign {
@GetMapping("/sinaNews/taskForPRC")
R sinaTaskForPRC();
@GetMapping("/sinaNews/getNewsForRpc")
R<Map<Object, Object>> getNews();
}

@ -6,6 +6,8 @@ import lombok.extern.log4j.Log4j2;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
*
* @author xiejs
@ -23,6 +25,12 @@ public class RemoteWebmagicSinaFactory implements FallbackFactory<RemoteWebmagic
log.error("新浪 爬虫定时任务 降级------服务可能正在运行");
return R.fail("降级处理------服务可能正在运行");
}
@Override
public R<Map<Object, Object>> getNews() {
log.error("新浪 获取最新新闻 降级------服务可能正在运行");
return R.fail("降级处理------服务可能正在运行");
}
};
}
}

@ -42,6 +42,11 @@ public class ServiceNameConstants {
*/
public static final String BUSINESS_WEBMAGIC_SERVICE = "xjs-webmagic";
/**
* serviceid
*/
public static final String BUSINESS_ENGLISH_SERVICE = "xjs-english";
/**
* serviceid
*/

@ -23,6 +23,9 @@ import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import java.time.Duration;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
/**
* redis
@ -93,8 +96,21 @@ public class RedisConfig extends CachingConfigurerSupport {
config = config.disableCachingNullValues();
}
RedisCacheManager cacheManager = RedisCacheManager.builder(redisConnectionFactory).cacheDefaults(config).build();
return cacheManager;
//单独给某个定义过期时间
Set<String> cacheNames = new HashSet<>();
cacheNames.add("bussiness:index:wb_search");
cacheNames.add("bussiness:index:log_count");
cacheNames.add("bussiness:index:oper_log");
ConcurrentHashMap<String, RedisCacheConfiguration> configMap = new ConcurrentHashMap<>();
configMap.put("bussiness:index:wb_search", config.entryTtl(Duration.ofMinutes(10L)));
configMap.put("bussiness:index:log_count", config.entryTtl(Duration.ofMinutes(10L)));
configMap.put("bussiness:index:oper_log", config.entryTtl(Duration.ofSeconds(10L)));
return RedisCacheManager.builder(redisConnectionFactory)
.cacheDefaults(config)
.initialCacheNames(cacheNames)
.withInitialCacheConfigurations(configMap)
.build();
}

@ -1,15 +1,6 @@
package com.ruoyi.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
@ -20,6 +11,11 @@ import com.ruoyi.common.security.annotation.InnerAuth;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.api.domain.SysOperLog;
import com.ruoyi.system.service.ISysOperLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
*
@ -75,4 +71,12 @@ public class SysOperlogController extends BaseController
{
return toAjax(operLogService.insertOperlog(operLog));
}
//--------------------------------内部调用rpc----------------------------------------
@GetMapping("selectNewOperLog")
@InnerAuth
public R<List<SysOperLog>> selectNewOperLog() {
List<SysOperLog> sysOperLogs = operLogService.selectNewOperLog();
return R.ok(sysOperLogs);
}
}

@ -1,8 +1,9 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.api.domain.SysOperLog;
import java.util.List;
/**
*
*
@ -45,4 +46,10 @@ public interface SysOperLogMapper
*
*/
public void cleanOperLog();
/**
* 5
* @return list
*/
List<SysOperLog> selectNewOperLog();
}

@ -1,8 +1,9 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.api.domain.SysOperLog;
import java.util.List;
/**
*
*
@ -46,4 +47,10 @@ public interface ISysOperLogService
*
*/
public void cleanOperLog();
/**
* 5
* @return list
*/
List<SysOperLog> selectNewOperLog();
}

@ -1,11 +1,12 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.api.domain.SysOperLog;
import com.ruoyi.system.mapper.SysOperLogMapper;
import com.ruoyi.system.service.ISysOperLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
*
@ -13,8 +14,7 @@ import com.ruoyi.system.service.ISysOperLogService;
* @author ruoyi
*/
@Service
public class SysOperLogServiceImpl implements ISysOperLogService
{
public class SysOperLogServiceImpl implements ISysOperLogService {
@Autowired
private SysOperLogMapper operLogMapper;
@ -25,8 +25,7 @@ public class SysOperLogServiceImpl implements ISysOperLogService
* @return
*/
@Override
public int insertOperlog(SysOperLog operLog)
{
public int insertOperlog(SysOperLog operLog) {
return operLogMapper.insertOperlog(operLog);
}
@ -37,8 +36,7 @@ public class SysOperLogServiceImpl implements ISysOperLogService
* @return
*/
@Override
public List<SysOperLog> selectOperLogList(SysOperLog operLog)
{
public List<SysOperLog> selectOperLogList(SysOperLog operLog) {
return operLogMapper.selectOperLogList(operLog);
}
@ -49,8 +47,7 @@ public class SysOperLogServiceImpl implements ISysOperLogService
* @return
*/
@Override
public int deleteOperLogByIds(Long[] operIds)
{
public int deleteOperLogByIds(Long[] operIds) {
return operLogMapper.deleteOperLogByIds(operIds);
}
@ -61,8 +58,7 @@ public class SysOperLogServiceImpl implements ISysOperLogService
* @return
*/
@Override
public SysOperLog selectOperLogById(Long operId)
{
public SysOperLog selectOperLogById(Long operId) {
return operLogMapper.selectOperLogById(operId);
}
@ -70,8 +66,12 @@ public class SysOperLogServiceImpl implements ISysOperLogService
*
*/
@Override
public void cleanOperLog()
{
public void cleanOperLog() {
operLogMapper.cleanOperLog();
}
@Override
public List<SysOperLog> selectNewOperLog() {
return operLogMapper.selectNewOperLog();
}
}

@ -1,81 +1,104 @@
<?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>
<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') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and date_format(oper_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
</where>
order by oper_id desc
</select>
<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') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and date_format(oper_time,'%y%m%d') &lt;= 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}
<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>
</delete>
<select id="selectOperLogById" parameterType="Long" resultMap="SysOperLogResult">
<include refid="selectOperLogVo"/>
where oper_id = #{operId}
</select>
<select id="selectOperLogById" parameterType="Long" resultMap="SysOperLogResult">
<include refid="selectOperLogVo"/>
where oper_id = #{operId}
</select>
<update id="cleanOperLog">
<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>

@ -2,18 +2,12 @@
import request from '@/utils/request'
export function showWbSearch() {
export function showData() {
return request({
url: '/openapi/index/showWbSearch',
url: '/openapi/index/showData',
method: 'get'
})
}
export function showCopyWriting() {
return request({
url: '/openapi/index/showCopyWriting',
method: 'get'
})
}

@ -1,27 +1,111 @@
<template>
<div class="app-container">
<div class="app-container" style="padding-top: 0">
<el-row :gutter="5">
<el-col :span="8">
<div class="grid-content bg-purple">
<el-col :span="4">
<div>
<el-card shadow="hover" :body-style="{padding:'3px'}">
<router-link :to="'/business/logs/apilog/'">
<div class="board">
<div class="top_board">API数</div>
<div class="content_board">今日:<span class="num_class">{{ logCount.apiLog.todayNumber }}</span></div>
<div class="content_board">总计:<span class="num_class">{{ logCount.apiLog.total }}</span></div>
</div>
</router-link>
</el-card>
</div>
</el-col>
<el-col :span="4">
<div>
<el-card shadow="hover" :body-style="{padding:'3px'}">
<router-link :to="'/business/logs/reptileLog/'">
<div class="board">
<div class="top_board">爬虫数</div>
<div class="content_board">今日:<span class="num_class">{{ logCount.webmagicLog.todayNumber }}</span>
</div>
<div class="content_board">总计:<span class="num_class">{{ logCount.webmagicLog.total }}</span></div>
</div>
</router-link>
</el-card>
</div>
</el-col>
<el-col :span="4">
<div>
<el-card shadow="hover" :body-style="{padding:'3px'}">
<router-link :to="'/business/logs/taskLog/'">
<div class="board">
<div class="top_board">任务数</div>
<div class="content_board">今日:<span class="num_class">{{ logCount.taskLog.todayNumber }}</span></div>
<div class="content_board">总计:<span class="num_class">{{ logCount.taskLog.total }}</span></div>
</div>
</router-link>
</el-card>
</div>
</el-col>
<el-col :span="4">
<div>
<el-card shadow="hover" :body-style="{padding:'3px'}">
<router-link :to="'/business/logs/maillog/'">
<div class="board">
<div class="top_board">邮件数</div>
<div class="content_board">今日:<span class="num_class">{{ logCount.mailLog.todayNumber }}</span></div>
<div class="content_board">总计:<span class="num_class">{{ logCount.mailLog.total }}</span></div>
</div>
</router-link>
</el-card>
</div>
</el-col>
<el-col :span="4">
<div>
<el-card shadow="hover" :body-style="{padding:'3px'}">
<router-link :to="'/user/profile/'">
<div class="board">
<div class="top_board">登录数</div>
<div class="content_board"><span v-html="'&nbsp'"></span></div>
<div class="content_board">总计:<span class="num_class">{{ loginCount }}</span></div>
</div>
</router-link>
</el-card>
</div>
</el-col>
<el-col :span="4">
<div>
<el-card shadow="hover" :body-style="{padding:'3px'}">
<div class="board">
<div class="top_board">IP信息</div>
<div class="content_board">IP:<span class="num_class">{{ ipInfo.ip }}</span></div>
<div class="content_board">归属地:<span class="num_class">{{ ipInfo.desc }}</span></div>
</div>
</el-card>
</div>
</el-col>
</el-row>
<el-row :gutter="5">
<el-col :span="6">
<div>
<el-card class="box-card" :body-style="{padding:'3px'}" shadow="hover">
<div slot="header" style="font-size: 18px;color: #3A71A8;font-weight: 800;padding: 0">
<span>最新微博热搜</span>
</div>
<div v-for="wb in WbDataList" :key="wb.id" style="color: #8492a6;">
<div v-for="wb in WbDataList" :key="wb.id" style="color: #8492a6;" class="top_content">
{{ wb.hotword }}
</div>
</el-card>
</div>
</el-col>
<el-col :span="16">
<div class="grid-content bg-purple">
<el-col :span="18">
<div>
<el-card class="box-card" :body-style="{padding:'3px'}" shadow="hover">
<div slot="header" style="font-size: 18px;color: #00BCD4;font-weight: 800;padding: 0">
<span>文案</span>
</div>
<div v-for="copyWriting in copyWritingList" :key="copyWriting.id" class="top_content"
style="color: #bfcbd9;">
<el-tooltip effect="light" :content="copyWriting.content+' ——— '+copyWriting.type" placement="top">
<el-tooltip effect="light" :content="copyWriting.content+' ——— '+copyWriting.type" placement="top"
:enterable="false">
<span>{{ copyWriting.content }} <span style="color: #bfcbc5">{{ copyWriting.type }}</span></span>
</el-tooltip>
</div>
@ -31,17 +115,159 @@
</el-row>
<el-row :gutter="5">
<el-col :span="24">
<div class="grid-content bg-purple"></div>
<div>
<el-card class="box-card" :body-style="{padding:'3px'}" shadow="hover">
<div slot="header" style="font-size: 18px;color: #7a6df0;font-weight: 800;padding: 0">
<span>网易云热评</span>
</div>
<div v-for="yun in yunList" :key="yun.id" class="top_content" style="color: #999999;">
<el-tooltip effect="light" :content="yun.content+' ——— '+yun.source" placement="top" :enterable="false">
<span>{{ yun.content }} <span style="color: #bfcbc5">{{ yun.source }}</span></span>
</el-tooltip>
</div>
</el-card>
</div>
</el-col>
</el-row>
<el-row :gutter="5">
<el-col :span="24">
<div class="grid-content bg-purple"></div>
<el-col :span="13">
<div>
<el-card class="box-card" :body-style="{padding:'3px'}" shadow="hover">
<div slot="header" style="font-size: 18px;color: #ffba00;font-weight: 800;padding: 0">
<span>最新操作日志</span>
</div>
<el-table
:data="operLogTableData"
style="width: 100%"
:row-style="{height: '0'}"
:cell-style="{padding: '0'}"
border
>
<el-table-column prop="title" label="系统模块" align="center" :show-overflow-tooltip="true"/>
<el-table-column prop="businessType" label="操作类型" align="center" :show-overflow-tooltip="true">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_oper_type" :value="scope.row.businessType"/>
</template>
</el-table-column>
<el-table-column prop="requestMethod" label="请求方式" align="center" :show-overflow-tooltip="true"/>
<el-table-column prop="operName" label="操作人员" align="center" :show-overflow-tooltip="true"/>
<el-table-column label="主机" align="center" prop="operIp" :show-overflow-tooltip="true"/>
</el-table>
</el-card>
</div>
</el-col>
<el-col :span="11">
<el-card class="box-card" :body-style="{padding:'3px'}" shadow="hover">
<div slot="header" style="font-size: 18px;color: #ff4949;font-weight: 800;padding: 0">
<span>英语单词</span>
</div>
<el-table
:data="englishWordTableData"
style="width: 100%"
:row-style="{height: '0'}"
:cell-style="{padding: '0'}"
border
>
<el-table-column prop="englishWord" label="英语单词" align="center" :show-overflow-tooltip="true"/>
<el-table-column prop="chineseWord" label="中文翻译" align="center" :show-overflow-tooltip="true">
<template slot-scope="scope">
<el-tag type="success">{{ scope.row.chineseWord }}</el-tag>
</template>
</el-table-column>
<el-table-column prop="lookCount" label="查看次数" align="center" :show-overflow-tooltip="true"/>
<el-table-column prop="createTime" label="创建时间" align="center" :show-overflow-tooltip="true"/>
</el-table>
</el-card>
</el-col>
</el-row>
<el-row :gutter="5">
<el-col :span="24">
<div class="grid-content bg-purple"></div>
<el-col :span="12">
<div>
<el-card class="box-card" :body-style="{padding:'3px'}" shadow="hover">
<div slot="header" style="font-size: 18px;color: #BD2828;font-weight: 800;padding: 0">
<span>最新国内新闻</span>
</div>
<div v-for="internalNews in internalNewsList" :key="internalNews.title" class="top_content"
style="color: #666666;">
<span @click="toLookNews(internalNews.url)" style="cursor: pointer">{{ internalNews.title }}</span>
</div>
</el-card>
</div>
</el-col>
<el-col :span="12">
<div>
<el-card class="box-card" :body-style="{padding:'3px'}" shadow="hover">
<div slot="header" style="font-size: 18px;color: #3d8610;font-weight: 800;padding: 0">
<span>最新国际新闻</span>
</div>
<div v-for="internationalNews in internationalNewsList" :key="internationalNews.title" class="top_content"
style="color: #324157;">
<span @click="toLookNews(internationalNews.url)" style="cursor: pointer">{{
internationalNews.title
}}</span>
</div>
</el-card>
</div>
</el-col>
</el-row>
<el-row :gutter="5">
<el-col :span="8">
<div>
<el-card class="box-card" :body-style="{padding:'3px'}" shadow="hover">
<div slot="header" style="font-size: 18px;color: #1482f0;font-weight: 800;padding: 0">
<span>美图鉴赏-1</span>
</div>
<el-carousel :interval="1500" type="card" height="132px">
<el-carousel-item v-for="pic in beautyPictureList1" :key="pic">
<el-image
style="width: 234px; height: 132px"
:src="pic"
:preview-src-list="beautyPictureList1">
</el-image>
</el-carousel-item>
</el-carousel>
</el-card>
</div>
</el-col>
<el-col :span="8">
<div>
<el-card class="box-card" :body-style="{padding:'3px'}" shadow="hover">
<div slot="header" style="font-size: 18px;color: #1482f0;font-weight: 800;padding: 0">
<span>美图鉴赏-2</span>
</div>
<el-carousel :interval="1500" type="card" height="132px">
<el-carousel-item v-for="pic in beautyPictureList2" :key="pic">
<el-image
style="width: 234px; height: 132px"
:src="pic"
:preview-src-list="beautyPictureList2">
</el-image>
</el-carousel-item>
</el-carousel>
</el-card>
</div>
</el-col>
<el-col :span="8">
<div>
<el-card class="box-card" :body-style="{padding:'3px'}" shadow="hover">
<div slot="header" style="font-size: 18px;color: #1482f0;font-weight: 800;padding: 0">
<span>美图鉴赏-3</span>
</div>
<el-carousel :interval="1500" type="card" height="132px">
<el-carousel-item v-for="pic in beautyPictureList3" :key="pic">
<el-image
style="width: 234px; height: 132px"
:src="pic"
:preview-src-list="beautyPictureList3">
</el-image>
</el-carousel-item>
</el-carousel>
</el-card>
</div>
</el-col>
</el-row>
</div>
@ -49,21 +275,53 @@
<script>
import {showCopyWriting, showWbSearch} from "@/api";
import {showData} from "@/api";
export default {
name: "Index",
dicts: ['sys_oper_type'],
data() {
return {
WbDataList: {},
copyWritingList: {},
WbDataList: [],
copyWritingList: [],
yunList: [],
logCount: {
apiLog: {
todayNumber: 0,
total: 0
},
webmagicLog: {
todayNumber: 0,
total: 0
},
taskLog: {
todayNumber: 0,
total: 0
},
mailLog: {
todayNumber: 0,
total: 0
}
},
loginCount: 0,
operLogTableData: [],
englishWordTableData: [],
internalNewsList: [],
internationalNewsList: [],
beautyPictureList1: [],
beautyPictureList2: [],
beautyPictureList3: [],
ipInfo:{},
};
},
created() {
this.showWbSearch()
this.showCopyWriting()
this.showData()
},
mounted() {
@ -72,17 +330,32 @@ export default {
methods: {
showWbSearch() {
showWbSearch().then(res => {
this.WbDataList = res.data
})
toLookNews(url) {
window.open(url)
},
showCopyWriting() {
showCopyWriting().then(res => {
this.copyWritingList = res.data
showData() {
this.$modal.loading("请稍后...")
showData().then(res => {
this.WbDataList = res.data.weiboList
this.copyWritingList = res.data.networkDTOList
this.yunList = res.data.yunList
this.logCount = res.data.logCount
this.loginCount = res.data.loginCount
this.operLogTableData = res.data.sysOperLog
this.englishWordTableData = res.data.englishWord
this.internalNewsList = res.data.news.internal
this.internationalNewsList = res.data.news.international
this.beautyPictureList1 = res.data.beautyPicture.one
this.beautyPictureList2 = res.data.beautyPicture.two
this.beautyPictureList3 = res.data.beautyPicture.three
this.ipInfo = res.data.ipInfo
this.$modal.closeLoading()
})
},
},
@ -97,34 +370,30 @@ export default {
text-overflow: ellipsis; /*超出显示省略号*/
font-size: 14px;
font-weight: 700;
font-weight: 600;
padding-left: 10px;
}
.el-col {
border-radius: 4px;
.top_board {
font-weight: 800;
font-size: 20px;
color: #0072c6;
}
.bg-purple-dark {
background: #99a9bf;
.board {
width: 100%;
text-align: center;
cursor: pointer;
}
.bg-purple {
background: #d3dce6;
.content_board {
color: #999093;
font-weight: 600;
}
.bg-purple-light {
background: #e5e9f2;
.num_class {
color: #7171C6;
}
.grid-content {
border-radius: 4px;
min-height: 36px;
}
.row-bg {
padding: 10px 0;
background-color: #f9fafc;
}
</style>

@ -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";
}

@ -1,6 +1,7 @@
package com.xjs.word.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.log.annotation.Log;
@ -80,6 +81,15 @@ public class EnglishWordController extends MyBaseController<EnglishWord> {
}
//------------------------内部调用rpc-----------------------------------
@GetMapping("getEnglishWordForRpc")
@ApiOperation("随机获取5条英语单词数据")
public R<List<EnglishWord>> getEnglishWordByRandom() {
List<EnglishWord> englishWordList=englishWordService.getEnglishWordByRandom();
return R.ok(englishWordList);
}
//------------------------代码自动生成-----------------------------------

@ -46,4 +46,11 @@ public interface EnglishWordMapper extends BaseMapper<EnglishWord> {
* @return
*/
int deleteEnglishWordByIds(Long[] ids);
/**
* 5
* @return list
*/
List<EnglishWord> getEnglishWordByRandom();
}

@ -72,6 +72,12 @@ public interface IEnglishWordService extends IService<EnglishWord> {
*/
public int deleteEnglishWordByIds(Long[] ids);
/**
* 5
* @return list
*/
List<EnglishWord> getEnglishWordByRandom();
//------------------------代码自动生成-----------------------------------
@ -84,4 +90,7 @@ public interface IEnglishWordService extends IService<EnglishWord> {
* @return
*/
public int deleteEnglishWordById(Long id);
}

@ -175,6 +175,11 @@ public class EnglishWordServiceImpl extends ServiceImpl<EnglishWordMapper, Engli
return englishWordMapper.deleteEnglishWordByIds(ids);
}
@Override
public List<EnglishWord> getEnglishWordByRandom() {
return englishWordMapper.getEnglishWordByRandom();
}
/**
*

@ -47,6 +47,9 @@
<include refid="selectEnglishWordVo"/>
where id = #{id}
</select>
<select id="getEnglishWordByRandom" resultType="com.xjs.word.domain.EnglishWord">
select english_word,chinese_word,look_count,create_time from english_word ORDER BY RAND() LIMIT 5
</select>
<delete id="deleteEnglishWordById" parameterType="Long">
delete

@ -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);
}
}

@ -2,6 +2,7 @@ package com.xjs.apilog.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xjs.apilog.domain.ApiLog;
import com.xjs.other.LogNumberVo;
import java.util.List;
import java.util.Map;
@ -14,6 +15,27 @@ import java.util.Map;
*/
public interface IApiLogService extends IService<ApiLog> {
/**
* api
* @return
*/
List<String> getApiName();
/**
* API
* @param startDate
* @param endDate
* @return map
*/
Map<String, List> statisticsByDate(String startDate, String endDate);
/**
*
* @return LogNumberVo
*/
LogNumberVo getCount();
//------------------------代码自动生成-----------------------------------
/**
@ -48,17 +70,6 @@ public interface IApiLogService extends IService<ApiLog> {
*/
int deleteApiLogById(Long id);
/**
* api
* @return
*/
List<String> getApiName();
/**
* API
* @param startDate
* @param endDate
* @return map
*/
Map<String, List> statisticsByDate(String startDate, String endDate);
}

@ -1,5 +1,7 @@
package com.xjs.apilog.service.impl;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.constant.HttpStatus;
import com.ruoyi.common.core.domain.R;
@ -8,14 +10,15 @@ import com.xjs.apilog.mapper.ApiLogMapper;
import com.xjs.apilog.service.IApiLogService;
import com.xjs.apilog.vo.ApiLogVo;
import com.xjs.business.warning.RemoteWarningCRUDFeign;
import com.xjs.other.LogNumberVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import static com.xjs.consts.CommonConst.TODAY_END;
import static com.xjs.consts.CommonConst.TODAY_START;
/**
* Service
@ -30,6 +33,49 @@ public class ApiLogServiceImpl extends ServiceImpl<ApiLogMapper,ApiLog> implemen
@Autowired
private RemoteWarningCRUDFeign remoteWarningCRUDFeign;
@Override
public List<String> getApiName() {
R<List<String>> apiName = remoteWarningCRUDFeign.getApiNameForRPC();
if (apiName.getCode() == HttpStatus.SUCCESS) {
return apiName.getData();
}
return new ArrayList<String>();
}
@Override
public Map<String, List> statisticsByDate(String startDate, String endDate) {
List<ApiLogVo> recordList =apiLogMapper.statisticsByDate(startDate, endDate);
Map<String, List> map = new HashMap<>();
List<String> apiNames = new ArrayList<>();
List<Long> count = new ArrayList<>();
recordList.forEach(record ->{
apiNames.add(record.getApiName());
count.add(record.getCount());
});
map.put("apiNames", apiNames);
map.put("count", count);
return map;
}
@Override
public LogNumberVo getCount() {
LogNumberVo logNumberVo = new LogNumberVo();
long total = super.count();
logNumberVo.setTotal(total);
LambdaQueryWrapper<ApiLog> wrapper = new LambdaQueryWrapper<>();
String startDate = DateUtil.today() + " "+TODAY_START;
String endDate = DateUtil.today() + " "+TODAY_END;
wrapper.between(ApiLog::getCreateTime, startDate, endDate);
long todayCount = super.count(wrapper);
logNumberVo.setTodayNumber(todayCount);
return logNumberVo;
}
//------------------------代码自动生成-----------------------------------
/**
@ -76,27 +122,5 @@ public class ApiLogServiceImpl extends ServiceImpl<ApiLogMapper,ApiLog> implemen
return apiLogMapper.deleteApiLogById(id);
}
@Override
public List<String> getApiName() {
R<List<String>> apiName = remoteWarningCRUDFeign.getApiNameForRPC();
if (apiName.getCode() == HttpStatus.SUCCESS) {
return apiName.getData();
}
return new ArrayList<String>();
}
@Override
public Map<String, List> statisticsByDate(String startDate, String endDate) {
List<ApiLogVo> recordList =apiLogMapper.statisticsByDate(startDate, endDate);
Map<String, List> map = new HashMap<>();
List<String> apiNames = new ArrayList<>();
List<Long> count = new ArrayList<>();
recordList.forEach(record ->{
apiNames.add(record.getApiName());
count.add(record.getCount());
});
map.put("apiNames", apiNames);
map.put("count", count);
return map;
}
}

@ -2,6 +2,7 @@ package com.xjs.maillog.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xjs.maillog.domain.MailLog;
import com.xjs.other.LogNumberVo;
import java.util.List;
@ -12,6 +13,11 @@ import java.util.List;
* @since 2022-04-14
*/
public interface MailLogService extends IService<MailLog> {
/**
*
* @return LogNumberVo
*/
LogNumberVo getCount();
//---------------------------代码生成-----------------------------------
@ -47,4 +53,6 @@ public interface MailLogService extends IService<MailLog> {
* @return
*/
int deleteMailLogById(Long id);
}

@ -1,14 +1,20 @@
package com.xjs.maillog.service.impl;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjs.maillog.domain.MailLog;
import com.xjs.maillog.mapper.MailLogMapper;
import com.xjs.maillog.service.MailLogService;
import com.xjs.other.LogNumberVo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import static com.xjs.consts.CommonConst.TODAY_END;
import static com.xjs.consts.CommonConst.TODAY_START;
/**
* Service
*
@ -20,8 +26,28 @@ public class MailLogServiceImpl extends ServiceImpl<MailLogMapper,MailLog> imple
@Resource
private MailLogMapper mailLogMapper;
@Override
public LogNumberVo getCount() {
LogNumberVo logNumberVo = new LogNumberVo();
long total = super.count();
logNumberVo.setTotal(total);
LambdaQueryWrapper<MailLog> wrapper = new LambdaQueryWrapper<>();
String startDate = DateUtil.today() + " "+TODAY_START;
String endDate = DateUtil.today() + " "+TODAY_END;
wrapper.between(MailLog::getCreateTime, startDate, endDate);
long todayCount = super.count(wrapper);
logNumberVo.setTodayNumber(todayCount);
return logNumberVo;
}
//---------------------------代码生成-----------------------------------
/**
*
*

@ -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;
}

@ -1,6 +1,7 @@
package com.xjs.reptileLog.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xjs.other.LogNumberVo;
import com.xjs.reptileLog.domain.WebmagicLog;
import java.util.List;
@ -12,6 +13,12 @@ import java.util.List;
*/
public interface WebmagicLogService extends IService<WebmagicLog> {
/**
*
* @return LogNumberVo
*/
LogNumberVo getCount();
//------------------------代码生成-------------------------
/**

@ -1,6 +1,9 @@
package com.xjs.reptileLog.service.impl;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjs.other.LogNumberVo;
import com.xjs.reptileLog.domain.WebmagicLog;
import com.xjs.reptileLog.mapper.WebmagicLogMapper;
import com.xjs.reptileLog.service.WebmagicLogService;
@ -9,6 +12,9 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import static com.xjs.consts.CommonConst.TODAY_END;
import static com.xjs.consts.CommonConst.TODAY_START;
/**
* @author xiejs
* @since 2022-02-17
@ -19,6 +25,24 @@ public class WebmagicLogServiceImpl extends ServiceImpl<WebmagicLogMapper, Webma
@Resource
private WebmagicLogMapper webmagicLogMapper;
@Override
public LogNumberVo getCount() {
LogNumberVo logNumberVo = new LogNumberVo();
long total = super.count();
logNumberVo.setTotal(total);
LambdaQueryWrapper<WebmagicLog> wrapper = new LambdaQueryWrapper<>();
String startDate = DateUtil.today() + " "+TODAY_START;
String endDate = DateUtil.today() + " "+TODAY_END;
wrapper.between(WebmagicLog::getCreateTime, startDate, endDate);
long todayCount = super.count(wrapper);
logNumberVo.setTodayNumber(todayCount);
return logNumberVo;
}
//------------------------代码生成-----------------------------

@ -1,6 +1,7 @@
package com.xjs.tasklog.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xjs.other.LogNumberVo;
import com.xjs.tasklog.domain.TaskLog;
import java.util.List;
@ -12,6 +13,13 @@ import java.util.List;
*/
public interface TaskLogService extends IService<TaskLog> {
/**
*
* @return LogNumberVo
*/
LogNumberVo getCount();
//-----------------------代码生成------------------------------
/**

@ -1,6 +1,10 @@
package com.xjs.tasklog.service.impl;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjs.apilog.domain.ApiLog;
import com.xjs.other.LogNumberVo;
import com.xjs.tasklog.domain.TaskLog;
import com.xjs.tasklog.mapper.TaskLogMapper;
import com.xjs.tasklog.service.TaskLogService;
@ -9,6 +13,9 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import static com.xjs.consts.CommonConst.TODAY_END;
import static com.xjs.consts.CommonConst.TODAY_START;
/**
* service
*
@ -20,6 +27,23 @@ public class TaskLogServiceImpl extends ServiceImpl<TaskLogMapper, TaskLog> impl
@Resource
private TaskLogMapper taskLogMapper;
@Override
public LogNumberVo getCount() {
LogNumberVo logNumberVo = new LogNumberVo();
long total = super.count();
logNumberVo.setTotal(total);
LambdaQueryWrapper<TaskLog> wrapper = new LambdaQueryWrapper<>();
String startDate = DateUtil.today() + " "+TODAY_START;
String endDate = DateUtil.today() + " "+TODAY_END;
wrapper.between(TaskLog::getCreateTime, startDate, endDate);
long todayCount = super.count(wrapper);
logNumberVo.setTodayNumber(todayCount);
return logNumberVo;
}
//----------------------------------代码生成------------------------------------

@ -40,7 +40,6 @@ public class ApiAWordController extends BaseController {
@GetMapping
@ApiOperation("每日一句接口")
@Log(title = "获取每日一句")
@RequiresLogin
public AjaxResult getApiAWord(@Validated RequestBody requestBody) {
requestBody = Optional.ofNullable(requestBody).orElseGet(RequestBody::new);

@ -1,24 +1,50 @@
package com.xjs.common.controller;
import cn.hutool.core.map.MapUtil;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.system.api.RemoteLogService;
import com.ruoyi.system.api.RemoteUserService;
import com.ruoyi.system.api.domain.SysOperLog;
import com.ruoyi.system.api.model.LoginUser;
import com.xjs.apitools.domain.ApiBeautyPicture;
import com.xjs.apitools.service.ApiToolsService;
import com.xjs.business.english.RemoteEnglishFeign;
import com.xjs.business.english.domain.EnglishWordDTO;
import com.xjs.business.log.RemoteLogFeign;
import com.xjs.business.webmagic.RemoteWebmagicCopyWritingNetworkFeign;
import com.xjs.business.webmagic.RemoteWebmagicSinaFeign;
import com.xjs.business.webmagic.domain.CopyWritingNetworkDTO;
import com.xjs.copywriting.domain.CopyWriting;
import com.xjs.copywriting.service.CopyWritingService;
import com.xjs.topsearch.domain.ApiTopsearchWeibo;
import com.xjs.topsearch.service.ApiTopsearchWeiboService;
import com.xjs.weather.domain.IPInfoVo;
import com.xjs.weather.service.IPService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
/**
*
*
* @author xiejs
* @since 2022-06-14
*/
@ -28,23 +54,148 @@ import java.util.List;
@Log4j2
public class IndexController {
private final ExecutorService executor = Executors.newFixedThreadPool(5);
@Autowired
private ApiTopsearchWeiboService apiTopsearchWeiboService;
@Autowired
private CopyWritingService copyWritingService;
@Autowired //解决aop 调用this不代理问题
private IndexController indexController;
@Resource
private RemoteWebmagicCopyWritingNetworkFeign remoteWebmagicCopyWritingNetworkFeign;
@Resource
private RemoteLogFeign remoteLogFeign;
@Resource
private RemoteUserService remoteUserService;
@Resource
private RemoteLogService remoteLogService;
@Resource
private RemoteEnglishFeign remoteEnglishFeign;
@Resource
private RemoteWebmagicSinaFeign remoteWebmagicSinaFeign;
@Autowired
private ApiToolsService apiToolsService;
@Autowired
private IPService ipService;
@GetMapping("showData")
@ApiOperation("展示数据")
public AjaxResult showWbSearch() throws ExecutionException, InterruptedException {
CompletableFuture<List<ApiTopsearchWeibo>> weiboListFuture = CompletableFuture.supplyAsync(() ->
apiTopsearchWeiboService.showWbSearch(), executor);
CompletableFuture<List<CopyWritingNetworkDTO>> networkDTOListFuture = CompletableFuture.supplyAsync(indexController::getCopyWritingNetworkList, executor);
CompletableFuture<List<CopyWriting>> yunListFuture = CompletableFuture.supplyAsync(() ->
copyWritingService.NeteaseHotWord(), executor);
CompletableFuture<Map<Object, Object>> logCountFuture = CompletableFuture.supplyAsync(indexController::getLogCount, executor);
CompletableFuture<Integer> loginCountFuture = CompletableFuture.supplyAsync(indexController::getLoginCount, executor);
CompletableFuture<List<SysOperLog>> sysOperLogFuture = CompletableFuture.supplyAsync(indexController::getSysOperLog, executor);
CompletableFuture<List<EnglishWordDTO>> englishFuture = CompletableFuture.supplyAsync(indexController::getEnglish, executor);
CompletableFuture<Map<String, List<String>>> beautyPictureFuture = CompletableFuture.supplyAsync(indexController::getBeautyPictureList, executor);
CompletableFuture<Map<Object, Object>> newsFuture = CompletableFuture.supplyAsync(indexController::getNews, executor);
CompletableFuture<IPInfoVo> ipInfoFuture = CompletableFuture.supplyAsync(indexController::getIpInfo, executor);
CompletableFuture.allOf(
weiboListFuture,
networkDTOListFuture,
yunListFuture,
logCountFuture,
sysOperLogFuture,
englishFuture,
newsFuture,
beautyPictureFuture,
ipInfoFuture
).get();
Map<Object, Object> map = MapUtil.builder()
.put("weiboList", weiboListFuture.get())
.put("networkDTOList", networkDTOListFuture.get())
.put("yunList", yunListFuture.get())
.put("logCount", logCountFuture.get())
.put("loginCount", loginCountFuture.get())
.put("sysOperLog", sysOperLogFuture.get())
.put("englishWord", englishFuture.get())
.put("news", newsFuture.get())
.put("beautyPicture", beautyPictureFuture.get())
.put("ipInfo", ipInfoFuture.get())
.build();
return AjaxResult.success(map);
}
@Cacheable(cacheNames = "bussiness:index:copy_writing", key = "#root.method.name")
public List<CopyWritingNetworkDTO> getCopyWritingNetworkList() {
return remoteWebmagicCopyWritingNetworkFeign.showCopyWriting().getData();
}
@Cacheable(cacheNames = "bussiness:index:log_count", key = "#root.method.name")
public Map<Object, Object> getLogCount() {
return remoteLogFeign.groupLogNumber().getData();
}
@Cacheable(cacheNames = "bussiness:index:login_count", key = "#root.method.name")
public Integer getLoginCount() {
R<LoginUser> r = remoteUserService.getUserInfo("admin", SecurityConstants.INNER);
return r.getData().getSysUser().getLoginCount();
}
@Cacheable(cacheNames = "bussiness:index:oper_log", key = "#root.method.name")
public List<SysOperLog> getSysOperLog() {
R<List<SysOperLog>> listR = remoteLogService.selectNewOperLog(SecurityConstants.INNER);
return listR.getData();
}
@Cacheable(cacheNames = "bussiness:index:english", key = "#root.method.name")
public List<EnglishWordDTO> getEnglish() {
R<List<EnglishWordDTO>> r = remoteEnglishFeign.getEnglishWordByRandom();
return r.getData();
}
@Cacheable(cacheNames = "bussiness:index:news", key = "#root.method.name")
public Map<Object, Object> getNews() {
R<Map<Object, Object>> r = remoteWebmagicSinaFeign.getNews();
return r.getData();
}
@SneakyThrows
@Cacheable(cacheNames = "bussiness:index:beauty_picture", key = "#root.method.name")
public Map<String, List<String>> getBeautyPictureList() {
CompletableFuture<List<String>> oneFuture = CompletableFuture.supplyAsync(() ->
apiToolsService.getBeautyPictureList().stream()
.map(ApiBeautyPicture::getImageUrl).collect(Collectors.toList()), executor);
CompletableFuture<List<String>> twoFuture = CompletableFuture.supplyAsync(() ->
apiToolsService.getBeautyPictureList().stream()
.map(ApiBeautyPicture::getImageUrl).collect(Collectors.toList()), executor);
CompletableFuture<List<String>> threeFuture = CompletableFuture.supplyAsync(() ->
apiToolsService.getBeautyPictureList().stream()
.map(ApiBeautyPicture::getImageUrl).collect(Collectors.toList()), executor);
CompletableFuture.allOf(oneFuture, twoFuture, threeFuture).get();
Map<String, List<String>> map = new HashMap<>();
map.put("one", oneFuture.get());
map.put("two", twoFuture.get());
map.put("three", threeFuture.get());
@GetMapping("showWbSearch")
@ApiOperation("展示微博热搜")
public AjaxResult showWbSearch() {
List<ApiTopsearchWeibo> weiboList = apiTopsearchWeiboService.showWbSearch();
return AjaxResult.success(weiboList);
return map;
}
@GetMapping("showCopyWriting")
@ApiOperation("首页展示文案")
public AjaxResult showCopyWriting() {
R<List<CopyWritingNetworkDTO>> data = remoteWebmagicCopyWritingNetworkFeign.showCopyWriting();
return AjaxResult.success(data.getData());
@Cacheable(cacheNames = "bussiness:index:ip_info", key = "#root.method.name")
public IPInfoVo getIpInfo() {
return ipService.getIPApiData();
}

@ -68,7 +68,6 @@ public class CopyWritingController extends BaseController {
@GetMapping
@ApiOperation("文案接口")
@Log(title = "获取文案")
@RequiresLogin
public AjaxResult copyWriting(@Validated RequestBody requestBody) {
requestBody = Optional.ofNullable(requestBody).orElseGet(RequestBody::new);

@ -2,6 +2,7 @@ package com.xjs.copywriting.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xjs.copywriting.domain.CopyWriting;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -64,4 +65,10 @@ public interface CopyWritingMapper extends BaseMapper<CopyWriting> {
*/
int deleteCopyWritingByIds(Long[] ids);
/**
* 5
* @param wyy
* @return list
*/
List<CopyWriting> NeteaseHotWord(@Param("wyy") Integer wyy);
}

@ -30,6 +30,12 @@ public interface CopyWritingService extends IService<CopyWriting> {
*/
int deleteRepeatData();
/**
*
* @return list
*/
List<CopyWriting> NeteaseHotWord();
//-------------------------代码自动生成----------------------------------
/**

@ -1,6 +1,7 @@
package com.xjs.copywriting.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjs.consts.CopyWritingConst;
import com.xjs.copywriting.domain.CopyWriting;
import com.xjs.copywriting.mapper.CopyWritingMapper;
import com.xjs.copywriting.service.CopyWritingService;
@ -36,6 +37,12 @@ public class CopyWritingServiceImpl extends ServiceImpl<CopyWritingMapper, CopyW
return copyWritingMapper.deleteRepeatData();
}
@Override
@Cacheable(cacheNames = "bussiness:index:yun_hot_word",key = "#root.method.name")
public List<CopyWriting> NeteaseHotWord() {
return copyWritingMapper.NeteaseHotWord(CopyWritingConst.WYY);
}
//----------------------代码自动生成------------------------------------
/**

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjs.topsearch.domain.ApiTopsearchWeibo;
import com.xjs.topsearch.mapper.ApiTopsearchWeiboMapper;
import com.xjs.topsearch.service.ApiTopsearchWeiboService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -25,6 +26,7 @@ public class ApiTopsearchWeiboServiceImpl extends ServiceImpl<ApiTopsearchWeiboM
}
@Override
@Cacheable(cacheNames = "bussiness:index:wb_search",key = "#root.method.name")
public List<ApiTopsearchWeibo> showWbSearch() {
LambdaQueryWrapper<ApiTopsearchWeibo> wrapper = new LambdaQueryWrapper<>();
wrapper.select(ApiTopsearchWeibo::getHotword,ApiTopsearchWeibo::getId);

@ -2,7 +2,6 @@ package com.xjs.weather.controller;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.security.annotation.RequiresLogin;
import com.xjs.utils.WeekUtils;
import com.xjs.weather.domain.Casts;
@ -40,7 +39,6 @@ public class WeatherController {
@GetMapping("now")
@ApiOperation("获取实时天气信息")
@Log(title = "获取实时天气")
@RequiresLogin
public AjaxResult getNowWeatherApiData() {
return AjaxResult.success(weatherService.saveNowWeather());
@ -48,7 +46,6 @@ public class WeatherController {
@GetMapping("forecast")
@ApiOperation("获取预报天气信息")
@Log(title = "获取预报天气")
@RequiresLogin
public AjaxResult getForecastWeatherApiData() {
ForecastWeather forecastWeather = weatherService.cacheForecastWeather();

@ -52,6 +52,9 @@
<include refid="selectCopyWritingVo"/>
where id = #{id}
</select>
<select id="NeteaseHotWord" resultType="com.xjs.copywriting.domain.CopyWriting">
SELECT id,source,content FROM api_copywriting WHERE type=#{wyy} ORDER BY RAND() LIMIT 5
</select>
<delete id="deleteCopyWritingById" parameterType="Long">
delete

@ -13,6 +13,10 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.xjs.consts.CommonConst.TODAY_END;
import static com.xjs.consts.CommonConst.TODAY_START;
/**
* service
* @author xiejs
@ -28,8 +32,8 @@ public class WeatherStatisticsServiceImpl implements WeatherStatisticsService {
@Override
public Map<String, List> historyWeather(String startDate, String endDate) {
if (StringUtils.isEmpty(startDate) || StringUtils.isEmpty(endDate)) {
startDate = DateUtil.today() + " 00:00:00";
endDate = DateUtil.today() + " 23:59:59";
startDate = DateUtil.today() + " "+TODAY_START;
endDate = DateUtil.today() + " "+TODAY_END;
}
return remoteWeatherFeign.getHistoryWeatherForRPC(startDate, endDate).getData();
}

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjs.copywritingNetwork.mapper.CopyWritingNetworkMapper;
import com.xjs.copywritingNetwork.pojo.CopyWritingNetwork;
import com.xjs.copywritingNetwork.service.CopyWritingNetworkService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

@ -18,6 +18,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* controller
@ -28,7 +29,7 @@ import java.util.List;
@RestController
@RequestMapping("sinaNews")
@Api(tags = "爬虫模块-新浪新闻")
public class SinaNewsController extends MyBaseController {
public class SinaNewsController extends MyBaseController<SinaNews> {
@Autowired
private SinaNewsTask sinaNewsTask;
@Autowired
@ -52,6 +53,14 @@ public class SinaNewsController extends MyBaseController {
}
@GetMapping("getNewsForRpc")
@ApiOperation("获取最新新闻")
public R<Map<Object, Object>> getNews() {
Map<Object, Object> map=sinaNewsService.getNews();
return R.ok(map);
}
//----------------------代码生成----------------------------
/**

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.xjs.sina.pojo.SinaNews;
import java.util.List;
import java.util.Map;
/**
* Service
@ -50,4 +51,10 @@ public interface SinaNewsService extends IService<SinaNews> {
public int deleteSinaNewsById(Long id);
/**
*
* @return map
*/
Map<Object, Object> getNews();
}

@ -1,5 +1,7 @@
package com.xjs.sina.service.impl;
import cn.hutool.core.map.MapUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjs.sina.mapper.SinaNewsMapper;
@ -9,6 +11,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* Service
@ -70,5 +73,27 @@ public class SinaNewsServiceImpl extends ServiceImpl<SinaNewsMapper, SinaNews> i
return sinaNewsMapper.deleteSinaNewsById(id);
}
@Override
public Map<Object, Object> getNews() {
LambdaQueryWrapper<SinaNews> internalWrapper = new LambdaQueryWrapper<>();
internalWrapper.select(SinaNews::getTitle, SinaNews::getUrl);
internalWrapper.eq(SinaNews::getCategory, "国内");
internalWrapper.orderByDesc(SinaNews::getCreateTime);
internalWrapper.last("limit 5");
List<SinaNews> internalList = super.list(internalWrapper);
LambdaQueryWrapper<SinaNews> internationalWrapper = new LambdaQueryWrapper<>();
internationalWrapper.select(SinaNews::getTitle, SinaNews::getUrl);
internationalWrapper.eq(SinaNews::getCategory, "国际");
internationalWrapper.orderByDesc(SinaNews::getCreateTime);
internationalWrapper.last("limit 5");
List<SinaNews> internationalList = super.list(internationalWrapper);
return MapUtil.builder()
.put("internal", internalList)
.put("international", internationalList)
.build();
}
}

Loading…
Cancel
Save