Commit 41054ca9 by lzy

空间

parent 9c39bf8e
Showing with 263 additions and 69 deletions
......@@ -94,6 +94,9 @@ public enum CodeMessageEnum {
PLATFORM_ERROR_ELDER_CERTIFICATENUMBER_DUPLICATE(500, "PLATFORM.ERROR.ELDER.CERTIFICATENUMBER.DUPLICATE"),
PLATFORM_ERROR_SPACE_NAME_DUPLICATE(500,"PLATFORM.ERROR.SPACE.NAME.DUPLICATE"),
......
......@@ -87,4 +87,7 @@ SYSTEM.ERROR.SMS.SEND=短信发送错误,错误信息%s
SYSTEM.ERROR.SMS.CODE.NOT.EXIST=验证码已过期
SYSTEM.ERROR.SMS.CODE.NOT.CORRECT=验证码不正确
PLATFORM.ERROR.ELDER.CERTIFICATENUMBER.DUPLICATE=证件号不能重复
\ No newline at end of file
PLATFORM.ERROR.ELDER.CERTIFICATENUMBER.DUPLICATE=证件号不能重复
PLATFORM.ERROR.SPACE.NAME.DUPLICATE=同一层级,空间名称不能重复
\ No newline at end of file
package com.makeit.module.controller.space;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.space.PlatSpaceAddDTO;
import com.makeit.service.platform.space.PlatSpaceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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;
/**
* @Author:lzy
* @Date:2023/9/4 16:52
* @Describe:
*/
@Api(tags = "空间管理")
@RestController
@RequestMapping("/plat/space")
public class PlatSpaceController {
@Autowired
private PlatSpaceService spaceService;
@ApiOperation("新增")
@PostMapping("add")
public ApiResponseEntity<?> add(@Validated @RequestBody PlatSpaceAddDTO dto) {
spaceService.add(dto);
return ApiResponseUtils.success();
}
}
package com.makeit.dto.platform.space;
import com.makeit.common.dto.BaseTenantDTO;
import com.makeit.enums.platform.space.PlatSpaceEnum;
import com.makeit.global.validator.DictEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
/**
* @Author:lzy
* @Date:2023/9/5 9:50
* @Describe:
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "PlatSpaceAddDTO对象", description = "空间添加")
public class PlatSpaceAddDTO extends BaseTenantDTO {
@NotBlank(message = "空间名称不能为空")
@Size(max = 50, message = "空间名称最长为50个字符")
@ApiModelProperty(value = "空间名称")
private String name;
@DictEnum(em = PlatSpaceEnum.TypeEnum.class, message = "空间类型可选值为{m}")
@ApiModelProperty(value = "空间类型 数据字典 1:小区/社区/街道 2:楼栋 3:单元 4 楼层")
private String type;
@ApiModelProperty(value = "上级空间")
private String parentId;
@ApiModelProperty(value = "地址")
private String address;
@ApiModelProperty(value = "经度")
private String longitude;
@ApiModelProperty(value = "纬度")
private String latitude;
}
......@@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "Bed对象", description = "床位管理")
public class Bed extends BaseBusEntity {
public class PlatBed extends BaseBusEntity {
@ApiModelProperty(value = "名称")
private String name;
......
......@@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "RegionSetting对象", description = "区域设置")
public class RegionSetting extends BaseBusEntity {
public class PlatRegionSetting extends BaseBusEntity {
@ApiModelProperty(value = "区域名称")
private String name;
......
......@@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "RegionSettingLocation对象", description = "区域设置定位")
public class RegionSettingLocation extends BaseBusEntity {
public class PlatRegionSettingLocation extends BaseBusEntity {
@ApiModelProperty("区域设置Id")
private String regionSettingId;
......
......@@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "Room对象", description = "房间管理")
public class Room extends BaseBusEntity {
public class PlatRoom extends BaseBusEntity {
@ApiModelProperty(value = "名称")
......
......@@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "Space对象", description = "空间管理")
public class Space extends BaseBusEntity {
public class PlatSpace extends BaseBusEntity {
@ApiModelProperty(value = "名称")
private String name;
......
package com.makeit.enums.platform.space;
import com.makeit.enums.BaseEnum;
import com.makeit.utils.sys.SysDictUtil;
/**
* @Author:lzy
* @Date:2023/9/4 17:57
* @Describe:
*/
public class PlatSpaceEnum {
public enum TypeEnum implements BaseEnum {
//community 小区/社区/街道
//building 楼栋
//unit 单元
//floor 楼层
COMMUNITY("space.type.community"),
BUILDING("space.type.building"),
UNIT("space.type.unit"),
FLOOR("space.type.floor");
private String code;
TypeEnum(String code) {
this.code = code;
}
@Override
public String getValue() {
return SysDictUtil.getValue(code);
}
}
}
package com.makeit.mapper.platform.space;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.entity.platform.space.Bed;
import com.makeit.entity.platform.space.PlatBed;
/**
* @Author:lzy
* @Date:2023/8/31 11:58
* @Describe:
*/
public interface BedMapper extends BaseMapper<Bed> {
public interface PlatBedMapper extends BaseMapper<PlatBed> {
}
package com.makeit.mapper.platform.space;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.entity.platform.space.RegionSettingLocation;
import com.makeit.entity.platform.space.PlatRegionSettingLocation;
/**
* @Author:lzy
* @Date:2023/8/31 11:59
* @Describe:
*/
public interface RegionSettingLocationMapper extends BaseMapper<RegionSettingLocation> {
public interface PlatRegionSettingLocationMapper extends BaseMapper<PlatRegionSettingLocation> {
}
package com.makeit.mapper.platform.space;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.entity.platform.space.RegionSetting;
import com.makeit.entity.platform.space.PlatRegionSetting;
/**
* @Author:lzy
* @Date:2023/8/31 11:59
* @Describe:
*/
public interface RegionSettingMapper extends BaseMapper<RegionSetting> {
public interface PlatRegionSettingMapper extends BaseMapper<PlatRegionSetting> {
}
package com.makeit.mapper.platform.space;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.entity.platform.space.Room;
import com.makeit.entity.platform.space.PlatRoom;
/**
* @Author:lzy
* @Date:2023/8/31 12:00
* @Describe:
*/
public interface RoomMapper extends BaseMapper<Room> {
public interface PlatRoomMapper extends BaseMapper<PlatRoom> {
}
package com.makeit.mapper.platform.space;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.entity.platform.space.Space;
import com.makeit.entity.platform.space.PlatSpace;
/**
* @Author:lzy
* @Date:2023/8/31 12:01
* @Describe:
*/
public interface SpaceMapper extends BaseMapper<Space> {
public interface PlatSpaceMapper extends BaseMapper<PlatSpace> {
}
package com.makeit.service.platform.space;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.entity.platform.space.Bed;
import com.makeit.entity.platform.space.PlatBed;
/**
* @Author:lzy
* @Date:2023/8/31 15:08
* @Describe:
*/
public interface BedService extends IService<Bed> {
public interface PlatBedService extends IService<PlatBed> {
}
package com.makeit.service.platform.space;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.entity.platform.space.RegionSettingLocation;
import com.makeit.entity.platform.space.PlatRegionSettingLocation;
/**
* @Author:lzy
* @Date:2023/8/31 16:10
* @Describe:
*/
public interface RegionSettingLocationService extends IService<RegionSettingLocation> {
public interface PlatRegionSettingLocationService extends IService<PlatRegionSettingLocation> {
}
package com.makeit.service.platform.space;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.entity.platform.space.RegionSetting;
import com.makeit.entity.platform.space.PlatRegionSetting;
/**
* @Author:lzy
* @Date:2023/8/31 16:13
* @Describe:
*/
public interface RegionSettingService extends IService<RegionSetting> {
public interface PlatRegionSettingService extends IService<PlatRegionSetting> {
}
package com.makeit.service.platform.space;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.entity.platform.space.Room;
import com.makeit.entity.platform.space.PlatRoom;
/**
* @Author:lzy
* @Date:2023/8/31 16:15
* @Describe:
*/
public interface RoomService extends IService<Room> {
public interface PlatRoomService extends IService<PlatRoom> {
}
package com.makeit.service.platform.space;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.dto.platform.space.PlatSpaceAddDTO;
import com.makeit.entity.platform.space.PlatSpace;
/**
* @Author:lzy
* @Date:2023/8/31 16:17
* @Describe:
*/
public interface PlatSpaceService extends IService<PlatSpace> {
/**
* 添加
* @param dto
*/
void add(PlatSpaceAddDTO dto);
/**
* 编辑
* @param dto
*/
void edit(PlatSpaceAddDTO dto);
/**
* 删除
* @param id
*/
void del(String id);
}
package com.makeit.service.platform.space;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.entity.platform.space.Space;
/**
* @Author:lzy
* @Date:2023/8/31 16:17
* @Describe:
*/
public interface SpaceService extends IService<Space> {
}
package com.makeit.service.platform.space.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.entity.platform.space.Bed;
import com.makeit.mapper.platform.space.BedMapper;
import com.makeit.service.platform.space.BedService;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.mapper.platform.space.PlatBedMapper;
import com.makeit.service.platform.space.PlatBedService;
import org.springframework.stereotype.Service;
/**
......@@ -12,5 +12,5 @@ import org.springframework.stereotype.Service;
* @Describe:
*/
@Service
public class BedServiceImpl extends ServiceImpl<BedMapper, Bed> implements BedService {
public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> implements PlatBedService {
}
package com.makeit.service.platform.space.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.entity.platform.space.RegionSettingLocation;
import com.makeit.mapper.platform.space.RegionSettingLocationMapper;
import com.makeit.service.platform.space.RegionSettingLocationService;
import com.makeit.entity.platform.space.PlatRegionSettingLocation;
import com.makeit.mapper.platform.space.PlatRegionSettingLocationMapper;
import com.makeit.service.platform.space.PlatRegionSettingLocationService;
import org.springframework.stereotype.Service;
/**
......@@ -12,5 +12,5 @@ import org.springframework.stereotype.Service;
* @Describe:
*/
@Service
public class RegionSettingLocationServiceImpl extends ServiceImpl<RegionSettingLocationMapper, RegionSettingLocation> implements RegionSettingLocationService {
public class PlatRegionSettingLocationServiceImpl extends ServiceImpl<PlatRegionSettingLocationMapper, PlatRegionSettingLocation> implements PlatRegionSettingLocationService {
}
package com.makeit.service.platform.space.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.entity.platform.space.RegionSetting;
import com.makeit.mapper.platform.space.RegionSettingMapper;
import com.makeit.service.platform.space.RegionSettingService;
import com.makeit.entity.platform.space.PlatRegionSetting;
import com.makeit.mapper.platform.space.PlatRegionSettingMapper;
import com.makeit.service.platform.space.PlatRegionSettingService;
import org.springframework.stereotype.Service;
/**
......@@ -12,5 +12,5 @@ import org.springframework.stereotype.Service;
* @Describe:
*/
@Service
public class RegionSettingServiceImpl extends ServiceImpl<RegionSettingMapper, RegionSetting> implements RegionSettingService {
public class PlatRegionSettingServiceImpl extends ServiceImpl<PlatRegionSettingMapper, PlatRegionSetting> implements PlatRegionSettingService {
}
package com.makeit.service.platform.space.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.entity.platform.space.Room;
import com.makeit.mapper.platform.space.RoomMapper;
import com.makeit.service.platform.space.RoomService;
import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.mapper.platform.space.PlatRoomMapper;
import com.makeit.service.platform.space.PlatRoomService;
/**
* @Author:lzy
* @Date:2023/8/31 16:15
* @Describe:
*/
public class RoomServiceImpl extends ServiceImpl<RoomMapper, Room> implements RoomService {
public class PlatRoomServiceImpl extends ServiceImpl<PlatRoomMapper, PlatRoom> implements PlatRoomService {
}
package com.makeit.service.platform.space.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.dto.platform.space.PlatSpaceAddDTO;
import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.exception.BusinessException;
import com.makeit.mapper.platform.space.PlatSpaceMapper;
import com.makeit.service.platform.space.PlatSpaceService;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import jodd.util.StringUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* @Author:lzy
* @Date:2023/8/31 16:17
* @Describe:
*/
@Service
public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace> implements PlatSpaceService {
private void check(PlatSpaceAddDTO dto){
LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PlatSpace::getParentId,dto.getParentId());
queryWrapper.eq(PlatSpace::getName,dto.getName());
queryWrapper.ne(StringUtil.isNotEmpty(dto.getId()), PlatSpace::getId,dto.getId());
if(this.count(queryWrapper) > 0){
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_NAME_DUPLICATE);
}
}
@Override
@Transactional
public void add(PlatSpaceAddDTO dto) {
check(dto);
PlatSpace space = BeanDtoVoUtils.convert(dto, PlatSpace.class);
save(space);
}
@Override
@Transactional
public void edit(PlatSpaceAddDTO dto) {
check(dto);
PlatSpace space = this.getById(dto.getId());
space.setName(dto.getName());
space.setType(dto.getType());
space.setAddress(dto.getAddress());
space.setLatitude(dto.getLatitude());
space.setLongitude(dto.getLongitude());
space.setParentId(dto.getParentId());
this.updateById(space);
}
@Override
public void del(String id) {
this.removeById(id);
}
}
package com.makeit.service.platform.space.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.entity.platform.space.Space;
import com.makeit.mapper.platform.space.SpaceMapper;
import com.makeit.service.platform.space.SpaceService;
import org.springframework.stereotype.Service;
/**
* @Author:lzy
* @Date:2023/8/31 16:17
* @Describe:
*/
@Service
public class SpaceServiceImpl extends ServiceImpl<SpaceMapper, Space> implements SpaceService {
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment