From 7634d7ff15b1fa84ea84a51a1ba6e45b11a4aa21 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期日, 27 四月 2025 11:17:34 +0800 Subject: [PATCH] SSO登录逻辑再修改 --- pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/divide/DivideCtrl.java | 219 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 219 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/divide/DivideCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/divide/DivideCtrl.java new file mode 100644 index 0000000..5819ee3 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/divide/DivideCtrl.java @@ -0,0 +1,219 @@ +package com.dy.pipIrrBase.divide; + +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.pipIrrGlobal.pojoBa.BaDivide; +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; + +/** + * @author wuzeyu + * @date 2023/12/26 11:12 + * @LastEditTime 2023/12/26 11:12 + * @Description + */ +@Slf4j +@Tag(name = "鍒嗘按鍙g鐞�", description = "鍒嗘按鍙e鍒犳敼鏌ョ瓑鎿嶄綔") +@RestController +@RequestMapping(path = "divide") +@SuppressWarnings("unchecked") +//java鐗堟湰瓒婇珮锛屽娉涘瀷绾︽潫瓒婁弗锛屾墍浠ラ厤缃甋uppressWarnings("unchecked") +public class DivideCtrl { + + private DivideSv sv; + + @Autowired + private void setSv(DivideSv sv) { this.sv = sv; } + + /** + * 瀹㈡埛绔姹傚緱鍒版墍鏈夊垎姘村彛鍚嶅瓧 + * @return 鎵�鏈夊垎姘村彛鍚嶅瓧 + */ + @Operation(summary = "鑾峰緱鍏ㄩ儴鍒嗘按鍙�", description = "杩斿洖鍏ㄩ儴鍒嗘按鍙f暟鎹�") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "杩斿洖鍏ㄩ儴鍒嗘按鍙f暟鎹紙BaseResponse.content:QueryResultVo[{}]锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = BaDivide.class))} + ) + }) + @GetMapping(path = "all") + @SsoAop() + public BaseResponse<QueryResultVo<List<BaDivide>>> all(){ + try { + QueryResultVo<List<BaDivide>> res = this.sv.selectAll() ; + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鏌ヨ鍒嗘按鍙e紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + } + + /** + * 寰楀埌涓�涓垎姘村彛鏁版嵁 + * @return 涓�涓垎姘村彛鏁版嵁 + */ + @Operation(summary = "涓�涓垎姘村彛", description = "寰楀埌涓�涓垎姘村彛鏁版嵁") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "杩斿洖涓�涓垎姘村彛鏁版嵁锛圔aseResponse.content:{}锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = BaDivide.class))} + ) + }) + @GetMapping(path = "one", consumes = MediaType.TEXT_PLAIN_VALUE) + @SsoAop() + public BaseResponse<BaDivide> one(Long id){ + return BaseResponseUtils.buildSuccess(this.sv.selectById(id)); + } + /** + * 瀹㈡埛绔姹傚緱鍒颁竴浜涘垎姘村彛鏁版嵁 + * @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 = BaDivide.class))} + ) + }) + @PostMapping(path = "some", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop() + public BaseResponse<QueryResultVo<List<BaDivide>>> some(@RequestBody DivideVo vo){ + try { + QueryResultVo<List<BaDivide>> res = this.sv.selectSome(vo) ; + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鏌ヨ鍒嗘按鍙e紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + } + + /** + * 鏂板淇濆瓨鍒嗘按鍙� + * @param po 鏂板淇濆瓨鍒嗘按鍙orm琛ㄥ崟瀵硅薄 + * @return 鏄惁鎴愬姛 + */ + @Operation(summary = "淇濆瓨鍒嗘按鍙�", description = "鎻愪氦鍒嗘按鍙f暟鎹紙form琛ㄥ崟锛夛紝杩涜淇濆瓨") + @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 BaDivide 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紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + if(count <= 0){ + return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ; + }else{ + return BaseResponseUtils.buildSuccess(true) ; + } + } + /** + * 缂栬緫淇敼鍒嗘按鍙� + * @param po 淇濆瓨鍒嗘按鍙orm琛ㄥ崟瀵硅薄 + * @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 BaDivide 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紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + if(count <= 0){ + return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ; + }else{ + return BaseResponseUtils.buildSuccess(true) ; + } + } + + + /** + * 鍒犻櫎鍒嗘按鍙� + * @param id 鍒嗘按鍙D + * @return 鏄惁鎴愬姛 + */ + @Operation(summary = "鍒犻櫎鍒嗘按鍙�", description = "鎻愪氦鍒嗘按鍙D锛岃繘琛岄�昏緫鍒犻櫎") + @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涓嶈兘涓虹┖") ; + } + int count; + try { + count = this.sv.delete(id); + } catch (Exception e) { + log.error("淇濆瓨鍒嗘按鍙e紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + if(count <= 0){ + return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ; + }else{ + return BaseResponseUtils.buildSuccess(true) ; + } + } +} + + -- Gitblit v1.8.0