临时提交
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user