临时提交

pull/1642/head
648540858 2024-07-22 18:00:01 +08:00
parent ff5ba1698a
commit 05fabc87a2
4 changed files with 63 additions and 22 deletions

View File

@ -15,50 +15,50 @@ public class Region implements Comparable<Region>{
* ID * ID
*/ */
@Schema(description = "数据库自增ID") @Schema(description = "数据库自增ID")
private int commonRegionId; private int id;
/** /**
* *
*/ */
@Schema(description = "区域国标编号") @Schema(description = "区域国标编号")
private String commonRegionDeviceId; private String deviceId;
/** /**
* *
*/ */
@Schema(description = "区域名称") @Schema(description = "区域名称")
private String commonRegionName; private String name;
/** /**
* ID * ID
*/ */
@Schema(description = "父区域国标ID") @Schema(description = "父区域国标ID")
private String commonRegionParentId; private String parentDeviceId;
/** /**
* *
*/ */
@Schema(description = "创建时间") @Schema(description = "创建时间")
private String commonRegionCreateTime; private String createTime;
/** /**
* *
*/ */
@Schema(description = "更新时间") @Schema(description = "更新时间")
private String commonRegionUpdateTime; private String updateTime;
public static Region getInstance(String commonRegionDeviceId, String commonRegionName, String commonRegionParentId) { public static Region getInstance(String commonRegionDeviceId, String commonRegionName, String commonRegionParentId) {
Region region = new Region(); Region region = new Region();
region.setCommonRegionDeviceId(commonRegionDeviceId); region.setDeviceId(commonRegionDeviceId);
region.setCommonRegionName(commonRegionName); region.setName(commonRegionName);
region.setCommonRegionParentId(commonRegionParentId); region.setParentDeviceId(commonRegionParentId);
region.setCommonRegionCreateTime(DateUtil.getNow()); region.setCreateTime(DateUtil.getNow());
region.setCommonRegionUpdateTime(DateUtil.getNow()); region.setUpdateTime(DateUtil.getNow());
return region; return region;
} }
@Override @Override
public int compareTo(@NotNull Region region) { public int compareTo(@NotNull Region region) {
return Integer.compare(Integer.parseInt(this.commonRegionDeviceId), Integer.parseInt(region.getCommonRegionDeviceId())); return Integer.compare(Integer.parseInt(this.deviceId), Integer.parseInt(region.getDeviceId()));
} }
} }

View File

@ -1,17 +1,37 @@
package com.genersoft.iot.vmp.gb28181.dao; package com.genersoft.iot.vmp.gb28181.dao;
import com.genersoft.iot.vmp.gb28181.bean.Region; import com.genersoft.iot.vmp.gb28181.bean.Region;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.*;
import java.util.List; import java.util.List;
@Mapper @Mapper
public interface RegionMapper { public interface RegionMapper {
@Insert("INSERT INTO wvp_common_region (device_id, name, parent_device_id, create_time, update_time) " +
"VALUES (#{deviceId}, #{name}, #{parentDeviceId}, #{createTime}, #{updateTime})")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
void add(Region region); void add(Region region);
List<Region> query(String query); @Delete("DELETE FROM wvp_common_region WHERE id=#{id}")
int delete(@Param("id") int id);
List<Region> getChildren(String regionParentId); @Update(" UPDATE wvp_common_region " +
" SET update_time=#{updateTime}, device_id=#{deviceId}, name=#{name}, parent_device_id=#{parentDeviceId}" +
" WHERE id = #{id}")
int update(Region region);
Region queryRegion(int id); @Select(value = {" <script>" +
"SELECT * from wvp_common_region WHERE 1=1 " +
" <if test='query != null'> AND (device_id LIKE concat('%',#{query},'%') OR name LIKE concat('%',#{query},'%'))</if> " +
" <if test='parentId != null'> AND parent_device_id = #{parentId}</if> " +
"ORDER BY id " +
" </script>"})
List<Region> query(@Param("query") String query, @Param("parentId") String parentId);
@Select("SELECT * from wvp_common_region WHERE parent_device_id = #{parentId} ORDER BY id ")
List<Region> getChildren(String parentId);
@Select("SELECT * from wvp_common_region WHERE id = #{id} ")
Region queryOne(int id);
} }

View File

@ -35,13 +35,13 @@ public class RegionServiceImpl implements IRegionService {
@Override @Override
public void add(Region region) { public void add(Region region) {
assert region.getCommonRegionName() != null; assert region.getName() != null;
assert region.getCommonRegionDeviceId() != null; assert region.getDeviceId() != null;
if (ObjectUtils.isEmpty(region.getCommonRegionParentId().trim())) { if (ObjectUtils.isEmpty(region.getParentDeviceId().trim())) {
region.setCommonRegionParentId(null); region.setParentDeviceId(null);
} }
region.setCommonRegionCreateTime(DateUtil.getNow()); region.setCreateTime(DateUtil.getNow());
region.setCommonRegionUpdateTime(DateUtil.getNow()); region.setUpdateTime(DateUtil.getNow());
regionMapper.add(region); regionMapper.add(region);
} }

View File

@ -381,5 +381,26 @@ create table wvp_user_api_key (
INSERT INTO wvp_user VALUES (1, 'admin','21232f297a57a5a743894a0e4a801fc3',1,'2021-04-13 14:14:57','2021-04-13 14:14:57','3e80d1762a324d5b0ff636e0bd16f1e3'); INSERT INTO wvp_user VALUES (1, 'admin','21232f297a57a5a743894a0e4a801fc3',1,'2021-04-13 14:14:57','2021-04-13 14:14:57','3e80d1762a324d5b0ff636e0bd16f1e3');
INSERT INTO wvp_user_role VALUES (1, 'admin','0','2021-04-13 14:14:57','2021-04-13 14:14:57'); INSERT INTO wvp_user_role VALUES (1, 'admin','0','2021-04-13 14:14:57','2021-04-13 14:14:57');
CREATE TABLE wvp_common_group
(
id serial primary key,
device_id varchar(50) NOT NULL,
name varchar(255) NOT NULL,
parent_device_id varchar(50) DEFAULT NULL,
business_group varchar(50) DEFAULT NULL,
create_time varchar(50) NOT NULL,
update_time varchar(50) NOT NULL,
UNIQUE KEY common_group_device_id (device_id)
);
CREATE TABLE wvp_common_region
(
id serial primary key,
device_id varchar(50) NOT NULL,
name varchar(255) NOT NULL,
parent_device_id varchar(50) DEFAULT NULL,
create_time varchar(50) NOT NULL,
update_time varchar(50) NOT NULL,
UNIQUE KEY common_region_device_id (device_id)
);