From e5bbc226451d5c0b4ccd7ddc8f0c45f1cbd6ce27 Mon Sep 17 00:00:00 2001 From: Ziin Date: Fri, 13 Jun 2025 15:30:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=9B=BD=E5=AE=B6=E4=B8=8B?= =?UTF-8?q?=E5=B1=9E=E7=9A=84=E6=89=80=E6=9C=89=E5=9B=BD=E5=AE=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HostInfoController.java | 12 ++ .../mapper/CountryInfoMapper.java | 28 +++ .../model/entity/CountryInfo.java | 156 ++++++++++++++++ .../model/vo/country/CountryInfoVO.java | 12 ++ .../service/HostInfoService.java | 8 +- .../service/impl/HostInfoServiceImpl.java | 11 +- .../resources/mapper/CountryInfoMapper.xml | 174 ++++++++++++++++++ 7 files changed, 396 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/yupi/springbootinit/mapper/CountryInfoMapper.java create mode 100644 src/main/java/com/yupi/springbootinit/model/entity/CountryInfo.java create mode 100644 src/main/java/com/yupi/springbootinit/model/vo/country/CountryInfoVO.java create mode 100644 src/main/resources/mapper/CountryInfoMapper.xml diff --git a/src/main/java/com/yupi/springbootinit/controller/HostInfoController.java b/src/main/java/com/yupi/springbootinit/controller/HostInfoController.java index 077b541..9d7d532 100644 --- a/src/main/java/com/yupi/springbootinit/controller/HostInfoController.java +++ b/src/main/java/com/yupi/springbootinit/controller/HostInfoController.java @@ -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 addHost(@RequestBody List newHosts){ mqSender.send(newHosts); return ResultUtils.success(true); } + @GetMapping("host_info") + public BaseResponse> getCountryInfo(@Param("countryName") String countryName){ + + return ResultUtils.success(hostInfoService.getCountryInfo(countryName)); + } + + } diff --git a/src/main/java/com/yupi/springbootinit/mapper/CountryInfoMapper.java b/src/main/java/com/yupi/springbootinit/mapper/CountryInfoMapper.java new file mode 100644 index 0000000..774212b --- /dev/null +++ b/src/main/java/com/yupi/springbootinit/mapper/CountryInfoMapper.java @@ -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 selectCountryGroupCountryByCountryName(String countryName); +} \ No newline at end of file diff --git a/src/main/java/com/yupi/springbootinit/model/entity/CountryInfo.java b/src/main/java/com/yupi/springbootinit/model/entity/CountryInfo.java new file mode 100644 index 0000000..410ddf3 --- /dev/null +++ b/src/main/java/com/yupi/springbootinit/model/entity/CountryInfo.java @@ -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; + } +} \ No newline at end of file diff --git a/src/main/java/com/yupi/springbootinit/model/vo/country/CountryInfoVO.java b/src/main/java/com/yupi/springbootinit/model/vo/country/CountryInfoVO.java new file mode 100644 index 0000000..d6b1044 --- /dev/null +++ b/src/main/java/com/yupi/springbootinit/model/vo/country/CountryInfoVO.java @@ -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; +} diff --git a/src/main/java/com/yupi/springbootinit/service/HostInfoService.java b/src/main/java/com/yupi/springbootinit/service/HostInfoService.java index 70a82b8..e75afb6 100644 --- a/src/main/java/com/yupi/springbootinit/service/HostInfoService.java +++ b/src/main/java/com/yupi/springbootinit/service/HostInfoService.java @@ -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 { - public CompletableFuture saveHostInfo(List newHosts); + CompletableFuture saveHostInfo(List newHosts); - public CompletableFuture processHosts(List hosts); + CompletableFuture processHosts(List hosts); - List getConditionHosts(HostInfoDTO hostInfoDTO); + + List getCountryInfo(String countryName); } diff --git a/src/main/java/com/yupi/springbootinit/service/impl/HostInfoServiceImpl.java b/src/main/java/com/yupi/springbootinit/service/impl/HostInfoServiceImpl.java index 9bdc944..45862a8 100644 --- a/src/main/java/com/yupi/springbootinit/service/impl/HostInfoServiceImpl.java +++ b/src/main/java/com/yupi/springbootinit/service/impl/HostInfoServiceImpl.java @@ -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 implements HostInfoService { + @Resource + private CountryInfoMapper countryInfoMapper; @Override @Async("taskExecutor") @@ -80,8 +85,10 @@ public class HostInfoServiceImpl extends ServiceImpl i } @Override - public List getConditionHosts(HostInfoDTO hostInfoDTO) { - + public List getCountryInfo(String countryName) { + countryInfoMapper.selectCountryGroupCountryByCountryName(countryName); return List.of(); } + + } diff --git a/src/main/resources/mapper/CountryInfoMapper.xml b/src/main/resources/mapper/CountryInfoMapper.xml new file mode 100644 index 0000000..9781db5 --- /dev/null +++ b/src/main/resources/mapper/CountryInfoMapper.xml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + id, country_id, country_group, country_group_name, country_name, `language`, language_name, + create_time, creator, update_time, updater + + + + + delete from country_info + where id = #{id,jdbcType=INTEGER} + and country_id = #{countryId,jdbcType=VARCHAR} + + + + 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 into country_info + + + country_id, + + + country_group, + + + country_group_name, + + + country_name, + + + `language`, + + + language_name, + + + create_time, + + + creator, + + + update_time, + + + updater, + + + + + #{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}, + + + + + + update country_info + + + 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 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} + + + + \ No newline at end of file