From d841701650c9d3824c73f4829e347e812001a3e8 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Wed, 8 Mar 2023 10:05:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xkrs/common/config/WebSecurityConfig.java | 1 + src/main/java/com/xkrs/dao/SomeThingDao.java | 14 +++++ .../xkrs/model/entity/SomeThingEntity.java | 50 +++++++++++++++++ .../xkrs/service/impl/StreetServiceImpl.java | 54 +++++++++++++++++-- 4 files changed, 115 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/xkrs/dao/SomeThingDao.java create mode 100644 src/main/java/com/xkrs/model/entity/SomeThingEntity.java diff --git a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java index 38903a7..1ba07b0 100644 --- a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java +++ b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java @@ -72,6 +72,7 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter { .antMatchers(HttpMethod.GET, "/getCityList").permitAll()//根据省编号获取市列表 .antMatchers(HttpMethod.GET, "/getCountyList").permitAll()//根据市编号获取区县列表 .antMatchers(HttpMethod.GET, "/getStreetList").permitAll()//根据区县编号获取街道列表 + .antMatchers(HttpMethod.GET, "/getAllRegionList").permitAll()//获取全部的区划信息 .antMatchers(HttpMethod.GET, "/api/adm/getProvinceList").permitAll()//获取省列表 .antMatchers(HttpMethod.GET, "/api/adm/getCityList").permitAll()//根据省编号获取市列表 .antMatchers(HttpMethod.GET, "/api/adm/getCountyList").permitAll()//根据市编号获取区县列表 diff --git a/src/main/java/com/xkrs/dao/SomeThingDao.java b/src/main/java/com/xkrs/dao/SomeThingDao.java new file mode 100644 index 0000000..4d43f49 --- /dev/null +++ b/src/main/java/com/xkrs/dao/SomeThingDao.java @@ -0,0 +1,14 @@ +package com.xkrs.dao; + +import com.xkrs.model.entity.SomeThingEntity; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Component; + +/** + * @author xkrs + */ +@Component +public interface SomeThingDao extends JpaRepository, JpaSpecificationExecutor { + +} diff --git a/src/main/java/com/xkrs/model/entity/SomeThingEntity.java b/src/main/java/com/xkrs/model/entity/SomeThingEntity.java new file mode 100644 index 0000000..1549fac --- /dev/null +++ b/src/main/java/com/xkrs/model/entity/SomeThingEntity.java @@ -0,0 +1,50 @@ +package com.xkrs.model.entity; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * @author xkrs + */ +@Entity +@Table(name = "some_thing") +public class SomeThingEntity implements Serializable { + + /** + * 主键id + */ + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "some_thing_seq_gen") + @SequenceGenerator(name = "some_thing_seq_gen", sequenceName = "some_thing_id_seq", allocationSize = 1) + private Long id; + + @Column(length = 4096000, columnDefinition = "varchar(4096000)") + private String content; + + public SomeThingEntity() { + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + @Override + public String toString() { + return "SomeThingEntity{" + + "id=" + id + + ", content='" + content + '\'' + + '}'; + } +} diff --git a/src/main/java/com/xkrs/service/impl/StreetServiceImpl.java b/src/main/java/com/xkrs/service/impl/StreetServiceImpl.java index 801e05a..36c4e63 100644 --- a/src/main/java/com/xkrs/service/impl/StreetServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/StreetServiceImpl.java @@ -1,15 +1,19 @@ package com.xkrs.service.impl; +import com.xkrs.common.encapsulation.PromptMessageEnum; +import com.xkrs.dao.SomeThingDao; import com.xkrs.dao.StreetDao; +import com.xkrs.model.bean.RegionBean; +import com.xkrs.model.entity.SomeThingEntity; import com.xkrs.model.entity.StreetEntity; import com.xkrs.service.StreetService; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.List; -import java.util.Locale; -import java.util.Map; +import java.util.*; + +import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; @Service public class StreetServiceImpl implements StreetService { @@ -19,6 +23,10 @@ public class StreetServiceImpl implements StreetService { @Resource private StreetDao streetDao; + @Resource + private SomeThingDao someThingDao; + + @Override public List findByProName(String proName) { return streetDao.findByProName(proName); @@ -82,7 +90,45 @@ public class StreetServiceImpl implements StreetService { @Override public String getAllRegionList() { + Optional targetOptional = someThingDao.findById(1L); + return targetOptional.get().getContent(); - return null; +// List> provinceList = selectProvinceList(); +// List provinceBeanList = new ArrayList<>(); +// for (Map province : provinceList) { +// RegionBean provinceBean = new RegionBean(); +// provinceBean.setCode(province.get("code")); +// provinceBean.setName(province.get("name")); +// List> cityList = selectCityList(province.get("code")); +// List cityBeanList = new ArrayList<>(); +// for (Map city : cityList) { +// RegionBean cityBean = new RegionBean(); +// cityBean.setCode(city.get("code")); +// cityBean.setName(city.get("name")); +// List> countyList = selectCountyList(city.get("code")); +// List countyBeanList = new ArrayList<>(); +// for (Map county : countyList) { +// RegionBean countyBean = new RegionBean(); +// countyBean.setCode(county.get("code")); +// countyBean.setName(county.get("name")); +//// List> streetList = selectStreetList(county.get("name")); +//// List streetBeanList = new ArrayList<>(); +//// for (Map street : streetList) { +//// RegionBean streetBean = new RegionBean(); +//// streetBean.setCode(street.get("code")); +//// streetBean.setName(street.get("name")); +//// streetBeanList.add(streetBean); +//// } +//// countyBean.setChildren(streetBeanList); +// countyBeanList.add(countyBean); +// } +// cityBean.setChildren(countyBeanList); +// cityBeanList.add(cityBean); +// } +// provinceBean.setChildren(cityBeanList); +// provinceBeanList.add(provinceBean); +// } +// return outputEncapsulationObject(PromptMessageEnum.SUCCESS, provinceBeanList, locale); } + }