增加 CommonResult 的 check 逻辑
This commit is contained in:
@@ -44,9 +44,7 @@ public interface DeptApi {
|
||||
* @return 部门 Map
|
||||
*/
|
||||
default Map<Long, DeptRespDTO> getDeptMap(Set<Long> ids) {
|
||||
CommonResult<List<DeptRespDTO>> result = getDepts(ids);
|
||||
result.checkError();
|
||||
return CollectionUtils.convertMap(result.getData(), DeptRespDTO::getId);
|
||||
return CollectionUtils.convertMap(getDepts(ids).getCheckedData(), DeptRespDTO::getId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.system.api.errorcode;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.system.api.errorcode.dto.ErrorCodeAutoGenerateReqDTO;
|
||||
import cn.iocoder.yudao.module.system.api.errorcode.dto.ErrorCodeRespDTO;
|
||||
import cn.iocoder.yudao.module.system.enums.ApiConstants;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||
@Api(tags = "RPC 服务 - 错误码")
|
||||
public interface ErrorCodeApi {
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/oauth2/token";
|
||||
|
||||
@PostMapping(PREFIX + "/auto-generate")
|
||||
@ApiOperation("自动创建错误码")
|
||||
CommonResult<Boolean> autoGenerateErrorCodes(@Valid @RequestBody List<ErrorCodeAutoGenerateReqDTO> autoGenerateDTOs);
|
||||
|
||||
@GetMapping(PREFIX + "/list")
|
||||
@ApiOperation(value = "增量获得错误码数组", notes = "如果 minUpdateTime 为空时,则获取所有错误码")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "applicationName", value = "应用名", example = "system-server", required = true, dataTypeClass = String.class),
|
||||
@ApiImplicitParam(name = "minUpdateTime", value = "最小更新时间", dataTypeClass = Date.class)
|
||||
})
|
||||
CommonResult<List<ErrorCodeRespDTO>> getErrorCodeList(@RequestParam(value = "applicationName") String applicationName,
|
||||
@RequestParam(value = "minUpdateTime", required = false) Date minUpdateTime);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.system.api.errorcode.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 错误码自动生成 DTO
|
||||
*
|
||||
* @author dylan
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ErrorCodeAutoGenerateReqDTO {
|
||||
|
||||
/**
|
||||
* 应用名
|
||||
*/
|
||||
@NotNull(message = "应用名不能为空")
|
||||
private String applicationName;
|
||||
/**
|
||||
* 错误码编码
|
||||
*/
|
||||
@NotNull(message = "错误码编码不能为空")
|
||||
private Integer code;
|
||||
/**
|
||||
* 错误码错误提示
|
||||
*/
|
||||
@NotEmpty(message = "错误码错误提示不能为空")
|
||||
private String message;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.system.api.errorcode.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 错误码的 Response DTO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Data
|
||||
public class ErrorCodeRespDTO {
|
||||
|
||||
/**
|
||||
* 错误码编码
|
||||
*/
|
||||
private Integer code;
|
||||
/**
|
||||
* 错误码错误提示
|
||||
*/
|
||||
private String message;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
@@ -49,9 +49,7 @@ public interface AdminUserApi {
|
||||
* @return 用户 Map
|
||||
*/
|
||||
default Map<Long, AdminUserRespDTO> getUserMap(Collection<Long> ids) {
|
||||
CommonResult<List<AdminUserRespDTO>> getUsersResult = getUsers(ids);
|
||||
getUsersResult.checkError();
|
||||
return CollectionUtils.convertMap(getUsersResult.getData(), AdminUserRespDTO::getId);
|
||||
return CollectionUtils.convertMap(getUsers(ids).getCheckedData(), AdminUserRespDTO::getId);
|
||||
}
|
||||
|
||||
@GetMapping(PREFIX + "/valid")
|
||||
|
||||
Reference in New Issue
Block a user