住户删改
parent
cbcecf161b
commit
dcad0ec731
|
@ -12,6 +12,7 @@ public class Building {
|
||||||
private Integer endFloor;
|
private Integer endFloor;
|
||||||
private Integer startHold;
|
private Integer startHold;
|
||||||
private Integer endHold;
|
private Integer endHold;
|
||||||
|
private Integer residents;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,9 @@ public class Households {
|
||||||
private Integer type;
|
private Integer type;
|
||||||
private Integer unit;
|
private Integer unit;
|
||||||
|
|
||||||
private String name;
|
private String typename;
|
||||||
private String buildId;
|
private String buildId;
|
||||||
|
private String pic;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package com.zyh.system.controller;
|
package com.zyh.system.controller;
|
||||||
|
|
||||||
import com.zyh.common.domain.Building;
|
import com.zyh.common.domain.Building;
|
||||||
|
import com.zyh.common.domain.Households;
|
||||||
import com.zyh.common.result.Result;
|
import com.zyh.common.result.Result;
|
||||||
import com.zyh.system.service.BuildService;
|
import com.zyh.system.service.BuildService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import java.util.List;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("build")
|
@RequestMapping("build")
|
||||||
|
@ -18,9 +18,36 @@ public class BuildController {
|
||||||
|
|
||||||
//添加楼栋(住户)
|
//添加楼栋(住户)
|
||||||
@PostMapping("addBuild")
|
@PostMapping("addBuild")
|
||||||
public Result addBuild(@RequestBody Building building){
|
public Result addBuild(@RequestBody Building building) {
|
||||||
|
|
||||||
return buildService.addBuild(building);
|
return buildService.addBuild(building);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//查询楼栋信息
|
||||||
|
@PostMapping("getBuild")
|
||||||
|
public Result<List<Building>> getBuild() {
|
||||||
|
|
||||||
|
return buildService.getBuild();
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询住户信息
|
||||||
|
@PostMapping("getHouse")
|
||||||
|
public Result<List<Households>> getHouse(@RequestParam String buildId, @RequestParam Integer unit) {
|
||||||
|
|
||||||
|
return buildService.getHouse(buildId, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
//删除住户
|
||||||
|
@PostMapping("deleteHouse")
|
||||||
|
public Result deleteHouse(@RequestParam Integer id) {
|
||||||
|
|
||||||
|
return buildService.deleteHouse(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
//修改住户信息
|
||||||
|
@PostMapping("updateHouse")
|
||||||
|
public Result updateHouse(@RequestBody Households households) {
|
||||||
|
|
||||||
|
return buildService.updateHouse(households);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@ import com.zyh.common.domain.Households;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface BuildMapper {
|
public interface BuildMapper {
|
||||||
Integer addBuild(Building building);
|
Integer addBuild(Building building);
|
||||||
|
@ -12,4 +14,12 @@ public interface BuildMapper {
|
||||||
void addHouse(Households households);
|
void addHouse(Households households);
|
||||||
|
|
||||||
String selectBuildId(@Param("buildId") String buildId);
|
String selectBuildId(@Param("buildId") String buildId);
|
||||||
|
|
||||||
|
List<Building> getBuild();
|
||||||
|
|
||||||
|
List<Households> getHouse(@Param("buildId") String buildId, @Param("unit") Integer unit);
|
||||||
|
|
||||||
|
Integer deleteHouse(@Param("id") Integer id);
|
||||||
|
|
||||||
|
Integer updateHouse(Households households);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,19 @@
|
||||||
package com.zyh.system.service;
|
package com.zyh.system.service;
|
||||||
|
|
||||||
import com.zyh.common.domain.Building;
|
import com.zyh.common.domain.Building;
|
||||||
|
import com.zyh.common.domain.Households;
|
||||||
import com.zyh.common.result.Result;
|
import com.zyh.common.result.Result;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface BuildService {
|
public interface BuildService {
|
||||||
Result addBuild(Building building);
|
Result addBuild(Building building);
|
||||||
|
|
||||||
|
Result<List<Building>> getBuild();
|
||||||
|
|
||||||
|
Result<List<Households>> getHouse(String buildId,Integer unit);
|
||||||
|
|
||||||
|
Result deleteHouse(Integer id);
|
||||||
|
|
||||||
|
Result updateHouse(Households households);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,9 @@ import com.zyh.system.mapper.BuildMapper;
|
||||||
import com.zyh.system.service.BuildService;
|
import com.zyh.system.service.BuildService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class BuildServicempl implements BuildService {
|
public class BuildServicempl implements BuildService {
|
||||||
|
@ -44,4 +47,35 @@ public class BuildServicempl implements BuildService {
|
||||||
|
|
||||||
return Result.error("添加失败");
|
return Result.error("添加失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<List<Building>> getBuild() {
|
||||||
|
List<Building> buildings =buildMapper.getBuild();
|
||||||
|
return Result.success(buildings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<List<Households>> getHouse(String buildId,Integer unit) {
|
||||||
|
List<Households> households =buildMapper.getHouse(buildId,unit);
|
||||||
|
return Result.success(households);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result deleteHouse(Integer id) {
|
||||||
|
Integer delete =buildMapper.deleteHouse(id);
|
||||||
|
if(delete>0){
|
||||||
|
return Result.success("删除成功");
|
||||||
|
}
|
||||||
|
return Result.error("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result updateHouse(Households households) {
|
||||||
|
Integer update =buildMapper.updateHouse(households);
|
||||||
|
if(update>0){
|
||||||
|
return Result.success("更新成功");
|
||||||
|
}
|
||||||
|
return Result.error("更新失败");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,40 @@
|
||||||
|
|
||||||
|
|
||||||
<insert id="addBuild">
|
<insert id="addBuild">
|
||||||
insert into building values (0,#{buildId},#{address},#{unit},#{startFloor},#{endFloor},#{startHold},#{endHold})
|
insert into building values (0,#{buildId},#{address},#{unit},#{startFloor},#{endFloor},#{startHold},#{endHold},0)
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="addHouse">
|
<insert id="addHouse">
|
||||||
insert into households values (0,#{holdId},0,1,#{buildId},#{unit})
|
insert into households values (0,#{holdId},0,1,#{buildId},#{unit})
|
||||||
</insert>
|
</insert>
|
||||||
|
<update id="updateHouse">
|
||||||
|
update households set
|
||||||
|
hold_id = #{holdId},
|
||||||
|
build_id = #{buildId},
|
||||||
|
unit = #{unit},
|
||||||
|
person_num = #{personNum},
|
||||||
|
type = #{type}
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
<delete id="deleteHouse">
|
||||||
|
delete from households where id = #{id}
|
||||||
|
</delete>
|
||||||
<select id="selectBuildId" resultType="java.lang.String">
|
<select id="selectBuildId" resultType="java.lang.String">
|
||||||
select buildId from building where build_id = #{buildId}
|
select build_id from building where build_id = #{buildId}
|
||||||
|
</select>
|
||||||
|
<select id="getBuild" resultType="com.zyh.common.domain.Building">
|
||||||
|
select * from building
|
||||||
|
</select>
|
||||||
|
<select id="getHouse" resultType="com.zyh.common.domain.Households">
|
||||||
|
select households.*,housetype.name as typename from households
|
||||||
|
left join housetype on households.type=housetype.id
|
||||||
|
<where>
|
||||||
|
|
||||||
|
<if test="unit != null">
|
||||||
|
and unit = #{unit}
|
||||||
|
</if>
|
||||||
|
<if test="buildId != null">
|
||||||
|
and build_id = #{buildId}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue