mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-02 02:06:38 +08:00
commit
93b5b1df1c
@ -55,6 +55,8 @@ public class ResponseCodeConst {
|
||||
|
||||
public static ResponseCodeConst JSON_FORMAT_ERROR = new ResponseCodeConst(115, "JSON格式错误");
|
||||
|
||||
public static ResponseCodeConst NOT_EXISTS_PROD = new ResponseCodeConst(116, "商品不存在!");
|
||||
|
||||
protected int code;
|
||||
|
||||
protected String msg;
|
||||
|
@ -23,6 +23,6 @@ public class Example implements ITask {
|
||||
|
||||
@Override
|
||||
public void execute(String paramJson) throws Exception {
|
||||
log.warn("{}-今天搬了{}块砖,paramJson:{}",SmartDateUtil.formatYMDHMS(new Date()),System.currentTimeMillis(),paramJson );
|
||||
//log.warn("{}-今天搬了{}块砖,paramJson:{}",SmartDateUtil.formatYMDHMS(new Date()),System.currentTimeMillis(),paramJson );
|
||||
}
|
||||
}
|
||||
|
@ -25,10 +25,9 @@ import net.lab1024.smartadmin.util.MapRemoveNullUtil;
|
||||
import net.lab1024.smartadmin.util.SmartHttpUtil;
|
||||
import net.lab1024.smartadmin.util.SmartJWTUtil;
|
||||
import net.lab1024.smartadmin.util.SmartStringUtil;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -230,6 +229,25 @@ public class GoodController {
|
||||
return ResponseDTO.succ();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改购物车商品数量信息", notes = "修改购物车数量信息")
|
||||
@PostMapping("royalcanin/updateCartCount")
|
||||
public ResponseDTO<String> updateCartCount(HttpServletRequest request,@RequestBody CartEntity cartEntity){
|
||||
String memberId = SmartJWTUtil.decodeToken(request.getHeader(TOKEN_NAME));
|
||||
if (cartEntity.getBuyCount() < 0 ){
|
||||
return ResponseDTO.wrap(ResponseCodeConst.ERROR_PARAM);
|
||||
}
|
||||
CartEntity cart = cartService.getInfoByProductIdAndMemberID(memberId, cartEntity.getId());
|
||||
if (null == cart){
|
||||
return ResponseDTO.wrap(ResponseCodeConst.NOT_EXISTS_PROD);
|
||||
}
|
||||
|
||||
cart.setBuyCount(cartEntity.getBuyCount());
|
||||
if (1 == cartService.updateInfo(cart)) {
|
||||
return ResponseDTO.succ();
|
||||
}else {
|
||||
return ResponseDTO.wrap(ResponseCodeConst.ERROR_PARAM);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,4 +18,6 @@ public interface CartDao extends BaseMapper<CartEntity> {
|
||||
int cancelCartProduct(@Param("memberId")String memberId, @Param("productCode")String productCode);
|
||||
|
||||
CartEntity getInfoByProductCodeAndMemberId(@Param("memberId")String memberId, @Param("productCode")String productCode);
|
||||
|
||||
CartEntity getInfoByProductIdAndMemberID(@Param("memberId")String memberId,@Param("productId") Long productId);
|
||||
}
|
||||
|
@ -32,4 +32,7 @@ public class CartService {
|
||||
return cartDao.updateById(cartEntity);
|
||||
}
|
||||
|
||||
public CartEntity getInfoByProductIdAndMemberID(String memberId, Long productId) {
|
||||
return cartDao.getInfoByProductIdAndMemberID(memberId, productId);
|
||||
}
|
||||
}
|
||||
|
@ -19,4 +19,9 @@
|
||||
<select id="getInfoByProductCodeAndMemberId" resultMap="CartEntity">
|
||||
select * from t_royalcanin_cart WHERE member_id = #{memberId} and product_code = #{productCode} and is_deleted = 1
|
||||
</select>
|
||||
|
||||
<!-- 根据memberID和商品Id查询当前的数据 -->
|
||||
<select id="getInfoByProductIdAndMemberID" resultMap="CartEntity">
|
||||
select * from t_royalcanin_cart WHERE member_id = #{memberId} and id = #{productId} and is_deleted = 1
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user