添加账号查询次数接口
This commit is contained in:
11
pom.xml
11
pom.xml
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.7.2</version>
|
||||
<version>2.6.11</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.yupi</groupId>
|
||||
@@ -51,11 +51,12 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
<version>2.7.18</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-data-redis</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.session</groupId>-->
|
||||
<!-- <artifactId>spring-session-data-redis</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- https://doc.xiaominfo.com/docs/quick-start#openapi2 -->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
* @from <a href="https://yupi.icu">编程导航知识星球</a>
|
||||
*/
|
||||
// todo 如需开启 Redis,须移除 exclude 中的内容
|
||||
@SpringBootApplication(exclude = {RedisAutoConfiguration.class})
|
||||
@SpringBootApplication()
|
||||
@MapperScan("com.yupi.springbootinit.mapper")
|
||||
@EnableScheduling
|
||||
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
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.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();
|
||||
template.setConnectionFactory(factory);
|
||||
//key序列化方式
|
||||
template.setKeySerializer(redisSerializer);
|
||||
//value序列化
|
||||
template.setValueSerializer(redisSerializer);
|
||||
//value hashmap序列化
|
||||
template.setHashValueSerializer(redisSerializer);
|
||||
//key haspmap序列化
|
||||
template.setHashKeySerializer(redisSerializer);
|
||||
//
|
||||
return template;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.yupi.springbootinit.controller;
|
||||
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.QueryCountDTO;
|
||||
import com.yupi.springbootinit.model.entity.NewHosts;
|
||||
import com.yupi.springbootinit.model.vo.country.CountryInfoVO;
|
||||
import com.yupi.springbootinit.model.vo.hosts.NewHostsVO;
|
||||
@@ -37,11 +38,14 @@ public class HostInfoController {
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
@GetMapping("host_info")
|
||||
public BaseResponse<List<CountryInfoVO>> getCountryInfo(@Param("countryName") String countryName){
|
||||
@GetMapping("country_info")
|
||||
public BaseResponse<List<CountryInfoVO>> getCountryInfo(@RequestParam(name = "countryName") String countryName){
|
||||
|
||||
return ResultUtils.success(hostInfoService.getCountryInfo(countryName));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("query_count")
|
||||
public void count_query(@RequestBody QueryCountDTO queryCountDTO){
|
||||
hostInfoService.queryCount(queryCountDTO);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yupi.springbootinit.model.dto.host;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/6/13 15:35
|
||||
*/
|
||||
@Data
|
||||
public class QueryCountDTO {
|
||||
public String tkAccount;
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.yupi.springbootinit.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yupi.springbootinit.model.dto.host.HostInfoDTO;
|
||||
import com.yupi.springbootinit.model.dto.host.QueryCountDTO;
|
||||
import com.yupi.springbootinit.model.entity.NewHosts;
|
||||
import com.yupi.springbootinit.model.vo.country.CountryInfoVO;
|
||||
import com.yupi.springbootinit.model.vo.hosts.NewHostsVO;
|
||||
@@ -22,4 +23,6 @@ public interface HostInfoService extends IService<NewHosts> {
|
||||
|
||||
|
||||
List<CountryInfoVO> getCountryInfo(String countryName);
|
||||
|
||||
void queryCount(QueryCountDTO queryCountDTO);
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.yupi.springbootinit.mapper.CountryInfoMapper;
|
||||
import com.yupi.springbootinit.mapper.NewHostsMapper;
|
||||
import com.yupi.springbootinit.model.dto.host.HostInfoDTO;
|
||||
import com.yupi.springbootinit.model.dto.host.QueryCountDTO;
|
||||
import com.yupi.springbootinit.model.entity.NewHosts;
|
||||
import com.yupi.springbootinit.model.vo.country.CountryInfoVO;
|
||||
import com.yupi.springbootinit.model.vo.hosts.NewHostsVO;
|
||||
import com.yupi.springbootinit.service.HostInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -32,6 +34,19 @@ public class HostInfoServiceImpl extends ServiceImpl<NewHostsMapper, NewHosts> i
|
||||
@Resource
|
||||
private CountryInfoMapper countryInfoMapper;
|
||||
|
||||
|
||||
@Resource
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
|
||||
//
|
||||
// private final RedisTemplate<String,Object> redisTemplate;
|
||||
//
|
||||
// public HostInfoServiceImpl(RedisTemplate<String, Object> redisTemplate) {
|
||||
// this.redisTemplate = redisTemplate;
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
@Async("taskExecutor")
|
||||
public CompletableFuture<Void> saveHostInfo(List<NewHosts> newHosts) {
|
||||
@@ -86,8 +101,13 @@ public class HostInfoServiceImpl extends ServiceImpl<NewHostsMapper, NewHosts> i
|
||||
|
||||
@Override
|
||||
public List<CountryInfoVO> getCountryInfo(String countryName) {
|
||||
countryInfoMapper.selectCountryGroupCountryByCountryName(countryName);
|
||||
return List.of();
|
||||
return countryInfoMapper.selectCountryGroupCountryByCountryName(countryName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queryCount(QueryCountDTO queryCountDTO) {
|
||||
|
||||
redisTemplate.opsForValue().increment(queryCountDTO.getTkAccount(),1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -14,11 +14,10 @@ spring:
|
||||
# Redis 配置
|
||||
# todo 需替换配置
|
||||
redis:
|
||||
database: 1
|
||||
database: 0
|
||||
host: localhost
|
||||
port: 6379
|
||||
timeout: 5000
|
||||
password: 123456
|
||||
rabbitmq:
|
||||
host: localhost
|
||||
port: 5672
|
||||
|
||||
@@ -14,11 +14,10 @@ spring:
|
||||
# Redis 配置
|
||||
# todo 需替换配置
|
||||
redis:
|
||||
database: 1
|
||||
database: 0
|
||||
host: localhost
|
||||
port: 6379
|
||||
timeout: 5000
|
||||
password: 123456
|
||||
rabbitmq:
|
||||
host: localhost
|
||||
port: 5672
|
||||
|
||||
@@ -50,35 +50,8 @@ mybatis-plus:
|
||||
logic-delete-field: isDelete # 全局逻辑删除的实体字段名
|
||||
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
|
||||
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
|
||||
# 微信相关
|
||||
wx:
|
||||
# 微信公众平台
|
||||
# todo 需替换配置
|
||||
mp:
|
||||
token: xxx
|
||||
aesKey: xxx
|
||||
appId: xxx
|
||||
secret: xxx
|
||||
config-storage:
|
||||
http-client-type: HttpClient
|
||||
key-prefix: wx
|
||||
redis:
|
||||
host: 127.0.0.1
|
||||
port: 6379
|
||||
type: Memory
|
||||
# 微信开放平台
|
||||
# todo 需替换配置
|
||||
open:
|
||||
appId: xxx
|
||||
appSecret: xxx
|
||||
# 对象存储
|
||||
# todo 需替换配置
|
||||
cos:
|
||||
client:
|
||||
accessKey: xxx
|
||||
secretKey: xxx
|
||||
region: xxx
|
||||
bucket: xxx
|
||||
|
||||
|
||||
# 接口文档配置
|
||||
knife4j:
|
||||
enable: true
|
||||
|
||||
@@ -166,7 +166,7 @@
|
||||
</update>
|
||||
|
||||
<select id="selectCountryGroupCountryByCountryName" resultType="com.yupi.springbootinit.model.vo.country.CountryInfoVO">
|
||||
SELECT c2.country_name
|
||||
SELECT c2.country_name as countryName
|
||||
FROM country_info c1
|
||||
JOIN country_info c2 ON c1.country_group = c2.country_group
|
||||
WHERE c1.country_name = #{countryName,jdbcType=VARCHAR}
|
||||
|
||||
Reference in New Issue
Block a user