修改:
1.直接返回查询TK账号统计次数 2.修复查询主播国家 sqlXML BUG 3.添加主播HostInfo日期格式化注解
This commit is contained in:
@@ -1,14 +1,20 @@
|
|||||||
package com.yupi.springbootinit.config;
|
package com.yupi.springbootinit.config;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.fun.strategy.SaCorsHandleFunction;
|
||||||
import cn.dev33.satoken.interceptor.SaInterceptor;
|
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 cn.dev33.satoken.stp.StpUtil;
|
||||||
import com.yupi.springbootinit.common.ErrorCode;
|
import com.yupi.springbootinit.common.ErrorCode;
|
||||||
import com.yupi.springbootinit.exception.BusinessException;
|
import com.yupi.springbootinit.exception.BusinessException;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@Slf4j
|
||||||
public class SaTokenConfigure implements WebMvcConfigurer {
|
public class SaTokenConfigure implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
|
||||||
@@ -17,7 +23,7 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
|||||||
public void addInterceptors(InterceptorRegistry registry) {
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
// 注册Sa-Token的拦截器
|
// 注册Sa-Token的拦截器
|
||||||
registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin()))
|
registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin()))
|
||||||
.addPathPatterns("/api/**")
|
.addPathPatterns("/**")
|
||||||
.excludePathPatterns(getExcludePaths());
|
.excludePathPatterns(getExcludePaths());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,4 +47,24 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
|||||||
"/tenant/get-id-by-name"
|
"/tenant/get-id-by-name"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public SaCorsHandleFunction corsHandle() {
|
||||||
|
return (req, res, sto) -> {
|
||||||
|
res.
|
||||||
|
// 允许指定域访问跨域资源
|
||||||
|
setHeader("Access-Control-Allow-Origin", "*")
|
||||||
|
// 允许所有请求方式
|
||||||
|
.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE")
|
||||||
|
// 有效时间
|
||||||
|
.setHeader("Access-Control-Max-Age", "3600")
|
||||||
|
// 允许的header参数
|
||||||
|
.setHeader("Access-Control-Allow-Headers", "*");
|
||||||
|
|
||||||
|
// 如果是预检请求,则立即返回到前端
|
||||||
|
SaRouter.match(SaHttpMethod.OPTIONS)
|
||||||
|
.back();
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ public class CommonController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("accountCount")
|
@GetMapping("accountCount")
|
||||||
public BaseResponse<AccountCrawlCount> getAccountCount(@RequestParam String accountName){
|
public BaseResponse<Integer> getAccountCount(@RequestParam String accountName){
|
||||||
return ResultUtils.success(commonService.getAccountCrawlCount(accountName));
|
return ResultUtils.success(commonService.getAccountCrawlCount(accountName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -157,12 +157,14 @@ public class HostInfoDTO extends PageRequest implements Serializable {
|
|||||||
* 数据插入最大
|
* 数据插入最大
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "创建时间查询上限(yyyy-MM-dd)", example = "2023-12-31")
|
@ApiModelProperty(value = "创建时间查询上限(yyyy-MM-dd)", example = "2023-12-31")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
private Date createTimeMax;
|
private Date createTimeMax;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据插入最小
|
* 数据插入最小
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "创建时间查询下限(yyyy-MM-dd)", example = "2023-01-01")
|
@ApiModelProperty(value = "创建时间查询下限(yyyy-MM-dd)", example = "2023-01-01")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
private Date createTimeMin;
|
private Date createTimeMin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,5 +7,5 @@ import com.yupi.springbootinit.model.vo.common.AccountCrawlCount;
|
|||||||
* @date: 2025/6/16 14:07
|
* @date: 2025/6/16 14:07
|
||||||
*/
|
*/
|
||||||
public interface CommonService {
|
public interface CommonService {
|
||||||
AccountCrawlCount getAccountCrawlCount(String accountName);
|
Integer getAccountCrawlCount(String accountName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,15 +21,16 @@ public class CommonServiceImpl implements CommonService {
|
|||||||
private RedisTemplate redisTemplate;
|
private RedisTemplate redisTemplate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AccountCrawlCount getAccountCrawlCount(String accountName) {
|
public Integer getAccountCrawlCount(String accountName) {
|
||||||
AccountCrawlCount accountCrawlCount = new AccountCrawlCount();
|
AccountCrawlCount accountCrawlCount = new AccountCrawlCount();
|
||||||
accountCrawlCount.setAccountName(accountName);
|
accountCrawlCount.setAccountName(accountName);
|
||||||
Object o = redisTemplate.opsForValue().get("tkaccount:" + accountName);
|
Object o = redisTemplate.opsForValue().get("tkaccount:" + accountName);
|
||||||
if (o != null) {
|
if (o != null) {
|
||||||
accountCrawlCount.setCount(Integer.valueOf(o.toString()));
|
accountCrawlCount.setCount(Integer.valueOf(o.toString()));
|
||||||
return accountCrawlCount;
|
return accountCrawlCount.getCount();
|
||||||
}else{
|
}else{
|
||||||
throw new BusinessException(ErrorCode.NOT_FOUND_ERROR);
|
accountCrawlCount.setCount(0);
|
||||||
|
return accountCrawlCount.getCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,9 +245,8 @@
|
|||||||
|
|
||||||
<select id="selectPageByCondition" resultMap="HostInfoVo">
|
<select id="selectPageByCondition" resultMap="HostInfoVo">
|
||||||
select ns.id,hosts_id, hosts_level, hosts_coins, Invitation_type, fans, fllowernum,
|
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 join server_country_info ci where
|
yesterday_coins,ns.create_time, country, online_fans,hosts_kind from server_new_hosts ns join server_country_info ci ON ns.country = ci.country_name
|
||||||
ns.creator=#{hostInfoDTO.creator}
|
where ns.tenant_id=#{hostInfoDTO.tenantId}
|
||||||
and ns.tenant_id=#{hostInfoDTO.tenantId}
|
|
||||||
<!-- 主播国家筛选 -->
|
<!-- 主播国家筛选 -->
|
||||||
<if test="hostInfoDTO.country!= '' and hostInfoDTO.country != null">
|
<if test="hostInfoDTO.country!= '' and hostInfoDTO.country != null">
|
||||||
and ci.country_group_name =#{hostInfoDTO.country,jdbcType=VARCHAR}
|
and ci.country_group_name =#{hostInfoDTO.country,jdbcType=VARCHAR}
|
||||||
@@ -318,11 +317,14 @@
|
|||||||
order by
|
order by
|
||||||
<choose>
|
<choose>
|
||||||
<!-- 传空和默认的情况下按照时间降序排序 -->
|
<!-- 传空和默认的情况下按照时间降序排序 -->
|
||||||
<when test="hostInfoDTO.sortName == '' and hostInfoDTO.sortName == null ">
|
<when test="hostInfoDTO.sortName == '' and hostInfoDTO.sortName == null">
|
||||||
ns.create_time desc
|
ns.create_time desc
|
||||||
</when>
|
</when>
|
||||||
<!-- sortNmae 有值的情况下排序 -->
|
<!-- sortNmae 有值的情况下排序 -->
|
||||||
<when test="hostInfoDTO.sortName != null and 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>
|
||||||
<!-- 昨日主播金币条件排序 -->
|
<!-- 昨日主播金币条件排序 -->
|
||||||
<if test="hostInfoDTO.sortName == 'yesterdayCoins' and hostInfoDTO.sort != null">
|
<if test="hostInfoDTO.sortName == 'yesterdayCoins' and hostInfoDTO.sort != null">
|
||||||
ns.yesterday_coins ${hostInfoDTO.sort}
|
ns.yesterday_coins ${hostInfoDTO.sort}
|
||||||
|
|||||||
Reference in New Issue
Block a user