添加设备新增接口

This commit is contained in:
648540858
2024-03-13 23:21:49 +08:00
parent 4eb0163e43
commit e400c92f53
4 changed files with 48 additions and 2 deletions

View File

@@ -68,7 +68,7 @@ public class JT1078Controller {
return service.getDeviceList(page, count, query, online);
}
@Operation(summary = "更新设备信息", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Operation(summary = "更新设备", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "device", description = "设备", required = true)
@PostMapping("/device/update")
public void updateDevice(JTDevice device){
@@ -77,5 +77,15 @@ public class JT1078Controller {
service.updateDevice(device);
}
@Operation(summary = "新增设备", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "device", description = "设备", required = true)
@PostMapping("/device/add")
public void addDevice(JTDevice device){
assert device.getDeviceId() != null;
service.addDevice(device);
}
}

View File

@@ -20,7 +20,7 @@ public interface JTDeviceMapper {
"<if test=\"deviceModel != null\">, device_model=#{deviceModel}</if>" +
"<if test=\"plateColor != null\">, plate_color=#{plateColor}</if>" +
"<if test=\"plateNo != null\">, plate_no=#{plateNo}</if>" +
"<if test=\"authenticationCode != null\">, authenticationCode=#{localIp}</if>" +
"<if test=\"authenticationCode != null\">, authentication_code=#{localIp}</if>" +
"<if test=\"longitude != null\">, longitude=#{longitude}</if>" +
"<if test=\"latitude != null\">, latitude=#{latitude}</if>" +
"<if test=\"status != null\">, status=#{status}</if>" +
@@ -46,4 +46,31 @@ public interface JTDeviceMapper {
"ORDER BY jd.update_time " +
" </script>"})
List<JTDevice> getDeviceList(@Param("query") String query, @Param("online") Boolean online);
@Insert("INSERT INTO wvp_jt_device (" +
"province_id,"+
"city_id,"+
"maker_id,"+
"device_model,"+
"plate_color,"+
"plate_no,"+
"authentication_code,"+
"longitude,"+
"latitude,"+
"create_time,"+
"update_time"+
") VALUES (" +
"#{provinceId}," +
"#{cityId}," +
"#{makerId}," +
"#{deviceModel}," +
"#{plateColor}," +
"#{plateNo}," +
"#{authenticationCode}," +
"#{longitude}," +
"#{latitude}," +
"#{createTime}," +
"#{updateTime}" +
")")
void addDevice(JTDevice device);
}

View File

@@ -11,4 +11,6 @@ public interface Ijt1078Service {
void updateDevice(JTDevice deviceInDb);
PageInfo<JTDevice> getDeviceList(int page, int count, String query, Boolean online);
void addDevice(JTDevice device);
}

View File

@@ -35,4 +35,11 @@ public class jt1078ServiceImpl implements Ijt1078Service {
List<JTDevice> all = jtDeviceMapper.getDeviceList(query, online);
return new PageInfo<>(all);
}
@Override
public void addDevice(JTDevice device) {
device.setCreateTime(DateUtil.getNow());
device.setUpdateTime(DateUtil.getNow());
jtDeviceMapper.addDevice(device);
}
}