Compare commits
36 Commits
a6a9e46812
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 49a0022ee8 | |||
| e2eb5f9ad0 | |||
| cd7aba7aaa | |||
| b69e36391e | |||
| a9ea0d1ebf | |||
| a2cdb813c7 | |||
| 3e66d8461b | |||
| 5ed0e5aaf9 | |||
| ed980e953a | |||
| a12cf82833 | |||
| a630ae7b23 | |||
| 6b3aa1203c | |||
| 8b5b7719f1 | |||
| 40ae31786d | |||
| edfd9a083f | |||
| e86e561c37 | |||
| 22a1a8b963 | |||
| a44651dd2f | |||
| 43cbd262ea | |||
| 07a4142818 | |||
| 5ea65a8d25 | |||
| 3f1c4df78a | |||
| 061711a9c0 | |||
| e74a8bfd98 | |||
| cc82f85e00 | |||
| d6d3647216 | |||
| 23e5fcdde6 | |||
| 01e91d252c | |||
| 178ec58836 | |||
| d178285efa | |||
| 7bf4b80281 | |||
| 4f7e0e4576 | |||
| 55e9f3d538 | |||
| 0d933e09d4 | |||
| 01b880e90c | |||
| bcb3157faa |
25
pom.xml
25
pom.xml
@@ -12,8 +12,8 @@
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.yupi</groupId>
|
||||
<artifactId>springboot-init</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<artifactId>crawl-client</artifactId>
|
||||
<version>1.0</version>
|
||||
<name>springboot-init</name>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
@@ -70,12 +70,6 @@
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-data-redis</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.github.binarywang/wx-java-mp-spring-boot-starter -->
|
||||
<dependency>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java-mp-spring-boot-starter</artifactId>
|
||||
<version>4.4.0</version>
|
||||
</dependency>
|
||||
<!-- https://doc.xiaominfo.com/docs/quick-start#openapi2 -->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
@@ -125,6 +119,17 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara.x-file-storage</groupId>
|
||||
<artifactId>x-file-storage-spring</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -145,8 +150,8 @@
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
//package com.yupi.springbootinit.Interceptor;
|
||||
//
|
||||
//import cn.dev33.satoken.stp.StpUtil;
|
||||
//
|
||||
//import org.springframework.web.servlet.HandlerInterceptor;
|
||||
//import org.springframework.web.servlet.ModelAndView;
|
||||
//
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//import javax.servlet.http.HttpServletResponse;
|
||||
//
|
||||
///**
|
||||
// * 自定义拦截器(token续期 和 token定期刷新)
|
||||
// */
|
||||
//public class TokenInterceptor implements HandlerInterceptor {
|
||||
//
|
||||
// @Override
|
||||
// public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler){
|
||||
// response.setHeader( "Content-Security-Policy" , "default-src 'self'; script-src 'self'; frame-ancestors 'self'");
|
||||
// response.setHeader("Access-Control-Allow-Origin", (request).getHeader("Origin"));
|
||||
// response.setHeader("Access-Control-Allow-Credentials", "true");
|
||||
// response.setHeader("Referrer-Policy","no-referrer");
|
||||
// response.setContentType("application/json");
|
||||
// response.setCharacterEncoding("UTF-8");
|
||||
// // 登录校验 -- 拦截所有请求,只有登录后才可以访问
|
||||
// StpUtil.checkLogin();
|
||||
// String tokenValue = StpUtil.getTokenValue();
|
||||
// StpUtil.renewTimeout(tokenValue,259200);
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,ModelAndView modelAndView) throws Exception {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||
// }
|
||||
//}
|
||||
@@ -19,7 +19,7 @@ public enum ErrorCode {
|
||||
NOT_FOUND_ERROR(40800, "请求数据不存在"),
|
||||
FORBIDDEN_ERROR(40300, "禁止访问"),
|
||||
TENANT_NAME_NOT_EXISTS(40600, "租户不存在"),
|
||||
LOGIN_NOW_ALLOWED(40700, "当前账号不允许登录"),
|
||||
LOGIN_NOT_ALLOWED(40700, "当前账号没有登录权限"),
|
||||
SYSTEM_ERROR(50000, "系统内部异常"),
|
||||
OPERATION_ERROR(50001, "操作失败"),
|
||||
QUEUE_ERROR(60001, "队列消息添加失败"),
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.yupi.springbootinit.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import org.springframework.amqp.core.ExchangeBuilder;
|
||||
import org.springframework.amqp.core.HeadersExchange;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
||||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class RabbitMQConfig {
|
||||
|
||||
private static final String QUEUE = "HOST_INFO_QUEUE";
|
||||
|
||||
public static final String EXCHANGE_NAME = "user.headers.exchange";
|
||||
public static final String AI_CHAT_EXCHANGE_NAME = "ai.chat.headers.exchange";
|
||||
public static final String BIG_BROTHER_EXCHANGE_NAME = "big.brother.headers.exchange";
|
||||
public static final String WEB_AI_EXCHANGE_NAME = "web.ai.headers.exchange";
|
||||
|
||||
//创建队列
|
||||
//true:表示持久化
|
||||
//队列在默认情况下放到内存,rabbitmq重启后就丢失了,如果希望重启后,队列
|
||||
//数据还能使用,就需要持久化
|
||||
@Bean
|
||||
public Queue hostInfoQueue(){
|
||||
return new Queue(QUEUE,true);
|
||||
}
|
||||
|
||||
//
|
||||
// @Bean
|
||||
// public MessageConverter messageConverter(){
|
||||
// return new Jackson2JsonMessageConverter();
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@Bean
|
||||
public HeadersExchange userHeadersExchange() {
|
||||
return ExchangeBuilder.headersExchange(EXCHANGE_NAME)
|
||||
.durable(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public HeadersExchange aiChatHeadersExchange() {
|
||||
return ExchangeBuilder.headersExchange(AI_CHAT_EXCHANGE_NAME)
|
||||
.durable(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public HeadersExchange bigBrotherHeadersExchange() {
|
||||
return ExchangeBuilder.headersExchange(BIG_BROTHER_EXCHANGE_NAME)
|
||||
.durable(true)
|
||||
.build();
|
||||
}
|
||||
/** 网页AI使用的 HeadersExchange */
|
||||
@Bean
|
||||
public HeadersExchange webAiHeadersExchange() {
|
||||
return ExchangeBuilder.headersExchange(WEB_AI_EXCHANGE_NAME)
|
||||
.durable(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RabbitAdmin rabbitAdmin(ConnectionFactory cf) {
|
||||
return new RabbitAdmin(cf);
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public MessageConverter messageConverter() {
|
||||
ObjectMapper om = new ObjectMapper();
|
||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
om.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
om.registerModule(new JavaTimeModule());
|
||||
return new Jackson2JsonMessageConverter(om);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +1,49 @@
|
||||
package com.yupi.springbootinit.config;
|
||||
|
||||
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
|
||||
|
||||
@Bean(name="redisTemplate")
|
||||
public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) {
|
||||
RedisTemplate<String, String> template = new RedisTemplate<>();
|
||||
RedisSerializer<String> redisSerializer = new StringRedisSerializer();
|
||||
// @Bean(name="redisTemplate")
|
||||
// public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) {
|
||||
// RedisTemplate<String, String> template = new RedisTemplate<>();
|
||||
// RedisSerializer<String> redisSerializer = new StringRedisSerializer();
|
||||
// template.setConnectionFactory(factory);
|
||||
// //key序列化方式
|
||||
// template.setKeySerializer(redisSerializer);
|
||||
// //value序列化
|
||||
// template.setValueSerializer(redisSerializer);
|
||||
// //value hashmap序列化
|
||||
// template.setHashValueSerializer(redisSerializer);
|
||||
// //key haspmap序列化
|
||||
// template.setHashKeySerializer(redisSerializer);
|
||||
// //
|
||||
// return template;
|
||||
// }
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
|
||||
RedisTemplate<String, Object> template = new RedisTemplate<>();
|
||||
template.setConnectionFactory(factory);
|
||||
//key序列化方式
|
||||
template.setKeySerializer(redisSerializer);
|
||||
//value序列化
|
||||
template.setValueSerializer(redisSerializer);
|
||||
//value hashmap序列化
|
||||
template.setHashValueSerializer(redisSerializer);
|
||||
//key haspmap序列化
|
||||
template.setHashKeySerializer(redisSerializer);
|
||||
//
|
||||
|
||||
// 使用 JSON 序列化器
|
||||
GenericJackson2JsonRedisSerializer jsonSerializer = new GenericJackson2JsonRedisSerializer();
|
||||
|
||||
template.setKeySerializer(new StringRedisSerializer());
|
||||
template.setValueSerializer(jsonSerializer);
|
||||
template.setHashKeySerializer(new StringRedisSerializer());
|
||||
template.setHashValueSerializer(jsonSerializer);
|
||||
|
||||
template.afterPropertiesSet();
|
||||
return template;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@ import cn.dev33.satoken.interceptor.SaInterceptor;
|
||||
import cn.dev33.satoken.router.SaHttpMethod;
|
||||
import cn.dev33.satoken.router.SaRouter;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.yupi.springbootinit.common.ErrorCode;
|
||||
import com.yupi.springbootinit.exception.BusinessException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -25,8 +23,12 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin()))
|
||||
.addPathPatterns("/**")
|
||||
.excludePathPatterns(getExcludePaths());
|
||||
// registry.addInterceptor(new TokenInterceptor())
|
||||
// .addPathPatterns("/**")
|
||||
// .excludePathPatterns(getExcludePaths());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取需要放行的路径
|
||||
*/
|
||||
@@ -45,7 +47,11 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
// 你的其他放行路径,例如登录接口
|
||||
"/user/doLogin",
|
||||
"/tenant/get-id-by-name",
|
||||
"/user/bigbrother-doLogin"
|
||||
"/user/bigbrother-doLogin",
|
||||
"/user/aiChat-doLogin",
|
||||
"/user/aiChat-logout",
|
||||
"/user/webAi-doLogin",
|
||||
"/error",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -66,6 +72,5 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
SaRouter.match(SaHttpMethod.OPTIONS)
|
||||
.back();
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,19 @@ package com.yupi.springbootinit.controller;
|
||||
|
||||
import com.yupi.springbootinit.common.BaseResponse;
|
||||
import com.yupi.springbootinit.common.ResultUtils;
|
||||
import com.yupi.springbootinit.model.entity.AiComment;
|
||||
import com.yupi.springbootinit.model.entity.AiTemplate;
|
||||
import com.yupi.springbootinit.model.vo.common.AccountCrawlCount;
|
||||
import com.yupi.springbootinit.model.vo.country.CountryInfoVO;
|
||||
import com.yupi.springbootinit.service.AiCommentService;
|
||||
import com.yupi.springbootinit.service.AiTemplateService;
|
||||
import com.yupi.springbootinit.service.CommonService;
|
||||
import com.yupi.springbootinit.service.CountryInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
@@ -25,9 +30,15 @@ public class CommonController {
|
||||
@Resource
|
||||
private CountryInfoService countryInfoService;
|
||||
|
||||
@Resource
|
||||
private AiTemplateService aiTemplateService;
|
||||
|
||||
@Resource
|
||||
private CommonService commonService;
|
||||
|
||||
@Resource
|
||||
private AiCommentService aiCommentService;
|
||||
|
||||
@PostMapping("country_info")
|
||||
public BaseResponse<List<CountryInfoVO>> countryInfo() {
|
||||
|
||||
@@ -39,4 +50,28 @@ public class CommonController {
|
||||
return ResultUtils.success(commonService.getAccountCrawlCount(accountName));
|
||||
}
|
||||
|
||||
@GetMapping("prologue")
|
||||
public BaseResponse<List<String>> getPrologue(){
|
||||
List<AiTemplate> list = aiTemplateService.list();
|
||||
ArrayList<String> prologueList = new ArrayList<>();
|
||||
list.forEach(item -> {
|
||||
prologueList.add(item.getContent());
|
||||
});
|
||||
return ResultUtils.success(prologueList);
|
||||
}
|
||||
|
||||
@GetMapping("comment")
|
||||
public BaseResponse<List<String>> getComment(){
|
||||
List<AiComment> list = aiCommentService.list();
|
||||
ArrayList<String> commentList = new ArrayList<>();
|
||||
list.forEach(item -> {
|
||||
commentList.add(item.getContent());
|
||||
});
|
||||
return ResultUtils.success(commentList);
|
||||
}
|
||||
|
||||
@GetMapping("health")
|
||||
public BaseResponse<String> health(){
|
||||
return ResultUtils.success("ok");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.yupi.springbootinit.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yupi.springbootinit.common.BaseResponse;
|
||||
import com.yupi.springbootinit.common.ResultUtils;
|
||||
import com.yupi.springbootinit.model.dto.host.HostInfoDTO;
|
||||
import com.yupi.springbootinit.model.dto.host.ServerEmployeeHostsDTO;
|
||||
import com.yupi.springbootinit.model.entity.ServerEmployeeHosts;
|
||||
import com.yupi.springbootinit.model.vo.hosts.NewHostsVO;
|
||||
import com.yupi.springbootinit.model.vo.hosts.ServerEmployeeHostsVO;
|
||||
import com.yupi.springbootinit.service.HostInfoService;
|
||||
import com.yupi.springbootinit.service.ServerEmployeeHostsService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/6/10 17:09
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/emp_host")
|
||||
@Slf4j
|
||||
@CrossOrigin
|
||||
public class EmployeeHostInfoController {
|
||||
|
||||
|
||||
@Resource
|
||||
private HostInfoService hostInfoService;
|
||||
|
||||
@Resource
|
||||
private ServerEmployeeHostsService service;
|
||||
|
||||
@PostMapping("update")
|
||||
public BaseResponse<Boolean> updateEmployeeHost(@RequestBody ServerEmployeeHostsDTO hostInfoDTO){
|
||||
service.updateEmployeeHost(hostInfoDTO);
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.yupi.springbootinit.controller;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/8/25 13:36
|
||||
*/
|
||||
|
||||
import com.yupi.springbootinit.common.BaseResponse;
|
||||
import com.yupi.springbootinit.common.ResultUtils;
|
||||
import com.yupi.springbootinit.service.ServerAiLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/log")
|
||||
@Slf4j
|
||||
@CrossOrigin
|
||||
public class FileController {
|
||||
|
||||
@Resource
|
||||
private ServerAiLogService serverAiLogService;
|
||||
|
||||
@PostMapping("upload")
|
||||
public BaseResponse<Boolean> upload(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam Long tenantId,
|
||||
@RequestParam Long userId) {
|
||||
return ResultUtils.success(serverAiLogService.saveLog(file,tenantId,userId));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
package com.yupi.springbootinit.controller;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yupi.springbootinit.common.BaseResponse;
|
||||
import com.yupi.springbootinit.common.ResultUtils;
|
||||
import com.yupi.springbootinit.model.dto.host.HistoryDataDTO;
|
||||
import com.yupi.springbootinit.model.dto.host.HostInfoDTO;
|
||||
import com.yupi.springbootinit.model.entity.NewHosts;
|
||||
import com.yupi.springbootinit.model.vo.hosts.NewHostsVO;
|
||||
import com.yupi.springbootinit.model.vo.hosts.SevenDaysData;
|
||||
import com.yupi.springbootinit.service.HostInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -35,11 +33,17 @@ public class HostInfoController {
|
||||
return ResultUtils.success(conditionHosts);
|
||||
}
|
||||
|
||||
// @PostMapping("7days_data")
|
||||
// public BaseResponse<List<SevenDaysData>> sevenDaysData(@RequestBody HistoryDataDTO historyDataDTO){
|
||||
// Object loginId = StpUtil.getLoginId();
|
||||
// historyDataDTO.setUserId(Long.valueOf(loginId.toString()));
|
||||
// List<SevenDaysData> data = hostInfoService.getSevenDaysData(historyDataDTO);
|
||||
// return ResultUtils.success(data);
|
||||
// }
|
||||
@PostMapping("/update")
|
||||
public BaseResponse<Boolean> update(@RequestBody NewHosts newHosts){
|
||||
boolean b = hostInfoService.updateById(newHosts);
|
||||
return ResultUtils.success(b);
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/updates")
|
||||
public BaseResponse<Boolean> updates(@RequestBody List<NewHosts> newHosts){
|
||||
boolean b = hostInfoService.updateBatchById(newHosts);
|
||||
return ResultUtils.success(b);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,15 @@ import com.yupi.springbootinit.common.BaseResponse;
|
||||
import com.yupi.springbootinit.common.ErrorCode;
|
||||
import com.yupi.springbootinit.common.ResultUtils;
|
||||
import com.yupi.springbootinit.exception.BusinessException;
|
||||
import com.yupi.springbootinit.model.entity.SystemTenant;
|
||||
import com.yupi.springbootinit.model.vo.user.SystemTenantVO;
|
||||
import com.yupi.springbootinit.model.vo.user.SystemUsersVO;
|
||||
import com.yupi.springbootinit.service.SystemTenantService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.annotation.security.PermitAll;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
@@ -30,7 +33,12 @@ public class TenantController {
|
||||
throw new BusinessException(ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
return ResultUtils.success( systemTenantService.getTenantIdByName(name));
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/get-expired-time")
|
||||
public BaseResponse<SystemTenantVO> getTenantIdExpired(@RequestParam("tenantId") Long tenantId) {
|
||||
return ResultUtils.success(systemTenantService.getTenantIdExpired(tenantId));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -10,8 +10,10 @@ import com.yupi.springbootinit.exception.BusinessException;
|
||||
import com.yupi.springbootinit.model.dto.user.SystemUsersDTO;
|
||||
import com.yupi.springbootinit.model.entity.SystemUsers;
|
||||
import com.yupi.springbootinit.model.enums.CommonStatusEnum;
|
||||
import com.yupi.springbootinit.model.enums.LoginSceneEnum;
|
||||
import com.yupi.springbootinit.model.vo.user.SystemUsersVO;
|
||||
import com.yupi.springbootinit.service.SystemUsersService;
|
||||
import com.yupi.springbootinit.service.impl.LoginService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -28,70 +30,42 @@ import javax.annotation.Resource;
|
||||
public class UserController {
|
||||
|
||||
|
||||
|
||||
@Resource
|
||||
private SystemUsersService usersService;
|
||||
private LoginService loginService;
|
||||
|
||||
// 用户登陆接口
|
||||
@PostMapping("doLogin")
|
||||
public BaseResponse<SystemUsersVO> doLogin(@RequestBody SystemUsersDTO usersDTO) {
|
||||
SystemUsers user = usersService.getUserByUserName(usersDTO.getUsername(),usersDTO.getTenantId());
|
||||
if (user == null) {
|
||||
throw new BusinessException(ErrorCode.USERNAME_OR_PASSWORD_ERROR);
|
||||
}
|
||||
if (!usersService.isPasswordMatch(usersDTO.getPassword(), user.getPassword())) {
|
||||
throw new BusinessException(ErrorCode.USERNAME_OR_PASSWORD_ERROR);
|
||||
}
|
||||
|
||||
if (CommonStatusEnum.isDisable(Integer.valueOf(user.getStatus()))) {
|
||||
throw new BusinessException(ErrorCode.USER_DISABLE);
|
||||
}
|
||||
if (usersService.isExpired(usersDTO.getTenantId())){
|
||||
throw new BusinessException(ErrorCode.PACKAGE_EXPIRED);
|
||||
}
|
||||
if (!usersService.checkCrawlRole(user.getId())){
|
||||
throw new BusinessException(ErrorCode.LOGIN_NOW_ALLOWED);
|
||||
}
|
||||
Long second = usersService.getTenantExpiredTime(usersDTO.getTenantId());
|
||||
SystemUsersVO systemUsersVO = new SystemUsersVO();
|
||||
BeanUtil.copyProperties(user, systemUsersVO);
|
||||
// 赋予用户 Id
|
||||
StpUtil.login(user.getId(),"host");
|
||||
// 设置 token 有效期为当前日期和套餐有效期的差值
|
||||
StpUtil.renewTimeout(second);
|
||||
systemUsersVO.setTokenName(StpUtil.getTokenName());
|
||||
systemUsersVO.setTokenValue(StpUtil.getTokenValue());
|
||||
return ResultUtils.success(systemUsersVO);
|
||||
return ResultUtils.success(loginService.login(LoginSceneEnum.HOST, usersDTO));
|
||||
}
|
||||
|
||||
|
||||
// 用户登陆接口
|
||||
@PostMapping("bigbrother-doLogin")
|
||||
public BaseResponse<SystemUsersVO> bigBrotherDoLogin(@RequestBody SystemUsersDTO usersDTO) {
|
||||
SystemUsers user = usersService.getUserByUserName(usersDTO.getUsername(),usersDTO.getTenantId());
|
||||
if (user == null) {
|
||||
throw new BusinessException(ErrorCode.USERNAME_OR_PASSWORD_ERROR);
|
||||
}
|
||||
if (!usersService.isPasswordMatch(usersDTO.getPassword(), user.getPassword())) {
|
||||
throw new BusinessException(ErrorCode.USERNAME_OR_PASSWORD_ERROR);
|
||||
}
|
||||
|
||||
if (CommonStatusEnum.isDisable(Integer.valueOf(user.getStatus()))) {
|
||||
throw new BusinessException(ErrorCode.USER_DISABLE);
|
||||
}
|
||||
if (usersService.isExpired(usersDTO.getTenantId())){
|
||||
throw new BusinessException(ErrorCode.PACKAGE_EXPIRED);
|
||||
}
|
||||
if (!usersService.checkbigBrotherlRole(user.getId())){
|
||||
throw new BusinessException(ErrorCode.LOGIN_NOW_ALLOWED);
|
||||
}
|
||||
Long second = usersService.getTenantExpiredTime(usersDTO.getTenantId());
|
||||
SystemUsersVO systemUsersVO = new SystemUsersVO();
|
||||
BeanUtil.copyProperties(user, systemUsersVO);
|
||||
// 赋予用户 Id
|
||||
StpUtil.login(user.getId(),"bigbrother");
|
||||
// 设置 token 有效期为当前日期和套餐有效期的差值
|
||||
StpUtil.renewTimeout(second);
|
||||
systemUsersVO.setTokenName(StpUtil.getTokenName());
|
||||
systemUsersVO.setTokenValue(StpUtil.getTokenValue());
|
||||
return ResultUtils.success(systemUsersVO);
|
||||
return ResultUtils.success(loginService.login(LoginSceneEnum.BIG_BROTHER, usersDTO));
|
||||
}
|
||||
|
||||
// 用户登陆接口
|
||||
@PostMapping("aiChat-doLogin")
|
||||
public BaseResponse<SystemUsersVO> aiChatDoLogin(@RequestBody SystemUsersDTO usersDTO) {
|
||||
return ResultUtils.success(loginService.login(LoginSceneEnum.AI_CHAT, usersDTO));
|
||||
}
|
||||
|
||||
@PostMapping("aiChat-logout")
|
||||
public BaseResponse<Boolean> aiChatLogout(@RequestBody SystemUsersDTO usersDTO){
|
||||
return ResultUtils.success(loginService.aiChatLogout(usersDTO));
|
||||
}
|
||||
|
||||
@PostMapping("webAi-doLogin")
|
||||
public BaseResponse<SystemUsersVO> webAiDoLogin(@RequestBody SystemUsersDTO usersDTO) {
|
||||
return ResultUtils.success(loginService.login(LoginSceneEnum.WEB_AI, usersDTO));
|
||||
}
|
||||
|
||||
@GetMapping("/logout")
|
||||
public BaseResponse<Boolean> logout(){
|
||||
return ResultUtils.success(loginService.logout());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yupi.springbootinit.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yupi.springbootinit.model.entity.AiComment;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/7/23 16:00
|
||||
*/
|
||||
|
||||
public interface AiCommentMapper extends BaseMapper<AiComment> {
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yupi.springbootinit.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yupi.springbootinit.model.entity.AiTemplate;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/7/18 21:06
|
||||
*/
|
||||
|
||||
public interface AiTemplateMapper extends BaseMapper<AiTemplate> {
|
||||
}
|
||||
@@ -15,7 +15,4 @@ public interface CountryInfoMapper extends BaseMapper<CountryInfo> {
|
||||
|
||||
List<CountryInfoVO> selectByCountryGroupName();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -33,6 +33,5 @@ public interface NewHostsMapper extends BaseMapper<NewHosts> {
|
||||
|
||||
Page<NewHostsVO> selectPageByCondition(@Param("page") Page<NewHostsVO> page, @Param("hostInfoDTO") HostInfoDTO hostInfoDTO);
|
||||
|
||||
List<SevenDaysData> selectSevenDaysData(HistoryDataDTO historyDataDTO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yupi.springbootinit.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yupi.springbootinit.model.entity.ServerAiLog;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/8/25 13:37
|
||||
*/
|
||||
|
||||
public interface ServerAiLogMapper extends BaseMapper<ServerAiLog> {
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yupi.springbootinit.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yupi.springbootinit.model.dto.host.HostInfoDTO;
|
||||
import com.yupi.springbootinit.model.entity.ServerEmployeeHosts;
|
||||
import com.yupi.springbootinit.model.vo.hosts.ServerEmployeeHostsVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/7/3 19:12
|
||||
*/
|
||||
|
||||
public interface ServerEmployeeHostsMapper extends BaseMapper<ServerEmployeeHosts> {
|
||||
Page<ServerEmployeeHostsVO> selectPageByCondition(@Param("page") Page<ServerEmployeeHostsVO> page,@Param("hostInfoDTO") HostInfoDTO hostInfoDTO);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.yupi.springbootinit.model.dto.file;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/8/25 14:32
|
||||
*/
|
||||
@Data
|
||||
public class FileDTO {
|
||||
/**
|
||||
* 日志租户
|
||||
*/
|
||||
@TableField(value = "log_tenant_id")
|
||||
@ApiModelProperty(value="日志租户")
|
||||
private Long logTenantId;
|
||||
|
||||
/**
|
||||
* 用户 Id
|
||||
*/
|
||||
@TableField(value = "log_user_id")
|
||||
@ApiModelProperty(value="用户 Id")
|
||||
private Long logUserId;
|
||||
|
||||
@ApiModelProperty(value="日志文件")
|
||||
private MultipartFile file;
|
||||
}
|
||||
@@ -165,4 +165,8 @@ public class ServerBigBrotherDTO extends PageRequest implements Serializable {
|
||||
@TableField(value = "hostcoins")
|
||||
@ApiModelProperty(value="大哥打赏的金币")
|
||||
private Integer hostcoins;
|
||||
|
||||
@TableField(value = "fans_level")
|
||||
@ApiModelProperty(value = "大哥粉丝团等级")
|
||||
private Integer fansLevel;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.yupi.springbootinit.model.dto.host;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/7/3 19:12
|
||||
*/
|
||||
|
||||
/**
|
||||
* 员工分配主播表,结构和主播表相同,多了user_id 字段来区分所属员工
|
||||
*/
|
||||
@ApiModel(description="员工分配主播表,结构和主播表相同,多了user_id 字段来区分所属员工")
|
||||
@Data
|
||||
@TableName(value = "server_employee_hosts")
|
||||
public class ServerEmployeeHostsDTO {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value="主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 主播id
|
||||
*/
|
||||
@TableField(value = "hosts_id")
|
||||
@ApiModelProperty(value="主播id")
|
||||
private String hostsId;
|
||||
|
||||
/**
|
||||
* 用户 Id
|
||||
*/
|
||||
@TableField(value = "user_id")
|
||||
@ApiModelProperty(value="用户 Id")
|
||||
private Long userId;
|
||||
|
||||
|
||||
/**
|
||||
* 操作状态
|
||||
*/
|
||||
@TableField(value = "operation_status")
|
||||
@ApiModelProperty(value="操作状态")
|
||||
private Integer operationStatus;
|
||||
|
||||
|
||||
/**
|
||||
* 租户 Id
|
||||
*/
|
||||
@TableField(value = "tenant_id")
|
||||
@ApiModelProperty(value="租户 Id")
|
||||
private Long tenantId;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -29,4 +29,8 @@ public class SystemUsersDTO {
|
||||
* 租户编号
|
||||
*/
|
||||
private Long tenantId;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private Byte aiReplay;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.yupi.springbootinit.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/7/23 16:00
|
||||
*/
|
||||
|
||||
@ApiModel(description="ai_comment")
|
||||
@Data
|
||||
@TableName(value = "ai_comment")
|
||||
public class AiComment {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value="主键")
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 具体评论
|
||||
*/
|
||||
@TableField(value = "content")
|
||||
@ApiModelProperty(value="具体评论")
|
||||
private String content;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.yupi.springbootinit.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/7/18 21:06
|
||||
*/
|
||||
|
||||
@ApiModel(description="ai_template")
|
||||
@Data
|
||||
@TableName(value = "ai_template")
|
||||
public class AiTemplate {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value="主键")
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 具体话术
|
||||
*/
|
||||
@TableField(value = "content")
|
||||
@ApiModelProperty(value="具体话术")
|
||||
private String content;
|
||||
}
|
||||
@@ -1,99 +1,152 @@
|
||||
package com.yupi.springbootinit.model.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/6/10 18:54
|
||||
*/
|
||||
* @author: ziin
|
||||
* @date: 2025/7/18 14:36
|
||||
*/
|
||||
|
||||
/**
|
||||
* 主播数据表
|
||||
*/
|
||||
@Data
|
||||
@TableName(value = "server_new_hosts")
|
||||
public class NewHosts {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 主播id
|
||||
*/
|
||||
* 主播id
|
||||
*/
|
||||
@TableField(value = "hosts_id")
|
||||
private String hostsId;
|
||||
|
||||
/**
|
||||
* 主播等级
|
||||
*/
|
||||
* 主播等级
|
||||
*/
|
||||
@TableField(value = "hosts_level")
|
||||
private String hostsLevel;
|
||||
|
||||
/**
|
||||
* 主播金币
|
||||
*/
|
||||
* 主播金币
|
||||
*/
|
||||
@TableField(value = "hosts_coins")
|
||||
private Integer hostsCoins;
|
||||
|
||||
/**
|
||||
* 邀请类型
|
||||
*/
|
||||
* 邀请类型
|
||||
*/
|
||||
@TableField(value = "Invitation_type")
|
||||
private Integer invitationType;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "在线人数", example = "1000")
|
||||
private Integer onlineFans;
|
||||
/**
|
||||
* 粉丝数量
|
||||
*/
|
||||
* 在线人数
|
||||
*/
|
||||
@TableField(value = "online_fans")
|
||||
private Integer onlineFans;
|
||||
|
||||
/**
|
||||
* 粉丝数量
|
||||
*/
|
||||
@TableField(value = "fans")
|
||||
private Integer fans;
|
||||
|
||||
/**
|
||||
* 关注数量
|
||||
*/
|
||||
* 关注数量
|
||||
*/
|
||||
@TableField(value = "fllowernum")
|
||||
private Integer fllowernum;
|
||||
|
||||
/**
|
||||
* 昨日金币
|
||||
*/
|
||||
* 昨日金币
|
||||
*/
|
||||
@TableField(value = "yesterday_coins")
|
||||
private Integer yesterdayCoins;
|
||||
|
||||
/**
|
||||
* 主播国家
|
||||
*/
|
||||
* 主播国家
|
||||
*/
|
||||
@TableField(value = "country")
|
||||
private String country;
|
||||
|
||||
/**
|
||||
* 直播类型 娱乐,游戏
|
||||
*/
|
||||
* 直播类型 娱乐,游戏
|
||||
*/
|
||||
@TableField(value = "hosts_kind")
|
||||
private String hostsKind;
|
||||
|
||||
/**
|
||||
* 租户 Id
|
||||
*/
|
||||
* 是否已经分配给员工
|
||||
*/
|
||||
@TableField(value = "is_assigned")
|
||||
private Byte isAssigned;
|
||||
|
||||
/**
|
||||
* 租户 Id
|
||||
*/
|
||||
@TableField(value = "tenant_id")
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 入库人
|
||||
*/
|
||||
@TableField(value = "creator")
|
||||
private Long creator;
|
||||
|
||||
/**
|
||||
* 数据插入时间
|
||||
*/
|
||||
@TableField(value = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@TableField(value = "updater")
|
||||
private String updater;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 用户 Id
|
||||
*/
|
||||
@TableField(value = "user_id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 入库人
|
||||
*/
|
||||
private Long creator;
|
||||
* 是否删除
|
||||
*/
|
||||
@TableField(value = "deleted")
|
||||
private Byte deleted;
|
||||
|
||||
/**
|
||||
* 数据插入时间
|
||||
*/
|
||||
private Date createTime;
|
||||
* uid
|
||||
*/
|
||||
@TableField(value = "`uid`")
|
||||
private String uid;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updater;
|
||||
* AI 操作
|
||||
*/
|
||||
@TableField(value = "ai_operation")
|
||||
private Byte aiOperation;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
* 是否建联
|
||||
*/
|
||||
@TableField(value = "operation_status")
|
||||
private Byte operationStatus;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.yupi.springbootinit.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/8/25 13:37
|
||||
*/
|
||||
|
||||
@ApiModel(description="server_ai_log")
|
||||
@Data
|
||||
@TableName(value = "server_ai_log")
|
||||
public class ServerAiLog {
|
||||
/**
|
||||
* 日志主键
|
||||
*/
|
||||
@TableId(value = "log_id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value="日志主键")
|
||||
private Long logId;
|
||||
|
||||
/**
|
||||
* 日志主键
|
||||
*/
|
||||
@TableField(value = "log_name")
|
||||
@ApiModelProperty(value="日志主键")
|
||||
private String logName;
|
||||
|
||||
/**
|
||||
* 日志路径
|
||||
*/
|
||||
@TableField(value = "log_file_path")
|
||||
@ApiModelProperty(value="日志路径")
|
||||
private String logFilePath;
|
||||
|
||||
/**
|
||||
* 日志租户
|
||||
*/
|
||||
@TableField(value = "log_tenant_id")
|
||||
@ApiModelProperty(value="日志租户")
|
||||
private Long logTenantId;
|
||||
|
||||
/**
|
||||
* 用户 Id
|
||||
*/
|
||||
@TableField(value = "log_user_id")
|
||||
@ApiModelProperty(value="用户 Id")
|
||||
private Long logUserId;
|
||||
|
||||
@TableField(value = "creator")
|
||||
@ApiModelProperty(value="")
|
||||
private String creator;
|
||||
|
||||
@TableField(value = "create_time")
|
||||
@ApiModelProperty(value="")
|
||||
private Date createTime;
|
||||
|
||||
@TableField(value = "updater")
|
||||
@ApiModelProperty(value="")
|
||||
private String updater;
|
||||
|
||||
@TableField(value = "update_time")
|
||||
@ApiModelProperty(value="")
|
||||
private Date updateTime;
|
||||
}
|
||||
@@ -150,4 +150,7 @@ public class ServerBigBrother {
|
||||
@TableField(value = "tenant_id")
|
||||
@ApiModelProperty(value="租户 Id")
|
||||
private Long tenantId;
|
||||
|
||||
@TableField(value = "sec_uid")
|
||||
private String secUid;
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
package com.yupi.springbootinit.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/7/3 19:12
|
||||
*/
|
||||
|
||||
/**
|
||||
* 员工分配主播表,结构和主播表相同,多了user_id 字段来区分所属员工
|
||||
*/
|
||||
@ApiModel(description="员工分配主播表,结构和主播表相同,多了user_id 字段来区分所属员工")
|
||||
@Data
|
||||
@TableName(value = "server_employee_hosts")
|
||||
public class ServerEmployeeHosts {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value="主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 主播id
|
||||
*/
|
||||
@TableField(value = "hosts_id")
|
||||
@ApiModelProperty(value="主播id")
|
||||
private String hostsId;
|
||||
|
||||
/**
|
||||
* 用户 Id
|
||||
*/
|
||||
@TableField(value = "user_id")
|
||||
@ApiModelProperty(value="用户 Id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 主播等级
|
||||
*/
|
||||
@TableField(value = "hosts_level")
|
||||
@ApiModelProperty(value="主播等级")
|
||||
private String hostsLevel;
|
||||
|
||||
/**
|
||||
* 主播金币
|
||||
*/
|
||||
@TableField(value = "hosts_coins")
|
||||
@ApiModelProperty(value="主播金币")
|
||||
private Integer hostsCoins;
|
||||
|
||||
/**
|
||||
* 邀请类型
|
||||
*/
|
||||
@TableField(value = "Invitation_type")
|
||||
@ApiModelProperty(value="邀请类型")
|
||||
private Integer invitationType;
|
||||
|
||||
/**
|
||||
* 在线人数
|
||||
*/
|
||||
@TableField(value = "online_fans")
|
||||
@ApiModelProperty(value="在线人数")
|
||||
private Integer onlineFans;
|
||||
|
||||
/**
|
||||
* 粉丝数量
|
||||
*/
|
||||
@TableField(value = "fans")
|
||||
@ApiModelProperty(value="粉丝数量")
|
||||
private Integer fans;
|
||||
|
||||
/**
|
||||
* 关注数量
|
||||
*/
|
||||
@TableField(value = "fllowernum")
|
||||
@ApiModelProperty(value="关注数量")
|
||||
private Integer fllowernum;
|
||||
|
||||
/**
|
||||
* 昨日金币
|
||||
*/
|
||||
@TableField(value = "yesterday_coins")
|
||||
@ApiModelProperty(value="昨日金币")
|
||||
private Integer yesterdayCoins;
|
||||
|
||||
/**
|
||||
* 主播国家
|
||||
*/
|
||||
@TableField(value = "country")
|
||||
@ApiModelProperty(value="主播国家")
|
||||
private String country;
|
||||
|
||||
/**
|
||||
* 操作状态
|
||||
*/
|
||||
@TableField(value = "operation_status")
|
||||
@ApiModelProperty(value="操作状态")
|
||||
private Integer operationStatus;
|
||||
|
||||
/**
|
||||
* 直播类型 娱乐,游戏
|
||||
*/
|
||||
@TableField(value = "hosts_kind")
|
||||
@ApiModelProperty(value="直播类型 娱乐,游戏 ")
|
||||
private String hostsKind;
|
||||
|
||||
/**
|
||||
* 租户 Id
|
||||
*/
|
||||
@TableField(value = "tenant_id")
|
||||
@ApiModelProperty(value="租户 Id")
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 入库人
|
||||
*/
|
||||
@TableField(value = "creator")
|
||||
@ApiModelProperty(value="入库人")
|
||||
private Long creator;
|
||||
|
||||
/**
|
||||
* 数据插入时间
|
||||
*/
|
||||
@TableField(value = "create_time")
|
||||
@ApiModelProperty(value="数据插入时间")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@TableField(value = "updater")
|
||||
@ApiModelProperty(value="更新人")
|
||||
private String updater;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time")
|
||||
@ApiModelProperty(value="更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
@TableField(value = "deleted")
|
||||
@ApiModelProperty(value="是否删除")
|
||||
private Byte deleted;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@TableField(value = "remake")
|
||||
@ApiModelProperty(value="备注")
|
||||
private String remake;
|
||||
|
||||
/**
|
||||
* uid
|
||||
*/
|
||||
@TableField(value = "`uid`")
|
||||
@ApiModelProperty(value="uid")
|
||||
private String uid;
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -84,6 +86,20 @@ public class SystemTenant {
|
||||
@ApiModelProperty(value="过期时间")
|
||||
private Date expireTime;
|
||||
|
||||
/**
|
||||
* ai过期时间
|
||||
*/
|
||||
@TableField(value = "expire_time")
|
||||
@ApiModelProperty(value="ai过期时间")
|
||||
private Date aiExpireTime;
|
||||
|
||||
/**
|
||||
* 大哥过期时间
|
||||
*/
|
||||
@TableField(value = "expire_time")
|
||||
@ApiModelProperty(value="大哥过期时间")
|
||||
private Date brotherExpireTime;
|
||||
|
||||
/**
|
||||
* 账号数量
|
||||
*/
|
||||
|
||||
@@ -174,4 +174,25 @@ public class SystemUsers {
|
||||
@TableField(value = "big_brother")
|
||||
@ApiModelProperty(value = "能否登录大哥爬虫客户端")
|
||||
private Byte bigBrother;
|
||||
|
||||
/**
|
||||
* 能否登录大哥爬虫客户端
|
||||
*/
|
||||
@TableField(value = "ai_chat")
|
||||
@ApiModelProperty(value = "能否登录大哥爬虫客户端")
|
||||
private Byte aiChat;
|
||||
|
||||
/**
|
||||
* 是否开启智能回复
|
||||
*/
|
||||
@TableField(value = "ai_replay")
|
||||
@ApiModelProperty(value = "是否开启智能回复")
|
||||
private Byte aiReplay;
|
||||
|
||||
/**
|
||||
* 能否登录智能回复客户端
|
||||
*/
|
||||
@TableField(value = "web_ai")
|
||||
@ApiModelProperty(value = "能否登录智能回复客户端")
|
||||
private Byte webAi;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yupi.springbootinit.model.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum LoginSceneEnum {
|
||||
HOST("doLogin", "host", "checkCrawlRole"),
|
||||
BIG_BROTHER("bigbrother-doLogin", "bigbrother", "checkBigBrotherRole"),
|
||||
AI_CHAT("aiChat-doLogin", "aiChat", "checkAiChatLoginRole"),
|
||||
WEB_AI("webAiChat-doLogin", "webAiChat", "checkWebAiChatLoginRole");
|
||||
|
||||
private final String path; // 对应 @PostMapping
|
||||
private final String saMode; // Sa-Token 登录模式
|
||||
private final String checker; // SystemUsersService 中对应的校验方法名
|
||||
}
|
||||
@@ -109,4 +109,10 @@ public class ServerBigBrotherVO {
|
||||
@ApiModelProperty(value="创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@TableField(value = "fans_level")
|
||||
@ApiModelProperty(value = "大哥粉丝团等级")
|
||||
private Integer fansLevel;
|
||||
|
||||
@TableField(value = "sec_uid")
|
||||
private String secUid;
|
||||
}
|
||||
@@ -64,4 +64,11 @@ public class CountryInfoVO {
|
||||
@ApiModelProperty(value = "语言中文")
|
||||
private String languageName;
|
||||
|
||||
|
||||
/**
|
||||
* 国家名称英文
|
||||
*/
|
||||
@TableField(value = "country_name_english")
|
||||
@ApiModelProperty(value = "国家名称英文")
|
||||
private String countryNameEnglish;
|
||||
}
|
||||
@@ -84,4 +84,5 @@ public class NewHostsVO {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
private String uid;
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
package com.yupi.springbootinit.model.vo.hosts;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/7/3 19:12
|
||||
*/
|
||||
|
||||
/**
|
||||
* 员工分配主播表,结构和主播表相同,多了user_id 字段来区分所属员工
|
||||
*/
|
||||
@ApiModel(description="员工分配主播表,结构和主播表相同,多了user_id 字段来区分所属员工")
|
||||
@Data
|
||||
@TableName(value = "server_employee_hosts")
|
||||
public class ServerEmployeeHostsVO {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value="主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 主播id
|
||||
*/
|
||||
@TableField(value = "hosts_id")
|
||||
@ApiModelProperty(value="主播id")
|
||||
private String hostsId;
|
||||
|
||||
/**
|
||||
* 用户 Id
|
||||
*/
|
||||
@TableField(value = "user_id")
|
||||
@ApiModelProperty(value="用户 Id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 主播等级
|
||||
*/
|
||||
@TableField(value = "hosts_level")
|
||||
@ApiModelProperty(value="主播等级")
|
||||
private String hostsLevel;
|
||||
|
||||
/**
|
||||
* 主播金币
|
||||
*/
|
||||
@TableField(value = "hosts_coins")
|
||||
@ApiModelProperty(value="主播金币")
|
||||
private Integer hostsCoins;
|
||||
|
||||
/**
|
||||
* 邀请类型
|
||||
*/
|
||||
@TableField(value = "Invitation_type")
|
||||
@ApiModelProperty(value="邀请类型")
|
||||
private Integer invitationType;
|
||||
|
||||
/**
|
||||
* 在线人数
|
||||
*/
|
||||
@TableField(value = "online_fans")
|
||||
@ApiModelProperty(value="在线人数")
|
||||
private Integer onlineFans;
|
||||
|
||||
/**
|
||||
* 粉丝数量
|
||||
*/
|
||||
@TableField(value = "fans")
|
||||
@ApiModelProperty(value="粉丝数量")
|
||||
private Integer fans;
|
||||
|
||||
/**
|
||||
* 关注数量
|
||||
*/
|
||||
@TableField(value = "fllowernum")
|
||||
@ApiModelProperty(value="关注数量")
|
||||
private Integer fllowernum;
|
||||
|
||||
/**
|
||||
* 昨日金币
|
||||
*/
|
||||
@TableField(value = "yesterday_coins")
|
||||
@ApiModelProperty(value="昨日金币")
|
||||
private Integer yesterdayCoins;
|
||||
|
||||
/**
|
||||
* 主播国家
|
||||
*/
|
||||
@TableField(value = "country")
|
||||
@ApiModelProperty(value="主播国家")
|
||||
private String country;
|
||||
|
||||
/**
|
||||
* 操作状态
|
||||
*/
|
||||
@TableField(value = "operation_status")
|
||||
@ApiModelProperty(value="操作状态")
|
||||
private Integer operationStatus;
|
||||
|
||||
/**
|
||||
* 直播类型 娱乐,游戏
|
||||
*/
|
||||
@TableField(value = "hosts_kind")
|
||||
@ApiModelProperty(value="直播类型 娱乐,游戏 ")
|
||||
private String hostsKind;
|
||||
|
||||
/**
|
||||
* 租户 Id
|
||||
*/
|
||||
@TableField(value = "tenant_id")
|
||||
@ApiModelProperty(value="租户 Id")
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 入库人
|
||||
*/
|
||||
@TableField(value = "creator")
|
||||
@ApiModelProperty(value="入库人")
|
||||
private Long creator;
|
||||
|
||||
/**
|
||||
* 数据插入时间
|
||||
*/
|
||||
@TableField(value = "create_time")
|
||||
@ApiModelProperty(value="数据插入时间")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@TableField(value = "updater")
|
||||
@ApiModelProperty(value="更新人")
|
||||
private String updater;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time")
|
||||
@ApiModelProperty(value="更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
@TableField(value = "deleted")
|
||||
@ApiModelProperty(value="是否删除")
|
||||
private Byte deleted;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@TableField(value = "remake")
|
||||
@ApiModelProperty(value="备注")
|
||||
private String remake;
|
||||
|
||||
/**
|
||||
* uid
|
||||
*/
|
||||
@TableField(value = "`uid`")
|
||||
@ApiModelProperty(value="uid")
|
||||
private String uid;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.yupi.springbootinit.model.vo.user;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/8/25 14:12
|
||||
*/
|
||||
@Data
|
||||
public class SystemTenantVO {
|
||||
private Date expiredTime;
|
||||
}
|
||||
@@ -29,4 +29,12 @@ public class SystemUsersVO {
|
||||
private String tokenName;
|
||||
|
||||
private String tokenValue;
|
||||
|
||||
private Date expireTime;
|
||||
|
||||
private Date brotherExpireTime;
|
||||
|
||||
private Date aiExpireTime;
|
||||
|
||||
private Byte aiReplay;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.yupi.springbootinit.service;
|
||||
|
||||
import com.yupi.springbootinit.model.entity.AiComment;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/7/23 16:00
|
||||
*/
|
||||
|
||||
public interface AiCommentService extends IService<AiComment>{
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.yupi.springbootinit.service;
|
||||
|
||||
import com.yupi.springbootinit.model.entity.AiTemplate;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/7/18 21:06
|
||||
*/
|
||||
|
||||
public interface AiTemplateService extends IService<AiTemplate>{
|
||||
|
||||
|
||||
}
|
||||
@@ -21,5 +21,4 @@ public interface HostInfoService extends IService<NewHosts> {
|
||||
|
||||
Page<NewHostsVO> getConditionHosts(HostInfoDTO hostInfoDTO);
|
||||
|
||||
List<SevenDaysData> getSevenDaysData(HistoryDataDTO historyDataDTO);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.yupi.springbootinit.service;
|
||||
|
||||
import com.yupi.springbootinit.model.entity.ServerAiLog;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/8/25 13:37
|
||||
*/
|
||||
|
||||
public interface ServerAiLogService extends IService<ServerAiLog>{
|
||||
|
||||
|
||||
Boolean saveLog(MultipartFile file, Long tenantId, Long userId);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.yupi.springbootinit.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yupi.springbootinit.model.dto.host.HostInfoDTO;
|
||||
import com.yupi.springbootinit.model.dto.host.ServerEmployeeHostsDTO;
|
||||
import com.yupi.springbootinit.model.entity.ServerEmployeeHosts;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yupi.springbootinit.model.vo.hosts.ServerEmployeeHostsVO;
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/7/3 19:12
|
||||
*/
|
||||
|
||||
public interface ServerEmployeeHostsService extends IService<ServerEmployeeHosts>{
|
||||
|
||||
|
||||
|
||||
void updateEmployeeHost(ServerEmployeeHostsDTO hostInfoDTO);
|
||||
}
|
||||
@@ -3,7 +3,8 @@ package com.yupi.springbootinit.service;
|
||||
import com.yupi.springbootinit.common.BaseResponse;
|
||||
import com.yupi.springbootinit.model.entity.SystemTenant;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
/*
|
||||
import com.yupi.springbootinit.model.vo.user.SystemTenantVO;
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/6/20 14:50
|
||||
*/
|
||||
@@ -12,4 +13,6 @@ public interface SystemTenantService extends IService<SystemTenant>{
|
||||
|
||||
|
||||
Long getTenantIdByName(String name);
|
||||
|
||||
SystemTenantVO getTenantIdExpired(Long tenantId);
|
||||
}
|
||||
|
||||
@@ -23,4 +23,7 @@ public interface SystemUsersService extends IService<SystemUsers> {
|
||||
|
||||
boolean checkbigBrotherlRole(Long userId);
|
||||
|
||||
boolean checkAiCHatLoginRole(Long userId);
|
||||
|
||||
boolean checkWebAILoginRole(Long userId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yupi.springbootinit.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yupi.springbootinit.model.entity.AiComment;
|
||||
import com.yupi.springbootinit.mapper.AiCommentMapper;
|
||||
import com.yupi.springbootinit.service.AiCommentService;
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/7/23 16:00
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class AiCommentServiceImpl extends ServiceImpl<AiCommentMapper, AiComment> implements AiCommentService{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yupi.springbootinit.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yupi.springbootinit.model.entity.AiTemplate;
|
||||
import com.yupi.springbootinit.mapper.AiTemplateMapper;
|
||||
import com.yupi.springbootinit.service.AiTemplateService;
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/7/18 21:06
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class AiTemplateServiceImpl extends ServiceImpl<AiTemplateMapper, AiTemplate> implements AiTemplateService{
|
||||
|
||||
}
|
||||
@@ -1,30 +1,17 @@
|
||||
package com.yupi.springbootinit.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.yupi.springbootinit.common.BaseResponse;
|
||||
import com.yupi.springbootinit.common.ResultUtils;
|
||||
import com.yupi.springbootinit.mapper.NewHostsMapper;
|
||||
import com.yupi.springbootinit.model.dto.host.HistoryDataDTO;
|
||||
import com.yupi.springbootinit.model.dto.host.HostInfoDTO;
|
||||
import com.yupi.springbootinit.model.entity.NewHosts;
|
||||
import com.yupi.springbootinit.model.vo.hosts.NewHostsVO;
|
||||
import com.yupi.springbootinit.model.vo.hosts.SevenDaysData;
|
||||
import com.yupi.springbootinit.service.HostInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StopWatch;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
@@ -44,9 +31,5 @@ public class HostInfoServiceImpl extends ServiceImpl<NewHostsMapper, NewHosts> i
|
||||
return newHostsMapper.selectPageByCondition(page, hostInfoDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SevenDaysData> getSevenDaysData(HistoryDataDTO historyDataDTO) {
|
||||
List<SevenDaysData> data = newHostsMapper.selectSevenDaysData(historyDataDTO);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,262 @@
|
||||
package com.yupi.springbootinit.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.yupi.springbootinit.common.ErrorCode;
|
||||
import com.yupi.springbootinit.exception.BusinessException;
|
||||
import com.yupi.springbootinit.mapper.SystemTenantMapper;
|
||||
import com.yupi.springbootinit.model.dto.user.SystemUsersDTO;
|
||||
import com.yupi.springbootinit.model.entity.SystemTenant;
|
||||
import com.yupi.springbootinit.model.entity.SystemUsers;
|
||||
import com.yupi.springbootinit.model.enums.CommonStatusEnum;
|
||||
import com.yupi.springbootinit.model.enums.LoginSceneEnum;
|
||||
import com.yupi.springbootinit.model.vo.user.SystemUsersVO;
|
||||
import com.yupi.springbootinit.service.SystemUsersService;
|
||||
import com.yupi.springbootinit.utils.DateUtils;
|
||||
import com.yupi.springbootinit.utils.RedisUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.*;
|
||||
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 登录相关业务实现类
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class LoginService {
|
||||
|
||||
/** 用户业务服务 */
|
||||
private final SystemUsersService usersService;
|
||||
|
||||
/** 用于缓存 AI 登录状态的 RedisTemplate(布尔值) */
|
||||
@Resource
|
||||
private RedisTemplate<String, Boolean> redisTemplate;
|
||||
|
||||
/** AI聊天使用的 HeadersExchange */
|
||||
private final HeadersExchange aiChatHeadersExchange;
|
||||
|
||||
/** 大哥使用的 HeadersExchange */
|
||||
private final HeadersExchange bigBrotherHeadersExchange;
|
||||
|
||||
/** 网页AI使用的 HeadersExchange */
|
||||
private final HeadersExchange webAiHeadersExchange;
|
||||
|
||||
/** RabbitMQ 管理组件 */
|
||||
@Resource
|
||||
private RabbitAdmin rabbitAdmin;
|
||||
|
||||
/** 通用 Redis 工具类 */
|
||||
@Resource
|
||||
private RedisUtils redisUtils;
|
||||
|
||||
@Resource
|
||||
private SystemTenantMapper tenantMapper;
|
||||
|
||||
/**
|
||||
* 统一登录入口
|
||||
*
|
||||
* @param scene 登录场景(HOST / BIG_BROTHER / AI_CHAT)
|
||||
* @param dto 登录参数(用户名、密码、租户 ID)
|
||||
* @return 登录成功后的用户信息 + Token
|
||||
*/
|
||||
public SystemUsersVO login(LoginSceneEnum scene, SystemUsersDTO dto) {
|
||||
// 1. 校验用户名、密码、状态、租户过期
|
||||
SystemUsers user = validateUser(dto);
|
||||
// 2. 按场景校验角色权限
|
||||
checkRole(scene, user.getId());
|
||||
|
||||
|
||||
// 3. AI_CHAT 场景专属逻辑:缓存登录状态并动态创建 RabbitMQ 队列
|
||||
if (scene.equals(LoginSceneEnum.AI_CHAT)) {
|
||||
// 记录该用户已登录 AI_CHAT
|
||||
redisTemplate.opsForValue().set("ai_login:" + user.getTenantId() + ":" + user.getId(), true);
|
||||
String queueName = "q.tenant." + user.getTenantId();
|
||||
// 若该租户队列尚未创建,则创建队列并绑定到 HeadersExchange
|
||||
Queue queue = QueueBuilder.durable(queueName).build();
|
||||
rabbitAdmin.declareQueue(queue);
|
||||
Map<String, Object> headers = Map.of("tenantId", user.getTenantId(), "x-match", "all");
|
||||
Binding binding = BindingBuilder
|
||||
.bind(queue)
|
||||
.to(aiChatHeadersExchange) // 使用AI聊天专用交换机
|
||||
.whereAll(headers)
|
||||
.match();
|
||||
rabbitAdmin.declareBinding(binding);
|
||||
}
|
||||
// 3. 大哥场景专属逻辑:缓存登录状态并动态创建 RabbitMQ 队列
|
||||
if (scene.equals(LoginSceneEnum.BIG_BROTHER)) {
|
||||
// 记录该用户已登录 BIG_BROTHER
|
||||
redisTemplate.opsForValue().set("bigbrother_login:" + user.getTenantId() + ":" + user.getId(), true);
|
||||
String queueName = "b.tenant." + user.getTenantId();
|
||||
// 若该租户队列尚未创建,则创建队列并绑定到 HeadersExchange
|
||||
Queue queue = QueueBuilder.durable(queueName).build();
|
||||
rabbitAdmin.declareQueue(queue);
|
||||
Map<String, Object> headers = Map.of("tenantId", user.getTenantId(), "x-match", "all");
|
||||
Binding binding = BindingBuilder
|
||||
.bind(queue)
|
||||
.to(bigBrotherHeadersExchange) // 使用大哥专用交换机
|
||||
.whereAll(headers)
|
||||
.match();
|
||||
rabbitAdmin.declareBinding(binding);
|
||||
}
|
||||
if (scene.equals(LoginSceneEnum.WEB_AI)) {
|
||||
redisTemplate.opsForValue().set("webAI_login:" + user.getTenantId() + ":" + user.getId(), true);
|
||||
String queueName = "w.tenant." + user.getTenantId();
|
||||
// 若该租户队列尚未创建,则创建队列并绑定到 HeadersExchange
|
||||
Queue queue = QueueBuilder.durable(queueName).build();
|
||||
rabbitAdmin.declareQueue(queue);
|
||||
Map<String, Object> headers = Map.of("tenantId", user.getTenantId(), "x-match", "all");
|
||||
Binding binding = BindingBuilder
|
||||
.bind(queue)
|
||||
.to(webAiHeadersExchange) // 使用webAi专用交换机
|
||||
.whereAll(headers)
|
||||
.match();
|
||||
rabbitAdmin.declareBinding(binding);
|
||||
}
|
||||
|
||||
SystemTenant systemTenant = tenantMapper.selectById(user.getTenantId());
|
||||
// 封装返回数据
|
||||
SystemUsersVO vo = new SystemUsersVO();
|
||||
BeanUtil.copyProperties(user, vo);
|
||||
vo.setTokenName(StpUtil.getTokenName());
|
||||
vo.setTokenValue(StpUtil.getTokenValue());
|
||||
|
||||
// 5. Sa-Token 登录
|
||||
StpUtil.login(user.getId(), scene.getSaMode());
|
||||
switch (scene) {
|
||||
case AI_CHAT:
|
||||
StpUtil.logout(user.getId(), LoginSceneEnum.WEB_AI.getSaMode());
|
||||
StpUtil.renewTimeout(DateUtils.dateBetween(systemTenant.getAiExpireTime(),DateUtil.date()));
|
||||
BeanUtil.copyProperties(user, vo);
|
||||
vo.setTokenName(StpUtil.getTokenName());
|
||||
vo.setTokenValue(StpUtil.getTokenValue());
|
||||
vo.setAiExpireTime(systemTenant.getAiExpireTime());
|
||||
return vo;
|
||||
case HOST:
|
||||
StpUtil.renewTimeout(DateUtils.dateBetween(systemTenant.getExpireTime(),DateUtil.date()));
|
||||
BeanUtil.copyProperties(user, vo);
|
||||
vo.setTokenName(StpUtil.getTokenName());
|
||||
vo.setTokenValue(StpUtil.getTokenValue());
|
||||
vo.setExpireTime(systemTenant.getExpireTime());
|
||||
return vo;
|
||||
case BIG_BROTHER:
|
||||
StpUtil.renewTimeout(DateUtils.dateBetween(systemTenant.getBrotherExpireTime(),DateUtil.date()));
|
||||
BeanUtil.copyProperties(user, vo);
|
||||
vo.setTokenName(StpUtil.getTokenName());
|
||||
vo.setTokenValue(StpUtil.getTokenValue());
|
||||
vo.setBrotherExpireTime(systemTenant.getBrotherExpireTime());
|
||||
return vo;
|
||||
case WEB_AI:
|
||||
StpUtil.logout(user.getId(), LoginSceneEnum.AI_CHAT.getSaMode());
|
||||
StpUtil.renewTimeout(DateUtils.dateBetween(systemTenant.getAiExpireTime(),DateUtil.date()));
|
||||
BeanUtil.copyProperties(user, vo);
|
||||
vo.setTokenName(StpUtil.getTokenName());
|
||||
vo.setTokenValue(StpUtil.getTokenValue());
|
||||
vo.setAiExpireTime(systemTenant.getAiExpireTime());
|
||||
return vo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户登录信息
|
||||
*
|
||||
* @param dto 登录参数
|
||||
* @return 校验通过的用户实体
|
||||
* @throws BusinessException 校验失败时抛出
|
||||
*/
|
||||
private SystemUsers validateUser(SystemUsersDTO dto) {
|
||||
SystemUsers user = usersService.getUserByUserName(dto.getUsername(), dto.getTenantId());
|
||||
if (user == null) {
|
||||
throw new BusinessException(ErrorCode.USERNAME_OR_PASSWORD_ERROR);
|
||||
}
|
||||
if (!usersService.isPasswordMatch(dto.getPassword(), user.getPassword())) {
|
||||
throw new BusinessException(ErrorCode.USERNAME_OR_PASSWORD_ERROR);
|
||||
}
|
||||
if (CommonStatusEnum.isDisable(Integer.valueOf(user.getStatus()))) {
|
||||
throw new BusinessException(ErrorCode.USER_DISABLE);
|
||||
}
|
||||
if (usersService.isExpired(dto.getTenantId())) {
|
||||
throw new BusinessException(ErrorCode.PACKAGE_EXPIRED);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按登录场景校验角色权限
|
||||
*
|
||||
* @param scene 登录场景
|
||||
* @param userId 用户 ID
|
||||
* @throws BusinessException 无权限时抛出
|
||||
*/
|
||||
private void checkRole(LoginSceneEnum scene, Long userId) {
|
||||
Boolean pass = switch (scene) {
|
||||
case HOST -> usersService.checkCrawlRole(userId);
|
||||
case BIG_BROTHER -> usersService.checkbigBrotherlRole(userId);
|
||||
case AI_CHAT -> usersService.checkAiCHatLoginRole(userId);
|
||||
case WEB_AI -> usersService.checkWebAILoginRole(userId);
|
||||
};
|
||||
if (!pass) {
|
||||
throw new BusinessException(ErrorCode.LOGIN_NOT_ALLOWED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* AI_CHAT 场景专属登出
|
||||
*
|
||||
* @param usersDTO 包含租户 ID 与用户 ID
|
||||
* @return 固定返回 true
|
||||
*/
|
||||
public Boolean aiChatLogout(SystemUsersDTO usersDTO) {
|
||||
// 1. 删除 Redis 中该用户的 AI_CHAT 登录标记
|
||||
Boolean ai_login = redisTemplate.delete("ai_login:" + usersDTO.getTenantId() + ":" + usersDTO.getUserId());
|
||||
Boolean webAi_login = redisTemplate.delete("webAI_login:" + usersDTO.getTenantId() + ":" + usersDTO.getUserId());
|
||||
|
||||
|
||||
// 2. 使当前 Token 失效
|
||||
String tokenValue = StpUtil.getTokenValue();
|
||||
StpUtil.logoutByTokenValue(tokenValue);
|
||||
|
||||
log.info("删除租户:{} 登录状态:{}", usersDTO.getTenantId(), ai_login);
|
||||
log.info("删除租户:{} 登录状态:{}", usersDTO.getTenantId(), webAi_login);
|
||||
|
||||
// 3. 若该租户下已无 AI_CHAT 在线用户,则删除队列
|
||||
if (!redisUtils.hasKeyByPrefix("ai_login:" + usersDTO.getTenantId())) {
|
||||
boolean b = rabbitAdmin.deleteQueue("q.tenant." + usersDTO.getTenantId());
|
||||
log.info("删除Ai_CHAT租户:{} 队列删除状态:{}", usersDTO.getTenantId(), b);
|
||||
}
|
||||
|
||||
if (!redisUtils.hasKeyByPrefix("webAI_login:" + usersDTO.getTenantId())) {
|
||||
boolean b = rabbitAdmin.deleteQueue("w.tenant." + usersDTO.getTenantId());
|
||||
log.info("删除Web_AI租户:{} 队列删除状态:{}", usersDTO.getTenantId(), b);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用登出(不区分场景)
|
||||
*
|
||||
* @return 固定返回 true
|
||||
*/
|
||||
public Boolean logout() {
|
||||
String tokenValue = StpUtil.getTokenValue();
|
||||
Long loginId = (Long) StpUtil.getLoginId();
|
||||
StpUtil.logoutByTokenValue(tokenValue);
|
||||
log.info("用户:{} 登出成功", loginId);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.yupi.springbootinit.service.impl;
|
||||
|
||||
import com.yupi.springbootinit.common.ErrorCode;
|
||||
import com.yupi.springbootinit.exception.BusinessException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yupi.springbootinit.mapper.ServerAiLogMapper;
|
||||
import com.yupi.springbootinit.model.entity.ServerAiLog;
|
||||
import com.yupi.springbootinit.service.ServerAiLogService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/8/25 13:37
|
||||
*/
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ServerAiLogServiceImpl extends ServiceImpl<ServerAiLogMapper, ServerAiLog> implements ServerAiLogService{
|
||||
|
||||
@Resource
|
||||
private ServerAiLogMapper serverAiLogMapper;
|
||||
|
||||
@Value("${ai_log_path}")
|
||||
private String basePath;
|
||||
|
||||
@Override
|
||||
public Boolean saveLog(MultipartFile file, Long tenantId, Long userId) {
|
||||
|
||||
if (file.isEmpty()) {
|
||||
throw new BusinessException(ErrorCode.SYSTEM_ERROR,"上传文件为空");
|
||||
}
|
||||
Path dir = Paths.get(basePath, tenantId.toString(), userId.toString());
|
||||
if (!Files.exists(dir)) {
|
||||
try {
|
||||
Files.createDirectories(dir);
|
||||
} catch (IOException e) {
|
||||
throw new BusinessException(ErrorCode.SYSTEM_ERROR,"创建目录失败");
|
||||
}
|
||||
}
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
Path target = dir.resolve(originalFilename);
|
||||
try {
|
||||
Files.copy(file.getInputStream(), target, StandardCopyOption.REPLACE_EXISTING);
|
||||
log.info("文件名{},文件上传路径{},",originalFilename,target);
|
||||
} catch (IOException e) {
|
||||
throw new BusinessException(ErrorCode.SYSTEM_ERROR,"保存文件失败");
|
||||
}
|
||||
ServerAiLog log = new ServerAiLog();
|
||||
log.setLogName(originalFilename);
|
||||
log.setLogFilePath(target.toString());
|
||||
log.setLogTenantId(tenantId);
|
||||
log.setLogUserId(userId);
|
||||
log.setCreator(String.valueOf(userId)); // 可替换为当前登录用户
|
||||
return serverAiLogMapper.insert(log) == 1;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.yupi.springbootinit.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yupi.springbootinit.mapper.ServerEmployeeHostsMapper;
|
||||
import com.yupi.springbootinit.model.dto.host.ServerEmployeeHostsDTO;
|
||||
import com.yupi.springbootinit.model.entity.ServerEmployeeHosts;
|
||||
import com.yupi.springbootinit.service.ServerEmployeeHostsService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/7/3 19:12
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class ServerEmployeeHostsServiceImpl extends ServiceImpl<ServerEmployeeHostsMapper, ServerEmployeeHosts> implements ServerEmployeeHostsService{
|
||||
|
||||
|
||||
@Override
|
||||
public void updateEmployeeHost(ServerEmployeeHostsDTO hostInfoDTO) {
|
||||
BeanUtils.copyProperties(hostInfoDTO,ServerEmployeeHosts.class);
|
||||
lambdaUpdate().eq(ServerEmployeeHosts::getHostsId, hostInfoDTO.getHostsId())
|
||||
.eq(ServerEmployeeHosts::getUserId, hostInfoDTO.getUserId())
|
||||
.eq(ServerEmployeeHosts::getTenantId, hostInfoDTO.getTenantId())
|
||||
.set(ServerEmployeeHosts::getOperationStatus, hostInfoDTO.getOperationStatus())
|
||||
.update();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.yupi.springbootinit.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.yupi.springbootinit.common.BaseResponse;
|
||||
import com.yupi.springbootinit.common.ErrorCode;
|
||||
import com.yupi.springbootinit.exception.BusinessException;
|
||||
import com.yupi.springbootinit.model.vo.user.SystemTenantVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import java.util.List;
|
||||
@@ -11,6 +13,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yupi.springbootinit.model.entity.SystemTenant;
|
||||
import com.yupi.springbootinit.mapper.SystemTenantMapper;
|
||||
import com.yupi.springbootinit.service.SystemTenantService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/6/20 14:50
|
||||
@@ -19,10 +23,14 @@ import com.yupi.springbootinit.service.SystemTenantService;
|
||||
@Service
|
||||
public class SystemTenantServiceImpl extends ServiceImpl<SystemTenantMapper, SystemTenant> implements SystemTenantService{
|
||||
|
||||
@Resource
|
||||
private SystemTenantMapper systemTenantMapper;
|
||||
|
||||
@Override
|
||||
public Long getTenantIdByName(String name) {
|
||||
QueryWrapper<SystemTenant> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("name",name);
|
||||
queryWrapper.eq("name",name)
|
||||
.eq("deleted",false );
|
||||
SystemTenant systemTenant = baseMapper.selectOne(queryWrapper);
|
||||
if (systemTenant == null){
|
||||
throw new BusinessException(ErrorCode.TENANT_NAME_NOT_EXISTS);
|
||||
@@ -30,4 +38,12 @@ public class SystemTenantServiceImpl extends ServiceImpl<SystemTenantMapper, Sys
|
||||
return systemTenant.getId();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemTenantVO getTenantIdExpired(Long tenantId) {
|
||||
SystemTenant systemTenant = systemTenantMapper.selectById(tenantId);
|
||||
SystemTenantVO systemTenantVO = new SystemTenantVO();
|
||||
systemTenantVO.setExpiredTime(systemTenant.getExpireTime());
|
||||
return systemTenantVO;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ public class SystemUsersServiceImpl extends ServiceImpl<SystemUsersMapper,System
|
||||
QueryWrapper <SystemUsers> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("username",username);
|
||||
queryWrapper.eq("tenant_id",tenantId);
|
||||
queryWrapper.eq("deleted",false);
|
||||
return baseMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
@@ -76,5 +77,18 @@ public class SystemUsersServiceImpl extends ServiceImpl<SystemUsersMapper,System
|
||||
return systemUsers.getBigBrother() == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkAiCHatLoginRole(Long userId) {
|
||||
SystemUsers systemUsers = baseMapper.selectById(userId);
|
||||
return systemUsers.getAiChat() == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkWebAILoginRole(Long userId) {
|
||||
SystemUsers systemUsers = baseMapper.selectById(userId);
|
||||
return systemUsers.getWebAi() == 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
17
src/main/java/com/yupi/springbootinit/utils/DateUtils.java
Normal file
17
src/main/java/com/yupi/springbootinit/utils/DateUtils.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.yupi.springbootinit.utils;
|
||||
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/9/16 16:31
|
||||
*/
|
||||
public class DateUtils {
|
||||
|
||||
public static Long dateBetween(Date date1, Date date2) {
|
||||
return DateUtil.between(date1, date2, DateUnit.SECOND);
|
||||
}
|
||||
}
|
||||
40
src/main/java/com/yupi/springbootinit/utils/RedisUtils.java
Normal file
40
src/main/java/com/yupi/springbootinit/utils/RedisUtils.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.yupi.springbootinit.utils;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/8/27 20:35
|
||||
*/
|
||||
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
@Component
|
||||
public class RedisUtils {
|
||||
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String,Object> redisTemplate;
|
||||
|
||||
public boolean hasAiLoginKeys(String prefix) {
|
||||
Set<String> keys = redisTemplate.keys(prefix); // 获取匹配的键集合
|
||||
return !keys.isEmpty(); // 如果有键匹配,返回true,否则返回false
|
||||
}
|
||||
|
||||
public boolean hasKeyByPrefix(String prefix) {
|
||||
return Boolean.TRUE.equals(
|
||||
redisTemplate.execute((RedisCallback<Boolean>) conn -> {
|
||||
try (Cursor<byte[]> cursor = conn.scan(
|
||||
ScanOptions.scanOptions()
|
||||
.match(prefix + ":*")
|
||||
.count(100) // 每次返回条数,可调整
|
||||
.build())) {
|
||||
return cursor.hasNext(); // 只要存在一条就返回 true
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ spring:
|
||||
# todo 需替换配置
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://47.79.98.113:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true
|
||||
url: jdbc:mysql://localhost:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true
|
||||
username: root
|
||||
password: 123asd
|
||||
# Redis 配置
|
||||
@@ -37,3 +37,13 @@ spring:
|
||||
simple:
|
||||
acknowledge-mode: manual
|
||||
|
||||
knife4j:
|
||||
enable: true
|
||||
openapi:
|
||||
title: "接口文档"
|
||||
version: 1.0
|
||||
group:
|
||||
default:
|
||||
api-rule: package
|
||||
api-rule-resources:
|
||||
- com.yupi.springbootinit.controller
|
||||
@@ -6,7 +6,7 @@ spring:
|
||||
name: springboot-init
|
||||
# 默认 dev 环境
|
||||
profiles:
|
||||
active: prod
|
||||
active: dev
|
||||
# 支持 swagger3
|
||||
mvc:
|
||||
pathmatch:
|
||||
@@ -49,7 +49,7 @@ mybatis-plus:
|
||||
map-underscore-to-camel-case: false
|
||||
log-impl: org.apache.ibatis.logging.log4j2.Log4j2Impl
|
||||
log-sql:
|
||||
default-executor-type: batch
|
||||
default-executor-type: simple
|
||||
global-config:
|
||||
db-config:
|
||||
logic-delete-field: isDelete # 全局逻辑删除的实体字段名
|
||||
@@ -86,25 +86,14 @@ cos:
|
||||
region: xxx
|
||||
bucket: xxx
|
||||
# 接口文档配置
|
||||
knife4j:
|
||||
enable: false
|
||||
openapi:
|
||||
title: "接口文档"
|
||||
version: 1.0
|
||||
group:
|
||||
default:
|
||||
api-rule: package
|
||||
api-rule-resources:
|
||||
- com.yupi.springbootinit.controller
|
||||
|
||||
|
||||
############## Sa-Token 配置 (文档: https://sa-token.cc) ##############
|
||||
sa-token:
|
||||
# token 名称(同时也是 cookie 名称)
|
||||
token-name: vvtoken
|
||||
# token 有效期(单位:秒) 默认30天,-1 代表永久有效
|
||||
timeout: 2592000
|
||||
# token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
|
||||
active-timeout: -1
|
||||
timeout: 172800
|
||||
# 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
|
||||
is-concurrent: false
|
||||
# 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token)
|
||||
@@ -117,3 +106,5 @@ sa-token:
|
||||
|
||||
md5:
|
||||
salt: (-FhqvXO,wMz
|
||||
|
||||
ai_log_path: /test/ai_log
|
||||
68
src/main/resources/logback-spring.xml
Normal file
68
src/main/resources/logback-spring.xml
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds">
|
||||
<!-- 日志上下文名称 -->
|
||||
<contextName>TK-DataSave</contextName>
|
||||
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="PATTERN_DEFAULT" value="%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}} | %highlight(${LOG_LEVEL_PATTERN:-%5p} ${PID:- }) | %boldYellow(%thread) %boldGreen(%-40.40logger{39}) | %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%ex}"/>
|
||||
<property name="FILE_PATTERN" value="%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}} | ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } | %thread %-40.40logger{39} | %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%ex}"/>
|
||||
|
||||
<!-- <property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n"/>-->
|
||||
<!-- 日志文件路径 -->
|
||||
<property name="LOG_FILE_PATH" value="${LOG_FILE:-${user.dir}}/tk-data-user"/>
|
||||
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<pattern>${PATTERN_DEFAULT}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 文件输出 (滚动策略: 按时间) -->
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${LOG_FILE_PATH}.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE_PATH}.%d{yyyy-MM-dd}.%i.gz}</fileNamePattern>
|
||||
<maxHistory>${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-7}</maxHistory>
|
||||
<maxFileSize>${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB}</maxFileSize>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${FILE_PATTERN}</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 开发环境配置 -->
|
||||
<springProfile name="dev">
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
<appender-ref ref="FILE"/>
|
||||
</root>
|
||||
<!-- 项目包日志级别 -->
|
||||
<logger name="com.yupi.springbootinit" level="DEBUG" additivity="false">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</logger>
|
||||
<!-- MyBatis日志级别 -->
|
||||
<logger name="com.baomidou.mybatisplus" level="INFO"/>
|
||||
</springProfile>
|
||||
|
||||
<!-- 生产环境配置 -->
|
||||
<springProfile name="prod">
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
<appender-ref ref="FILE"/>
|
||||
</root>
|
||||
<!-- 项目包日志级别 -->
|
||||
<logger name="com.yupi.springbootinit" level="INFO" additivity="false">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
<appender-ref ref="FILE"/>
|
||||
</logger>
|
||||
<!-- 第三方框架日志级别 -->
|
||||
<logger name="org.springframework" level="WARN"/>
|
||||
<logger name="com.baomidou.mybatisplus" level="WARN"/>
|
||||
<logger name="org.redisson" level="WARN"/>
|
||||
</springProfile>
|
||||
|
||||
|
||||
</configuration>
|
||||
14
src/main/resources/mapper/AiCommentMapper.xml
Normal file
14
src/main/resources/mapper/AiCommentMapper.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yupi.springbootinit.mapper.AiCommentMapper">
|
||||
<resultMap id="BaseResultMap" type="com.yupi.springbootinit.model.entity.AiComment">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table ai_comment-->
|
||||
<id column="id" jdbcType="INTEGER" property="id" />
|
||||
<result column="content" jdbcType="VARCHAR" property="content" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
id, content
|
||||
</sql>
|
||||
</mapper>
|
||||
14
src/main/resources/mapper/AiTemplateMapper.xml
Normal file
14
src/main/resources/mapper/AiTemplateMapper.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yupi.springbootinit.mapper.AiTemplateMapper">
|
||||
<resultMap id="BaseResultMap" type="com.yupi.springbootinit.model.entity.AiTemplate">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table ai_template-->
|
||||
<id column="id" jdbcType="INTEGER" property="id" />
|
||||
<result column="content" jdbcType="VARCHAR" property="content" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
id, content
|
||||
</sql>
|
||||
</mapper>
|
||||
@@ -26,6 +26,7 @@
|
||||
<result column="country_name" jdbcType="VARCHAR" property="countryName" />
|
||||
<result column="language" jdbcType="VARCHAR" property="language" />
|
||||
<result column="language_name" jdbcType="VARCHAR" property="languageName" />
|
||||
<result column="country_name_english" jdbcType="VARCHAR" property="countryNameEnglish" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<result column="hosts_kind" jdbcType="VARCHAR" property="hostsKind" />
|
||||
<result column="online_fans" jdbcType="INTEGER" property="onlineFans"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="uid" jdbcType="VARCHAR" property="uid" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
@@ -245,7 +246,7 @@
|
||||
|
||||
<select id="selectPageByCondition" resultMap="HostInfoVo">
|
||||
select ns.id,hosts_id, hosts_level, hosts_coins, Invitation_type, fans, fllowernum,
|
||||
yesterday_coins,ns.create_time, country, online_fans,hosts_kind from server_new_hosts ns left join server_country_info ci ON ns.country = ci.country_name
|
||||
yesterday_coins,ns.create_time, country, online_fans,hosts_kind, uid from server_new_hosts ns left join server_country_info ci ON ns.country = ci.country_name
|
||||
where ns.tenant_id=#{hostInfoDTO.tenantId}
|
||||
<!-- 主播国家筛选 -->
|
||||
<if test="hostInfoDTO.country!= '' and hostInfoDTO.country != null">
|
||||
@@ -260,50 +261,50 @@
|
||||
and ns.hosts_id like concat(#{hostInfoDTO.hostsId,jdbcType=VARCHAR},'%')
|
||||
</if>
|
||||
<!-- 今日主播金币筛选 -->
|
||||
<if test="hostInfoDTO.hostsCoinsMin != null and hostInfoDTO.hostsCoinsMax == null and hostInfoDTO.hostsCoinsMax != '' ">
|
||||
<if test="hostInfoDTO.hostsCoinsMin != null and hostInfoDTO.hostsCoinsMax == null ">
|
||||
and ns.hosts_coins >=#{hostInfoDTO.hostsCoinsMin,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="hostInfoDTO.hostsCoinsMax != null and hostInfoDTO.hostsCoinsMin == null and hostInfoDTO.hostsCoinsMin !='' ">
|
||||
<if test="hostInfoDTO.hostsCoinsMax != null and hostInfoDTO.hostsCoinsMin == null ">
|
||||
and ns.hosts_coins <=#{hostInfoDTO.hostsCoinsMax,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="hostInfoDTO.hostsCoinsMin != null and hostInfoDTO.hostsCoinsMax != null " >
|
||||
and ns.hosts_coins between #{hostInfoDTO.hostsCoinsMin,jdbcType=INTEGER} and #{hostInfoDTO.hostsCoinsMax,jdbcType=INTEGER}
|
||||
</if>
|
||||
<!-- 昨日主播金币筛选 -->
|
||||
<if test="hostInfoDTO.yesterdayCoinsMin != null and hostInfoDTO.yesterdayCoinsMax == null and hostInfoDTO.yesterdayCoinsMax != ''">
|
||||
<if test="hostInfoDTO.yesterdayCoinsMin != null and hostInfoDTO.yesterdayCoinsMax == null ">
|
||||
and ns.yesterday_coins >=#{hostInfoDTO.yesterdayCoinsMin,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="hostInfoDTO.yesterdayCoinsMax != null and hostInfoDTO.yesterdayCoinsMin == null and hostInfoDTO.yesterdayCoinsMin != '' ">
|
||||
<if test="hostInfoDTO.yesterdayCoinsMax != null and hostInfoDTO.yesterdayCoinsMin == null ">
|
||||
and ns.yesterday_coins <=#{hostInfoDTO.yesterdayCoinsMax,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="hostInfoDTO.yesterdayCoinsMin != null and hostInfoDTO.yesterdayCoinsMax != null " >
|
||||
and ns.yesterday_coins between #{hostInfoDTO.yesterdayCoinsMin,jdbcType=INTEGER} and #{hostInfoDTO.yesterdayCoinsMax,jdbcType=INTEGER}
|
||||
</if>
|
||||
<!-- 主播粉丝数筛选-->
|
||||
<if test="hostInfoDTO.fansMin != null and hostInfoDTO.fansMax == null and hostInfoDTO.fansMax != ''">
|
||||
<if test="hostInfoDTO.fansMin != null and hostInfoDTO.fansMax == null ">
|
||||
and ns.fans >=#{hostInfoDTO.fansMin,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="hostInfoDTO.fansMax != null and hostInfoDTO.fansMin == null and hostInfoDTO.fansMin != '' ">
|
||||
<if test="hostInfoDTO.fansMax != null and hostInfoDTO.fansMin == null ">
|
||||
and ns.fans <=#{hostInfoDTO.fansMax,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="hostInfoDTO.fansMin != null and hostInfoDTO.fansMax != null " >
|
||||
and ns.fans between #{hostInfoDTO.fansMin,jdbcType=INTEGER} and #{hostInfoDTO.fansMax,jdbcType=INTEGER}
|
||||
</if>
|
||||
<!-- 主播关注筛选-->
|
||||
<if test="hostInfoDTO.fllowernumMin != null and hostInfoDTO.fllowernumMax == null and hostInfoDTO.fllowernumMax != ''">
|
||||
<if test="hostInfoDTO.fllowernumMin != null and hostInfoDTO.fllowernumMax == null">
|
||||
and ns.fllowernum >=#{hostInfoDTO.fllowernumMin,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="hostInfoDTO.fllowernumMax != null and hostInfoDTO.fllowernumMin == null and hostInfoDTO.fllowernumMin != ''">
|
||||
<if test="hostInfoDTO.fllowernumMax != null and hostInfoDTO.fllowernumMin == null">
|
||||
and ns.fllowernum <=#{hostInfoDTO.fllowernumMax,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="hostInfoDTO.fllowernumMin != null and hostInfoDTO.fllowernumMax != null " >
|
||||
and ns.fllowernum between #{hostInfoDTO.fllowernumMin,jdbcType=INTEGER} and #{hostInfoDTO.fllowernumMax,jdbcType=INTEGER}
|
||||
</if>
|
||||
<!-- 主播在线人数筛选-->
|
||||
<if test="hostInfoDTO.onlineFansMin != null and hostInfoDTO.onlineFansMax == null and hostInfoDTO.onlineFansMax != '' ">
|
||||
<if test="hostInfoDTO.onlineFansMin != null and hostInfoDTO.onlineFansMax == null ">
|
||||
and ns.online_fans >=#{hostInfoDTO.onlineFansMin,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="hostInfoDTO.onlineFansMax != null and hostInfoDTO.onlineFansMin == null and hostInfoDTO.onlineFansMin != ''">
|
||||
<if test="hostInfoDTO.onlineFansMax != null and hostInfoDTO.onlineFansMin == null ">
|
||||
and ns.online_fans <= #{hostInfoDTO.onlineFansMax,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="hostInfoDTO.onlineFansMin != null and hostInfoDTO.onlineFansMax != null " >
|
||||
@@ -316,12 +317,12 @@
|
||||
<!-- 排序类型 -->
|
||||
order by
|
||||
<choose>
|
||||
<!-- 传空和默认的情况下按照时间降序排序 -->
|
||||
<when test="hostInfoDTO.sortName == '' or hostInfoDTO.sortName == null">
|
||||
<!-- 传空和默认的情况下按照时间降序排序 -->
|
||||
<when test="hostInfoDTO.sortName == '' and hostInfoDTO.sortName == null">
|
||||
ns.create_time desc
|
||||
</when>
|
||||
<!-- sortNmae 有值的情况下排序 -->
|
||||
<when test="hostInfoDTO.sortName != null or hostInfoDTO.sort != null ">
|
||||
<when test="hostInfoDTO.sortName != null and hostInfoDTO.sort != null ">
|
||||
<if test="hostInfoDTO.sortName == 'createTime' and hostInfoDTO.sort != null">
|
||||
ns.create_time ${hostInfoDTO.sort}
|
||||
</if>
|
||||
@@ -346,6 +347,9 @@
|
||||
ns.online_fans ${hostInfoDTO.sort}
|
||||
</if>
|
||||
</when>
|
||||
<otherwise>
|
||||
ns.create_time desc
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
|
||||
22
src/main/resources/mapper/ServerAiLogMapper.xml
Normal file
22
src/main/resources/mapper/ServerAiLogMapper.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yupi.springbootinit.mapper.ServerAiLogMapper">
|
||||
<resultMap id="BaseResultMap" type="com.yupi.springbootinit.model.entity.ServerAiLog">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table server_ai_log-->
|
||||
<id column="log_id" jdbcType="BIGINT" property="logId" />
|
||||
<result column="log_name" jdbcType="VARCHAR" property="logName" />
|
||||
<result column="log_file_path" jdbcType="VARCHAR" property="logFilePath" />
|
||||
<result column="log_tenant_id" jdbcType="BIGINT" property="logTenantId" />
|
||||
<result column="log_user_id" jdbcType="BIGINT" property="logUserId" />
|
||||
<result column="creator" jdbcType="VARCHAR" property="creator" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="updater" jdbcType="VARCHAR" property="updater" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
log_id, log_name, log_file_path, log_tenant_id, log_user_id, creator, create_time,
|
||||
updater, update_time
|
||||
</sql>
|
||||
</mapper>
|
||||
@@ -23,12 +23,13 @@
|
||||
<result column="updater" jdbcType="VARCHAR" property="updater" />
|
||||
<result column="deleted" jdbcType="BOOLEAN" property="deleted" />
|
||||
<result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
|
||||
<result column="secUid" jdbcType="VARCHAR" property="secUid" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
id, display_id, user_id_str, nickname, `level`, hostcoins, follower_count, following_count,
|
||||
region, historic_high_coins, total_gift_coins, host_display_id, owner_id, create_time,
|
||||
update_time, creator, updater, deleted, tenant_id
|
||||
update_time, creator, updater, deleted, tenant_id,secUid
|
||||
</sql>
|
||||
|
||||
<resultMap id="BaseResultMapCopy" type="com.yupi.springbootinit.model.vo.bigbrother.ServerBigBrotherVO">
|
||||
@@ -46,6 +47,8 @@
|
||||
<result column="total_gift_coins" jdbcType="INTEGER" property="totalGiftCoins" />
|
||||
<result column="host_display_id" jdbcType="VARCHAR" property="hostDisplayId" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="fans_level" jdbcType="INTEGER" property="fansLevel" />
|
||||
<result column="secUid" jdbcType="VARCHAR" property="secUid" />
|
||||
</resultMap>
|
||||
|
||||
|
||||
@@ -53,7 +56,7 @@
|
||||
<select id="selectPageByCondition" resultMap="BaseResultMapCopy">
|
||||
select sbr.display_id, sbr.user_id_str,sbr.nickname,sbr.level,sbr.hostcoins,
|
||||
sbr.follower_count, sbr.following_count, sbr.region, sbr.historic_high_coins, sbr.total_gift_coins,
|
||||
sbr.host_display_id,sbr.create_time from
|
||||
sbr.host_display_id,sbr.create_time,sbr.fans_level,sbr.secUid from
|
||||
server_big_brother sbr left join server_country_info ci ON sbr.region = ci.country_name
|
||||
where sbr.tenant_id=#{dto.tenantId}
|
||||
<!-- 大哥所属国家筛选 -->
|
||||
|
||||
144
src/main/resources/mapper/ServerEmployeeHostsMapper.xml
Normal file
144
src/main/resources/mapper/ServerEmployeeHostsMapper.xml
Normal file
@@ -0,0 +1,144 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yupi.springbootinit.mapper.ServerEmployeeHostsMapper">
|
||||
<resultMap id="BaseResultMap" type="com.yupi.springbootinit.model.entity.ServerEmployeeHosts">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table server_employee_hosts-->
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="hosts_id" jdbcType="VARCHAR" property="hostsId" />
|
||||
<result column="user_id" jdbcType="BIGINT" property="userId" />
|
||||
<result column="hosts_level" jdbcType="VARCHAR" property="hostsLevel" />
|
||||
<result column="hosts_coins" jdbcType="INTEGER" property="hostsCoins" />
|
||||
<result column="Invitation_type" jdbcType="INTEGER" property="invitationType" />
|
||||
<result column="online_fans" jdbcType="INTEGER" property="onlineFans" />
|
||||
<result column="fans" jdbcType="INTEGER" property="fans" />
|
||||
<result column="fllowernum" jdbcType="INTEGER" property="fllowernum" />
|
||||
<result column="yesterday_coins" jdbcType="INTEGER" property="yesterdayCoins" />
|
||||
<result column="country" jdbcType="VARCHAR" property="country" />
|
||||
<result column="operation_status" jdbcType="INTEGER" property="operationStatus" />
|
||||
<result column="hosts_kind" jdbcType="VARCHAR" property="hostsKind" />
|
||||
<result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
|
||||
<result column="creator" jdbcType="BIGINT" property="creator" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="updater" jdbcType="VARCHAR" property="updater" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
<result column="deleted" jdbcType="TINYINT" property="deleted" />
|
||||
<result column="remake" jdbcType="VARCHAR" property="remake" />
|
||||
<result column="uid" jdbcType="VARCHAR" property="uid" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
id, hosts_id, user_id, hosts_level, hosts_coins, Invitation_type, online_fans, fans,
|
||||
fllowernum, yesterday_coins, country, operation_status, hosts_kind, tenant_id, creator,
|
||||
create_time, updater, update_time, deleted, remake, `uid`
|
||||
</sql>
|
||||
|
||||
<select id="selectPageByCondition" resultType="com.yupi.springbootinit.model.vo.hosts.ServerEmployeeHostsVO">
|
||||
select ns.id,hosts_id, hosts_level, hosts_coins, Invitation_type, fans, fllowernum,
|
||||
yesterday_coins,ns.create_time, country, online_fans,hosts_kind, uid from server_new_hosts ns left join server_country_info ci ON ns.country = ci.country_name
|
||||
where ns.tenant_id=#{hostInfoDTO.tenantId}
|
||||
<!-- 主播国家筛选 -->
|
||||
<if test="hostInfoDTO.country!= '' and hostInfoDTO.country != null">
|
||||
and ci.country_group_name =#{hostInfoDTO.country,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<!-- 按照入库时间筛选主播 -->
|
||||
<if test="hostInfoDTO.createTime != null">
|
||||
and DATE(ns.create_time) =#{hostInfoDTO.createTime}
|
||||
</if>
|
||||
<!-- 主播 Id 模糊搜索 -->
|
||||
<if test="hostInfoDTO.hostsId != '' and hostInfoDTO.hostsId != null ">
|
||||
and ns.hosts_id like concat(#{hostInfoDTO.hostsId,jdbcType=VARCHAR},'%')
|
||||
</if>
|
||||
<!-- 今日主播金币筛选 -->
|
||||
<if test="hostInfoDTO.hostsCoinsMin != null and hostInfoDTO.hostsCoinsMax == null ">
|
||||
and ns.hosts_coins >=#{hostInfoDTO.hostsCoinsMin,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="hostInfoDTO.hostsCoinsMax != null and hostInfoDTO.hostsCoinsMin == null ">
|
||||
and ns.hosts_coins <=#{hostInfoDTO.hostsCoinsMax,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="hostInfoDTO.hostsCoinsMin != null and hostInfoDTO.hostsCoinsMax != null " >
|
||||
and ns.hosts_coins between #{hostInfoDTO.hostsCoinsMin,jdbcType=INTEGER} and #{hostInfoDTO.hostsCoinsMax,jdbcType=INTEGER}
|
||||
</if>
|
||||
<!-- 昨日主播金币筛选 -->
|
||||
<if test="hostInfoDTO.yesterdayCoinsMin != null and hostInfoDTO.yesterdayCoinsMax == null ">
|
||||
and ns.yesterday_coins >=#{hostInfoDTO.yesterdayCoinsMin,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="hostInfoDTO.yesterdayCoinsMax != null and hostInfoDTO.yesterdayCoinsMin == null ">
|
||||
and ns.yesterday_coins <=#{hostInfoDTO.yesterdayCoinsMax,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="hostInfoDTO.yesterdayCoinsMin != null and hostInfoDTO.yesterdayCoinsMax != null " >
|
||||
and ns.yesterday_coins between #{hostInfoDTO.yesterdayCoinsMin,jdbcType=INTEGER} and #{hostInfoDTO.yesterdayCoinsMax,jdbcType=INTEGER}
|
||||
</if>
|
||||
<!-- 主播粉丝数筛选-->
|
||||
<if test="hostInfoDTO.fansMin != null and hostInfoDTO.fansMax == null ">
|
||||
and ns.fans >=#{hostInfoDTO.fansMin,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="hostInfoDTO.fansMax != null and hostInfoDTO.fansMin == null ">
|
||||
and ns.fans <=#{hostInfoDTO.fansMax,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="hostInfoDTO.fansMin != null and hostInfoDTO.fansMax != null " >
|
||||
and ns.fans between #{hostInfoDTO.fansMin,jdbcType=INTEGER} and #{hostInfoDTO.fansMax,jdbcType=INTEGER}
|
||||
</if>
|
||||
<!-- 主播关注筛选-->
|
||||
<if test="hostInfoDTO.fllowernumMin != null and hostInfoDTO.fllowernumMax == null">
|
||||
and ns.fllowernum >=#{hostInfoDTO.fllowernumMin,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="hostInfoDTO.fllowernumMax != null and hostInfoDTO.fllowernumMin == null">
|
||||
and ns.fllowernum <=#{hostInfoDTO.fllowernumMax,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="hostInfoDTO.fllowernumMin != null and hostInfoDTO.fllowernumMax != null " >
|
||||
and ns.fllowernum between #{hostInfoDTO.fllowernumMin,jdbcType=INTEGER} and #{hostInfoDTO.fllowernumMax,jdbcType=INTEGER}
|
||||
</if>
|
||||
<!-- 主播在线人数筛选-->
|
||||
<if test="hostInfoDTO.onlineFansMin != null and hostInfoDTO.onlineFansMax == null ">
|
||||
and ns.online_fans >=#{hostInfoDTO.onlineFansMin,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="hostInfoDTO.onlineFansMax != null and hostInfoDTO.onlineFansMin == null ">
|
||||
and ns.online_fans <= #{hostInfoDTO.onlineFansMax,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="hostInfoDTO.onlineFansMin != null and hostInfoDTO.onlineFansMax != null " >
|
||||
and ns.online_fans between #{hostInfoDTO.onlineFansMin,jdbcType=INTEGER} and #{hostInfoDTO.onlineFansMax,jdbcType=INTEGER}
|
||||
</if>
|
||||
<!-- 邀请类筛选 -->
|
||||
<if test="hostInfoDTO.invitationType != null">
|
||||
and ns.Invitation_type =#{hostInfoDTO.invitationType,jdbcType=INTEGER}
|
||||
</if>
|
||||
<!-- 排序类型 -->
|
||||
order by
|
||||
<choose>
|
||||
<!-- 传空和默认的情况下按照时间降序排序 -->
|
||||
<when test="hostInfoDTO.sortName == '' and hostInfoDTO.sortName == null">
|
||||
ns.create_time desc
|
||||
</when>
|
||||
<!-- sortNmae 有值的情况下排序 -->
|
||||
<when test="hostInfoDTO.sortName != null and hostInfoDTO.sort != null ">
|
||||
<if test="hostInfoDTO.sortName == 'createTime' and hostInfoDTO.sort != null">
|
||||
ns.create_time ${hostInfoDTO.sort}
|
||||
</if>
|
||||
<!-- 昨日主播金币条件排序 -->
|
||||
<if test="hostInfoDTO.sortName == 'yesterdayCoins' and hostInfoDTO.sort != null">
|
||||
ns.yesterday_coins ${hostInfoDTO.sort}
|
||||
</if>
|
||||
<!-- 主播金币条件排序 -->
|
||||
<if test="hostInfoDTO.sortName == 'hostsCoins' and hostInfoDTO.sort != null">
|
||||
ns.hosts_coins ${hostInfoDTO.sort}
|
||||
</if>
|
||||
<!-- 主播粉丝条件排序 -->
|
||||
<if test="hostInfoDTO.sortName == 'fans' and hostInfoDTO.sort != null">
|
||||
ns.fans ${hostInfoDTO.sort}
|
||||
</if>
|
||||
<!-- 主播关注数量排序 -->
|
||||
<if test="hostInfoDTO.sortName == 'fllowernum' and hostInfoDTO.sort != null">
|
||||
ns.fllowernum ${hostInfoDTO.sort}
|
||||
</if>
|
||||
<!-- 主播直播间在线数量排序 -->
|
||||
<if test="hostInfoDTO.sortName == 'onlineFans' and hostInfoDTO.sort != null">
|
||||
ns.online_fans ${hostInfoDTO.sort}
|
||||
</if>
|
||||
</when>
|
||||
<otherwise>
|
||||
ns.create_time desc
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -25,6 +25,7 @@
|
||||
<result column="deleted" jdbcType="BIT" property="deleted" />
|
||||
<result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
|
||||
<result column="crawl" jdbcType="TINYINT" property="crawl" />
|
||||
<result column="ai_replay" jdbcType="TINYINT" property="aiReplay" />
|
||||
<result column="big_brother" jdbcType="TINYINT" property="bigBrother" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
|
||||
@@ -10,7 +10,8 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
* @from <a href="https://yupi.icu">编程导航知识星球</a>
|
||||
*/
|
||||
@SpringBootTest
|
||||
class MainApplicationTests {
|
||||
class
|
||||
MainApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
|
||||
Reference in New Issue
Block a user