添加账号查询次数接口
This commit is contained in:
11
pom.xml
11
pom.xml
@@ -8,7 +8,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>2.7.2</version>
|
<version>2.6.11</version>
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>com.yupi</groupId>
|
<groupId>com.yupi</groupId>
|
||||||
@@ -51,11 +51,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
<version>2.7.18</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>org.springframework.session</groupId>
|
<!-- <groupId>org.springframework.session</groupId>-->
|
||||||
<artifactId>spring-session-data-redis</artifactId>
|
<!-- <artifactId>spring-session-data-redis</artifactId>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
<!-- https://doc.xiaominfo.com/docs/quick-start#openapi2 -->
|
<!-- https://doc.xiaominfo.com/docs/quick-start#openapi2 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.xiaoymin</groupId>
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||||||
* @from <a href="https://yupi.icu">编程导航知识星球</a>
|
* @from <a href="https://yupi.icu">编程导航知识星球</a>
|
||||||
*/
|
*/
|
||||||
// todo 如需开启 Redis,须移除 exclude 中的内容
|
// todo 如需开启 Redis,须移除 exclude 中的内容
|
||||||
@SpringBootApplication(exclude = {RedisAutoConfiguration.class})
|
@SpringBootApplication()
|
||||||
@MapperScan("com.yupi.springbootinit.mapper")
|
@MapperScan("com.yupi.springbootinit.mapper")
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
|
@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.BaseResponse;
|
||||||
import com.yupi.springbootinit.common.ResultUtils;
|
import com.yupi.springbootinit.common.ResultUtils;
|
||||||
import com.yupi.springbootinit.model.dto.host.HostInfoDTO;
|
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.entity.NewHosts;
|
||||||
import com.yupi.springbootinit.model.vo.country.CountryInfoVO;
|
import com.yupi.springbootinit.model.vo.country.CountryInfoVO;
|
||||||
import com.yupi.springbootinit.model.vo.hosts.NewHostsVO;
|
import com.yupi.springbootinit.model.vo.hosts.NewHostsVO;
|
||||||
@@ -37,11 +38,14 @@ public class HostInfoController {
|
|||||||
return ResultUtils.success(true);
|
return ResultUtils.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("host_info")
|
@GetMapping("country_info")
|
||||||
public BaseResponse<List<CountryInfoVO>> getCountryInfo(@Param("countryName") String countryName){
|
public BaseResponse<List<CountryInfoVO>> getCountryInfo(@RequestParam(name = "countryName") String countryName){
|
||||||
|
|
||||||
return ResultUtils.success(hostInfoService.getCountryInfo(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.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.yupi.springbootinit.model.dto.host.HostInfoDTO;
|
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.entity.NewHosts;
|
||||||
import com.yupi.springbootinit.model.vo.country.CountryInfoVO;
|
import com.yupi.springbootinit.model.vo.country.CountryInfoVO;
|
||||||
import com.yupi.springbootinit.model.vo.hosts.NewHostsVO;
|
import com.yupi.springbootinit.model.vo.hosts.NewHostsVO;
|
||||||
@@ -22,4 +23,6 @@ public interface HostInfoService extends IService<NewHosts> {
|
|||||||
|
|
||||||
|
|
||||||
List<CountryInfoVO> getCountryInfo(String countryName);
|
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.google.common.collect.Lists;
|
||||||
import com.yupi.springbootinit.mapper.CountryInfoMapper;
|
import com.yupi.springbootinit.mapper.CountryInfoMapper;
|
||||||
import com.yupi.springbootinit.mapper.NewHostsMapper;
|
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.entity.NewHosts;
|
||||||
import com.yupi.springbootinit.model.vo.country.CountryInfoVO;
|
import com.yupi.springbootinit.model.vo.country.CountryInfoVO;
|
||||||
import com.yupi.springbootinit.model.vo.hosts.NewHostsVO;
|
|
||||||
import com.yupi.springbootinit.service.HostInfoService;
|
import com.yupi.springbootinit.service.HostInfoService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
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.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -32,6 +34,19 @@ public class HostInfoServiceImpl extends ServiceImpl<NewHostsMapper, NewHosts> i
|
|||||||
@Resource
|
@Resource
|
||||||
private CountryInfoMapper countryInfoMapper;
|
private CountryInfoMapper countryInfoMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// private final RedisTemplate<String,Object> redisTemplate;
|
||||||
|
//
|
||||||
|
// public HostInfoServiceImpl(RedisTemplate<String, Object> redisTemplate) {
|
||||||
|
// this.redisTemplate = redisTemplate;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Async("taskExecutor")
|
@Async("taskExecutor")
|
||||||
public CompletableFuture<Void> saveHostInfo(List<NewHosts> newHosts) {
|
public CompletableFuture<Void> saveHostInfo(List<NewHosts> newHosts) {
|
||||||
@@ -86,8 +101,13 @@ public class HostInfoServiceImpl extends ServiceImpl<NewHostsMapper, NewHosts> i
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CountryInfoVO> getCountryInfo(String countryName) {
|
public List<CountryInfoVO> getCountryInfo(String countryName) {
|
||||||
countryInfoMapper.selectCountryGroupCountryByCountryName(countryName);
|
return countryInfoMapper.selectCountryGroupCountryByCountryName(countryName);
|
||||||
return List.of();
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void queryCount(QueryCountDTO queryCountDTO) {
|
||||||
|
|
||||||
|
redisTemplate.opsForValue().increment(queryCountDTO.getTkAccount(),1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,11 +14,10 @@ spring:
|
|||||||
# Redis 配置
|
# Redis 配置
|
||||||
# todo 需替换配置
|
# todo 需替换配置
|
||||||
redis:
|
redis:
|
||||||
database: 1
|
database: 0
|
||||||
host: localhost
|
host: localhost
|
||||||
port: 6379
|
port: 6379
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
password: 123456
|
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
host: localhost
|
host: localhost
|
||||||
port: 5672
|
port: 5672
|
||||||
|
|||||||
@@ -14,11 +14,10 @@ spring:
|
|||||||
# Redis 配置
|
# Redis 配置
|
||||||
# todo 需替换配置
|
# todo 需替换配置
|
||||||
redis:
|
redis:
|
||||||
database: 1
|
database: 0
|
||||||
host: localhost
|
host: localhost
|
||||||
port: 6379
|
port: 6379
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
password: 123456
|
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
host: localhost
|
host: localhost
|
||||||
port: 5672
|
port: 5672
|
||||||
|
|||||||
@@ -50,35 +50,8 @@ mybatis-plus:
|
|||||||
logic-delete-field: isDelete # 全局逻辑删除的实体字段名
|
logic-delete-field: isDelete # 全局逻辑删除的实体字段名
|
||||||
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
|
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
|
||||||
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
|
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:
|
knife4j:
|
||||||
enable: true
|
enable: true
|
||||||
|
|||||||
@@ -166,7 +166,7 @@
|
|||||||
</update>
|
</update>
|
||||||
|
|
||||||
<select id="selectCountryGroupCountryByCountryName" resultType="com.yupi.springbootinit.model.vo.country.CountryInfoVO">
|
<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
|
FROM country_info c1
|
||||||
JOIN country_info c2 ON c1.country_group = c2.country_group
|
JOIN country_info c2 ON c1.country_group = c2.country_group
|
||||||
WHERE c1.country_name = #{countryName,jdbcType=VARCHAR}
|
WHERE c1.country_name = #{countryName,jdbcType=VARCHAR}
|
||||||
|
|||||||
Reference in New Issue
Block a user