临时提交
parent
ff5ba1698a
commit
05fabc87a2
|
@ -15,50 +15,50 @@ public class Region implements Comparable<Region>{
|
|||
* 数据库自增ID
|
||||
*/
|
||||
@Schema(description = "数据库自增ID")
|
||||
private int commonRegionId;
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* 区域国标编号
|
||||
*/
|
||||
@Schema(description = "区域国标编号")
|
||||
private String commonRegionDeviceId;
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 区域名称
|
||||
*/
|
||||
@Schema(description = "区域名称")
|
||||
private String commonRegionName;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 父区域国标ID
|
||||
*/
|
||||
@Schema(description = "父区域国标ID")
|
||||
private String commonRegionParentId;
|
||||
private String parentDeviceId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
private String commonRegionCreateTime;
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间")
|
||||
private String commonRegionUpdateTime;
|
||||
private String updateTime;
|
||||
|
||||
public static Region getInstance(String commonRegionDeviceId, String commonRegionName, String commonRegionParentId) {
|
||||
Region region = new Region();
|
||||
region.setCommonRegionDeviceId(commonRegionDeviceId);
|
||||
region.setCommonRegionName(commonRegionName);
|
||||
region.setCommonRegionParentId(commonRegionParentId);
|
||||
region.setCommonRegionCreateTime(DateUtil.getNow());
|
||||
region.setCommonRegionUpdateTime(DateUtil.getNow());
|
||||
region.setDeviceId(commonRegionDeviceId);
|
||||
region.setName(commonRegionName);
|
||||
region.setParentDeviceId(commonRegionParentId);
|
||||
region.setCreateTime(DateUtil.getNow());
|
||||
region.setUpdateTime(DateUtil.getNow());
|
||||
return region;
|
||||
}
|
||||
|
||||
@Override
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,37 @@
|
|||
package com.genersoft.iot.vmp.gb28181.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Region;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -35,13 +35,13 @@ public class RegionServiceImpl implements IRegionService {
|
|||
|
||||
@Override
|
||||
public void add(Region region) {
|
||||
assert region.getCommonRegionName() != null;
|
||||
assert region.getCommonRegionDeviceId() != null;
|
||||
if (ObjectUtils.isEmpty(region.getCommonRegionParentId().trim())) {
|
||||
region.setCommonRegionParentId(null);
|
||||
assert region.getName() != null;
|
||||
assert region.getDeviceId() != null;
|
||||
if (ObjectUtils.isEmpty(region.getParentDeviceId().trim())) {
|
||||
region.setParentDeviceId(null);
|
||||
}
|
||||
region.setCommonRegionCreateTime(DateUtil.getNow());
|
||||
region.setCommonRegionUpdateTime(DateUtil.getNow());
|
||||
region.setCreateTime(DateUtil.getNow());
|
||||
region.setUpdateTime(DateUtil.getNow());
|
||||
regionMapper.add(region);
|
||||
}
|
||||
|
||||
|
|
|
@ -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_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)
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue