Commit 55a3ab0f by wnb0128

Merge branch 'dev' of 192.168.3.233:open-source/chejia-smart-admin into dev

2 parents 4fcf50fa 1683233e
Showing 20 changed files with 187 additions and 242 deletions
package com.glsx.admin.controller; package com.glsx.admin.controller;
import com.glsx.admin.pojo.request.ProductReq;
import com.glsx.admin.remote.IndexFeignClient; import com.glsx.admin.remote.IndexFeignClient;
import com.glsx.biz.user.common.entity.User; import com.glsx.biz.user.common.entity.User;
import com.glsx.biz.user.service.UserService; import com.glsx.biz.user.service.UserService;
...@@ -8,13 +7,15 @@ import com.glsx.cloudframework.exception.ServiceException; ...@@ -8,13 +7,15 @@ import com.glsx.cloudframework.exception.ServiceException;
import com.glsx.plat.core.web.R; import com.glsx.plat.core.web.R;
import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
/** /**
* @Title: IndexController.java * @Title: IndexController.java
* @Description: 远程服务调用demo * @Description: 远程服务调用demo
* @author think.wang * @author think.wang
* @version V1.0 * @version V1.0
* @Company: Didihu.com.cn * @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017 * @Copyright Copyright (c) 2017
*/ */
...@@ -26,7 +27,7 @@ public class IndexController { ...@@ -26,7 +27,7 @@ public class IndexController {
@DubboReference(version = "1.0.0") @DubboReference(version = "1.0.0")
private UserService userService; private UserService userService;
@ResponseBody @ResponseBody
@RequestMapping("/home") @RequestMapping("/home")
public R home(){ public R home(){
...@@ -39,13 +40,4 @@ public class IndexController { ...@@ -39,13 +40,4 @@ public class IndexController {
return R.ok().data(indexFeignClient.getHome()); //feign调用远程服务 return R.ok().data(indexFeignClient.getHome()); //feign调用远程服务
} }
@ResponseBody
@RequestMapping(value = "/getProduct", method = {RequestMethod.GET, RequestMethod.POST})
public R getProduct(@RequestParam("url") String url, @RequestParam("name") String name){
ProductReq product = new ProductReq();
product.setIconUrl(url);
product.setProductName(name);
return R.ok().data(indexFeignClient.getProduct(product)); //feign调用远程服务
}
} }
package com.glsx.admin.controller; package com.glsx.admin.controller;
import javax.validation.groups.Default;
import java.util.List; import java.util.List;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glsx.admin.exception.BusinessException; import com.glsx.admin.exception.BusinessException;
import com.glsx.admin.exception.ResultEnum; import com.glsx.admin.exception.ResultEnum;
import com.glsx.admin.pojo.request.SmartProductReq; import com.glsx.admin.pojo.GroupA;
import com.glsx.admin.pojo.response.SmartDeviceOrderResp; import com.glsx.admin.pojo.request.ProductReq;
import com.glsx.admin.pojo.response.SmartProductResp; import com.glsx.admin.pojo.response.DeviceOrderResp;
import com.glsx.admin.pojo.response.ProductResp;
import com.glsx.admin.remote.ProductFeignClient; import com.glsx.admin.remote.ProductFeignClient;
import com.glsx.plat.common.utils.StringUtils; import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.core.web.R; import com.glsx.plat.core.web.R;
...@@ -40,25 +42,22 @@ public class ProductController { ...@@ -40,25 +42,22 @@ public class ProductController {
* @return 结果 * @return 结果
*/ */
@RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST})
public R getList(SmartProductReq req) { public R getList(ProductReq req) {
log.info("$$$$ /product/getList param: {}", JSON.toJSONString(req)); log.info("$$$$ /product/getList param: {}", JSON.toJSONString(req));
PageInfo<SmartProductResp> pageInfo = productFeignClient.getList(req); PageInfo<ProductResp> pageInfo = productFeignClient.getList(req);
return R.ok().putPageData(pageInfo); return R.ok().putPageData(pageInfo);
} }
/** /**
* 根据 id 查询产品详情。 * 根据 id 查询产品详情。
* *
* @param id 产品 id * @param req 请求体
* @return 结果 * @return 结果
*/ */
@RequestMapping(value = "/getById", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/getById", method = {RequestMethod.GET, RequestMethod.POST})
public R getById(Long id) { public R getById(@Validated({Default.class}) ProductReq req) {
log.info("$$$$ /product/getById param: {}", id); log.info("$$$$ /product/getById param: {}", JSON.toJSONString(req));
if (id == null) { ProductResp resp = productFeignClient.getById(req);
throw new BusinessException(ResultEnum.PARAM_ERROR);
}
SmartProductResp resp = productFeignClient.getById(id);
return R.ok().data(resp); return R.ok().data(resp);
} }
...@@ -66,56 +65,54 @@ public class ProductController { ...@@ -66,56 +65,54 @@ public class ProductController {
* 保存产品。无则插入,有则更新。 * 保存产品。无则插入,有则更新。
* *
* @param req 产品 * @param req 产品
* @return 结果
*/ */
@RequestMapping(value = "/save", method = {RequestMethod.POST}) @RequestMapping(value = "/save", method = {RequestMethod.POST})
public R save(@RequestBody @Validated SmartProductReq req) { public R save(@RequestBody @Validated({GroupA.class}) ProductReq req) {
log.info("$$$$ /product/save param: {}", JSON.toJSONString(req)); log.info("$$$$ /product/save param: {}", JSON.toJSONString(req));
productFeignClient.save(req); Boolean success = productFeignClient.save(req);
return R.ok(); return R.ok().data(success);
} }
/** /**
* 根据产品 id 获取指令集。 * 根据产品 id 获取指令集。
* *
* @param id 产品 id * @param req 请求体
* @return 结果
*/ */
@RequestMapping(value = "/getCommandSetById", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/getCommandSetById", method = {RequestMethod.GET, RequestMethod.POST})
public R getCommandSetById(String id) { public R getCommandSetById(@Validated({Default.class}) ProductReq req) {
log.info("$$$$ /product/getCommandSetById param: {}", id); log.info("$$$$ /product/getCommandSetById param: {}", JSON.toJSONString(req));
if (StringUtils.isBlank(id)) { List<DeviceOrderResp> respList = productFeignClient.getCommandSetById(req);
throw new BusinessException(ResultEnum.PARAM_ERROR);
}
List<SmartDeviceOrderResp> respList = productFeignClient.getCommandSetById(id);
return R.ok().data(respList); return R.ok().data(respList);
} }
/** /**
* 校验商城商品 id。 * 校验商城商品 id。
* *
* @param shopProductId 商品 id * @param req 请求体
* @return 结果
*/ */
@RequestMapping(value = "/checkShopProductId", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/checkShopProductId", method = {RequestMethod.GET, RequestMethod.POST})
public R checkShopProductId(String shopProductId) { public R checkShopProductId(ProductReq req) {
log.info("$$$$ /product/checkShopProductId param: {}", shopProductId); log.info("$$$$ /product/checkShopProductId param: {}", JSON.toJSONString(req));
if (StringUtils.isBlank(shopProductId)) { if (StringUtils.isBlank(req.getShopProductId())) {
throw new BusinessException(ResultEnum.PARAM_ERROR); throw new BusinessException(ResultEnum.PARAM_ERROR);
} }
Boolean productIdValid = productFeignClient.checkShopProductId(shopProductId); Boolean productIdValid = productFeignClient.checkShopProductId(req);
return R.ok().data(productIdValid); return R.ok().data(productIdValid);
} }
/** /**
* 上下架产品。 * 上下架产品。
* *
* @param id 产品 id * @param req 请求体
* @return 结果
*/ */
@RequestMapping(value = "/putOnOff", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/putOnOff", method = {RequestMethod.GET, RequestMethod.POST})
public R putOnOff(Long id) { public R putOnOff(@Validated({Default.class}) ProductReq req) {
log.info("$$$$ /product/putOnOff param: {}", id); log.info("$$$$ /product/putOnOff param: {}", JSON.toJSONString(req));
if (id == null) { Boolean success = productFeignClient.putOnOff(req);
throw new BusinessException(ResultEnum.PARAM_ERROR); return R.ok().data(success);
}
productFeignClient.putOnOff(id);
return R.ok();
} }
} }
package com.glsx.admin.controller; package com.glsx.admin.controller;
import javax.validation.groups.Default;
import java.util.List; import java.util.List;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glsx.admin.exception.BusinessException; import com.glsx.admin.pojo.GroupA;
import com.glsx.admin.exception.ResultEnum; import com.glsx.admin.pojo.request.ProductTypeReq;
import com.glsx.admin.pojo.request.SmartProductTypeReq; import com.glsx.admin.pojo.response.ProductTypeResp;
import com.glsx.admin.pojo.response.SmartProductTypeResp;
import com.glsx.admin.remote.ProductTypeFeignClient; import com.glsx.admin.remote.ProductTypeFeignClient;
import com.glsx.plat.core.web.R; import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -38,25 +38,22 @@ public class ProductTypeController { ...@@ -38,25 +38,22 @@ public class ProductTypeController {
* @return 结果 * @return 结果
*/ */
@RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST})
public R getList(SmartProductTypeReq req) { public R getList(ProductTypeReq req) {
log.info("$$$$ /productType/getList param: {}", JSON.toJSONString(req)); log.info("$$$$ /productType/getList param: {}", JSON.toJSONString(req));
PageInfo<SmartProductTypeResp> pageInfo = productTypeFeignClient.getList(req); PageInfo<ProductTypeResp> pageInfo = productTypeFeignClient.getList(req);
return R.ok().putPageData(pageInfo); return R.ok().putPageData(pageInfo);
} }
/** /**
* 根据 id 获取产品类型。 * 根据 id 获取产品类型。
* *
* @param id 产品类型 id * @param req 请求体
* @return 结果 * @return 结果
*/ */
@RequestMapping(value = "/getById", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/getById", method = {RequestMethod.GET, RequestMethod.POST})
public R getById(Long id) { public R getById(@Validated({Default.class}) ProductTypeReq req) {
log.info("$$$$ /productType/getById param: {}", id); log.info("$$$$ /productType/getById param: {}", JSON.toJSONString(req));
if (id == null) { ProductTypeResp resp = productTypeFeignClient.getById(req);
throw new BusinessException(ResultEnum.PARAM_ERROR);
}
SmartProductTypeResp resp = productTypeFeignClient.getById(id);
return R.ok().data(resp); return R.ok().data(resp);
} }
...@@ -64,16 +61,17 @@ public class ProductTypeController { ...@@ -64,16 +61,17 @@ public class ProductTypeController {
* 保存产品类型。 * 保存产品类型。
* *
* @param req 产品类型 * @param req 产品类型
* @return 结果
*/ */
@RequestMapping(value = "/save", method = {RequestMethod.POST}) @RequestMapping(value = "/save", method = {RequestMethod.POST})
public R save(@RequestBody @Validated SmartProductTypeReq req) { public R save(@RequestBody @Validated({GroupA.class}) ProductTypeReq req) {
log.info("$$$$ /productType/save param: {}", JSON.toJSONString(req)); log.info("$$$$ /productType/save param: {}", JSON.toJSONString(req));
productTypeFeignClient.save(req); Boolean success = productTypeFeignClient.save(req);
return R.ok(); return R.ok().data(success);
} }
/** /**
* 获取商城标签 * 获取商城标签。
* *
* @return 结果 * @return 结果
*/ */
......
package com.glsx.admin.exception; package com.glsx.admin.exception;
import java.util.List;
import java.util.concurrent.TimeoutException;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.glsx.plat.common.utils.StringUtils; import com.glsx.plat.common.utils.StringUtils;
...@@ -8,6 +10,7 @@ import com.netflix.hystrix.exception.HystrixRuntimeException; ...@@ -8,6 +10,7 @@ import com.netflix.hystrix.exception.HystrixRuntimeException;
import feign.FeignException; import feign.FeignException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindException; import org.springframework.validation.BindException;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.ServletRequestBindingException; import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
...@@ -33,7 +36,26 @@ public class GlobalExceptionHandler { ...@@ -33,7 +36,26 @@ public class GlobalExceptionHandler {
BindException.class}) BindException.class})
public R handleBindException(Exception e) { public R handleBindException(Exception e) {
log.error("!!!! 参数错误", e); log.error("!!!! 参数错误", e);
return R.error(ResultEnum.PARAM_ERROR.getCode(), ResultEnum.PARAM_ERROR.getMessage()); if ((e instanceof MethodArgumentNotValidException) || (e instanceof BindException)) {
List<FieldError> errorList;
if (e instanceof MethodArgumentNotValidException) {
MethodArgumentNotValidException ex = (MethodArgumentNotValidException) e;
errorList = ex.getBindingResult().getFieldErrors();
} else {
BindException ex = (BindException) e;
errorList = ex.getFieldErrors();
}
StringBuffer messageSb = new StringBuffer();
for (FieldError error : errorList) {
String fieldMessage = String.format("%s: %s, ",
error.getField(), error.getDefaultMessage());
messageSb.append(fieldMessage);
}
return R.error(ResultEnum.PARAM_ERROR.getCode(),
messageSb.toString().replaceAll(", +$", ""));
} else {
return R.error(ResultEnum.PARAM_ERROR.getCode(), ResultEnum.PARAM_ERROR.getMessage());
}
} }
@ExceptionHandler({HystrixRuntimeException.class}) @ExceptionHandler({HystrixRuntimeException.class})
...@@ -42,6 +64,10 @@ public class GlobalExceptionHandler { ...@@ -42,6 +64,10 @@ public class GlobalExceptionHandler {
if (cause instanceof FeignException) { if (cause instanceof FeignException) {
FeignException feignException = (FeignException) cause; FeignException feignException = (FeignException) cause;
return this.handleFeignException(feignException); return this.handleFeignException(feignException);
} else if (cause instanceof TimeoutException) {
log.error("!!!! 服务调用超时", e);
return R.error(ResultEnum.REMOTE_SERVER_TIME_OUT.getCode(),
ResultEnum.REMOTE_SERVER_TIME_OUT.getMessage());
} else { } else {
log.error("!!!! Hystrix熔断错误", e); log.error("!!!! Hystrix熔断错误", e);
return R.error(ResultEnum.ERROR.getCode(), ResultEnum.ERROR.getMessage()); return R.error(ResultEnum.ERROR.getCode(), ResultEnum.ERROR.getMessage());
......
...@@ -19,6 +19,7 @@ public enum ResultEnum { ...@@ -19,6 +19,7 @@ public enum ResultEnum {
PRODUCT_TYPE_NOT_FOUND(3001, "产品类型ID未找到"), PRODUCT_TYPE_NOT_FOUND(3001, "产品类型ID未找到"),
REMOTE_SERVICE_ERROR(9001, "服务调用错误"), REMOTE_SERVICE_ERROR(9001, "服务调用错误"),
REMOTE_SERVER_TIME_OUT(9002, "远程服务超时,请重试"),
; ;
private final Integer code; private final Integer code;
......
package com.glsx.admin.filter;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component;
/**
* <p>Description: 跨域配置
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-18
*/
@Component
public class CorsFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;
StringBuffer headersSb = new StringBuffer();
Enumeration<String> headerNames = httpRequest.getHeaderNames();
while (headerNames.hasMoreElements()) {
headersSb.append(headerNames.nextElement()).append(", ");
}
if (!headersSb.toString().toLowerCase().contains("authorization")) {
headersSb.append("authorization");
}
httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS,
headersSb.toString().replaceAll(", +$", ""));
httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true");
httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN,
httpRequest.getHeader(HttpHeaders.ORIGIN));
httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS,
httpRequest.getMethod());
httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, "*");
httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_MAX_AGE, "18000L");
chain.doFilter(request, response);
}
}
package com.glsx.admin.pojo.request;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-16
*/
public class DemoReq {
}
...@@ -11,7 +11,7 @@ import lombok.Data; ...@@ -11,7 +11,7 @@ import lombok.Data;
*/ */
@Data @Data
public class SmartDeviceOrderReq { public class DeviceOrderReq {
private Integer id; private Integer id;
/** /**
......
package com.glsx.admin.pojo.request; package com.glsx.admin.pojo.request;
import lombok.Data; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.groups.Default;
import java.util.Date; import java.util.Date;
import com.glsx.admin.pojo.BaseDTO;
import com.glsx.admin.pojo.GroupA;
import lombok.Data;
/** /**
* <p>Description: * <p>Description:
...@@ -17,66 +21,53 @@ import java.util.Date; ...@@ -17,66 +21,53 @@ import java.util.Date;
* 车家智能产品数据表 * 车家智能产品数据表
*/ */
@Data @Data
public class ProductReq { public class ProductReq extends BaseDTO {
/**
* 图标 url
*/
private String iconUrl;
/**
* 产品类型名称
*/
private String typeName;
/**
* 接入平台名称
*/
private String platformName;
/**
* 配网模式名称
*/
private String networkName;
/** /**
* 标识ID * 标识ID
*/ */
@NotNull(message = "id不能为空", groups = {Default.class})
private Long id; private Long id;
/** /**
* 产品名称 * 产品名称
*/ */
@NotBlank(message = "产品名称不能为空", groups = {GroupA.class})
private String productName; private String productName;
/** /**
* 图片ID 关联smart_sys_file中id * 图片ID 关联smart_sys_file中id
*/ */
@NotNull(message = "缩略图不能为空", groups = {GroupA.class})
private Long icon; private Long icon;
/** /**
* 产品类型ID 关联smart_product_type中id * 产品类型ID 关联smart_product_type中id
*/ */
@NotNull(message = "产品类型不能为空", groups = {GroupA.class})
private Long typeId; private Long typeId;
/** /**
* 商城产品id * 商城产品id
*/ */
@NotBlank(message = "商品id不能为空", groups = {GroupA.class})
private String shopProductId; private String shopProductId;
/** /**
* 接入平台key 关联smart_sys_code中dict_key * 接入平台key 关联smart_sys_code中dict_key
*/ */
@NotBlank(message = "接入平台不能为空", groups = {GroupA.class})
private String platformKey; private String platformKey;
/** /**
* 接入平台产品id * 接入平台产品id
*/ */
@NotBlank(message = "产品id不能为空", groups = {GroupA.class})
private String platformProductId; private String platformProductId;
/** /**
* 配网方式key 关联smart_sys_code中dict_key * 配网方式key 关联smart_sys_code中dict_key
*/ */
@NotBlank(message = "配网模式不能为空", groups = {GroupA.class})
private String networkKey; private String networkKey;
/** /**
......
...@@ -15,7 +15,7 @@ import lombok.Data; ...@@ -15,7 +15,7 @@ import lombok.Data;
* 车家智能产品类型参数表 * 车家智能产品类型参数表
*/ */
@Data @Data
public class SmartProductTypeParamReq { public class ProductTypeParamReq {
/** /**
* 标识ID * 标识ID
*/ */
......
package com.glsx.admin.pojo.request; package com.glsx.admin.pojo.request;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.groups.Default;
import java.util.Date; import java.util.Date;
import com.glsx.admin.pojo.BaseDTO; import com.glsx.admin.pojo.BaseDTO;
import com.glsx.admin.pojo.GroupA;
import lombok.Data; import lombok.Data;
/** /**
...@@ -18,26 +21,29 @@ import lombok.Data; ...@@ -18,26 +21,29 @@ import lombok.Data;
* 车家智能产品类型表 * 车家智能产品类型表
*/ */
@Data @Data
public class SmartProductTypeReq extends BaseDTO { public class ProductTypeReq extends BaseDTO {
/** /**
* 标识ID * 标识ID
*/ */
@NotNull(message = "id不能为空", groups = {Default.class})
private Long id; private Long id;
/** /**
* 类型名称 * 类型名称
*/ */
@NotBlank @NotBlank(message = "产品类型名称不能为空", groups = {GroupA.class})
private String typeName; private String typeName;
/** /**
* 类别key 关联smart_sys_code中dict_key * 类别key 关联smart_sys_code中dict_key
*/ */
@NotBlank(message = "分类不能为空", groups = {GroupA.class})
private String categoryKey; private String categoryKey;
/** /**
* 商城标签 * 商城标签
*/ */
@NotBlank(message = "商城标签不能为空", groups = {GroupA.class})
private String shopTag; private String shopTag;
/** /**
......
package com.glsx.admin.pojo.request;
import javax.validation.constraints.NotBlank;
import java.util.Date;
import com.glsx.admin.pojo.BaseDTO;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能产品数据表
*/
@Data
public class SmartProductReq extends BaseDTO {
/**
* 标识ID
*/
private Long id;
/**
* 产品名称
*/
@NotBlank
private String productName;
/**
* 图片ID 关联smart_sys_file中id
*/
private Long icon;
/**
* 产品类型ID 关联smart_product_type中id
*/
private Long typeId;
/**
* 商城产品id
*/
private String shopProductId;
/**
* 接入平台key 关联smart_sys_code中dict_key
*/
private String platformKey;
/**
* 接入平台产品id
*/
private String platformProductId;
/**
* 配网方式key 关联smart_sys_code中dict_key
*/
private String networkKey;
/**
* 状态:0下线 1上线
*/
private Byte status;
/**
* 备注
*/
private String remark;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private Long createBy;
/**
* 更新时间
*/
private Date updateTime;
/**
* 更新人
*/
private Long updateBy;
}
package com.glsx.admin.pojo.response;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-16
*/
public class DemoResp {
}
...@@ -11,7 +11,7 @@ import lombok.Data; ...@@ -11,7 +11,7 @@ import lombok.Data;
*/ */
@Data @Data
public class SmartDeviceOrderResp { public class DeviceOrderResp {
private Integer id; private Integer id;
/** /**
......
package com.glsx.admin.pojo.response; package com.glsx.admin.pojo.response;
import javax.persistence.Transient;
import java.util.Date; import java.util.Date;
import com.glsx.admin.pojo.BaseDTO; import com.glsx.admin.pojo.BaseDTO;
import lombok.Data; import lombok.Data;
...@@ -17,7 +18,20 @@ import lombok.Data; ...@@ -17,7 +18,20 @@ import lombok.Data;
* 车家智能产品数据表 * 车家智能产品数据表
*/ */
@Data @Data
public class SmartProductResp extends BaseDTO { public class ProductResp extends BaseDTO {
/**
* 图标 url
*/
@Transient
private String iconUrl;
/**
* 产品类型名称
*/
@Transient
private String typeName;
/** /**
* 标识ID * 标识ID
*/ */
......
package com.glsx.admin.pojo.response; package com.glsx.admin.pojo.response;
import javax.validation.constraints.NotBlank;
import java.util.Date; import java.util.Date;
import com.glsx.admin.pojo.BaseDTO; import com.glsx.admin.pojo.BaseDTO;
import lombok.Data; import lombok.Data;
...@@ -18,7 +17,7 @@ import lombok.Data; ...@@ -18,7 +17,7 @@ import lombok.Data;
* 车家智能产品类型表 * 车家智能产品类型表
*/ */
@Data @Data
public class SmartProductTypeResp extends BaseDTO { public class ProductTypeResp extends BaseDTO {
/** /**
* 标识ID * 标识ID
*/ */
...@@ -27,7 +26,6 @@ public class SmartProductTypeResp extends BaseDTO { ...@@ -27,7 +26,6 @@ public class SmartProductTypeResp extends BaseDTO {
/** /**
* 类型名称 * 类型名称
*/ */
@NotBlank
private String typeName; private String typeName;
/** /**
......
package com.glsx.admin.remote; package com.glsx.admin.remote;
import com.glsx.admin.pojo.request.ProductReq;
import com.glsx.admin.remote.impl.IndexHystrix; import com.glsx.admin.remote.impl.IndexHystrix;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
...@@ -14,9 +12,4 @@ public interface IndexFeignClient { ...@@ -14,9 +12,4 @@ public interface IndexFeignClient {
@ResponseBody @ResponseBody
@RequestMapping(value = "/home", method = {RequestMethod.GET}) @RequestMapping(value = "/home", method = {RequestMethod.GET})
String getHome(); String getHome();
@ResponseBody
@RequestMapping(value = "/getProduct", method = {RequestMethod.GET})
String getProduct(@RequestBody ProductReq product);
} }
...@@ -2,15 +2,14 @@ package com.glsx.admin.remote; ...@@ -2,15 +2,14 @@ package com.glsx.admin.remote;
import java.util.List; import java.util.List;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glsx.admin.pojo.request.SmartProductReq; import com.glsx.admin.pojo.request.ProductReq;
import com.glsx.admin.pojo.response.SmartDeviceOrderResp; import com.glsx.admin.pojo.response.DeviceOrderResp;
import com.glsx.admin.pojo.response.SmartProductResp; import com.glsx.admin.pojo.response.ProductResp;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap; import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
/** /**
...@@ -24,25 +23,25 @@ import org.springframework.web.bind.annotation.ResponseBody; ...@@ -24,25 +23,25 @@ import org.springframework.web.bind.annotation.ResponseBody;
public interface ProductFeignClient { public interface ProductFeignClient {
@RequestMapping(value = "/product/getList", method = {RequestMethod.GET}) @RequestMapping(value = "/product/getList", method = {RequestMethod.GET})
@ResponseBody @ResponseBody
PageInfo<SmartProductResp> getList(@SpringQueryMap SmartProductReq req); PageInfo<ProductResp> getList(@SpringQueryMap ProductReq req);
@RequestMapping(value = "/product/getById", method = {RequestMethod.GET}) @RequestMapping(value = "/product/getById", method = {RequestMethod.GET})
@ResponseBody @ResponseBody
SmartProductResp getById(@RequestParam Long id); ProductResp getById(@SpringQueryMap ProductReq req);
@RequestMapping(value = "/product/save", method = {RequestMethod.POST}) @RequestMapping(value = "/product/save", method = {RequestMethod.POST})
@ResponseBody @ResponseBody
void save(@RequestBody SmartProductReq req); Boolean save(@RequestBody ProductReq req);
@RequestMapping("/product/getCommandSetById") @RequestMapping("/product/getCommandSetById")
@ResponseBody @ResponseBody
List<SmartDeviceOrderResp> getCommandSetById(@RequestParam String id); List<DeviceOrderResp> getCommandSetById(@SpringQueryMap ProductReq req);
@RequestMapping(value = "/product/checkShopProductId", method = {RequestMethod.GET}) @RequestMapping(value = "/product/checkShopProductId", method = {RequestMethod.GET})
@ResponseBody @ResponseBody
Boolean checkShopProductId(@RequestParam String shopProductId); Boolean checkShopProductId(@SpringQueryMap ProductReq req);
@RequestMapping(value = "/product/putOnOff", method = {RequestMethod.POST}) @RequestMapping(value = "/product/putOnOff", method = {RequestMethod.POST})
@ResponseBody @ResponseBody
void putOnOff(@RequestParam Long id); Boolean putOnOff(@SpringQueryMap ProductReq req);
} }
...@@ -2,14 +2,13 @@ package com.glsx.admin.remote; ...@@ -2,14 +2,13 @@ package com.glsx.admin.remote;
import java.util.List; import java.util.List;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glsx.admin.pojo.request.SmartProductTypeReq; import com.glsx.admin.pojo.request.ProductTypeReq;
import com.glsx.admin.pojo.response.SmartProductTypeResp; import com.glsx.admin.pojo.response.ProductTypeResp;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap; import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
/** /**
...@@ -23,15 +22,15 @@ import org.springframework.web.bind.annotation.ResponseBody; ...@@ -23,15 +22,15 @@ import org.springframework.web.bind.annotation.ResponseBody;
public interface ProductTypeFeignClient { public interface ProductTypeFeignClient {
@RequestMapping(value = "/productType/getList", method = {RequestMethod.GET}) @RequestMapping(value = "/productType/getList", method = {RequestMethod.GET})
@ResponseBody @ResponseBody
PageInfo<SmartProductTypeResp> getList(@SpringQueryMap SmartProductTypeReq req); PageInfo<ProductTypeResp> getList(@SpringQueryMap ProductTypeReq req);
@RequestMapping(value = "/productType/getById", method = {RequestMethod.GET}) @RequestMapping(value = "/productType/getById", method = {RequestMethod.GET})
@ResponseBody @ResponseBody
SmartProductTypeResp getById(@RequestParam Long id); ProductTypeResp getById(@SpringQueryMap ProductTypeReq req);
@RequestMapping(value = "/productType/save", method = {RequestMethod.POST}) @RequestMapping(value = "/productType/save", method = {RequestMethod.POST})
@ResponseBody @ResponseBody
void save(@RequestBody SmartProductTypeReq req); Boolean save(@RequestBody ProductTypeReq req);
@RequestMapping(value = "/productType/getShopTagList", method = {RequestMethod.GET}) @RequestMapping(value = "/productType/getShopTagList", method = {RequestMethod.GET})
@ResponseBody @ResponseBody
......
package com.glsx.admin.remote.impl; package com.glsx.admin.remote.impl;
import com.glsx.admin.pojo.request.ProductReq;
import com.glsx.admin.remote.IndexFeignClient; import com.glsx.admin.remote.IndexFeignClient;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -22,9 +21,4 @@ public class IndexHystrix implements IndexFeignClient { ...@@ -22,9 +21,4 @@ public class IndexHystrix implements IndexFeignClient {
log.error("请求getHome()异常"); log.error("请求getHome()异常");
return "服务请求异常"; return "服务请求异常";
} }
@Override
public String getProduct(ProductReq product) {
return "服务请求异常";
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!