src/main/java/com/moral/controller/AreaController.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/moral/entity/AreaNames.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/moral/entity/Village.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/moral/mapper/VillageMapper.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/moral/service/AreaService.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/moral/service/impl/AreaServiceImpl.java | ●●●●● patch | view | raw | blame | history | |
src/main/resources/mapper/DeviceMapper.xml | ●●●●● patch | view | raw | blame | history | |
src/main/resources/mapper/HistoryMinutelyMapper.xml | ●●●●● patch | view | raw | blame | history | |
src/main/resources/mapper/MonitorPointMapper.xml | ●●●●● patch | view | raw | blame | history |
src/main/java/com/moral/controller/AreaController.java
@@ -4,6 +4,8 @@ import com.moral.entity.Area; import com.moral.entity.City; import com.moral.entity.Province; import com.moral.entity.Town; import com.moral.entity.Village; import com.moral.service.AreaService; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; @@ -47,4 +49,22 @@ resultBean.setCode(ResultBean.SUCCESS); return resultBean; } @GetMapping("get-towns") public ResultBean<List<Town>> getTowns(int areaCode){ ResultBean<List<Town>> resultBean = new ResultBean<>(); List<Town> list = areaService.getTowns(areaCode); resultBean.setData(list); resultBean.setCode(ResultBean.SUCCESS); return resultBean; } @GetMapping("get-villages") public ResultBean<List<Village>> getVillages(Long townCode){ ResultBean<List<Village>> resultBean = new ResultBean<>(); List<Village> list = areaService.getVillages(townCode); resultBean.setData(list); resultBean.setCode(ResultBean.SUCCESS); return resultBean; } } src/main/java/com/moral/entity/AreaNames.java
@@ -7,4 +7,6 @@ private String provinceName; private String cityName; private String areaName; private String townName; private String villageName; } src/main/java/com/moral/entity/Village.java
New file @@ -0,0 +1,25 @@ package com.moral.entity; import javax.persistence.Id; import lombok.Data; @Data public class Village { /** * This field was generated by MyBatis Generator. This field corresponds to the database column village.village_code * @mbg.generated Mon Jun 11 14:09:26 CST 2018 */ @Id private Long villageCode; /** * This field was generated by MyBatis Generator. This field corresponds to the database column village.village_name * @mbg.generated Mon Jun 11 14:09:26 CST 2018 */ private String villageName; /** * This field was generated by MyBatis Generator. This field corresponds to the database column village.town_code * @mbg.generated Mon Jun 11 14:09:26 CST 2018 */ private Long townCode; } src/main/java/com/moral/mapper/VillageMapper.java
New file @@ -0,0 +1,7 @@ package com.moral.mapper; import com.moral.common.mapper.BaseMapper; import com.moral.entity.Village; public interface VillageMapper extends BaseMapper<Village>{ } src/main/java/com/moral/service/AreaService.java
@@ -3,6 +3,8 @@ import com.moral.entity.Area; import com.moral.entity.City; import com.moral.entity.Province; import com.moral.entity.Town; import com.moral.entity.Village; import java.util.List; @@ -12,4 +14,7 @@ List<Area> getAreas(int cityCode); String queryFullNameByCode(Integer code); List<Town> getTowns(Integer areaCode); List<Village> getVillages(Long townCode); } src/main/java/com/moral/service/impl/AreaServiceImpl.java
@@ -3,9 +3,13 @@ import com.moral.entity.Area; import com.moral.entity.City; import com.moral.entity.Province; import com.moral.entity.Town; import com.moral.entity.Village; import com.moral.mapper.AreaMapper; import com.moral.mapper.CityMapper; import com.moral.mapper.ProvinceMapper; import com.moral.mapper.TownMapper; import com.moral.mapper.VillageMapper; import com.moral.service.AreaService; import org.springframework.stereotype.Service; import tk.mybatis.mapper.entity.Example; @@ -22,6 +26,12 @@ CityMapper cityMapper; @Resource AreaMapper areaMapper; @Resource private TownMapper townMapper; @Resource private VillageMapper villageMapper; @Override public List<Province> getProvinces() { @@ -75,4 +85,18 @@ } return fullName; } @Override public List<Town> getTowns(Integer areaCode) { Example example = new Example(Town.class); example.or().andEqualTo("areaCode",areaCode); return townMapper.selectByExample(example); } @Override public List<Village> getVillages(Long townCode) { Example example = new Example(Village.class); example.createCriteria().andEqualTo("townCode",townCode); return villageMapper.selectByExample(example); } } src/main/resources/mapper/DeviceMapper.xml
@@ -259,6 +259,12 @@ <if test="areaCode != null"> AND mp.area_code = #{areaCode} </if> <if test="townCode != null"> AND mp.town_code = #{townCode} </if> <if test="villageCode != null"> AND mp.village_code = #{villageCode} </if> ) <if test="professionId != null"> AND d.profession_id = #{professionId} @@ -291,6 +297,12 @@ <if test="monitorPointId != null"> AND mp.id = #{monitorPointId} </if> <if test="townCode != null"> AND mp.town_code = #{townCode} </if> <if test="villageCode != null"> AND mp.village_code = #{villageCode} </if> ) <if test="professionId != null"> AND d.profession_id = #{professionId} src/main/resources/mapper/HistoryMinutelyMapper.xml
@@ -17,13 +17,11 @@ (SELECT d.mac FROM device d, monitor_point mp device d WHERE d.is_delete = 0 AND d.monitor_point_id = mp.id <if test="monitorPointId != null"> AND mp.id = #{monitorPointId} AND d.monitor_point_id = #{monitorPointId} </if> <if test="mac != null"> AND d.mac = #{mac} src/main/resources/mapper/MonitorPointMapper.xml
@@ -19,6 +19,8 @@ <result column="province_name" property="provinceName" jdbcType="VARCHAR" /> <result column="city_name" property="cityName" jdbcType="VARCHAR" /> <result column="area_name" property="areaName" jdbcType="VARCHAR" /> <result column="town_name" property="townName" jdbcType="VARCHAR" /> <result column="village_name" property="villageName" jdbcType="VARCHAR" /> </association> <association property="organization" javaType="com.moral.entity.Organization"> <result column="organization_id" property="id" jdbcType="INTEGER" /> @@ -74,6 +76,8 @@ left join city cti on mpt.city_code = cti.city_code left join province pro on mpt.province_code = pro.province_code left join organization org on mpt.organization_id = org.id left join town t on mpt.town_code = t.town_code left join village v on mpt.village_code = v.village_code where mpt.id in ( select id from monitor_point <if test="_parameter != null">