From f44135f835bf62319f9bb8a32e4592a707e5e8c1 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期日, 27 四月 2025 11:09:55 +0800 Subject: [PATCH] SSO登录逻辑再修改 --- pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateScheduling/IrrigateSchedulingCtrl.java | 198 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 198 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateScheduling/IrrigateSchedulingCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateScheduling/IrrigateSchedulingCtrl.java new file mode 100644 index 0000000..50cdabe --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateScheduling/IrrigateSchedulingCtrl.java @@ -0,0 +1,198 @@ +package com.dy.pipIrrIrrigate.irrigateScheduling; + +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.pojoIr.IrIrrigateScheduling; +import com.dy.pipIrrGlobal.pojoIr.IrProject; +import com.dy.pipIrrGlobal.voIr.VoScheduling; +import com.dy.pipIrrGlobal.voIr.VoSchedulingOne; +import com.dy.pipIrrGlobal.voSe.VoActiveCard; +import com.dy.pipIrrIrrigate.result.IrrigateResultCode; +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.http.MediaType; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * @author :WuZeYu + * @Date :2024/5/27 10:12 + * @LastEditTime :2024/5/27 10:12 + * @Description + */ +@Slf4j +@Tag(name = "浣滅墿鐏屾簤鍒跺害绠$悊", description = "浣滅墿鐏屾簤鍒跺害鎿嶄綔") +@RestController +@RequestMapping(path = "scheduling") +@RequiredArgsConstructor +public class IrrigateSchedulingCtrl { + + private final IrIrrigateSchedulingSv irIrrigateSchedulingSv; + + /** + * 娣诲姞浣滅墿鐏屾簤鍒跺害 + * + * @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 = "add", consumes = MediaType.APPLICATION_JSON_VALUE) + @Transactional(rollbackFor = Exception.class) + @SsoAop() + public BaseResponse<Boolean> add(@RequestBody @Valid IrIrrigateScheduling po, BindingResult bindingResult) { + if (bindingResult != null && bindingResult.hasErrors()) { + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + try { + Integer rec = Optional.ofNullable(irIrrigateSchedulingSv.addScheduling(po)).orElse(0); + if (rec == 0) { + return BaseResponseUtils.buildFail(IrrigateResultCode.ADD_SCHEDULING_FAIL.getMessage()); + } + } catch (Exception e) { + log.error("娣诲姞浣滅墿鐏屾簤鍒跺害寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + 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() + public BaseResponse<Boolean> delete(@RequestBody Map map) { + if (map == null || map.size() <= 0) { + BaseResponseUtils.buildFail(IrrigateResultCode.PLEASE_INPUT_SCHEDULING_ID.getMessage()); + } + Long schedulingId = Long.parseLong(map.get("id").toString()); + try { + Integer rows = irIrrigateSchedulingSv.deleteScheduling(schedulingId); + if (rows == 0) { + return BaseResponseUtils.buildFail(IrrigateResultCode.DELETE_SCHEDULING_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 IrIrrigateScheduling po, BindingResult bindingResult){ + if (bindingResult != null && bindingResult.hasErrors()) { + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + try { + Integer rec = Optional.ofNullable(irIrrigateSchedulingSv.updateScheduling(po)).orElse(0); + if (rec == 0) { + return BaseResponseUtils.buildFail(IrrigateResultCode.UPDATE_SCHEDULING_FAIL.getMessage()); + } + } catch (Exception e) { + log.error("淇敼浣滅墿鐏屾簤鍒跺害寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + return BaseResponseUtils.buildSuccess(true); + } + + /** + * 鍒嗛〉鏌ヨ + * @param vo + * @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 = VoActiveCard.class))} + ) + }) + @GetMapping(path = "some") + @SsoAop() + public BaseResponse<QueryResultVo<List<VoScheduling>>> getSchedulings(QueryVo vo) { + try { + QueryResultVo<List<VoScheduling>> res = irIrrigateSchedulingSv.getSchedulings(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 = IrProject.class))} + ) + }) + @GetMapping(path = "one") + @SsoAop() + public BaseResponse<VoSchedulingOne> one(@RequestParam Long id) { + VoSchedulingOne irScheduling = this.irIrrigateSchedulingSv.selectById(id); + + return BaseResponseUtils.buildSuccess(irScheduling); + + } +} -- Gitblit v1.8.0