From 2938172b377e5ed7a55e5dde4a218244445e8a6e Mon Sep 17 00:00:00 2001
From: wuzeyu <1223318623@qq.com>
Date: 星期三, 15 五月 2024 17:10:12 +0800
Subject: [PATCH] 田间灌溉项目管理 修改项目信息接口 修改项目状态接口
---
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/result/IrrigateResultCode.java | 1
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrProjectMapper.java | 15 +++
pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrProjectMapper.xml | 52 ++++++++++++
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectCtrl.java | 113 +++++++++++++++++++++++++++-
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectSv.java | 46 +++++++++++
5 files changed, 219 insertions(+), 8 deletions(-)
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrProjectMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrProjectMapper.java
index 6f69940..91b2091 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrProjectMapper.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrProjectMapper.java
@@ -3,7 +3,9 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dy.pipIrrGlobal.pojoIr.IrProject;
import com.dy.pipIrrGlobal.pojoPr.PrController;
+import com.dy.pipIrrGlobal.pojoPr.PrIntake;
import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
/**
* @author :WuZeYu
@@ -13,10 +15,19 @@
*/
@Mapper
public interface IrProjectMapper extends BaseMapper<IrProject> {
-
+//澧�
int insertSelective(IrProject record);
-
+//鍒�
int deleteLogicById(Long id);
+//鏀�
+ int updateByPrimaryKeySelective(IrProject record);
+
+ /**
+ * 淇敼椤圭洰鐘舵��
+ * @param id
+ * @return
+ */
+ int updateProjectState(IrProject record);
/**
* 鏍规嵁涓嬬骇Id鑾峰彇涓婁竴绾у湴鍧�Id
diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrProjectMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrProjectMapper.xml
index 81848e5..bc12c84 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrProjectMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrProjectMapper.xml
@@ -17,7 +17,7 @@
<result column="operate_time" jdbcType="TIMESTAMP" property="operateDt" />
<result column="deleted" jdbcType="TINYINT" property="deleted" />
</resultMap>
-
+ <!--娣诲姞-->
<insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrProject">
<!--@mbg.generated-->
insert into ir_project
@@ -108,11 +108,59 @@
on dis_vil.supperId = dis_tow.id
where dis_vil.id = #{vaId,jdbcType=BIGINT}
</select>
-
+ <!--閫昏緫鍒犻櫎-->
<delete id="deleteLogicById" parameterType="java.lang.Long">
<!--@mbg.generated-->
update ir_project
set deleted = 1
where id = #{id,jdbcType=BIGINT}
</delete>
+
+ <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrProject">
+ update ir_project
+ <set>
+ <if test="projectName != null">
+ project_name = #{projectName,jdbcType=VARCHAR},
+ </if>
+ <if test="provinceId != null">
+ province_id = #{provinceId,jdbcType=BIGINT},
+ </if>
+ <if test="cityId != null">
+ city_id = #{cityId,jdbcType=BIGINT},
+ </if>
+ <if test="countyId != null">
+ county_id = #{countyId,jdbcType=BIGINT},
+ </if>
+ <if test="townId != null">
+ town_id = #{townId,jdbcType=BIGINT},
+ </if>
+ <if test="villageId != null">
+ village_id = #{villageId,jdbcType=BIGINT},
+ </if>
+ <if test="projectState != null">
+ project_state = #{projectState,jdbcType=TINYINT},
+ </if>
+ <if test="remarks != null">
+ remarks = #{remarks,jdbcType=VARCHAR},
+ </if>
+ <if test="operator != null">
+ operator = #{operator,jdbcType=BIGINT},
+ </if>
+ <if test="operateDt != null">
+ operate_time = #{operateDt,jdbcType=TIMESTAMP},
+ </if>
+ <if test="deleted != null">
+ deleted = #{deleted,jdbcType=TINYINT},
+ </if>
+ </set>
+ where id = #{id,jdbcType=BIGINT}
+ </update>
+
+ <update id="updateProjectState">
+ update ir_project
+ set project_state = #{projectState,jdbcType=TINYINT},
+ operator = #{operator,jdbcType=BIGINT},
+ operate_time = #{operateDt,jdbcType=TIMESTAMP}
+ where id = #{id,jdbcType=BIGINT}
+ </update>
</mapper>
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectCtrl.java
index 409ed4e..ddcbe74 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectCtrl.java
@@ -24,9 +24,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
+import java.lang.reflect.Array;
+import java.util.*;
/**
* @author :WuZeYu
@@ -77,6 +76,20 @@
return BaseResponseUtils.buildSuccess(true);
}
+ /**
+ * 閫昏緫鍒犻櫎椤圭洰
+ * @param map
+ * @return
+ */
+ @Operation(summary = "閫昏緫鍒犻櫎椤圭洰", description = "閫昏緫鍒犻櫎椤圭洰")
+ @ApiResponses(value = {
+ @ApiResponse(
+ responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+ description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�",
+ content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+ schema = @Schema(implementation = Boolean.class))}
+ )
+ })
@PostMapping(path = "delete", consumes = MediaType.APPLICATION_JSON_VALUE)
@Transactional(rollbackFor = Exception.class)
@SsoAop()
@@ -84,7 +97,7 @@
if (map == null || map.size() <= 0) {
BaseResponseUtils.buildFail(IrrigateResultCode.PLEASE_INPUT_PROJECT_ID.getMessage());
}
- Long projectId = Long.parseLong(map.get("projectId").toString());
+ Long projectId = Long.parseLong(map.get("id").toString());
try {
Integer rows = projectSv.deleteProject(projectId);
if (rows == 0) {
@@ -96,4 +109,96 @@
}
return BaseResponseUtils.buildSuccess(true);
}
+
+ /**
+ * 鎵归噺鍒犻櫎
+ * @param projectIds
+ * @return
+ */
+ @PostMapping(path = "delete_batch", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @Transactional(rollbackFor = Exception.class)
+ @SsoAop()
+ public BaseResponse<Boolean> delete_batch(@RequestBody List<Long> projectIds) {
+ if (projectIds == null || projectIds.size() <= 0) {
+ BaseResponseUtils.buildFail(IrrigateResultCode.PLEASE_INPUT_PROJECT_ID.getMessage());
+ }
+ for (int i = 0; i < projectIds.size(); i++) {
+ Long projectId = projectIds.get(i);
+ try {
+ Integer rows = projectSv.deleteProject(projectId);
+ if (rows == 0) {
+ return BaseResponseUtils.buildFail(IrrigateResultCode.DELETE_PROJECT_FAIL.getMessage());
+ }
+ } catch (Exception e) {
+ log.error("鍒犻櫎椤圭洰寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+ return BaseResponseUtils.buildSuccess(true);
+ }
+
+ /**
+ * 淇敼椤圭洰淇℃伅
+ * @param po
+ * @param bindingResult
+ * @return
+ */
+ @Operation(summary = "淇敼椤圭洰淇℃伅", description = "淇敼椤圭洰淇℃伅")
+ @ApiResponses(value = {
+ @ApiResponse(
+ responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+ description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�",
+ content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+ schema = @Schema(implementation = Boolean.class))}
+ )
+ })
+ @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @Transactional(rollbackFor = Exception.class)
+ @SsoAop()
+ public BaseResponse<Boolean> update(@RequestBody @Valid IrProject po, BindingResult bindingResult){
+ if (bindingResult != null && bindingResult.hasErrors()) {
+ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+ try {
+ Integer rec = Optional.ofNullable(projectSv.updateProject(po)).orElse(0);
+ if (rec == 0) {
+ return BaseResponseUtils.buildFail(IrrigateResultCode.UPDATE_PROJECT_FAIL.getMessage());
+ }
+ } catch (Exception e) {
+ log.error("淇敼椤圭洰寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ return BaseResponseUtils.buildSuccess(true);
+ }
+
+ /**
+ * 淇敼椤圭洰鐘舵��
+ * @param po
+ * @param
+ * @return
+ */
+ @Operation(summary = "淇敼椤圭洰鐘舵��", description = "淇敼椤圭洰鐘舵��")
+ @ApiResponses(value = {
+ @ApiResponse(
+ responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+ description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�",
+ content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+ schema = @Schema(implementation = Boolean.class))}
+ )
+ })
+ @PostMapping(path = "update_state", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @Transactional(rollbackFor = Exception.class)
+ @SsoAop()
+ public BaseResponse<Boolean> update_state(@RequestBody IrProject po){
+ try {
+ Integer rec = Optional.ofNullable(projectSv.updateProjectState(po)).orElse(0);
+ if (rec == 0) {
+ return BaseResponseUtils.buildFail(IrrigateResultCode.UPDATE_PROJECT_FAIL.getMessage());
+ }
+ } catch (Exception e) {
+ log.error("淇敼椤圭洰寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ return BaseResponseUtils.buildSuccess(true);
+ }
}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectSv.java
index 3a5ce63..3d9e86d 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectSv.java
@@ -67,4 +67,50 @@
}
return 1;
}
+
+ /**
+ * 淇敼椤圭洰淇℃伅
+ * @param po
+ * @return
+ */
+ public Integer updateProject(IrProject po){
+ po.setOperateDt(new Date());
+ if (po.getVillageId() != null) {
+ po.setTownId(irProjectMapper.getSupperByVillageId(po.getVillageId()));
+ po.setCountyId(irProjectMapper.getSupperByVillageId(po.getTownId()));
+ po.setCityId(irProjectMapper.getSupperByVillageId(po.getCountyId()));
+ po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId()));
+ }
+ if (po.getTownId() != null) {
+ po.setCountyId(irProjectMapper.getSupperByVillageId(po.getTownId()));
+ po.setCityId(irProjectMapper.getSupperByVillageId(po.getCountyId()));
+ po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId()));
+ }
+ if (po.getCountyId() != null) {
+ po.setCityId(irProjectMapper.getSupperByVillageId(po.getCountyId()));
+ po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId()));
+ }
+ if (po.getCityId() != null) {
+ po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId()));
+ }
+ int rows = irProjectMapper.updateByPrimaryKeySelective(po);
+ if (rows == 0){
+ return 0;
+ }
+ return 1;
+ }
+
+ /**
+ * 淇敼椤圭洰鐘舵��
+ * @param po
+ * @return
+ */
+ public Integer updateProjectState(IrProject po){
+ po.setOperateDt(new Date());
+ int rows = irProjectMapper.updateProjectState(po);
+ if (rows == 0){
+ return 0;
+ }
+ return 1;
+ }
}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/result/IrrigateResultCode.java b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/result/IrrigateResultCode.java
index f165eaf..57eaebf 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/result/IrrigateResultCode.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/result/IrrigateResultCode.java
@@ -19,6 +19,7 @@
ADD_PROJECT_FAIL(10001, "椤圭洰娣诲姞澶辫触"),
PLEASE_INPUT_PROJECT_ID(10002, "璇疯緭鍏ラ」鐩甀D"),
DELETE_PROJECT_FAIL(10003, "椤圭洰鍒犻櫎澶辫触"),
+ UPDATE_PROJECT_FAIL(10004, "椤圭洰淇敼澶辫触"),
NO_DIVIDES(10001, "鏃犵鍚堟潯浠剁殑鍒嗘按鎴胯褰�");
--
Gitblit v1.8.0