Commit 140aaf97 by tyfanchz

产品模块实体类修改

1 parent 571e8f61
package cn.com.glsx.smart.modules.controller; package cn.com.glsx.smart.modules.controller;
import java.util.List;
import cn.com.glsx.smart.modules.entity.SmartDeviceOrder; import cn.com.glsx.smart.modules.entity.SmartDeviceOrder;
import cn.com.glsx.smart.modules.entity.SmartProduct; import cn.com.glsx.smart.modules.entity.SmartProduct;
import cn.com.glsx.smart.modules.model.ValidateGroups;
import cn.com.glsx.smart.modules.model.request.SmartProductQueryReq;
import cn.com.glsx.smart.modules.model.request.SmartProductSaveReq;
import cn.com.glsx.smart.modules.service.SmartProductService; import cn.com.glsx.smart.modules.service.SmartProductService;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.web.R; import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/** /**
* <p>Description: 产品列表业务 * <p>Description: 产品列表业务
...@@ -34,9 +43,10 @@ public class ProductController { ...@@ -34,9 +43,10 @@ public class ProductController {
* @return 结果 * @return 结果
*/ */
@GetMapping("/getPageList") @GetMapping("/getPageList")
public R getPageList(SmartProduct req) { public R getPageList(SmartProductQueryReq req) {
log.info("$$$$ /product/getPageList param: {}", JSON.toJSONString(req)); log.info("$$$$ /product/getPageList param: {}", JSON.toJSONString(req));
PageInfo<SmartProduct> pageInfo = productService.getPageList(req); SmartProduct product = BeanUtil.toBean(req, SmartProduct.class);
PageInfo<SmartProduct> pageInfo = productService.getPageList(product);
return R.ok().putPageData(pageInfo); return R.ok().putPageData(pageInfo);
} }
...@@ -47,9 +57,10 @@ public class ProductController { ...@@ -47,9 +57,10 @@ public class ProductController {
* @return 结果 * @return 结果
*/ */
@GetMapping("/getList") @GetMapping("/getList")
public R getList(SmartProduct req) { public R getList(SmartProductQueryReq req) {
log.info("$$$$ /product/getList param: {}", JSON.toJSONString(req)); log.info("$$$$ /product/getList param: {}", JSON.toJSONString(req));
List<SmartProduct> productList = productService.getList(req); SmartProduct product = BeanUtil.toBean(req, SmartProduct.class);
List<SmartProduct> productList = productService.getList(product);
return R.ok().data(productList); return R.ok().data(productList);
} }
...@@ -73,7 +84,7 @@ public class ProductController { ...@@ -73,7 +84,7 @@ public class ProductController {
* @return 结果 * @return 结果
*/ */
@GetMapping("/getById") @GetMapping("/getById")
public R getById(Long id) { public R getById(@RequestParam Long id) {
log.info("$$$$ /product/getById param: {}", id); log.info("$$$$ /product/getById param: {}", id);
SmartProduct product = productService.getById(id); SmartProduct product = productService.getById(id);
return R.ok().data(product); return R.ok().data(product);
...@@ -94,12 +105,13 @@ public class ProductController { ...@@ -94,12 +105,13 @@ public class ProductController {
/** /**
* 保存产品。无则插入,有则更新。 * 保存产品。无则插入,有则更新。
* *
* @param product 产品 * @param req 产品
* @return 是否成功 * @return 是否成功
*/ */
@PostMapping("/save") @PostMapping("/save")
public R save(@RequestBody SmartProduct product) { public R save(@RequestBody @Validated(ValidateGroups.Insert.class) SmartProductSaveReq req) {
log.info("$$$$ /product/save param: {}", JSON.toJSONString(product)); log.info("$$$$ /product/save param: {}", JSON.toJSONString(req));
SmartProduct product = BeanUtil.toBean(req, SmartProduct.class);
Boolean success = productService.save(product); Boolean success = productService.save(product);
return R.ok().data(success); return R.ok().data(success);
} }
...@@ -110,7 +122,7 @@ public class ProductController { ...@@ -110,7 +122,7 @@ public class ProductController {
* @param id 产品 id * @param id 产品 id
*/ */
@GetMapping("/getCommandSetById") @GetMapping("/getCommandSetById")
public R getCommandSetById(Long id) { public R getCommandSetById(@RequestParam Long id) {
log.info("$$$$ /product/getCommandSetById param: {}", id); log.info("$$$$ /product/getCommandSetById param: {}", id);
List<SmartDeviceOrder> deviceOrderList = productService.getCommandSetById(id); List<SmartDeviceOrder> deviceOrderList = productService.getCommandSetById(id);
return R.ok().data(deviceOrderList); return R.ok().data(deviceOrderList);
...@@ -123,7 +135,7 @@ public class ProductController { ...@@ -123,7 +135,7 @@ public class ProductController {
* @return 结果 * @return 结果
*/ */
@GetMapping("/getSupportedCommands") @GetMapping("/getSupportedCommands")
public R getSupportedCommands(String platformProductId) { public R getSupportedCommands(@RequestParam String platformProductId) {
log.info("$$$$ /product/getSupportedCommands param: {}", platformProductId); log.info("$$$$ /product/getSupportedCommands param: {}", platformProductId);
List<String> commands = productService.getSupportedCommands(platformProductId); List<String> commands = productService.getSupportedCommands(platformProductId);
return R.ok().data(commands); return R.ok().data(commands);
...@@ -136,7 +148,7 @@ public class ProductController { ...@@ -136,7 +148,7 @@ public class ProductController {
* @return 是否成功 * @return 是否成功
*/ */
@PostMapping("/putOnOff") @PostMapping("/putOnOff")
public R putOnOff(Long id) { public R putOnOff(@RequestParam Long id) {
log.info("$$$$ /product/putOnOff param: {}", id); log.info("$$$$ /product/putOnOff param: {}", id);
Boolean success = productService.putOnOff(id); Boolean success = productService.putOnOff(id);
return R.ok().data(success); return R.ok().data(success);
......
package cn.com.glsx.smart.modules.controller; package cn.com.glsx.smart.modules.controller;
import java.util.List;
import cn.com.glsx.smart.modules.entity.SmartProductType; import cn.com.glsx.smart.modules.entity.SmartProductType;
import cn.com.glsx.smart.modules.model.ValidateGroups;
import cn.com.glsx.smart.modules.model.request.SmartProductTypeQueryReq;
import cn.com.glsx.smart.modules.model.request.SmartProductTypeSaveReq;
import cn.com.glsx.smart.modules.service.SmartProductTypeService; import cn.com.glsx.smart.modules.service.SmartProductTypeService;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.web.R; import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/** /**
* <p>Description: 产品类型业务 * <p>Description: 产品类型业务
...@@ -32,9 +41,10 @@ public class ProductTypeController { ...@@ -32,9 +41,10 @@ public class ProductTypeController {
* @return 结果 * @return 结果
*/ */
@GetMapping("/getPageList") @GetMapping("/getPageList")
public R getPageList(SmartProductType req) { public R getPageList(SmartProductTypeQueryReq req) {
log.info("$$$$ /productType/getPageList param: {}", JSON.toJSONString(req)); log.info("$$$$ /productType/getPageList param: {}", JSON.toJSONString(req));
PageInfo<SmartProductType> pageInfo = productTypeService.getPageList(req); SmartProductType productType = BeanUtil.toBean(req, SmartProductType.class);
PageInfo<SmartProductType> pageInfo = productTypeService.getPageList(productType);
return R.ok().putPageData(pageInfo); return R.ok().putPageData(pageInfo);
} }
...@@ -45,9 +55,10 @@ public class ProductTypeController { ...@@ -45,9 +55,10 @@ public class ProductTypeController {
* @return 结果 * @return 结果
*/ */
@GetMapping("/getList") @GetMapping("/getList")
public R getList(SmartProductType req) { public R getList(SmartProductTypeQueryReq req) {
log.info("$$$$ /productType/getList param: {}", JSON.toJSONString(req)); log.info("$$$$ /productType/getList param: {}", JSON.toJSONString(req));
List<SmartProductType> productTypeList = productTypeService.getList(req); SmartProductType productType = BeanUtil.toBean(req, SmartProductType.class);
List<SmartProductType> productTypeList = productTypeService.getList(productType);
return R.ok().data(productTypeList); return R.ok().data(productTypeList);
} }
...@@ -58,7 +69,7 @@ public class ProductTypeController { ...@@ -58,7 +69,7 @@ public class ProductTypeController {
* @return 结果 * @return 结果
*/ */
@GetMapping("/getById") @GetMapping("/getById")
public R getById(Long id) { public R getById(@RequestParam Long id) {
SmartProductType productType = productTypeService.getById(id); SmartProductType productType = productTypeService.getById(id);
return R.ok().data(productType); return R.ok().data(productType);
} }
...@@ -66,12 +77,13 @@ public class ProductTypeController { ...@@ -66,12 +77,13 @@ public class ProductTypeController {
/** /**
* 保存产品类型。 * 保存产品类型。
* *
* @param productType 产品类型 * @param req 产品类型
* @return 是否成功 * @return 是否成功
*/ */
@PostMapping("/save") @PostMapping("/save")
public R save(@RequestBody SmartProductType productType) { public R save(@RequestBody @Validated(ValidateGroups.Insert.class) SmartProductTypeSaveReq req) {
log.info("$$$$ /productType/save param: {}", JSON.toJSONString(productType)); log.info("$$$$ /productType/save param: {}", JSON.toJSONString(req));
SmartProductType productType = BeanUtil.toBean(req, SmartProductType.class);
Boolean success = productTypeService.save(productType); Boolean success = productTypeService.save(productType);
return R.ok().data(success); return R.ok().data(success);
} }
......
package cn.com.glsx.smart.modules.model; package cn.com.glsx.smart.modules.model.request;
import cn.com.glsx.smart.modules.model.BaseDTO;
import lombok.Data; import lombok.Data;
/** /**
* <p>Description: 嘀加商城 API 实体类 * <p>Description:
* <p>Project: chejia-smart * <p>Project: chejia-smart
* *
* @author wbh * @author wbh
* @date 2021-03-24 * @date 2021-03-15
*/ */
@Data
public class DjApiDTO {
private String code;
private String errId;
private String message;
private String data; /**
* 车家智能产品数据表
*/
@Data
public class SmartProductQueryReq extends BaseDTO {
} }
package cn.com.glsx.smart.modules.model.request;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import cn.com.glsx.smart.modules.model.ValidateGroups;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能产品数据表
*/
@Data
public class SmartProductSaveReq implements Serializable {
/**
* 标识ID
*/
@NotNull(message = "id不能为空", groups = ValidateGroups.Query.class)
private Long id;
/**
* 产品名称
*/
@NotBlank(message = "产品名称不能为空", groups = ValidateGroups.Insert.class)
private String productName;
/**
* 图片ID 关联smart_sys_file中id
*/
@NotNull(message = "缩略图不能为空", groups = ValidateGroups.Insert.class)
private Long icon;
/**
* 产品类型ID 关联smart_product_type中id
*/
@NotNull(message = "产品类型不能为空", groups = ValidateGroups.Insert.class)
private Long typeId;
/**
* 商城产品id
*/
@NotBlank(message = "商品id不能为空", groups = ValidateGroups.Insert.class)
private String shopProductId;
/**
* 接入平台key 关联smart_sys_code中dict_key
*/
@NotBlank(message = "接入平台不能为空", groups = ValidateGroups.Insert.class)
private String platformKey;
/**
* 接入平台产品id
*/
@NotBlank(message = "产品id不能为空", groups = ValidateGroups.Insert.class)
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 cn.com.glsx.smart.modules.model.request;
import cn.com.glsx.smart.modules.model.BaseDTO;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能产品类型表
*/
@Data
public class SmartProductTypeQueryReq extends BaseDTO {
}
package cn.com.glsx.smart.modules.model.request;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import cn.com.glsx.smart.modules.model.ValidateGroups;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能产品类型表
*/
@Data
public class SmartProductTypeSaveReq implements Serializable {
/**
* 标识ID
*/
@NotNull(message = "id不能为空", groups = ValidateGroups.Query.class)
private Long id;
/**
* 类型名称
*/
@NotBlank(message = "产品类型名称不能为空", groups = ValidateGroups.Insert.class)
private String typeName;
/**
* 类别key 关联smart_sys_code中dict_key
*/
@NotBlank(message = "分类不能为空", groups = ValidateGroups.Insert.class)
private String categoryKey;
/**
* 商城标签
*/
@NotBlank(message = "商城标签不能为空", groups = ValidateGroups.Insert.class)
private String shopTag;
/**
* 备注
*/
private String remark;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private Long createBy;
/**
* 更新时间
*/
private Date updateTime;
/**
* 更新人
*/
private Long updateBy;
}
package cn.com.glsx.smart.modules.model.response;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能产品数据表
*/
@Data
public class SmartProductResp implements Serializable {
/**
* 图标 url
*/
private String iconUrl;
/**
* 二级分类 key
*/
private String categoryKey;
/**
* 产品类型名称
*/
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 cn.com.glsx.smart.modules.model.response;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import cn.com.glsx.smart.modules.entity.SmartDeviceOrder;
import cn.com.glsx.smart.modules.entity.SmartScenceSupstatus;
import lombok.Data;
/**
* <p>Description:
* <p>Project: chejia-smart
*
* @author wbh
* @date 2021-03-15
*/
/**
* 车家智能产品类型表
*/
@Data
public class SmartProductTypeResp implements Serializable {
/**
* 一级分类
*/
private String firstCategory;
/**
* 内容列表
*/
private List<SmartDeviceOrder> contentList;
/**
* 条件列表
*/
private List<SmartScenceSupstatus> conditionList;
/**
* 标识ID
*/
private Long id;
/**
* 类型名称
*/
private String typeName;
/**
* 类别key 关联smart_sys_code中dict_key
*/
private String categoryKey;
/**
* 商城标签
*/
private String shopTag;
/**
* 关联涂鸦的产品类型
*/
private Integer tuyaCategoryId;
/**
* 备注
*/
private String remark;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private Long createBy;
/**
* 更新时间
*/
private Date updateTime;
/**
* 更新人
*/
private Long updateBy;
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!