获取国家下属的所有国家
This commit is contained in:
@@ -4,10 +4,12 @@ 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.entity.NewHosts;
|
||||
import com.yupi.springbootinit.model.vo.country.CountryInfoVO;
|
||||
import com.yupi.springbootinit.model.vo.hosts.NewHostsVO;
|
||||
import com.yupi.springbootinit.rabbitMQ.MQSender;
|
||||
import com.yupi.springbootinit.service.HostInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -26,10 +28,20 @@ public class HostInfoController {
|
||||
@Resource
|
||||
private MQSender mqSender;
|
||||
|
||||
@Resource
|
||||
private HostInfoService hostInfoService;
|
||||
|
||||
@PostMapping("add_host")
|
||||
public BaseResponse<Boolean> addHost(@RequestBody List<NewHosts> newHosts){
|
||||
mqSender.send(newHosts);
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
@GetMapping("host_info")
|
||||
public BaseResponse<List<CountryInfoVO>> getCountryInfo(@Param("countryName") String countryName){
|
||||
|
||||
return ResultUtils.success(hostInfoService.getCountryInfo(countryName));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.yupi.springbootinit.mapper;
|
||||
|
||||
import com.yupi.springbootinit.model.entity.CountryInfo;
|
||||
import com.yupi.springbootinit.model.vo.country.CountryInfoVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/6/13 15:26
|
||||
*/
|
||||
|
||||
public interface CountryInfoMapper {
|
||||
int deleteByPrimaryKey(@Param("id") Integer id, @Param("countryId") String countryId);
|
||||
|
||||
int insert(CountryInfo record);
|
||||
|
||||
int insertSelective(CountryInfo record);
|
||||
|
||||
CountryInfo selectByPrimaryKey(@Param("id") Integer id, @Param("countryId") String countryId);
|
||||
|
||||
int updateByPrimaryKeySelective(CountryInfo record);
|
||||
|
||||
int updateByPrimaryKey(CountryInfo record);
|
||||
|
||||
List<CountryInfoVO> selectCountryGroupCountryByCountryName(String countryName);
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package com.yupi.springbootinit.model.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/6/13 15:26
|
||||
*/
|
||||
|
||||
/**
|
||||
* 国家与地区信息统计
|
||||
*/
|
||||
public class CountryInfo {
|
||||
/**
|
||||
* 主键id,无业务含义
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 国家id
|
||||
*/
|
||||
private String countryId;
|
||||
|
||||
/**
|
||||
* 业务区与地区码
|
||||
*/
|
||||
private String countryGroup;
|
||||
|
||||
/**
|
||||
* 业务区与地区名称
|
||||
*/
|
||||
private String countryGroupName;
|
||||
|
||||
/**
|
||||
* 国家名称
|
||||
*/
|
||||
private String countryName;
|
||||
|
||||
/**
|
||||
* 语言
|
||||
*/
|
||||
private String language;
|
||||
|
||||
/**
|
||||
* 语言中文
|
||||
*/
|
||||
private String languageName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private String creator;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新人id
|
||||
*/
|
||||
private String updater;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCountryId() {
|
||||
return countryId;
|
||||
}
|
||||
|
||||
public void setCountryId(String countryId) {
|
||||
this.countryId = countryId;
|
||||
}
|
||||
|
||||
public String getCountryGroup() {
|
||||
return countryGroup;
|
||||
}
|
||||
|
||||
public void setCountryGroup(String countryGroup) {
|
||||
this.countryGroup = countryGroup;
|
||||
}
|
||||
|
||||
public String getCountryGroupName() {
|
||||
return countryGroupName;
|
||||
}
|
||||
|
||||
public void setCountryGroupName(String countryGroupName) {
|
||||
this.countryGroupName = countryGroupName;
|
||||
}
|
||||
|
||||
public String getCountryName() {
|
||||
return countryName;
|
||||
}
|
||||
|
||||
public void setCountryName(String countryName) {
|
||||
this.countryName = countryName;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
public String getLanguageName() {
|
||||
return languageName;
|
||||
}
|
||||
|
||||
public void setLanguageName(String languageName) {
|
||||
this.languageName = languageName;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
public void setCreator(String creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public String getUpdater() {
|
||||
return updater;
|
||||
}
|
||||
|
||||
public void setUpdater(String updater) {
|
||||
this.updater = updater;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yupi.springbootinit.model.vo.country;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/6/13 15:23
|
||||
*/
|
||||
@Data
|
||||
public class CountryInfoVO {
|
||||
private String countryName;
|
||||
}
|
||||
@@ -4,6 +4,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.entity.NewHosts;
|
||||
import com.yupi.springbootinit.model.vo.country.CountryInfoVO;
|
||||
import com.yupi.springbootinit.model.vo.hosts.NewHostsVO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -15,9 +16,10 @@ import java.util.concurrent.CompletableFuture;
|
||||
*/
|
||||
public interface HostInfoService extends IService<NewHosts> {
|
||||
|
||||
public CompletableFuture<Void> saveHostInfo(List<NewHosts> newHosts);
|
||||
CompletableFuture<Void> saveHostInfo(List<NewHosts> newHosts);
|
||||
|
||||
public CompletableFuture<Void> processHosts(List<NewHosts> hosts);
|
||||
CompletableFuture<Void> processHosts(List<NewHosts> hosts);
|
||||
|
||||
List<NewHostsVO> getConditionHosts(HostInfoDTO hostInfoDTO);
|
||||
|
||||
List<CountryInfoVO> getCountryInfo(String countryName);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@ package com.yupi.springbootinit.service.impl;
|
||||
|
||||
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.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;
|
||||
@@ -13,6 +15,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -26,6 +29,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class HostInfoServiceImpl extends ServiceImpl<NewHostsMapper, NewHosts> implements HostInfoService {
|
||||
|
||||
@Resource
|
||||
private CountryInfoMapper countryInfoMapper;
|
||||
|
||||
@Override
|
||||
@Async("taskExecutor")
|
||||
@@ -80,8 +85,10 @@ public class HostInfoServiceImpl extends ServiceImpl<NewHostsMapper, NewHosts> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NewHostsVO> getConditionHosts(HostInfoDTO hostInfoDTO) {
|
||||
|
||||
public List<CountryInfoVO> getCountryInfo(String countryName) {
|
||||
countryInfoMapper.selectCountryGroupCountryByCountryName(countryName);
|
||||
return List.of();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
174
src/main/resources/mapper/CountryInfoMapper.xml
Normal file
174
src/main/resources/mapper/CountryInfoMapper.xml
Normal file
@@ -0,0 +1,174 @@
|
||||
<?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.CountryInfoMapper">
|
||||
<resultMap id="BaseResultMap" type="com.yupi.springbootinit.model.entity.CountryInfo">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table country_info-->
|
||||
<id column="id" jdbcType="INTEGER" property="id" />
|
||||
<id column="country_id" jdbcType="VARCHAR" property="countryId" />
|
||||
<result column="country_group" jdbcType="VARCHAR" property="countryGroup" />
|
||||
<result column="country_group_name" jdbcType="VARCHAR" property="countryGroupName" />
|
||||
<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="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="creator" jdbcType="VARCHAR" property="creator" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
<result column="updater" jdbcType="VARCHAR" property="updater" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
id, country_id, country_group, country_group_name, country_name, `language`, language_name,
|
||||
create_time, creator, update_time, updater
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="map" resultMap="BaseResultMap">
|
||||
<!--@mbg.generated-->
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from country_info
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
and country_id = #{countryId,jdbcType=VARCHAR}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="map">
|
||||
<!--@mbg.generated-->
|
||||
delete from country_info
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
and country_id = #{countryId,jdbcType=VARCHAR}
|
||||
</delete>
|
||||
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yupi.springbootinit.model.entity.CountryInfo" useGeneratedKeys="true">
|
||||
<!--@mbg.generated-->
|
||||
insert into country_info (country_id, country_group, country_group_name,
|
||||
country_name, `language`, language_name,
|
||||
create_time, creator, update_time,
|
||||
updater)
|
||||
values (#{countryId,jdbcType=VARCHAR}, #{countryGroup,jdbcType=VARCHAR}, #{countryGroupName,jdbcType=VARCHAR},
|
||||
#{countryName,jdbcType=VARCHAR}, #{language,jdbcType=VARCHAR}, #{languageName,jdbcType=VARCHAR},
|
||||
#{createTime,jdbcType=TIMESTAMP}, #{creator,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
|
||||
#{updater,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yupi.springbootinit.model.entity.CountryInfo" useGeneratedKeys="true">
|
||||
<!--@mbg.generated-->
|
||||
insert into country_info
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="countryId != null">
|
||||
country_id,
|
||||
</if>
|
||||
<if test="countryGroup != null">
|
||||
country_group,
|
||||
</if>
|
||||
<if test="countryGroupName != null">
|
||||
country_group_name,
|
||||
</if>
|
||||
<if test="countryName != null">
|
||||
country_name,
|
||||
</if>
|
||||
<if test="language != null">
|
||||
`language`,
|
||||
</if>
|
||||
<if test="languageName != null">
|
||||
language_name,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
creator,
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="updater != null">
|
||||
updater,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="countryId != null">
|
||||
#{countryId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="countryGroup != null">
|
||||
#{countryGroup,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="countryGroupName != null">
|
||||
#{countryGroupName,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="countryName != null">
|
||||
#{countryName,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="language != null">
|
||||
#{language,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="languageName != null">
|
||||
#{languageName,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
#{creator,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="updater != null">
|
||||
#{updater,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.yupi.springbootinit.model.entity.CountryInfo">
|
||||
<!--@mbg.generated-->
|
||||
update country_info
|
||||
<set>
|
||||
<if test="countryGroup != null">
|
||||
country_group = #{countryGroup,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="countryGroupName != null">
|
||||
country_group_name = #{countryGroupName,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="countryName != null">
|
||||
country_name = #{countryName,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="language != null">
|
||||
`language` = #{language,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="languageName != null">
|
||||
language_name = #{languageName,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
creator = #{creator,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="updater != null">
|
||||
updater = #{updater,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
and country_id = #{countryId,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.yupi.springbootinit.model.entity.CountryInfo">
|
||||
<!--@mbg.generated-->
|
||||
update country_info
|
||||
set country_group = #{countryGroup,jdbcType=VARCHAR},
|
||||
country_group_name = #{countryGroupName,jdbcType=VARCHAR},
|
||||
country_name = #{countryName,jdbcType=VARCHAR},
|
||||
`language` = #{language,jdbcType=VARCHAR},
|
||||
language_name = #{languageName,jdbcType=VARCHAR},
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
creator = #{creator,jdbcType=VARCHAR},
|
||||
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
||||
updater = #{updater,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
and country_id = #{countryId,jdbcType=VARCHAR}
|
||||
</update>
|
||||
|
||||
<select id="selectCountryGroupCountryByCountryName" resultType="com.yupi.springbootinit.model.vo.country.CountryInfoVO">
|
||||
SELECT c2.country_name
|
||||
FROM country_info c1
|
||||
JOIN country_info c2 ON c1.country_group = c2.country_group
|
||||
WHERE c1.country_name = #{countryName,jdbcType=VARCHAR}
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user