master
parent
2ced7a2a57
commit
cbcecf161b
|
@ -49,10 +49,10 @@ public class AuthServicempl implements AuthService {
|
||||||
HashMap<String, Object> map = new HashMap<>();
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
map.put(JwtConstants.USER_KEY, userkey);
|
map.put(JwtConstants.USER_KEY, userkey);
|
||||||
String token = JwtUtils.createToken(map);
|
String token = JwtUtils.createToken(map);
|
||||||
redisTemplate.opsForValue().set(TokenConstants.LOGIN_TOKEN_KEY + userkey, JSONObject.toJSONString(user), 30, TimeUnit.MINUTES);
|
redisTemplate.opsForValue().set(TokenConstants.LOGIN_TOKEN_KEY + userkey, JSONObject.toJSONString(user), 60, TimeUnit.MINUTES);
|
||||||
UserResponse userResponse = new UserResponse();
|
UserResponse userResponse = new UserResponse();
|
||||||
userResponse.setToken(token);
|
userResponse.setToken(token);
|
||||||
userResponse.setExpirTime("30MIN");
|
userResponse.setExpirTime("60MIN");
|
||||||
return Result.success(userResponse);
|
return Result.success(userResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.zyh.common.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Building {
|
||||||
|
private Integer id;
|
||||||
|
private String buildId;
|
||||||
|
private String address;
|
||||||
|
private Integer unit;
|
||||||
|
private Integer startFloor;
|
||||||
|
private Integer endFloor;
|
||||||
|
private Integer startHold;
|
||||||
|
private Integer endHold;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.zyh.common.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Households {
|
||||||
|
private Integer id;
|
||||||
|
private String holdId;
|
||||||
|
private Integer personNum;
|
||||||
|
private Integer type;
|
||||||
|
private Integer unit;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String buildId;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.zyh.common.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Housetype {
|
||||||
|
private Integer id;
|
||||||
|
private String name;
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.zyh.system.controller;
|
||||||
|
|
||||||
|
import com.zyh.common.domain.Building;
|
||||||
|
import com.zyh.common.result.Result;
|
||||||
|
import com.zyh.system.service.BuildService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("build")
|
||||||
|
public class BuildController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BuildService buildService;
|
||||||
|
|
||||||
|
//添加楼栋(住户)
|
||||||
|
@PostMapping("addBuild")
|
||||||
|
public Result addBuild(@RequestBody Building building){
|
||||||
|
|
||||||
|
return buildService.addBuild(building);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.zyh.system.mapper;
|
||||||
|
|
||||||
|
import com.zyh.common.domain.Building;
|
||||||
|
import com.zyh.common.domain.Households;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface BuildMapper {
|
||||||
|
Integer addBuild(Building building);
|
||||||
|
|
||||||
|
void addHouse(Households households);
|
||||||
|
|
||||||
|
String selectBuildId(@Param("buildId") String buildId);
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.zyh.system.service;
|
||||||
|
|
||||||
|
import com.zyh.common.domain.Building;
|
||||||
|
import com.zyh.common.result.Result;
|
||||||
|
|
||||||
|
public interface BuildService {
|
||||||
|
Result addBuild(Building building);
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.zyh.system.service.impl;
|
||||||
|
|
||||||
|
import com.zyh.common.domain.Building;
|
||||||
|
import com.zyh.common.domain.Households;
|
||||||
|
import com.zyh.common.result.Result;
|
||||||
|
import com.zyh.system.mapper.BuildMapper;
|
||||||
|
import com.zyh.system.service.BuildService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class BuildServicempl implements BuildService {
|
||||||
|
@Autowired
|
||||||
|
BuildMapper buildMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result addBuild(Building building) {
|
||||||
|
//查询编号重复不可添加
|
||||||
|
String buildId = buildMapper.selectBuildId(building.getBuildId());
|
||||||
|
if(buildId!=null){
|
||||||
|
return Result.error("编号重复不可添加");
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer add =buildMapper.addBuild(building);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(add>0){
|
||||||
|
int i = building.getEndFloor() - building.getStartFloor() + 1;//楼层
|
||||||
|
int i2 = building.getEndHold() - building.getStartHold();//户数
|
||||||
|
for (int i1 = 1; i1 <= i; i1++) {
|
||||||
|
for (int i3 = 1; i3 <= i2+1; i3++) {
|
||||||
|
Households households = new Households();
|
||||||
|
String holdId = String.valueOf(i1 * 100 + i3);
|
||||||
|
households.setHoldId(holdId);
|
||||||
|
households.setBuildId(building.getBuildId());
|
||||||
|
households.setUnit(building.getUnit());
|
||||||
|
buildMapper.addHouse(households);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result.success("添加成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.error("添加失败");
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,8 +29,6 @@ public class HouseServicempl implements HouseService {
|
||||||
|
|
||||||
checkHouse(house);
|
checkHouse(house);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Integer add = houseMapper.addHouse(house);
|
Integer add = houseMapper.addHouse(house);
|
||||||
if (add > 0) {
|
if (add > 0) {
|
||||||
return Result.success("添加成功");
|
return Result.success("添加成功");
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.zyh.system.mapper.BuildMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<insert id="addBuild">
|
||||||
|
insert into building values (0,#{buildId},#{address},#{unit},#{startFloor},#{endFloor},#{startHold},#{endHold})
|
||||||
|
</insert>
|
||||||
|
<insert id="addHouse">
|
||||||
|
insert into households values (0,#{holdId},0,1,#{buildId},#{unit})
|
||||||
|
</insert>
|
||||||
|
<select id="selectBuildId" resultType="java.lang.String">
|
||||||
|
select buildId from building where build_id = #{buildId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue