From d9437e8c8b95377fde98f5ed9f66e54d9d59e4c6 Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期二, 08 四月 2025 17:27:22 +0800 Subject: [PATCH] 小程序获取项目列表取消分页功能 --- pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/clientType/ClientTypeCtrl.java | 222 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 222 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/clientType/ClientTypeCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/clientType/ClientTypeCtrl.java new file mode 100644 index 0000000..01a550a --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/clientType/ClientTypeCtrl.java @@ -0,0 +1,222 @@ +package com.dy.pipIrrBase.clientType; + + +import com.dy.common.aop.SsoAop; +import com.dy.common.webUtil.BaseResponse; +import com.dy.common.webUtil.BaseResponseUtils; +import com.dy.common.webUtil.QueryResultVo; +import com.dy.common.webUtil.ResultCodeMsg; +import com.dy.pipIrrBase.user.QueryVo; +import com.dy.pipIrrGlobal.pojoBa.BaClientType; +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.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.List; +import java.util.Objects; + +@Slf4j +@Tag(name = "鍐滄埛绫诲瀷绠$悊", description = "鍐滄埛绫诲瀷澧炲垹鏀规煡绛夋搷浣�") +@RestController +@RequestMapping(path="clientType") +@SuppressWarnings("unchecked")//java鐗堟湰瓒婇珮锛屽娉涘瀷绾︽潫瓒婁弗锛屾墍浠ラ厤缃甋uppressWarnings("unchecked") +public class ClientTypeCtrl { + + private ClientTypeSv sv ; + + @Autowired + private void setSv(ClientTypeSv sv){ + this.sv = sv ; + } + + /** + * 瀹㈡埛绔姹傚緱鍒版墍鏈夊啘鎴风被鍨嬫暟鎹� + * @return 鎵�鏈夊啘鎴风被鍨嬫暟鎹� + */ + @Operation(summary = "鑾峰緱鍏ㄩ儴鍐滄埛绫诲瀷", description = "杩斿洖鍏ㄩ儴鍐滄埛绫诲瀷鏁版嵁") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "杩斿洖鍏ㄩ儴鍐滄埛绫诲瀷鏁版嵁锛圔aseResponse.content:QueryResultVo[{}]锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = BaClientType.class))} + ) + }) + @GetMapping(path = "all") + @SsoAop() + public BaseResponse<QueryResultVo<List<BaClientType>>> all(){ + try { + QueryResultVo<List<BaClientType>> res = this.sv.selectAll() ; + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鏌ヨ鍐滄埛绫诲瀷寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + } + + /** + * 瀹㈡埛绔姹傚緱鍒颁竴椤靛啘鎴风被鍨嬫暟鎹� + * @return 鎵�鏈夊啘鎴风被鍨嬫暟鎹� + */ + @Operation(summary = "鑾峰緱涓�椤靛啘鎴风被鍨�", description = "杩斿洖涓�椤靛啘鎴风被鍨嬫暟鎹�") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "杩斿洖涓�椤靛啘鎴风被鍨嬫暟鎹紙BaseResponse.content:QueryResultVo[{}]锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = BaClientType.class))} + ) + }) + @PostMapping(path = "some", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop() + public BaseResponse<QueryResultVo<List<BaClientType>>> some(@RequestBody @Valid QueryVo vo){ + try { + QueryResultVo<List<BaClientType>> res = this.sv.selectSome(vo) ; + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鏌ヨ鍐滄埛绫诲瀷寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + } + + /** + * 寰楀埌涓�涓啘鎴风被鍨嬫暟鎹� + * @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 = BaClientType.class))} + ) + }) + @GetMapping(path = "one", consumes = MediaType.TEXT_PLAIN_VALUE) + @SsoAop() + public BaseResponse<BaClientType> one(Long id){ + return BaseResponseUtils.buildSuccess(this.sv.selectById(id)); + } + + /** + * 淇濆瓨鍐滄埛绫诲瀷 + * @param po 淇濆瓨鍐滄埛绫诲瀷form琛ㄥ崟瀵硅薄 + * @return 鏄惁鎴愬姛 + */ + @Operation(summary = "淇濆瓨鍐滄埛绫诲瀷", description = "鎻愪氦鍐滄埛绫诲瀷鏁版嵁锛坒orm琛ㄥ崟锛夛紝杩涜淇濆瓨") + @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 = "save", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop() + public BaseResponse<Boolean> save(@RequestBody @Valid BaClientType po, BindingResult bindingResult){ + if(bindingResult != null && bindingResult.hasErrors()){ + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + po.id = null ; + 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 po 淇濆瓨鍐滄埛绫诲瀷form琛ㄥ崟瀵硅薄 + * @return 鏄惁鎴愬姛 + */ + @Operation(summary = "缂栬緫淇敼鍐滄埛绫诲瀷", description = "鎻愪氦鍐滄埛绫诲瀷鏁版嵁锛坒orm琛ㄥ崟锛夛紝杩涜淇敼") + @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) + @SsoAop() + public BaseResponse<Boolean> update(@RequestBody @Valid BaClientType po, BindingResult bindingResult){ + if(bindingResult != null && bindingResult.hasErrors()){ + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + if(po.id == null){ + return BaseResponseUtils.buildFail("鏃犳暟鎹疄浣揑D") ; + } + 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 = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = Boolean.class))} + ) + }) + @GetMapping(path = "delete", consumes = MediaType.TEXT_PLAIN_VALUE) + @SsoAop() + public BaseResponse<Boolean> delete(Long id){ + if(id == null){ + return BaseResponseUtils.buildFail("id涓嶈兘涓虹┖") ; + } + Long clientCount = this.sv.selectClientByType(id) ; + if(clientCount > 0){ + return BaseResponseUtils.buildFail("鍒犻櫎澶辫触锛屽瓨鍦�" + clientCount + "涓啘鎴峰綊灞炴绫诲瀷锛岃绫诲瀷涓嶈兘琚垹闄�") ; + }else{ + 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) ; + } + } + } + +} -- Gitblit v1.8.0