Commit 9ce5ee11 by 王能兵

Merge branch 'dev' into 'master'

Dev

See merge request !1
2 parents d7846762 7a93f5f4
Showing 50 changed files with 2668 additions and 36 deletions
### IntelliJ project files
.idea/
*.iml
out/
gen/
### Java template
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Maven template
target/
......@@ -61,5 +61,16 @@
<version>3.0.0-SNAPSHOT</version>
</dependency>
<!--商城接口 -->
<dependency>
<groupId>cn.com.glsx</groupId>
<artifactId>rpc-platform-shopmall-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.glsx.biz</groupId>
<artifactId>biz-user-service</artifactId>
<version>3.1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
</project>
......@@ -8,13 +8,12 @@ import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
/**
* @Title: ServiceApplication.java
* @Description:
* @author deployer name
* @version V1.0
* @author deployer name
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2015
*/
......@@ -24,7 +23,6 @@ import org.springframework.context.annotation.ComponentScan;
@ServletComponentScan
@EnableFeignClients
@EnableDubbo
@ComponentScan("com.glsx.admin")
public class SmartAdminApplication extends SpringBootServletInitializer {
/**
......
package com.glsx.admin.controller;
import com.glsx.admin.exception.BusinessException;
import com.glsx.admin.exception.ResultEnum;
import com.glsx.plat.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author think.wang
* @version 1.0.0
* @Title BaseController
* @Package com.glsx.admin.controller
* @Description controller基类
* @date 2021/3/17
*/
@Slf4j
public class BaseController {
/**
* hibernate-validator参数校验返回错误方法
*
* @param result
* @return
*/
public Map<String, String> getErrors(BindingResult result) {
Map<String, String> map = new HashMap<>();
List<FieldError> list = result.getFieldErrors();
for (FieldError error : list) {
map.put(error.getField(), error.getDefaultMessage());
}
return map;
}
/**
* 将请求参数进行校验,校验不成功则抛出 {@link BusinessException} 异常
*
* @param bindingResult Spring校验结果
*/
protected void checkRequestParam(BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
Map<String, String> errorMap = this.getErrors(bindingResult);
Collection<String> values = errorMap.values();
String errorMsg = StringUtils.join(values, ";");
throw BusinessException.create(ResultEnum.PARAM_ERROR.getCode(), errorMsg);
}
}
}
......@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
* @Title: IndexController.java
* @Description: 远程服务调用demo
* @author think.wang
* @version V1.0
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
......@@ -25,11 +25,11 @@ public class IndexController {
@Autowired
private IndexFeignClient indexFeignClient;
@DubboReference(version = "1.0.0")
@DubboReference(version = "1.0.0", registry = {"biz-user"})
private UserService userService;
@ResponseBody
@RequestMapping("home")
@RequestMapping("/home")
public R home(){
try {
User user = userService.getByUserId(92001768); //dubbo服务调用
......
package com.glsx.admin.controller;
import javax.validation.groups.Default;
import com.glsx.admin.pojo.request.DeviceOrderValueReq;
import com.glsx.admin.remote.OrderValueFeignClient;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
/**
* @Title: OrderValueController.java
* @Description: 场景设备指令集值列表
* @author think.wang
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@Slf4j
@RestController
@RequestMapping("/orderValue")
public class OrderValueController extends BaseController{
@Autowired
private OrderValueFeignClient valueFeignClient;
@ResponseBody
@RequestMapping(value = "/getList", method = {RequestMethod.POST})
public R getList(@Validated(value = {Default.class}) DeviceOrderValueReq req,
BindingResult result){
this.checkRequestParam(result);
return R.ok().data(valueFeignClient.getList(req));
}
}
package com.glsx.admin.controller;
import javax.validation.groups.Default;
import java.util.List;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.platform.shopmall.dto.CreateMallGoodsRequestDTO;
import cn.com.glsx.platform.shopmall.remote.ShopMallGoodsRemote;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.glsx.admin.exception.BusinessException;
import com.glsx.admin.exception.ResultEnum;
import com.glsx.admin.pojo.GroupA;
import com.glsx.admin.pojo.request.ProductReq;
import com.glsx.admin.pojo.response.DeviceOrderResp;
import com.glsx.admin.pojo.response.ProductResp;
import com.glsx.admin.remote.ProductFeignClient;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>Description: 产品列表业务
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Slf4j
@RestController
@RequestMapping("/product")
public class ProductController {
@Autowired
private ProductFeignClient productFeignClient;
@DubboReference(version = "1.0.0", registry = {"shopmall"})
private ShopMallGoodsRemote shopMallGoodsRemote;
/**
* 分页获取产品列表。
*
* @param req 请求体
* @return 结果
*/
@RequestMapping(value = "/getPageList", method = {RequestMethod.GET, RequestMethod.POST})
public R getPageList(ProductReq req) {
log.info("$$$$ /product/getPageList param: {}", JSON.toJSONString(req));
PageInfo<ProductResp> pageInfo = productFeignClient.getPageList(req);
return R.ok().putPageData(pageInfo);
}
/**
* 获取产品列表,不分页。
*
* @param req 请求体
* @return 结果
*/
@RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST})
public R getList(ProductReq req) {
log.info("$$$$ /product/getList param: {}", JSON.toJSONString(req));
List<ProductResp> respList = productFeignClient.getList(req);
return R.ok().data(respList);
}
/**
* 根据 id 查询产品详情。
*
* @param req 请求体
* @return 结果
*/
@RequestMapping(value = "/getById", method = {RequestMethod.GET, RequestMethod.POST})
public R getById(@Validated({Default.class}) ProductReq req) {
log.info("$$$$ /product/getById param: {}", JSON.toJSONString(req));
ProductResp resp = productFeignClient.getById(req);
return R.ok().data(resp);
}
/**
* 保存产品。无则插入,有则更新。
*
* @param req 产品
* @return 结果
*/
@RequestMapping(value = "/save", method = {RequestMethod.POST})
public R save(@RequestBody @Validated({GroupA.class}) ProductReq req) {
log.info("$$$$ /product/save param: {}", JSON.toJSONString(req));
Boolean success = productFeignClient.save(req);
return R.ok().data(success);
}
/**
* 根据产品 id 获取指令集。
*
* @param req 请求体
* @return 结果
*/
@RequestMapping(value = "/getCommandSetById", method = {RequestMethod.GET, RequestMethod.POST})
public R getCommandSetById(@Validated({Default.class}) ProductReq req) {
log.info("$$$$ /product/getCommandSetById param: {}", JSON.toJSONString(req));
List<DeviceOrderResp> respList = productFeignClient.getCommandSetById(req);
return R.ok().data(respList);
}
/**
* 校验商城商品 id。
*
* @param req 请求体
* @return 结果
*/
@RequestMapping(value = "/checkShopProductId", method = {RequestMethod.GET, RequestMethod.POST})
public R checkShopProductId(ProductReq req) {
log.info("$$$$ /product/checkShopProductId param: {}", JSON.toJSONString(req));
if (StringUtils.isBlank(req.getShopProductId())) {
throw new BusinessException(ResultEnum.PARAM_ERROR);
}
RpcResponse<CreateMallGoodsRequestDTO> rpcResponse = shopMallGoodsRemote
.selectOneById(Integer.valueOf(req.getShopProductId()), false);
log.info("$$$$ shopMallGoodsRemote.selectOneById response: {}",
JSON.toJSONString(rpcResponse));
boolean productIdValid = rpcResponse.isSuccess() && rpcResponse.getResult() != null;
return R.ok().data(productIdValid);
}
/**
* 上下架产品。
*
* @param req 请求体
* @return 结果
*/
@RequestMapping(value = "/putOnOff", method = {RequestMethod.GET, RequestMethod.POST})
public R putOnOff(@Validated({Default.class}) ProductReq req) {
log.info("$$$$ /product/putOnOff param: {}", JSON.toJSONString(req));
Boolean success = productFeignClient.putOnOff(req);
return R.ok().data(success);
}
}
package com.glsx.admin.controller;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.platform.shopmall.model.PlatformMallGoodLabel;
import cn.com.glsx.platform.shopmall.remote.ShopMallLGoodLabelRemote;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.glsx.admin.pojo.GroupA;
import com.glsx.admin.pojo.request.DeviceOrderReq;
import com.glsx.admin.pojo.request.ProductTypeReq;
import com.glsx.admin.pojo.request.ScenceSupstatusReq;
import com.glsx.admin.pojo.response.DeviceOrderResp;
import com.glsx.admin.pojo.response.ProductTypeResp;
import com.glsx.admin.pojo.response.ScenceSupstatusResp;
import com.glsx.admin.remote.ProductConditionFeignClient;
import com.glsx.admin.remote.ProductContentFeignClient;
import com.glsx.admin.remote.ProductTypeFeignClient;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.groups.Default;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-17
*/
@Slf4j
@RestController
@RequestMapping("/productType")
public class ProductTypeController {
@Autowired
private ProductTypeFeignClient productTypeFeignClient;
@Autowired
private ProductConditionFeignClient conditionFeignClient;
@Autowired
private ProductContentFeignClient contentFeignClient;
@DubboReference(version = "1.0.0", registry = {"shopmall"})
private ShopMallLGoodLabelRemote shopMallLGoodLabelRemote;
/**
* 分页获取产品类型列表。
*
* @param req 请求
* @return 结果
*/
@RequestMapping(value = "/getPageList", method = {RequestMethod.GET, RequestMethod.POST})
public R getPageList(ProductTypeReq req) {
log.info("$$$$ /productType/getPageList param: {}", JSON.toJSONString(req));
PageInfo<ProductTypeResp> pageInfo = productTypeFeignClient.getPageList(req);
return R.ok().putPageData(pageInfo);
}
/**
* 获取产品类型列表,不分页。
*
* @param req 请求
* @return 结果
*/
@RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST})
public R getList(ProductTypeReq req) {
log.info("$$$$ /productType/getList param: {}", JSON.toJSONString(req));
List<ProductTypeResp> respList = productTypeFeignClient.getList(req);
return R.ok().data(respList);
}
/**
* 根据 id 获取产品类型。
*
* @param req 请求体
* @return 结果
*/
@RequestMapping(value = "/getById", method = {RequestMethod.GET, RequestMethod.POST})
public R getById(@Validated({Default.class}) ProductTypeReq req) {
log.info("$$$$ /productType/getById param: {}", JSON.toJSONString(req));
ProductTypeResp resp = productTypeFeignClient.getById(req);
return R.ok().data(resp);
}
/**
* 保存产品类型。
*
* @param req 产品类型
* @return 结果
*/
@RequestMapping(value = "/save", method = {RequestMethod.POST})
public R save(@RequestBody @Validated({GroupA.class}) ProductTypeReq req) {
log.info("$$$$ /productType/save param: {}", JSON.toJSONString(req));
Boolean success = productTypeFeignClient.save(req);
return R.ok().data(success);
}
/**
* 获取商城标签。
*
* @return 结果
*/
@RequestMapping(value = "/getShopTagList", method = {RequestMethod.GET, RequestMethod.POST})
public R getShopTagList() {
log.info("$$$$ /productType/getShopTagList ...");
RpcResponse<List<PlatformMallGoodLabel>> rpcResponse = shopMallLGoodLabelRemote.queryAll();
log.info("$$$$ shopMallLGoodLabelRemote.queryAll response: {}",
JSON.toJSONString(rpcResponse));
List<String> shopTagList = new ArrayList<>();
List<PlatformMallGoodLabel> goodLabelList = rpcResponse.getResult();
if (rpcResponse.isSuccess() && goodLabelList != null) {
goodLabelList.forEach(item -> shopTagList.add(item.getLabelName()));
}
return R.ok().data(shopTagList);
}
/**
* 获取类型指令条件列表
*
* @return 结果
*/
@RequestMapping(value = "/getConditionList", method = {RequestMethod.GET, RequestMethod.POST})
public R getConditionList() {
ScenceSupstatusReq supstatusReq = new ScenceSupstatusReq();
supstatusReq.setStatus((byte)1);
List<ScenceSupstatusResp> respList = conditionFeignClient.getList(supstatusReq);
Set<Long> idList = new HashSet<>();
for (ScenceSupstatusResp resp : respList) {
idList.add(Long.valueOf(resp.getProductId()));
}
return R.ok().data(productTypeFeignClient.getListAndCondition(new ArrayList<>(idList)));
}
/**
* 获取类型指令执行内容列表
*
* @return 结果
*/
@RequestMapping(value = "/getContentList", method = {RequestMethod.GET, RequestMethod.POST})
public R getContentList() {
DeviceOrderReq orderReq = new DeviceOrderReq();
orderReq.setStatus((byte)1);
List<DeviceOrderResp> respList = contentFeignClient.getList(orderReq);
Set<Long> idList = new HashSet<>();
for (DeviceOrderResp resp : respList) {
idList.add(Long.valueOf(resp.getProductId()));
}
return R.ok().data(productTypeFeignClient.getListAndContent(new ArrayList<>(idList)));
}
}
package com.glsx.admin.controller;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.glsx.admin.exception.BusinessException;
import com.glsx.admin.exception.ResultEnum;
import com.glsx.admin.pojo.GroupA;
import com.glsx.admin.pojo.request.SceneTemplateReq;
import com.glsx.admin.pojo.response.SceneTemplateResp;
import com.glsx.admin.remote.SceneTemplateFeignClient;
import com.glsx.biz.user.common.entity.UserEventTrackAmount;
import com.glsx.biz.user.common.vo.request.UserEventTrackAmountRequest;
import com.glsx.biz.user.service.UserEventTrackAmountService;
import com.glsx.cloudframework.exception.ServiceException;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.groups.Default;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Slf4j
@RestController
@RequestMapping("/sceneTemplate")
public class SceneTemplateController extends BaseController {
@Autowired
private SceneTemplateFeignClient templateFeignClient;
@DubboReference(version = "1.0.0")
private UserEventTrackAmountService userEventTrackAmountService;
@RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST})
public R getList(SceneTemplateReq sceneTemplate) {
log.info("/sceneTemplate/getList param: {}", JSON.toJSONString(sceneTemplate));
PageInfo<SceneTemplateResp> pageList = templateFeignClient.getPageList(sceneTemplate);
List<SceneTemplateResp> list = pageList.getList();
if (CollectionUtils.isNotEmpty(list)) {
try {
UserEventTrackAmountRequest userEventTrackAmountRequest = new UserEventTrackAmountRequest();
userEventTrackAmountRequest.setFunctionType(4);
List<UserEventTrackAmount> eventTrackByUserFunctionList = userEventTrackAmountService.getEventTrackByFunctionList(userEventTrackAmountRequest);
log.info("返回的结果list{}",eventTrackByUserFunctionList.toString());
list.forEach(index -> {
if (CollectionUtils.isNotEmpty(eventTrackByUserFunctionList)) {
List<UserEventTrackAmount> collect = eventTrackByUserFunctionList.stream().filter(ind -> ind.getFunctionId().equals(index.getId()+"")).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
log.info("返回结果");
index.setViewTimes(collect.get(0).getFunctionCount().longValue());
} else {
index.setViewTimes(0L);
}
}
});
} catch (ServiceException e) {
log.info("调用异常,{}", e);
e.printStackTrace();
}
}
return R.ok().putPageData(pageList);
}
@RequestMapping(value = "/getById", method = {RequestMethod.GET, RequestMethod.POST})
public R getById(@RequestBody @Validated(value = Default.class) SceneTemplateReq sceneTemplate,
BindingResult result) {
this.checkRequestParam(result);
Long id = sceneTemplate.getId();
log.info("/sceneTemplate/getById param: {}", id);
return R.ok().data(templateFeignClient.getById(id));
}
@RequestMapping(value = "/save", method = {RequestMethod.POST})
public R save(@RequestBody @Validated(value = GroupA.class) SceneTemplateReq sceneTemplate, BindingResult result) {
log.info("新增调用/sceneTemplate/save param: {}", JSON.toJSONString(sceneTemplate));
this.checkRequestParam(result);
Long id = sceneTemplate.getId();
Date now = new Date();
SceneTemplateReq sameRequest = new SceneTemplateReq();
sameRequest.setSceneName(sceneTemplate.getSceneName());
List<SceneTemplateResp> list = templateFeignClient.getList(sameRequest);
if (id == null || id <= 0) { //新增
if (!list.isEmpty()) {
throw new BusinessException(ResultEnum.SAME_NAME_ERROR);
}
sceneTemplate.setCreateTime(now);
sceneTemplate.setCreateBy(-1L);
return R.ok().data(templateFeignClient.add(sceneTemplate));
} else {
if (!list.isEmpty() && list.get(0).getId() != id) {
throw new BusinessException(ResultEnum.SAME_NAME_ERROR);
}
sceneTemplate.setUpdateTime(now);
sceneTemplate.setUpdateBy(-1L);
return R.ok().data(templateFeignClient.update(sceneTemplate));
}
}
@RequestMapping(value = "/updateStatus", method = {RequestMethod.POST})
public R update(@RequestBody @Validated(value = Default.class) SceneTemplateReq sceneTemplate, BindingResult result) {
this.checkRequestParam(result);
log.info("更新调用/sceneTemplate/updateStatus param: {}", JSON.toJSONString(sceneTemplate));
Date now = new Date();
sceneTemplate.setUpdateTime(now);
sceneTemplate.setUpdateBy(-1L);
return R.ok().data(templateFeignClient.updateParam(sceneTemplate));
}
}
package com.glsx.admin.controller;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.glsx.admin.pojo.request.SysCodeReq;
import com.glsx.admin.pojo.response.SysCodeResp;
import com.glsx.admin.remote.SysCodeFeignClient;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>Description: 字典集业务
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-24
*/
@Slf4j
@RestController
@RequestMapping("/sysCode")
public class SysCodeController {
@Autowired
private SysCodeFeignClient sysCodeFeignClient;
@RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST})
public R getList(SysCodeReq req) {
log.info("$$$$ /sysCode/getList param: {}", JSON.toJSONString(req));
List<SysCodeResp> respList = sysCodeFeignClient.getListByCondition(req);
return R.ok().data(respList);
}
}
package com.glsx.admin.exception;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-16
*/
public class BusinessException extends RuntimeException {
private Integer code;
private String message;
public BusinessException() {}
public BusinessException(ResultEnum resultEnum) {
this.code = resultEnum.getCode();
this.message = resultEnum.getMessage();
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
@Override
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public static BusinessException create(int code, String message){
BusinessException businessException = new BusinessException();
businessException.code = code;
businessException.message = message;
return businessException;
}
public static BusinessException create(ResultEnum resultEnum) {
return create(resultEnum.getCode(), resultEnum.getMessage());
}
}
package com.glsx.admin.exception;
import java.util.List;
import java.util.concurrent.TimeoutException;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.core.web.R;
import com.netflix.hystrix.exception.HystrixRuntimeException;
import feign.FeignException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindException;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-16
*/
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler({BusinessException.class})
public R handleBusinessException(BusinessException e) {
log.error("!!!! 业务异常", e);
return R.error(e.getCode(), e.getMessage());
}
@ExceptionHandler({ServletRequestBindingException.class, MethodArgumentNotValidException.class,
BindException.class})
public R handleBindException(Exception e) {
log.error("!!!! 参数错误", e);
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})
public R handleHystrixException(HystrixRuntimeException e) {
Throwable cause = e.getCause();
if (cause instanceof FeignException) {
FeignException feignException = (FeignException) cause;
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 {
log.error("!!!! Hystrix熔断错误", e);
return R.error(ResultEnum.ERROR.getCode(), ResultEnum.ERROR.getMessage());
}
}
@ExceptionHandler({FeignException.class})
public R handleFeignException(FeignException e) {
log.error("!!!! 远程服务错误", e);
String respMessage;
if (StringUtils.isNotBlank(e.contentUTF8())) {
JSONObject respObj = JSON.parseObject(e.contentUTF8());
respMessage = respObj.getString("message");
} else {
respMessage = "";
}
int code = ResultEnum.REMOTE_SERVICE_ERROR.getCode();
String message = StringUtils.isBlank(respMessage)
? ResultEnum.REMOTE_SERVICE_ERROR.getMessage() : respMessage;
return R.error(code, message);
}
@ExceptionHandler(Exception.class)
public R handleException(Exception e) {
log.error("!!!! 未知异常", e);
return R.error(ResultEnum.ERROR.getCode(), ResultEnum.ERROR.getMessage());
}
}
package com.glsx.admin.exception;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-16
*/
public enum ResultEnum {
SUCCESS(200, "成功"),
ERROR(500, "系统异常"),
PARAM_ERROR(1001, "参数错误"),
ID_NOT_FOUND(1002, "ID不存在"),
PRODUCT_NOT_FOUND(2001, "产品ID未找到"),
PRODUCT_NAME_DUPLICATE(2002, "产品名称重复"),
SAME_NAME_ERROR(2003, "场景名字已存在"),
PRODUCT_TYPE_NOT_FOUND(3001, "产品类型ID未找到"),
REMOTE_SERVICE_ERROR(9001, "服务调用错误"),
REMOTE_SERVER_TIME_OUT(9002, "远程服务超时,请重试"),
;
private final Integer code;
private final String message;
ResultEnum(Integer code, String message) {
this.code = code;
this.message = message;
}
public Integer getCode() {
return code;
}
public String getMessage() {
return message;
}
}
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 com.glsx.plat.common.utils.StringUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
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 (!StringUtils.containsIgnoreCase(headersSb, HttpHeaders.CONTENT_TYPE)) {
headersSb.append(HttpHeaders.CONTENT_TYPE).append(", ");
}
if (!StringUtils.containsIgnoreCase(headersSb, HttpHeaders.AUTHORIZATION)) {
headersSb.append(HttpHeaders.AUTHORIZATION).append(", ");
}
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");
// 放行预检请求(preflight requests)
if (httpRequest.getMethod().equalsIgnoreCase(HttpMethod.OPTIONS.toString())) {
httpResponse.setStatus(HttpServletResponse.SC_OK);
httpResponse.getWriter().println("OK");
return;
}
chain.doFilter(request, response);
}
}
......@@ -40,11 +40,6 @@ public class BaseDTO {
*/
private String endTime;
/**
* 用户id
*/
private Long uid;
public int getPageIndex() {
return pageIndex;
}
......@@ -69,14 +64,6 @@ public class BaseDTO {
this.searchKey = searchKey;
}
public Long getUid() {
return uid;
}
public void setUid(Long uid) {
this.uid = uid;
}
public String getOrderBy() {
return orderBy;
}
......
package com.glsx.admin.pojo;
/**
* @author think.wang
* @version 1.0.0
* @Title GroupA
* @Package com.glsx.admin.pojo
* @Description Hibernate-validator的分组
* @date 2021/3/8
*/
public interface GroupA {
}
package com.glsx.admin.pojo.request;
import lombok.Data;
import javax.persistence.Column;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-17
*/
@Data
public class DeviceOrderReq {
private Integer id;
/**
* 产品id
*/
private String productId;
private String orderCode;
private String orderValue;
/**
* 设备类型 1.非固定值不需要查询 2.固定值需要查询
*/
private String orderType;
/**
* 1.String类型 2.Interger类型 3.boolean类型
*/
private String orderValueType;
/**
* 状态 1上线 0下线
*/
private Byte status;
}
package com.glsx.admin.pojo.request;
import lombok.Data;
import javax.validation.constraints.NotNull;
import javax.validation.groups.Default;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-19
*/
/**
* 车家智能场景设备指令集表
*/
@Data
public class DeviceOrderValueReq {
private Integer id;
/**
* 关联smart_device_order表中id
*/
@NotNull(message = "orderId不能为空", groups = {Default.class})
private Integer orderId;
private String deviceStatusCode;
private String deviceStatusValue;
}
package com.glsx.admin.pojo.request;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.groups.Default;
import java.util.Date;
import com.glsx.admin.pojo.BaseDTO;
import com.glsx.admin.pojo.GroupA;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能产品数据表
*/
@Data
public class ProductReq extends BaseDTO {
/**
* 标识ID
*/
@NotNull(message = "id不能为空", groups = {Default.class})
private Long id;
/**
* 产品名称
*/
@NotBlank(message = "产品名称不能为空", groups = {GroupA.class})
private String productName;
/**
* 图片ID 关联smart_sys_file中id
*/
@NotNull(message = "缩略图不能为空", groups = {GroupA.class})
private Long icon;
/**
* 产品类型ID 关联smart_product_type中id
*/
@NotNull(message = "产品类型不能为空", groups = {GroupA.class})
private Long typeId;
/**
* 商城产品id
*/
@NotBlank(message = "商品id不能为空", groups = {GroupA.class})
private String shopProductId;
/**
* 接入平台key 关联smart_sys_code中dict_key
*/
@NotBlank(message = "接入平台不能为空", groups = {GroupA.class})
private String platformKey;
/**
* 接入平台产品id
*/
@NotBlank(message = "产品id不能为空", groups = {GroupA.class})
private String platformProductId;
/**
* 配网方式key 关联smart_sys_code中dict_key
*/
//@NotBlank(message = "配网模式不能为空", groups = {GroupA.class})
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.request;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
import lombok.Data;
/**
* 车家智能产品类型参数表
*/
@Data
public class ProductTypeParamReq {
/**
* 标识ID
*/
private Long id;
/**
* 产品类型ID 关联smart_product_type中id
*/
private Long typeId;
/**
* 指令code
*/
private String devideOrderCode;
/**
* 指令名称
*/
private String devideOrderName;
/**
* 1.有效 0.无效
*/
private String status;
/**
* 指令集取值类型
*/
private String devideOrderValuetype;
}
package com.glsx.admin.pojo.request;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.groups.Default;
import java.util.Date;
import com.glsx.admin.pojo.BaseDTO;
import com.glsx.admin.pojo.GroupA;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能产品类型表
*/
@Data
public class ProductTypeReq extends BaseDTO {
/**
* 标识ID
*/
@NotNull(message = "id不能为空", groups = {Default.class})
private Long id;
/**
* 类型名称
*/
@NotBlank(message = "产品类型名称不能为空", groups = {GroupA.class})
private String typeName;
/**
* 类别key 关联smart_sys_code中dict_key
*/
@NotBlank(message = "分类不能为空", groups = {GroupA.class})
private String categoryKey;
/**
* 商城标签
*/
@NotBlank(message = "商城标签不能为空", groups = {GroupA.class})
private String shopTag;
/**
* 备注
*/
private String remark;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private Long createBy;
/**
* 更新时间
*/
private Date updateTime;
/**
* 更新人
*/
private Long updateBy;
}
package com.glsx.admin.pojo.request;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-19
*/
/**
* 车家智能场景支持设备条件表
*/
@Data
public class ScenceSupstatusReq {
private Integer id;
/**
* 产品支持状态code
*/
private String sceneSupstatusCode;
/**
* 产品支持状态value
*/
private String sceneSupstatusValue;
/**
* 产品id
*/
private String productId;
/**
* 状态对应的指令code
*/
private String orderCode;
private String orderValue;
/**
* 1.等于 2.大于 3.小于
*/
private String type;
/**
* 状态 1上线 0下线
*/
private Byte status;
}
package com.glsx.admin.pojo.request;
import com.glsx.admin.pojo.BaseDTO;
import com.glsx.admin.pojo.GroupA;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.groups.Default;
import java.util.Date;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能场景模板表
*/
@Data
public class SceneTemplateReq extends BaseDTO {
/**
* 标识ID
*/
@NotNull(message = "id不能为空", groups = {Default.class})
private Long id;
/**
* 场景名称
*/
@NotEmpty(message = "sceneName不能为空", groups = {GroupA.class})
private String sceneName;
/**
* 场景类型key 关联smart_sys_code中dict_key
*/
@NotEmpty(message = "typeKey不能为空", groups = {GroupA.class})
private String typeKey;
/**
* 场景图标ID 关联smart_sys_file中id
*/
@NotNull(message = "icon不能为空", groups = {GroupA.class})
private Long icon;
/**
* 场景背景图ID 关联smart_sys_file中id
*/
@NotNull(message = "backPic不能为空", groups = {GroupA.class})
private Long backPic;
/**
* 查看次数
*/
private Long viewTimes;
/**
* 场景描述
*/
private String description;
/**
* 条件规则 1任一条件 2全部条件
*/
private Byte conditionRule;
/**
* 执行周期 1每天 2工作日 3法定节假日
*/
private Byte executeCycle;
/**
* 状态:0下线 1上线
*/
private Byte status;
/**
* 备注
*/
private String remark;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private Long createBy;
/**
* 更新时间
*/
private Date updateTime;
/**
* 更新人
*/
private Long updateBy;
/**
* 模板list
*/
private List<TemplateParamReq> templateList;
}
package com.glsx.admin.pojo.request;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
@Data
@Table(name = "smart_device_status")
public class SmartDeviceStatusReq {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 设备id
*/
private String deviceId;
/**
* 设备指令
*/
private String deviceOrderCode;
/**
* 设备指令值
*/
private String deviceOrderValue;
/**
* 创建时间
*/
private Date createtime;
/**
* 更新时间
*/
private Date updatetime;
/**
* 产品id
*/
private String productKey;
}
package com.glsx.admin.pojo.request;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data;
/**
* 车家智能用户场景数据表
*/
@Data
@Table(name = "smart_scene_data")
public class SmartSceneDataReq {
/**
* 标识ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 场景ID 关联smart_scene中id
*/
private Long sceneId;
/**
* 类型 1触发条件 2执行内容
*/
private Byte type;
/**
* 排序
*/
private Byte sort;
/**
* 参数key
*/
private String paramKey;
/**
* 参数值 数组对象
*/
private String paramValue;
}
package com.glsx.admin.pojo.request;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能用户场景表
*/
@Data
@Table(name = "smart_scene")
public class SmartSceneReq {
/**
* 标识ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 用户ID 关联smart_user_relation中id
*/
private Long userId;
/**
* 场景名称
*/
private String scenesName;
/**
* 场景类型key 关联smart_sys_code中dict_key
*/
private String typeKey;
/**
* 场景图标ID 关联smart_sys_file中id
*/
private Long icon;
/**
* 场景背景图ID 关联smart_sys_file中id
*/
private Long backPic;
/**
* 查看次数
*/
private Long viewTimes;
/**
* 场景描述
*/
private String description;
/**
* 条件规则 1任一条件 2全部条件
*/
private Byte conditionRule;
/**
* 执行周期 1每天 2工作日 3法定节假日
*/
private Byte executeCycle;
/**
* 状态:0下线 1上线
*/
private Byte status;
/**
* 备注
*/
private String remark;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
}
package com.glsx.admin.pojo.request;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
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
@Table(name = "smart_sys_code")
public class SmartSysCodeReq extends BaseDTO {
/**
* 标识ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 字典类型
*/
private String dictType;
/**
* 字典键值
*/
private String dictKey;
/**
* 字典值
*/
private String dictValue;
/**
* 父级键值
*/
private String parentKey;
/**
* 排序
*/
private Byte sort;
/**
* 状态:0下线 1上线
*/
private Byte status;
/**
* 分级
*/
private Byte level;
/**
* 备注
*/
private String remark;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private Long createBy;
/**
* 更新时间
*/
private Date updateTime;
/**
* 更新人
*/
private Long updateBy;
}
package com.glsx.admin.pojo.request;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能系统文件表
*/
@Data
@Table(name = "smart_sys_file")
public class SmartSysFileReq {
/**
* 标识ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 文件名
*/
private String name;
/**
* 文件链接
*/
private String url;
/**
* 类型:0公共 1图片素材库
*/
private Byte type;
/**
* 创建时间
*/
private Date createTime;
}
package com.glsx.admin.pojo.request;
import java.util.Date;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-16
*/
/**
* 车家智能用户设备数据表
*/
@Data
public class SmartUserDeviceDataReq {
/**
* 标识ID
*/
private Long id;
/**
* 用户ID 关联smart_user_relation中id
*/
private Long userId;
/**
* 设备ID
*/
private String deviceId;
/**
* 查看次数
*/
private Long viewTimes;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
}
package com.glsx.admin.pojo.request;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能用户平台注册信息表
*/
@Data
@Table(name = "smart_user_relation")
public class SmartUserRelationReq {
/**
* 标识ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 用户昵称
*/
private String name;
/**
* 手机号 来自嘀加平台用户
*/
private String phone;
/**
* 用户密码
*/
private String password;
/**
* 第三方平台标识 1涂鸦
*/
private Byte channel;
/**
* 第三方平台用户id
*/
private String thirdId;
/**
* 状态 0注销 1正常
*/
private Byte status;
/**
* 备注
*/
private String remark;
/**
* 创建时间
*/
private Date createTime;
}
package com.glsx.admin.pojo.request;
import lombok.Data;
/**
* 车家智能系统代码集表
*/
@Data
public class SysCodeReq {
/**
* 标识ID
*/
private Long id;
/**
* 字典类型
*/
private String dictType;
/**
* 字典键值
*/
private String dictKey;
/**
* 字典值
*/
private String dictValue;
/**
* 父级键值
*/
private String parentKey;
/**
* 排序
*/
private Byte sort;
/**
* 状态:0下线 1上线
*/
private Byte status;
/**
* 分级
*/
private Byte level;
}
package com.glsx.admin.pojo.request;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
import lombok.Data;
/**
* 车家智能场景模板参数表
*/
@Data
public class TemplateParamReq {
/**
* 标识ID
*/
private Long id;
/**
* 模板ID 关联smart_scene_template中id
*/
private Long templateId;
/**
* 类型 1触发条件 2执行内容
*/
private Byte type;
/**
* 排序
*/
private Byte sort;
/**
* 参数key
*/
private String paramKey;
/**
* 模板值 数组对象
*/
private String paramValue;
}
package com.glsx.admin.pojo.response;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-17
*/
@Data
public class DeviceOrderResp {
private Integer id;
/**
* 产品id
*/
private String productId;
private String orderCode;
private String orderValue;
/**
* 设备类型 1.非固定值不需要查询 2.固定值需要查询
*/
private String orderType;
/**
* 1.String类型 2.Interger类型 3.boolean类型
*/
private String orderValueType;
}
package com.glsx.admin.pojo.response;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-19
*/
/**
* 车家智能场景设备指令集表
*/
@Data
public class DeviceOrderValueResp {
private Integer id;
/**
* 关联smart_device_order表中id
*/
private Integer orderId;
private String deviceStatusCode;
private String deviceStatusValue;
}
package com.glsx.admin.pojo.response;
import javax.persistence.Transient;
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 ProductResp extends BaseDTO {
/**
* 图标 url
*/
@Transient
private String iconUrl;
/**
* 产品类型名称
*/
@Transient
private String typeName;
/**
* 标识ID
*/
private Long id;
/**
* 产品名称
*/
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;
import java.util.Date;
import java.util.List;
import com.glsx.admin.pojo.BaseDTO;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能产品类型表
*/
@Data
public class ProductTypeResp extends BaseDTO {
/**
* 一级分类
*/
private String firstCategory;
/**
* 标识ID
*/
private Long id;
/**
* 类型名称
*/
private String typeName;
/**
* 类别key 关联smart_sys_code中dict_key
*/
private String categoryKey;
/**
* 商城标签
*/
private String shopTag;
/**
* 备注
*/
private String remark;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private Long createBy;
/**
* 更新时间
*/
private Date updateTime;
/**
* 更新人
*/
private Long updateBy;
private List<ScenceSupstatusResp> conditionList;
private List<DeviceOrderResp> contentList;
}
package com.glsx.admin.pojo.response;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-19
*/
/**
* 车家智能场景支持设备条件表
*/
@Data
public class ScenceSupstatusResp {
private Integer id;
/**
* 产品支持状态code
*/
private String sceneSupstatusCode;
/**
* 产品支持状态value
*/
private String sceneSupstatusValue;
/**
* 产品id
*/
private String productId;
/**
* 状态对应的指令code
*/
private String orderCode;
private String orderValue;
/**
* 1.等于 2.大于 3.小于
*/
private String type;
}
package com.glsx.admin.pojo.response;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能场景模板表
*/
@Data
public class SceneTemplateResp {
/**
* 标识ID
*/
private Long id;
/**
* 场景名称
*/
private String sceneName;
/**
* 场景类型key 关联smart_sys_code中dict_key
*/
private String typeKey;
/**
* 场景图标ID 关联smart_sys_file中id
*/
private Long icon;
/**
* 场景图标
*/
private String iconUrl;
/**
* 场景背景图ID 关联smart_sys_file中id
*/
private Long backPic;
/**
* 场景背景图
*/
private String backPicUrl;
/**
* 查看次数
*/
private Long viewTimes=0L;
/**
* 场景描述
*/
private String description;
/**
* 条件规则 1任一条件 2全部条件
*/
private Byte conditionRule;
/**
* 执行周期 1每天 2工作日 3法定节假日
*/
private Byte executeCycle;
/**
* 状态:0下线 1上线
*/
private Byte status;
/**
* 备注
*/
private String remark;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private Long createBy;
/**
* 更新时间
*/
private Date updateTime;
/**
* 更新人
*/
private Long updateBy;
/**
* 模板list
*/
private List<TemplateParamResp> templateList;
private int useCount;
}
package com.glsx.admin.pojo.response;
import java.util.Date;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能系统代码集表
*/
@Data
public class SysCodeResp {
/**
* 标识ID
*/
private Long id;
/**
* 字典类型
*/
private String dictType;
/**
* 字典键值
*/
private String dictKey;
/**
* 字典值
*/
private String dictValue;
/**
* 父级键值
*/
private String parentKey;
/**
* 排序
*/
private Byte sort;
/**
* 状态:0下线 1上线
*/
private Byte status;
/**
* 分级
*/
private Byte level;
/**
* 备注
*/
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-15
*/
import lombok.Data;
/**
* 车家智能场景模板参数表
*/
@Data
public class TemplateParamResp {
/**
* 标识ID
*/
private Long id;
/**
* 模板ID 关联smart_scene_template中id
*/
private Long templateId;
/**
* 类型 1触发条件 2执行内容
*/
private Byte type;
/**
* 排序
*/
private Byte sort;
/**
* 参数key
*/
private String paramKey;
/**
* 模板值 数组对象
*/
private String paramValue;
}
......@@ -6,11 +6,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@FeignClient(name = "${feigin.server.name}",url = "${feigin.server.url}", fallback = IndexHystrix.class)
@FeignClient(name = "${feign.server.name}",url = "${feign.server.url}", fallback = IndexHystrix.class)
public interface IndexFeignClient {
@ResponseBody
@RequestMapping(value = "/home", method = {RequestMethod.GET})
String getHome();
}
package com.glsx.admin.remote;
import com.glsx.admin.pojo.request.DeviceOrderValueReq;
import com.glsx.admin.pojo.response.DeviceOrderValueResp;
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.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@FeignClient(name = "${feign.server.name}",url = "${feign.server.url}")
public interface OrderValueFeignClient {
@ResponseBody
@RequestMapping(value = "/orderValue/getList", method = {RequestMethod.POST})
List<DeviceOrderValueResp> getList(@RequestBody DeviceOrderValueReq req);
}
package com.glsx.admin.remote;
import com.glsx.admin.pojo.request.ScenceSupstatusReq;
import com.glsx.admin.pojo.response.ScenceSupstatusResp;
import com.glsx.admin.remote.impl.IndexHystrix;
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.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@FeignClient(name = "${feign.server.name}",url = "${feign.server.url}")
public interface ProductConditionFeignClient {
@ResponseBody
@RequestMapping(value = "/condition/getList", method = {RequestMethod.GET})
List<ScenceSupstatusResp> getList(@RequestBody ScenceSupstatusReq req);
}
package com.glsx.admin.remote;
import com.glsx.admin.pojo.request.DeviceOrderReq;
import com.glsx.admin.pojo.response.DeviceOrderResp;
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.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@FeignClient(name = "${feign.server.name}",url = "${feign.server.url}")
public interface ProductContentFeignClient {
@ResponseBody
@RequestMapping(value = "/content/getList", method = {RequestMethod.GET})
List<DeviceOrderResp> getList(@RequestBody DeviceOrderReq req);
}
package com.glsx.admin.remote;
import java.util.List;
import com.github.pagehelper.PageInfo;
import com.glsx.admin.pojo.request.ProductReq;
import com.glsx.admin.pojo.response.DeviceOrderResp;
import com.glsx.admin.pojo.response.ProductResp;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-16
*/
@FeignClient(name = "${feign.server.name}",url = "${feign.server.url}")
public interface ProductFeignClient {
@RequestMapping(value = "/product/getPageList", method = {RequestMethod.GET})
@ResponseBody
PageInfo<ProductResp> getPageList(@SpringQueryMap ProductReq req);
@RequestMapping(value = "/product/getList", method = {RequestMethod.GET})
@ResponseBody
List<ProductResp> getList(@SpringQueryMap ProductReq req);
@RequestMapping(value = "/product/getById", method = {RequestMethod.GET})
@ResponseBody
ProductResp getById(@SpringQueryMap ProductReq req);
@RequestMapping(value = "/product/save", method = {RequestMethod.POST})
@ResponseBody
Boolean save(@RequestBody ProductReq req);
@RequestMapping("/product/getCommandSetById")
@ResponseBody
List<DeviceOrderResp> getCommandSetById(@SpringQueryMap ProductReq req);
@RequestMapping(value = "/product/putOnOff", method = {RequestMethod.POST})
@ResponseBody
Boolean putOnOff(@SpringQueryMap ProductReq req);
}
package com.glsx.admin.remote;
import java.util.List;
import com.github.pagehelper.PageInfo;
import com.glsx.admin.pojo.request.ProductTypeReq;
import com.glsx.admin.pojo.response.ProductTypeResp;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-17
*/
@FeignClient(name = "${feign.server.name}",url = "${feign.server.url}")
public interface ProductTypeFeignClient {
@RequestMapping(value = "/productType/getPageList", method = {RequestMethod.GET})
@ResponseBody
PageInfo<ProductTypeResp> getPageList(@SpringQueryMap ProductTypeReq req);
@RequestMapping(value = "/productType/getList", method = {RequestMethod.GET})
@ResponseBody
List<ProductTypeResp> getList(@SpringQueryMap ProductTypeReq req);
@RequestMapping(value = "/productType/getById", method = {RequestMethod.GET})
@ResponseBody
ProductTypeResp getById(@SpringQueryMap ProductTypeReq req);
@RequestMapping(value = "/productType/save", method = {RequestMethod.POST})
@ResponseBody
Boolean save(@RequestBody ProductTypeReq req);
@ResponseBody
@RequestMapping(value = "/productType/getListAndCondition", method = {RequestMethod.POST})
List<ProductTypeResp> getListAndCondition(@RequestBody List<Long> list);
@ResponseBody
@RequestMapping(value = "/productType/getListAndContent", method = {RequestMethod.POST})
List<ProductTypeResp> getListAndContent(@RequestBody List<Long> list);
}
package com.glsx.admin.remote;
import com.github.pagehelper.PageInfo;
import com.glsx.admin.pojo.request.SceneTemplateReq;
import com.glsx.admin.pojo.response.SceneTemplateResp;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author think.wang
* @date 2021-03-16
*/
@FeignClient(name = "${feign.server.name}",url = "${feign.server.url}")
public interface SceneTemplateFeignClient {
@ResponseBody
@RequestMapping(value = "/sceneTemplate/getPageList", method = {RequestMethod.GET})
PageInfo<SceneTemplateResp> getPageList(@RequestBody SceneTemplateReq req);
@ResponseBody
@RequestMapping(value = "/sceneTemplate/getList", method = {RequestMethod.POST})
List<SceneTemplateResp> getList(@RequestBody SceneTemplateReq req);
@ResponseBody
@RequestMapping(value = "/sceneTemplate/getById", method = {RequestMethod.GET})
SceneTemplateResp getById(@RequestParam("id") Long id);
@ResponseBody
@RequestMapping(value = "/sceneTemplate/add", method = {RequestMethod.POST})
boolean add(@RequestBody SceneTemplateReq req);
@ResponseBody
@RequestMapping(value = "/sceneTemplate/update", method = {RequestMethod.POST})
boolean update(@RequestBody SceneTemplateReq req);
@ResponseBody
@RequestMapping(value = "/sceneTemplate/updateParam", method = {RequestMethod.POST})
boolean updateParam(@RequestBody SceneTemplateReq req);
}
package com.glsx.admin.remote;
import java.util.List;
import com.glsx.admin.pojo.request.SysCodeReq;
import com.glsx.admin.pojo.response.SysCodeResp;
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.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author think.wang
* @date 2021-03-16
*/
@FeignClient(name = "${feign.server.name}",url = "${feign.server.url}")
public interface SysCodeFeignClient {
@ResponseBody
@RequestMapping(value = "/sysCode/getListByCondition", method = {RequestMethod.POST})
List<SysCodeResp> getListByCondition(@RequestBody SysCodeReq req);
}
......@@ -2,9 +2,6 @@
spring.profiles.active=dev
server.servlet.context-path=/smartAdmin
# \u5F00\u542F\u7194\u65AD
feign.hystrix.enabled=true
#\u6307\u5B9Adate\u8F93\u51FA\u683C\u5F0F\u4E3Ayyyy-MM-dd HH:mm:ss
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
......@@ -16,9 +13,8 @@ logging.level.org.springframework.boot.autoconfigure=off
logging.level.com.glsx.admin=DEBUG
logging.path=/data/java_log/jetty/smartService/chejia-smart-admin
feigin.server.name=chejia-smart-service
feigin.server.url=http://localhost:8209/smartService
dubbo.registry.address=zookeeper://192.168.1.36:2181
dubbo.registry.timeout=10000
# feign\u914D\u7F6E
feign.client.config.default.connect-timeout=20000
feign.client.config.default.read-timeout=20000
# \u5F00\u542F\u7194\u65AD
feign.hystrix.enabled=true
......@@ -71,12 +71,12 @@ else
fi
echo -e "Starting the $SERVER_NAME ...\c"
nohup $JAVA_HOME/bin/java $JAVA_OPTS $JAVA_MEM_OPTS $JAVA_DEBUG_OPTS $JAVA_JMX_OPTS -classpath $CONF_DIR:$LIB_JARS org.oreframework.boot.bootstrap.OreBootApplication env=$ENV > $STDOUT_FILE 2>&1 &
nohup $JAVA_HOME/bin/java $JAVA_OPTS $JAVA_MEM_OPTS $JAVA_DEBUG_OPTS $JAVA_JMX_OPTS -classpath $CONF_DIR:$LIB_JARS com.glsx.admin.SmartAdminApplication env=$ENV > $STDOUT_FILE 2>&1 &
COUNT=0
while [ $COUNT -lt 1 ]; do
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
sleep 1
if [ -n "$SERVER_PORT" ]; then
COUNT=`netstat -an | grep $SERVER_PORT | wc -l`
else
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!