basic-server/src/main/java/com/ruoyi/basic/service/impl/SupplyServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/AreaController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-common/src/main/java/com/ruoyi/basic/entity/dto/SelectOption.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-common/src/main/java/com/ruoyi/basic/entity/dto/TreeSelectOption.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-system/src/main/java/com/ruoyi/basic/service/ProvinceService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-system/src/main/java/com/ruoyi/basic/service/impl/ProvinceServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
basic-server/src/main/java/com/ruoyi/basic/service/impl/SupplyServiceImpl.java
@@ -65,6 +65,23 @@ public int addOrEditSupply(SupplyDto supplyDto) { Supply supply = new Supply(); BeanUtils.copyProperties(supplyDto, supply); if (supplyDto.getBids().size() != 3) { throw new RuntimeException("è¯·éæ©ç»è¥å°åçå¸åº"); } if (supplyDto.getCids().size() != 3) { throw new RuntimeException("è¯·éæ©èç³»å°åçå¸åº"); } supply.setBProvinceId(supplyDto.getBids().get(0)); supply.setBCityId(supplyDto.getBids().get(1)); supply.setBDistrictId(supplyDto.getBids().get(2)); supply.setCProvinceId(supplyDto.getCids().get(0)); supply.setCCityId(supplyDto.getCids().get(1)); supply.setCDistrictId(supplyDto.getCids().get(2)); if (Objects.isNull(supplyDto.getId())) { return supplyMapper.insert(supply); } else { ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/AreaController.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,28 @@ package com.ruoyi.web.controller.system; import com.ruoyi.basic.service.ProvinceService; import com.ruoyi.common.core.domain.R; import lombok.AllArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * <p> * å°åºæ¥å£ * </p> */ @RestController @AllArgsConstructor @RequestMapping("/area") public class AreaController { @Autowired private ProvinceService provinceService; @GetMapping("/options") public R getOptions() { return R.ok(provinceService.getAreaOptions()); } } ruoyi-common/src/main/java/com/ruoyi/basic/entity/dto/SelectOption.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,21 @@ package com.ruoyi.basic.entity.dto; import lombok.Data; /** * 䏿æ¡é项éç¨è¿åç»æä½ */ @Data public class SelectOption { private String value; private String label; private Long id; public SelectOption(String value, String label, Long id) { this.value = value; this.label = label; this.id = id; } public SelectOption() {} } ruoyi-common/src/main/java/com/ruoyi/basic/entity/dto/TreeSelectOption.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,25 @@ package com.ruoyi.basic.entity.dto; import lombok.Data; import java.util.List; /** * æ é项éç¨è¿åç»æä½ */ @Data public class TreeSelectOption { private String value; private String label; private Long id; private List<TreeSelectOption> children; public TreeSelectOption(String value, String label, Long id, List<TreeSelectOption> children) { this.value = value; this.label = label; this.id = id; this.children = children; } public TreeSelectOption() {} } ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
@@ -64,7 +64,7 @@ public String login(String username, String password, String code, String uuid) { // éªè¯ç æ ¡éª validateCaptcha(username, code, uuid); // validateCaptcha(username, code, uuid); // ç»å½åç½®æ ¡éª loginPreCheck(username, password); // ç¨æ·éªè¯ ruoyi-system/src/main/java/com/ruoyi/basic/service/ProvinceService.java
@@ -2,6 +2,9 @@ import com.ruoyi.basic.entity.Province; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.basic.entity.dto.TreeSelectOption; import java.util.List; /** * <p> @@ -13,4 +16,13 @@ */ public interface ProvinceService extends IService<Province> { /** * è·ååºåæ é项 * * @return List<TreeSelectOption> */ List<TreeSelectOption> getAreaOptions(); String getAreaDisplay(Long provinceId, Long cityId, Long districtId); } ruoyi-system/src/main/java/com/ruoyi/basic/service/impl/ProvinceServiceImpl.java
@@ -1,11 +1,21 @@ package com.ruoyi.basic.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.basic.entity.City; import com.ruoyi.basic.entity.District; import com.ruoyi.basic.entity.Province; import com.ruoyi.basic.entity.dto.TreeSelectOption; import com.ruoyi.basic.mapper.CityMapper; import com.ruoyi.basic.mapper.DistrictMapper; import com.ruoyi.basic.mapper.ProvinceMapper; import com.ruoyi.basic.service.ProvinceService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; /** * <p> @@ -19,4 +29,70 @@ @RequiredArgsConstructor public class ProvinceServiceImpl extends ServiceImpl<ProvinceMapper, Province> implements ProvinceService { @Autowired private ProvinceMapper provinceMapper; @Autowired private CityMapper cityMapper; @Autowired private DistrictMapper districtMapper; @Override public List<TreeSelectOption> getAreaOptions() { List<TreeSelectOption> res = new ArrayList<>(); List<Province> list = provinceMapper.selectList(null); for (Province province : list) { // æ¥è¯¢çä¸é¢çå¸ List<City> cityList = cityMapper.selectList(new LambdaQueryWrapper<City>().eq(City::getProvinceId, province.getId())); List<TreeSelectOption> cities = new ArrayList<>(); for (City city : cityList) { // æ¥è¯¢å¸ä¸é¢çåº List<District> districtList = districtMapper.selectList(new LambdaQueryWrapper<District>().eq(District::getCityId, city.getId())); List<TreeSelectOption> districts = new ArrayList<>(); for (District district : districtList) { districts.add(new TreeSelectOption(district.getId().toString(), district.getName(), district.getId(), null)); } TreeSelectOption cityTreeSelectOption = new TreeSelectOption(); cityTreeSelectOption.setValue(city.getId().toString()); cityTreeSelectOption.setLabel(city.getName()); cityTreeSelectOption.setId(city.getId()); cityTreeSelectOption.setChildren(districts); cities.add(cityTreeSelectOption); } TreeSelectOption treeSelectOption = new TreeSelectOption(); treeSelectOption.setValue(province.getId().toString()); treeSelectOption.setLabel(province.getName()); treeSelectOption.setId(province.getId()); treeSelectOption.setChildren(cities); res.add(treeSelectOption); } return res; } @Override public String getAreaDisplay(Long provinceId, Long cityId, Long districtId) { Province province = provinceMapper.selectById(provinceId); if (province == null) { throw new RuntimeException("çä¸åå¨"); } City city = cityMapper.selectById(cityId); if (city == null) { throw new RuntimeException("å¸ä¸åå¨"); } District district = districtMapper.selectById(districtId); if (district == null) { throw new RuntimeException("åºä¸åå¨"); } // 妿çåå¸åå if (province.getName().equals(city.getName())) { return province.getName() + " " + district.getName(); } return province.getName() + city.getName() + district.getName(); } }