修改:
1.直接返回查询TK账号统计次数 2.修复查询主播国家 sqlXML BUG 3.添加主播HostInfo日期格式化注解
This commit is contained in:
@@ -1,14 +1,20 @@
|
||||
package com.yupi.springbootinit.config;
|
||||
|
||||
import cn.dev33.satoken.fun.strategy.SaCorsHandleFunction;
|
||||
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;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
|
||||
|
||||
@@ -17,7 +23,7 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
// 注册Sa-Token的拦截器
|
||||
registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin()))
|
||||
.addPathPatterns("/api/**")
|
||||
.addPathPatterns("/**")
|
||||
.excludePathPatterns(getExcludePaths());
|
||||
}
|
||||
|
||||
@@ -41,4 +47,24 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
"/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")
|
||||
public BaseResponse<AccountCrawlCount> getAccountCount(@RequestParam String accountName){
|
||||
public BaseResponse<Integer> getAccountCount(@RequestParam String 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")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date createTimeMax;
|
||||
|
||||
/**
|
||||
* 数据插入最小
|
||||
*/
|
||||
@ApiModelProperty(value = "创建时间查询下限(yyyy-MM-dd)", example = "2023-01-01")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date createTimeMin;
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,5 +7,5 @@ import com.yupi.springbootinit.model.vo.common.AccountCrawlCount;
|
||||
* @date: 2025/6/16 14:07
|
||||
*/
|
||||
public interface CommonService {
|
||||
AccountCrawlCount getAccountCrawlCount(String accountName);
|
||||
Integer getAccountCrawlCount(String accountName);
|
||||
}
|
||||
|
||||
@@ -21,15 +21,16 @@ public class CommonServiceImpl implements CommonService {
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@Override
|
||||
public AccountCrawlCount getAccountCrawlCount(String accountName) {
|
||||
public Integer getAccountCrawlCount(String accountName) {
|
||||
AccountCrawlCount accountCrawlCount = new AccountCrawlCount();
|
||||
accountCrawlCount.setAccountName(accountName);
|
||||
Object o = redisTemplate.opsForValue().get("tkaccount:" + accountName);
|
||||
if (o != null) {
|
||||
accountCrawlCount.setCount(Integer.valueOf(o.toString()));
|
||||
return accountCrawlCount;
|
||||
return accountCrawlCount.getCount();
|
||||
}else{
|
||||
throw new BusinessException(ErrorCode.NOT_FOUND_ERROR);
|
||||
accountCrawlCount.setCount(0);
|
||||
return accountCrawlCount.getCount();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -245,9 +245,8 @@
|
||||
|
||||
<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 join server_country_info ci where
|
||||
ns.creator=#{hostInfoDTO.creator}
|
||||
and ns.tenant_id=#{hostInfoDTO.tenantId}
|
||||
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
|
||||
where ns.tenant_id=#{hostInfoDTO.tenantId}
|
||||
<!-- 主播国家筛选 -->
|
||||
<if test="hostInfoDTO.country!= '' and hostInfoDTO.country != null">
|
||||
and ci.country_group_name =#{hostInfoDTO.country,jdbcType=VARCHAR}
|
||||
@@ -318,11 +317,14 @@
|
||||
order by
|
||||
<choose>
|
||||
<!-- 传空和默认的情况下按照时间降序排序 -->
|
||||
<when test="hostInfoDTO.sortName == '' and hostInfoDTO.sortName == null ">
|
||||
<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}
|
||||
|
||||
Reference in New Issue
Block a user