package com.dy.pipIrrBase.user; 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.BaUser; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; 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 lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; @Slf4j @Tag(name = "用户管理", description = "用户增删改查等操作") @RestController @RequestMapping(path="user") @SuppressWarnings("unchecked")//java版本越高,对泛型约束越严,所以配置SuppressWarnings("unchecked") public class UserCtrl { private UserSv sv ; @Autowired private void setSv(UserSv sv){ this.sv = sv ; } /** * 客户端请求得到所有用户数据 * @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 = BaUser.class))} ) }) @PostMapping(path = "some") public BaseResponse>> some(QueryVo vo){ try { QueryResultVo> 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 = BaUser.class))} ) }) @GetMapping(path = "one") public BaseResponse one(@Parameter(description = "实体id", required = true) Long id){ return BaseResponseUtils.buildSuccess(this.sv.selectById(id)); } }