Commit 411cd5e8 by tyfanchz

车家智能相关功能开发

1 parent e1c612a2
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.request.SmartProductReq;
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.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;
/**
* 获取产品列表。
*
* @param req 请求体
* @return 结果
*/
@RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST})
public R getList(SmartProductReq req) {
log.info("$$$$ /product/getList param: {}", JSON.toJSONString(req));
PageInfo<SmartProductReq> pageInfo = productFeignClient.getList(req);
return R.ok().putPageData(pageInfo);
}
/**
* 根据 id 查询产品详情。
*
* @param id 产品 id
* @return 结果
*/
@RequestMapping(value = "/getById", method = {RequestMethod.GET, RequestMethod.POST})
public SmartProductReq getById(Long id) {
return null;
}
/**
* 保存产品。无则插入,有则更新。
*
* @param product 产品
*/
@RequestMapping(value = "/save", method = {RequestMethod.POST})
public void save(@RequestBody @Validated SmartProductReq product) {
log.info("$$$$ /product/save param: {}", JSON.toJSONString(product));
}
/**
* 根据产品 id 获取指令集。
*
* @param id 产品 id
*/
@RequestMapping(value = "/getCommandSetById", method = {RequestMethod.GET, RequestMethod.POST})
public void getCommandSetById(Long id) {
log.info("$$$$ /product/getCommandSetById param: {}", id);
}
/**
* 校验商城商品 id。
*
* @param shopProductId 商品 id
*/
@RequestMapping(value = "/checkShopProductId", method = {RequestMethod.GET, RequestMethod.POST})
public Boolean checkShopProductId(String shopProductId) {
log.info("$$$$ /product/checkShopProductId param: {}", shopProductId);
if (StringUtils.isBlank(shopProductId)) {
throw new BusinessException(ResultEnum.PARAM_ERROR);
}
return null;
}
/**
* 上下架产品。
*
* @param id 产品 id
*/
@RequestMapping(value = "/putOnOff", method = {RequestMethod.GET, RequestMethod.POST})
public void putOnOff(Long id) {
log.info("$$$$ /product/putOnOff param: {}", id);
if (id == null) {
throw new BusinessException(ResultEnum.PARAM_ERROR);
}
}
}
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;
}
}
package com.glsx.admin.exception;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindException;
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 String handleBusinessException(BusinessException e) {
log.error("!!!! 业务异常", e);
return e.getMessage();
}
@ExceptionHandler({ServletRequestBindingException.class, MethodArgumentNotValidException.class,
BindException.class})
public String handleBindException(Exception e) {
log.error("!!!! 参数错误", e);
return ResultEnum.PARAM_ERROR.getMessage();
}
@ExceptionHandler(Exception.class)
public String handleException(Exception e) {
log.error("!!!! 未知异常", e);
return 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, "产品名称重复"),
PRODUCT_TYPE_NOT_FOUND(3001, "产品类型ID未找到"),
;
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.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;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
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
@Table(name = "smart_product")
public class SmartProductReq extends BaseDTO {
/**
* 标识ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
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.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_product_type_param")
public class SmartProductTypeParamReq {
/**
* 标识ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
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.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
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
@Table(name = "smart_product_type")
public class SmartProductTypeReq extends BaseDTO {
/**
* 一级分类名
*/
@Transient
private String categoryName1;
/**
* 二级分类名
*/
@Transient
private String categoryName2;
/**
* 标识ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 类型名称
*/
@NotBlank
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;
}
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 lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能场景模板表
*/
@Data
@Table(name = "smart_scene_template")
public class SmartSceneTemplateReq {
/**
* 标识ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 场景名称
*/
private String sceneName;
/**
* 场景类型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 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 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;
/**
* <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_template_param")
public class SmartTemplateParamReq {
/**
* 标识ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
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.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;
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!