|
|
package com.yohoufo.product.controller;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import com.yohoufo.common.ApiResponse;
|
|
|
import com.yohoufo.dal.product.model.ProductSelfShelves;
|
|
|
import com.yohoufo.product.service.SelfShelvesService;
|
|
|
|
|
|
@RestController
|
|
|
public class SelfShelvesController {
|
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(SelfShelvesController.class);
|
|
|
|
|
|
@Autowired
|
|
|
private SelfShelvesService selfShelvesService;
|
|
|
|
|
|
@RequestMapping(params = "method=ufo.selfShelves.save")
|
|
|
@ResponseBody
|
|
|
public ApiResponse save(@RequestParam(value = "uid", required = true) Integer uid,
|
|
|
@RequestParam(value = "brand", required = true) String brand,
|
|
|
@RequestParam(value = "product_name", required = true) String productName,
|
|
|
@RequestParam(value = "price", required = true) String price,
|
|
|
@RequestParam(value = "sale_time", required = true) String saleTime,
|
|
|
@RequestParam(value = "product_code", required = true) String productCode,
|
|
|
@RequestParam(value = "imageList", required = true) List<String> imageList) {
|
|
|
LOGGER.info("ufo.selfShelves.save in. uid is {}, brand is {}, productName is {}, price is {}, "
|
|
|
+ "saleTime is {}, productCode is {}, imageList is {}", uid, brand, productName, price, saleTime, productCode, imageList);
|
|
|
if(StringUtils.isEmpty(brand) || StringUtils.isEmpty(productName) || StringUtils.isEmpty(price)
|
|
|
|| StringUtils.isEmpty(saleTime) || StringUtils.isEmpty(productCode) || CollectionUtils.isEmpty(imageList)) {
|
|
|
return new ApiResponse.ApiResponseBuilder().code(500).message("有参数为空").build();
|
|
|
}
|
|
|
if(null == uid || 0 == uid.intValue()) {
|
|
|
return new ApiResponse.ApiResponseBuilder().code(401).message("uid为空,请登录").build();
|
|
|
}
|
|
|
ProductSelfShelves pss = new ProductSelfShelves();
|
|
|
pss.setUid(uid);
|
|
|
pss.setBrand(brand);
|
|
|
pss.setProductName(productName);
|
|
|
pss.setProductCode(productCode);
|
|
|
int result = selfShelvesService.save(pss, price, saleTime, imageList);
|
|
|
if(result>0) {
|
|
|
return new ApiResponse.ApiResponseBuilder().code(200).message("保存成功").build();
|
|
|
}else {
|
|
|
return new ApiResponse.ApiResponseBuilder().code(500).message("保存失败").build();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|