Authored by caoyan

自助上架货号优化

package com.yohoufo.dal.product;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yohoufo.dal.product.model.ProductSelfShelves;
... ... @@ -9,4 +11,6 @@ public interface ProductSelfShelvesMapper {
int insert(@Param("record")ProductSelfShelves record);
List<ProductSelfShelves> selectByProductCode(@Param("productCode") String productCode);
}
\ No newline at end of file
... ...
... ... @@ -147,4 +147,11 @@
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectByProductCode" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from product_self_shelves
where product_code = #{productCode,jdbcType=VARCHAR}
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -12,7 +12,9 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.yoho.error.exception.ServiceException;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.dal.product.ProductSelfShelvesMapper;
import com.yohoufo.dal.product.model.ProductSelfShelves;
import com.yohoufo.product.service.SelfShelvesService;
... ... @@ -23,6 +25,8 @@ public class SelfShelvesController {
@Autowired
private SelfShelvesService selfShelvesService;
@Autowired
private ProductSelfShelvesMapper productSelfShelvesMapper;
@RequestMapping(params = "method=ufo.selfShelves.save")
@ResponseBody
... ... @@ -42,6 +46,12 @@ public class SelfShelvesController {
if(null == uid || 0 == uid.intValue()) {
return new ApiResponse.ApiResponseBuilder().code(401).message("uid为空,请登录").build();
}
//校验货号是否已存在
List<ProductSelfShelves> list = productSelfShelvesMapper.selectByProductCode(productCode);
if(CollectionUtils.isNotEmpty(list)) {
return new ApiResponse.ApiResponseBuilder().code(500).message("商品货号信息已存在,您可以直接通过搜索功能查询货号找到商品后进行出售").build();
}
ProductSelfShelves pss = new ProductSelfShelves();
pss.setUid(uid);
pss.setBrand(brand);
... ...