Merge pull request !254 from Admin/LTL_20220314
This commit is contained in:
Admin 2022-03-24 09:38:31 +00:00 committed by Gitee
commit 93b5b1df1c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 34 additions and 4 deletions

View File

@ -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;

View File

@ -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 );
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}

View File

@ -32,4 +32,7 @@ public class CartService {
return cartDao.updateById(cartEntity);
}
public CartEntity getInfoByProductIdAndMemberID(String memberId, Long productId) {
return cartDao.getInfoByProductIdAndMemberID(memberId, productId);
}
}

View File

@ -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>