pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrStManureMapper.java
@@ -16,6 +16,13 @@ public interface PrStManureMapper extends BaseMapper<PrStManure> { int deleteByPrimaryKey(Long id); /** * 逻辑删除 * @param id primaryKey * @return update count */ int deleteLogicById(Long id); int insert(PrStManure record); int insertSelective(PrStManure record); pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrStSoilMapper.java
@@ -16,6 +16,13 @@ public interface PrStSoilMapper extends BaseMapper<PrStSoil> { int deleteByPrimaryKey(Long id); /** * 逻辑删除 * @param id primaryKey * @return update count */ int deleteLogicById(Long id); int insert(PrStSoil record); int insertSelective(PrStSoil record); pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrStWeatherMapper.java
@@ -16,6 +16,13 @@ public interface PrStWeatherMapper extends BaseMapper<PrStWeather> { int deleteByPrimaryKey(Long id); /** * 逻辑删除 * @param id primaryKey * @return update count */ int deleteLogicById(Long id); int insert(PrStWeather record); int insertSelective(PrStWeather record); pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrStManureMapper.xml
@@ -43,6 +43,11 @@ delete from pr_st_manure where id = #{id,jdbcType=BIGINT} </delete> <delete id="deleteLogicById" parameterType="java.lang.Long"> <!--@mbg.generated--> update pr_st_manure set deleted = 1 where id = #{id,jdbcType=BIGINT} </delete> <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoPr.PrStManure"> <!--@mbg.generated--> insert into pr_st_manure (id, `no`, `name`, lng, pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrStSoilMapper.xml
@@ -43,6 +43,11 @@ delete from pr_st_soil where id = #{id,jdbcType=BIGINT} </delete> <delete id="deleteLogicById" parameterType="java.lang.Long"> <!--@mbg.generated--> update pr_st_soil set deleted = 1 where id = #{id,jdbcType=BIGINT} </delete> <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoPr.PrStSoil"> <!--@mbg.generated--> insert into pr_st_soil (id, `no`, `name`, lng, pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrStWeatherMapper.xml
@@ -43,6 +43,11 @@ delete from pr_st_weather where id = #{id,jdbcType=BIGINT} </delete> <delete id="deleteLogicById" parameterType="java.lang.Long"> <!--@mbg.generated--> update pr_st_weather set deleted = 1 where id = #{id,jdbcType=BIGINT} </delete> <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoPr.PrStWeather"> <!--@mbg.generated--> insert into pr_st_weather (id, `no`, `name`, lng, pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/mqtt/manure/ManureCtrl.java
@@ -1,9 +1,171 @@ package com.dy.pipIrrProject.mqtt.manure; import com.dy.common.aop.SsoAop; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import com.dy.common.webUtil.ResultCodeMsg; import com.dy.pipIrrGlobal.pojoPr.PrStManure; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; import java.util.Objects; /** * @Author: liurunyu * @Date: 2025/6/18 14:51 * @Date: 2025/6/19 10:41 * @Description */ @Slf4j @Tag(name = "水肥机管理", description = "水肥机管理") @RestController @RequestMapping(path = "manureStation") @RequiredArgsConstructor public class ManureCtrl { private ManureSv sv; @Autowired private void setSv(ManureSv sv){ this.sv = sv ; } /** * 得到一套水肥机数据 * @return 一套水肥机数据 */ @Operation(summary = "一套水肥机", description = "得到一套水肥机数据") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "返回一套水肥机数据(BaseResponse.content:{})", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = PrStManure.class))} ) }) @GetMapping(path = "one") @SsoAop() public BaseResponse<PrStManure> one(Long id){ return BaseResponseUtils.buildSuccess(this.sv.selectById(id)); } /** * 保存水肥机 * @param dto 保存水肥机form表单对象 * @return 是否成功 */ @Operation(summary = "保存水肥机", description = "提交水肥机数据(form表单),进行保存") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @PostMapping(path = "save", consumes = MediaType.APPLICATION_JSON_VALUE) @SsoAop() public BaseResponse<Boolean> save(@RequestBody @Valid ManureDto dto, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } PrStManure po = dto.toNewPo() ; po.deleted = 0 ; int count; try { count = this.sv.save(po); } catch (Exception e) { log.error("保存水肥机异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; } if(count <= 0){ return BaseResponseUtils.buildFail("数据库存储失败") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } } /** * 编辑修改水肥机 * @param dto 保存水肥机form表单对象 * @return 是否成功 */ @Operation(summary = "编辑修改水肥机", description = "提交水肥机数据(form表单),进行修改") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE) @SsoAop() public BaseResponse<Boolean> update(@RequestBody @Valid ManureDto dto, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } PrStManure po = dto.toPo() ; if(po.id == null){ return BaseResponseUtils.buildFail("无数据实体ID") ; } int count; try { count = this.sv.update(po); } catch (Exception e) { log.error("保存水肥机异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; } if(count <= 0){ return BaseResponseUtils.buildFail("数据库存储失败") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } } /** * 删除水肥机 * @param id 水肥机ID * @return 是否成功 */ @Operation(summary = "删除水肥机", description = "提交水肥机ID,进行逻辑删除") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @GetMapping(path = "delete") @SsoAop() public BaseResponse<Boolean> delete(Long id){ if(id == null){ return BaseResponseUtils.buildFail("id不能为空") ; } int count; try { count = this.sv.delete(id); } catch (Exception e) { log.error("保存水肥机异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; } if(count <= 0){ return BaseResponseUtils.buildFail("数据库存储失败") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } } } pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/mqtt/manure/ManureDto.java
@@ -1,9 +1,64 @@ package com.dy.pipIrrProject.mqtt.manure; import com.dy.pipIrrGlobal.pojoPr.PrStManure; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotEmpty; import lombok.Data; /** * @Author: liurunyu * @Date: 2025/6/18 14:52 * @Description */ @Data @Schema(name = "水肥机") public class ManureDto { public static final long serialVersionUID = 202506091032001L; /** * 主键 */ public String id; /** * 水肥机名称 */ @NotEmpty(message = "水肥机名称不能为空") //不能为空也不能为null public String name; /** * 水肥机编号 */ @NotEmpty(message = "水肥机编号不能为空") //不能为空也不能为null public Integer no; /** * 经度 */ public Double lng; /** * 纬度 */ public Double lat; /** * 备注 */ public String remark; public PrStManure toNewPo(){ PrStManure po = new PrStManure(); po.name = this.name; po.no = this.no; po.lng = this.lng; po.lat = this.lat; po.remark = this.remark; return po; } public PrStManure toPo(){ PrStManure po = this.toNewPo(); po.id = Long.parseLong(this.id) ; return po; } } pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/mqtt/manure/ManureQo.java
File was deleted pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/mqtt/manure/ManureSv.java
@@ -1,10 +1,12 @@ package com.dy.pipIrrProject.mqtt.manure; import com.dy.pipIrrGlobal.daoPr.PrStManureMapper; import com.dy.pipIrrGlobal.pojoPr.PrStManure; import com.dy.pipIrrGlobal.voPr.VoMqttSimple; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -23,4 +25,42 @@ public List<VoMqttSimple> allSimple(){ return this.dao.selectAllSimple() ; } /** * 得到一个实体 * @param id 实体ID * @return 实体 */ public PrStManure selectById(Long id){ return this.dao.selectById(id) ; } /** * 保存(添加)视频监控点 * @param po * @return */ @Transactional Integer save(PrStManure po) { return dao.insert(po); } /** * 修改实体 * @param po 实体 * @return 数量 */ @Transactional public int update(PrStManure po) { return this.dao.updateByPrimaryKeySelective(po); } /** * 保存修改实体 * @param id 实体ID * @return 影响记录数量 */ @Transactional public int delete(Long id){ return this.dao.deleteLogicById(id) ; } } pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/mqtt/soil/SoilCtrl.java
New file @@ -0,0 +1,171 @@ package com.dy.pipIrrProject.mqtt.soil; import com.dy.common.aop.SsoAop; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import com.dy.common.webUtil.ResultCodeMsg; import com.dy.pipIrrGlobal.pojoPr.PrStSoil; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; import java.util.Objects; /** * @Author: liurunyu * @Date: 2025/6/19 10:41 * @Description */ @Slf4j @Tag(name = "墒情站管理", description = "墒情站管理") @RestController @RequestMapping(path = "soilStation") @RequiredArgsConstructor public class SoilCtrl { private SoilSv sv; @Autowired private void setSv(SoilSv sv){ this.sv = sv ; } /** * 得到一套墒情站数据 * @return 一套墒情站数据 */ @Operation(summary = "一套墒情站", description = "得到一套墒情站数据") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "返回一套墒情站数据(BaseResponse.content:{})", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = PrStSoil.class))} ) }) @GetMapping(path = "one") @SsoAop() public BaseResponse<PrStSoil> one(Long id){ return BaseResponseUtils.buildSuccess(this.sv.selectById(id)); } /** * 保存墒情站 * @param dto 保存墒情站form表单对象 * @return 是否成功 */ @Operation(summary = "保存墒情站", description = "提交墒情站数据(form表单),进行保存") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @PostMapping(path = "save", consumes = MediaType.APPLICATION_JSON_VALUE) @SsoAop() public BaseResponse<Boolean> save(@RequestBody @Valid SoilDto dto, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } PrStSoil po = dto.toNewPo() ; po.deleted = 0 ; int count; try { count = this.sv.save(po); } catch (Exception e) { log.error("保存墒情站异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; } if(count <= 0){ return BaseResponseUtils.buildFail("数据库存储失败") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } } /** * 编辑修改墒情站 * @param dto 保存墒情站form表单对象 * @return 是否成功 */ @Operation(summary = "编辑修改墒情站", description = "提交墒情站数据(form表单),进行修改") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE) @SsoAop() public BaseResponse<Boolean> update(@RequestBody @Valid SoilDto dto, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } PrStSoil po = dto.toPo() ; if(po.id == null){ return BaseResponseUtils.buildFail("无数据实体ID") ; } int count; try { count = this.sv.update(po); } catch (Exception e) { log.error("保存墒情站异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; } if(count <= 0){ return BaseResponseUtils.buildFail("数据库存储失败") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } } /** * 删除墒情站 * @param id 墒情站ID * @return 是否成功 */ @Operation(summary = "删除墒情站", description = "提交墒情站ID,进行逻辑删除") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @GetMapping(path = "delete") @SsoAop() public BaseResponse<Boolean> delete(Long id){ if(id == null){ return BaseResponseUtils.buildFail("id不能为空") ; } int count; try { count = this.sv.delete(id); } catch (Exception e) { log.error("保存墒情站异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; } if(count <= 0){ return BaseResponseUtils.buildFail("数据库存储失败") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } } } pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/mqtt/soil/SoilDto.java
New file @@ -0,0 +1,64 @@ package com.dy.pipIrrProject.mqtt.soil; import com.dy.pipIrrGlobal.pojoPr.PrStSoil; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotEmpty; import lombok.Data; /** * @Author: liurunyu * @Date: 2025/6/18 14:52 * @Description */ @Data @Schema(name = "墒情站") public class SoilDto { public static final long serialVersionUID = 202506191032001L; /** * 主键 */ public String id; /** * 墒情站名称 */ @NotEmpty(message = "墒情站名称不能为空") //不能为空也不能为null public String name; /** * 墒情站编号 */ @NotEmpty(message = "墒情站编号不能为空") //不能为空也不能为null public Integer no; /** * 经度 */ public Double lng; /** * 纬度 */ public Double lat; /** * 备注 */ public String remark; public PrStSoil toNewPo(){ PrStSoil po = new PrStSoil(); po.name = this.name; po.no = this.no; po.lng = this.lng; po.lat = this.lat; po.remark = this.remark; return po; } public PrStSoil toPo(){ PrStSoil po = this.toNewPo(); po.id = Long.parseLong(this.id) ; return po; } } pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/mqtt/soil/SoilSv.java
@@ -1,10 +1,12 @@ package com.dy.pipIrrProject.mqtt.soil; import com.dy.pipIrrGlobal.daoPr.PrStSoilMapper; import com.dy.pipIrrGlobal.pojoPr.PrStSoil; import com.dy.pipIrrGlobal.voPr.VoMqttSimple; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -23,4 +25,43 @@ public List<VoMqttSimple> allSimple(){ return this.dao.selectAllSimple() ; } /** * 得到一个实体 * @param id 实体ID * @return 实体 */ public PrStSoil selectById(Long id){ return this.dao.selectById(id) ; } /** * 保存(添加)视频监控点 * @param po * @return */ @Transactional Integer save(PrStSoil po) { return dao.insert(po); } /** * 修改实体 * @param po 实体 * @return 数量 */ @Transactional public int update(PrStSoil po) { return this.dao.updateByPrimaryKeySelective(po); } /** * 保存修改实体 * @param id 实体ID * @return 影响记录数量 */ @Transactional public int delete(Long id){ return this.dao.deleteLogicById(id) ; } } pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/mqtt/weather/WeatherCtrl.java
New file @@ -0,0 +1,171 @@ package com.dy.pipIrrProject.mqtt.weather; import com.dy.common.aop.SsoAop; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import com.dy.common.webUtil.ResultCodeMsg; import com.dy.pipIrrGlobal.pojoPr.PrStWeather; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; import java.util.Objects; /** * @Author: liurunyu * @Date: 2025/6/19 10:41 * @Description */ @Slf4j @Tag(name = "气象站管理", description = "气象站管理") @RestController @RequestMapping(path = "weatherStation") @RequiredArgsConstructor public class WeatherCtrl { private WeatherSv sv; @Autowired private void setSv(WeatherSv sv){ this.sv = sv ; } /** * 得到一套气象站数据 * @return 一套气象站数据 */ @Operation(summary = "一套气象站", description = "得到一套气象站数据") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "返回一套气象站数据(BaseResponse.content:{})", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = PrStWeather.class))} ) }) @GetMapping(path = "one") @SsoAop() public BaseResponse<PrStWeather> one(Long id){ return BaseResponseUtils.buildSuccess(this.sv.selectById(id)); } /** * 保存气象站 * @param dto 保存气象站form表单对象 * @return 是否成功 */ @Operation(summary = "保存气象站", description = "提交气象站数据(form表单),进行保存") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @PostMapping(path = "save", consumes = MediaType.APPLICATION_JSON_VALUE) @SsoAop() public BaseResponse<Boolean> save(@RequestBody @Valid WeatherDto dto, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } PrStWeather po = dto.toNewPo() ; po.deleted = 0 ; int count; try { count = this.sv.save(po); } catch (Exception e) { log.error("保存气象站异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; } if(count <= 0){ return BaseResponseUtils.buildFail("数据库存储失败") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } } /** * 编辑修改气象站 * @param dto 保存气象站form表单对象 * @return 是否成功 */ @Operation(summary = "编辑修改气象站", description = "提交气象站数据(form表单),进行修改") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE) @SsoAop() public BaseResponse<Boolean> update(@RequestBody @Valid WeatherDto dto, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } PrStWeather po = dto.toPo() ; if(po.id == null){ return BaseResponseUtils.buildFail("无数据实体ID") ; } int count; try { count = this.sv.update(po); } catch (Exception e) { log.error("保存气象站异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; } if(count <= 0){ return BaseResponseUtils.buildFail("数据库存储失败") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } } /** * 删除气象站 * @param id 气象站ID * @return 是否成功 */ @Operation(summary = "删除气象站", description = "提交气象站ID,进行逻辑删除") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @GetMapping(path = "delete") @SsoAop() public BaseResponse<Boolean> delete(Long id){ if(id == null){ return BaseResponseUtils.buildFail("id不能为空") ; } int count; try { count = this.sv.delete(id); } catch (Exception e) { log.error("保存气象站异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; } if(count <= 0){ return BaseResponseUtils.buildFail("数据库存储失败") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } } } pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/mqtt/weather/WeatherDto.java
New file @@ -0,0 +1,64 @@ package com.dy.pipIrrProject.mqtt.weather; import com.dy.pipIrrGlobal.pojoPr.PrStWeather; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotEmpty; import lombok.Data; /** * @Author: liurunyu * @Date: 2025/6/18 14:52 * @Description */ @Data @Schema(name = "气象站") public class WeatherDto { public static final long serialVersionUID = 202506191038001L; /** * 主键 */ public String id; /** * 气象站名称 */ @NotEmpty(message = "气象站名称不能为空") //不能为空也不能为null public String name; /** * 气象站编号 */ @NotEmpty(message = "气象站编号不能为空") //不能为空也不能为null public Integer no; /** * 经度 */ public Double lng; /** * 纬度 */ public Double lat; /** * 备注 */ public String remark; public PrStWeather toNewPo(){ PrStWeather po = new PrStWeather(); po.name = this.name; po.no = this.no; po.lng = this.lng; po.lat = this.lat; po.remark = this.remark; return po; } public PrStWeather toPo(){ PrStWeather po = this.toNewPo(); po.id = Long.parseLong(this.id) ; return po; } } pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/mqtt/weather/WeatherSv.java
@@ -1,10 +1,12 @@ package com.dy.pipIrrProject.mqtt.weather; import com.dy.pipIrrGlobal.daoPr.PrStWeatherMapper; import com.dy.pipIrrGlobal.pojoPr.PrStWeather; import com.dy.pipIrrGlobal.voPr.VoMqttSimple; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -23,4 +25,43 @@ public List<VoMqttSimple> allSimple(){ return this.dao.selectAllSimple() ; } /** * 得到一个实体 * @param id 实体ID * @return 实体 */ public PrStWeather selectById(Long id){ return this.dao.selectById(id) ; } /** * 保存(添加)视频监控点 * @param po * @return */ @Transactional Integer save(PrStWeather po) { return dao.insert(po); } /** * 修改实体 * @param po 实体 * @return 数量 */ @Transactional public int update(PrStWeather po) { return this.dao.updateByPrimaryKeySelective(po); } /** * 保存修改实体 * @param id 实体ID * @return 影响记录数量 */ @Transactional public int delete(Long id){ return this.dao.deleteLogicById(id) ; } }