fix - 处理编译问题
This commit is contained in:
parent
8f1d1d90d4
commit
c95bc10fdc
@ -1,57 +0,0 @@
|
||||
package cn.axzo.tyr.client;
|
||||
|
||||
import cn.axzo.framework.domain.page.PageQO;
|
||||
import cn.axzo.framework.domain.page.PageResp;
|
||||
import cn.axzo.framework.domain.web.ApiException;
|
||||
import cn.axzo.framework.domain.web.result.ApiPageResult;
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.feign.TyrApi;
|
||||
import cn.axzo.tyr.client.model.NewUserReq;
|
||||
import cn.axzo.tyr.client.model.QueryUserReq;
|
||||
import cn.axzo.tyr.client.model.UpdateUserReq;
|
||||
import cn.axzo.tyr.client.model.UserRes;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/9/17
|
||||
* @Description:
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class TyrClient {
|
||||
|
||||
private final TyrApi api;
|
||||
|
||||
/**
|
||||
* 老项目迁移使用
|
||||
*/
|
||||
public UserRes createUser(@Valid NewUserReq req) {
|
||||
CommonResponse<UserRes> apiResult = api.createUser(req);
|
||||
if (apiResult.getCode() == 200) {
|
||||
return apiResult.getData();
|
||||
}
|
||||
throw new RuntimeException(apiResult.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 新项目使用
|
||||
*/
|
||||
public UserRes updateUser(Long id, @Valid UpdateUserReq req) {
|
||||
ApiResult<UserRes> apiResult = api.updateUser(id, req);
|
||||
if (apiResult.isSuccess()) {
|
||||
return apiResult.getData();
|
||||
}
|
||||
throw new ApiException(apiResult.getRespCode());
|
||||
}
|
||||
|
||||
public PageResp<UserRes> fetchUsers(QueryUserReq req, PageQO page) {
|
||||
ApiPageResult<UserRes> apiPageResult = api.fetchUsers(req.toQueryMap(), page);
|
||||
if (apiPageResult.isSuccess()) {
|
||||
return apiPageResult.toPage();
|
||||
}
|
||||
throw new ApiException(apiPageResult.getRespCode());
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,6 @@
|
||||
package cn.axzo.tyr.client.config;
|
||||
|
||||
import cn.axzo.tyr.client.TyrClient;
|
||||
import cn.axzo.tyr.client.feign.TyrApi;
|
||||
import cn.axzo.tyr.client.feign.TyrFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
@ -16,13 +12,4 @@ import org.springframework.context.annotation.Configuration;
|
||||
@Configuration
|
||||
public class TyrClientAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
public TyrFallbackFactory tyrFallbackFactory() {
|
||||
return new TyrFallbackFactory();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TyrClient tyrClient(TyrApi tyrApi) {
|
||||
return new TyrClient(tyrApi);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,6 @@ import cn.axzo.tyr.client.model.product.ProductSearchListReq;
|
||||
import cn.axzo.tyr.client.model.product.ProductSearchPageReq;
|
||||
import cn.axzo.tyr.client.model.product.ProductUpdateReq;
|
||||
import cn.axzo.tyr.client.model.product.ProductVO;
|
||||
import com.sun.tools.javac.util.DefinedBy;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
package cn.axzo.tyr.client.feign;
|
||||
|
||||
import cn.axzo.framework.domain.page.PageQO;
|
||||
import cn.axzo.framework.domain.web.result.ApiPageResult;
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.model.NewUserReq;
|
||||
import cn.axzo.tyr.client.model.UpdateUserReq;
|
||||
import cn.axzo.tyr.client.model.UserRes;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/9/17
|
||||
* @Description:
|
||||
*/
|
||||
@FeignClient(name = "tyr", url = "http://localhost:8899", fallbackFactory = TyrFallbackFactory.class)
|
||||
public interface TyrApi {
|
||||
|
||||
@PostMapping(value = "/api/v1/users", consumes = APPLICATION_JSON_VALUE)
|
||||
CommonResponse<UserRes> createUser(@RequestBody NewUserReq req);
|
||||
|
||||
@PutMapping(value = "/api/v2/users/{id}", consumes = APPLICATION_JSON_VALUE)
|
||||
ApiResult<UserRes> updateUser(@PathVariable("id") Long id, @RequestBody UpdateUserReq req);
|
||||
|
||||
@GetMapping(value = "/api/v2/users")
|
||||
ApiPageResult<UserRes> fetchUsers(@RequestParam Map<String, Object> query, PageQO page);
|
||||
}
|
||||
@ -1,52 +0,0 @@
|
||||
package cn.axzo.tyr.client.feign;
|
||||
|
||||
import cn.axzo.framework.client.feign.FeignFallback;
|
||||
import cn.axzo.framework.domain.page.PageQO;
|
||||
import cn.axzo.framework.domain.web.result.ApiPageResult;
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.model.NewUserReq;
|
||||
import cn.axzo.tyr.client.model.UpdateUserReq;
|
||||
import cn.axzo.tyr.client.model.UserRes;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author: liyong.tian
|
||||
* @Date: 2022/9/17
|
||||
* @Description:
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class TyrApiFallback implements TyrApi {
|
||||
|
||||
private final FeignFallback fallback;
|
||||
|
||||
/**
|
||||
* 老项目迁移使用
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CommonResponse<UserRes> createUser(NewUserReq req) {
|
||||
log.error("[tyr-api] createUser fallback", fallback.getCause());
|
||||
return CommonResponse.error("创建用户失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 新项目推荐使用
|
||||
*/
|
||||
@Override
|
||||
public ApiResult<UserRes> updateUser(Long id, UpdateUserReq req) {
|
||||
log.error("[tyr-api] updateUser fallback", fallback.getCause());
|
||||
return fallback.resp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiPageResult<UserRes> fetchUsers(Map<String, Object> query, PageQO page) {
|
||||
log.error("[tyr-api] fetchUsers fallback", fallback.getCause());
|
||||
return fallback.pageResp();
|
||||
}
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
package cn.axzo.tyr.client.feign;
|
||||
|
||||
import cn.axzo.framework.client.feign.FeignFallback;
|
||||
import cn.axzo.framework.domain.web.code.IRespCode;
|
||||
import cn.axzo.framework.domain.web.code.RespCode;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class TyrFallbackFactory implements FallbackFactory<TyrApiFallback> {
|
||||
|
||||
// TODO: 2022/11/3 100-调整为具体的项目编号,XXX-调整为项目名
|
||||
private final IRespCode respCode = new RespCode("100" + "91001", "XXX服务不可用");
|
||||
|
||||
@Override
|
||||
public TyrApiFallback create(Throwable cause) {
|
||||
return new TyrApiFallback(new FeignFallback(cause, respCode));
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,6 @@ package cn.axzo.tyr.client.model.product;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
@ -14,16 +13,35 @@ import javax.validation.constraints.NotNull;
|
||||
* @author wangli
|
||||
* @since 2023/9/6 15:13
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ProductUpdateReq extends ProductAddReq {
|
||||
public class ProductUpdateReq {
|
||||
/**
|
||||
* 产品 ID
|
||||
*/
|
||||
@NotNull(message = "产品 ID 不能为空")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 产品名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 产品图标
|
||||
*/
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 产品所属系统域 Code
|
||||
*/
|
||||
private String dictSysCode;
|
||||
|
||||
/**
|
||||
* 上下架状态 1:上架, 0:下架
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user