Commit db9bae72 by tyfanchz

1、删除无用代码

2、增加feign调用异常捕捉
3、车家智能后台接口开发
1 parent 99d857ff
...@@ -51,6 +51,10 @@ public class ProductController { ...@@ -51,6 +51,10 @@ public class ProductController {
*/ */
@RequestMapping(value = "/getById", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/getById", method = {RequestMethod.GET, RequestMethod.POST})
public SmartProduct getById(Long id) { public SmartProduct getById(Long id) {
log.info("$$$$ /product/getById param: {}", id);
if (id == null) {
throw new BusinessException(ResultEnum.PARAM_ERROR);
}
return productService.getById(id); return productService.getById(id);
} }
...@@ -85,7 +89,7 @@ public class ProductController { ...@@ -85,7 +89,7 @@ public class ProductController {
* @param shopProductId 商品 id * @param shopProductId 商品 id
*/ */
@RequestMapping(value = "/checkShopProductId", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/checkShopProductId", method = {RequestMethod.GET, RequestMethod.POST})
public boolean checkShopProductId(String shopProductId) { public Boolean checkShopProductId(String shopProductId) {
log.info("$$$$ /product/checkShopProductId param: {}", shopProductId); log.info("$$$$ /product/checkShopProductId param: {}", shopProductId);
if (StringUtils.isBlank(shopProductId)) { if (StringUtils.isBlank(shopProductId)) {
throw new BusinessException(ResultEnum.PARAM_ERROR); throw new BusinessException(ResultEnum.PARAM_ERROR);
......
...@@ -4,6 +4,8 @@ import java.util.List; ...@@ -4,6 +4,8 @@ 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.smart.dao.entity.SmartProductType; import com.glsx.smart.dao.entity.SmartProductType;
import com.glsx.smart.exception.BusinessException;
import com.glsx.smart.exception.ResultEnum;
import com.glsx.smart.service.SmartProductTypeService; import com.glsx.smart.service.SmartProductTypeService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -39,8 +41,17 @@ public class ProductTypeController { ...@@ -39,8 +41,17 @@ public class ProductTypeController {
return productTypeService.getList(req); return productTypeService.getList(req);
} }
/**
* 根据 id 获取产品类型。
*
* @param id 产品类型 id
* @return 结果
*/
@RequestMapping(value = "/getById", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/getById", method = {RequestMethod.GET, RequestMethod.POST})
public SmartProductType getById(Long id) { public SmartProductType getById(Long id) {
if (id == null) {
throw new BusinessException(ResultEnum.PARAM_ERROR);
}
return productTypeService.getById(id); return productTypeService.getById(id);
} }
......
...@@ -3,7 +3,6 @@ package com.glsx.smart.dao.mapper; ...@@ -3,7 +3,6 @@ package com.glsx.smart.dao.mapper;
import java.util.List; import java.util.List;
import com.glsx.smart.dao.entity.SmartProduct; import com.glsx.smart.dao.entity.SmartProduct;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/** /**
* <p>Description: * <p>Description:
...@@ -18,15 +17,4 @@ public interface SmartProductMapper extends tk.mybatis.mapper.common.Mapper<Smar ...@@ -18,15 +17,4 @@ public interface SmartProductMapper extends tk.mybatis.mapper.common.Mapper<Smar
List<SmartProduct> getList(SmartProduct req); List<SmartProduct> getList(SmartProduct req);
int countByProductName(String productName); int countByProductName(String productName);
int insertOrUpdate(SmartProduct record);
int insertOrUpdateSelective(SmartProduct record);
int updateBatch(List<SmartProduct> list);
int updateBatchSelective(List<SmartProduct> list);
int batchInsert(@Param("list") List<SmartProduct> list);
} }
...@@ -3,7 +3,6 @@ package com.glsx.smart.dao.mapper; ...@@ -3,7 +3,6 @@ package com.glsx.smart.dao.mapper;
import java.util.List; import java.util.List;
import com.glsx.smart.dao.entity.SmartProductType; import com.glsx.smart.dao.entity.SmartProductType;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/** /**
* <p>Description: * <p>Description:
...@@ -16,15 +15,4 @@ import org.apache.ibatis.annotations.Param; ...@@ -16,15 +15,4 @@ import org.apache.ibatis.annotations.Param;
@Mapper @Mapper
public interface SmartProductTypeMapper extends tk.mybatis.mapper.common.Mapper<SmartProductType> { public interface SmartProductTypeMapper extends tk.mybatis.mapper.common.Mapper<SmartProductType> {
List<SmartProductType> getList(SmartProductType req); List<SmartProductType> getList(SmartProductType req);
int insertOrUpdate(SmartProductType record);
int insertOrUpdateSelective(SmartProductType record);
int updateBatch(List<SmartProductType> list);
int updateBatchSelective(List<SmartProductType> list);
int batchInsert(@Param("list") List<SmartProductType> list);
} }
...@@ -5,7 +5,6 @@ import org.springframework.validation.BindException; ...@@ -5,7 +5,6 @@ import org.springframework.validation.BindException;
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;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/** /**
* <p>Description: * <p>Description:
...@@ -13,9 +12,11 @@ import org.springframework.web.bind.annotation.RestControllerAdvice; ...@@ -13,9 +12,11 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
* *
* @author wbh * @author wbh
* @date 2021-03-16 * @date 2021-03-16
* @deprecated 已废弃,需要抛出异常让上游服务感知
*/ */
@Slf4j @Slf4j
@RestControllerAdvice //@RestControllerAdvice
@Deprecated
public class GlobalExceptionHandler { public class GlobalExceptionHandler {
@ExceptionHandler({BusinessException.class}) @ExceptionHandler({BusinessException.class})
public String handleBusinessException(BusinessException e) { public String handleBusinessException(BusinessException e) {
......
...@@ -22,7 +22,7 @@ public interface SmartProductService { ...@@ -22,7 +22,7 @@ public interface SmartProductService {
List<SmartDeviceOrder> getCommandSetById(String productId); List<SmartDeviceOrder> getCommandSetById(String productId);
boolean checkShopProductId(String shopProductId); Boolean checkShopProductId(String shopProductId);
void putOnOff(Long id); void putOnOff(Long id);
} }
...@@ -109,7 +109,7 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct ...@@ -109,7 +109,7 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
* @return 商品 id 是否合法 * @return 商品 id 是否合法
*/ */
@Override @Override
public boolean checkShopProductId(String shopProductId) { public Boolean checkShopProductId(String shopProductId) {
return RandomUtil.randomBoolean(); return RandomUtil.randomBoolean();
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!