he2802 3 năm trước cách đây
mục cha
commit
44df415bef

+ 5 - 4
zhongzheng-api/src/main/java/com/zhongzheng/controller/base/ShoppingCartController.java

@@ -55,7 +55,7 @@ public class ShoppingCartController extends BaseController {
         ClientLoginUser loginUser = WxTokenService.getLoginUser(ServletUtils.getRequest());
         bo.setUserId(loginUser.getUser().getUserId());
         startPage();
-        List<ShoppingCartVo> list = iShoppingCartService.queryList(bo);
+        List<ShoppingCartVo> list = iShoppingCartService.selectList(bo);
         return getDataTable(list);
     }
 
@@ -108,8 +108,9 @@ public class ShoppingCartController extends BaseController {
      * 删除购物车
      */
     @ApiOperation("删除购物车")
-    @PostMapping("/delete/{ids}")
-    public AjaxResult<Void> remove(@PathVariable Long[] ids) {
-        return toAjax(iShoppingCartService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
+    @PostMapping("/delete/{id}")
+    public AjaxResult<Void> remove(@PathVariable Long id) {
+        ClientLoginUser loginUser = WxTokenService.getLoginUser(ServletUtils.getRequest());
+        return toAjax(iShoppingCartService.deleteById(id, loginUser.getUser().getUserId()) ? 1 : 0);
     }
 }

+ 7 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/base/mapper/ShoppingCartMapper.java

@@ -1,7 +1,13 @@
 package com.zhongzheng.modules.base.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zhongzheng.modules.base.bo.ApplyAreasQueryBo;
+import com.zhongzheng.modules.base.bo.ShoppingCartQueryBo;
+import com.zhongzheng.modules.base.domain.ApplyAreas;
 import com.zhongzheng.modules.base.domain.ShoppingCart;
+import com.zhongzheng.modules.base.vo.ShoppingCartVo;
+
+import java.util.List;
 
 /**
  * 购物车Mapper接口
@@ -10,5 +16,5 @@ import com.zhongzheng.modules.base.domain.ShoppingCart;
  * @date 2021-12-09
  */
 public interface ShoppingCartMapper extends BaseMapper<ShoppingCart> {
-
+    List<ShoppingCartVo> selectList(ShoppingCartQueryBo bo);
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/base/service/IShoppingCartService.java

@@ -23,6 +23,8 @@ public interface IShoppingCartService extends IService<ShoppingCart> {
 	 */
 	ShoppingCartVo queryById(Long id);
 
+	List<ShoppingCartVo> selectList(ShoppingCartQueryBo bo);
+
 	/**
 	 * 查询列表
 	 */
@@ -49,4 +51,6 @@ public interface IShoppingCartService extends IService<ShoppingCart> {
 	 * @return
 	 */
 	Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+
+	Boolean deleteById(Long id, Long userId);
 }

+ 16 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/base/service/impl/ShoppingCartServiceImpl.java

@@ -10,9 +10,11 @@ import com.zhongzheng.modules.base.bo.ShoppingCartEditBo;
 import com.zhongzheng.modules.base.bo.ShoppingCartQueryBo;
 import com.zhongzheng.modules.base.domain.ApplyAreas;
 import com.zhongzheng.modules.base.domain.ShoppingCart;
+import com.zhongzheng.modules.base.mapper.ApplyAreasMapper;
 import com.zhongzheng.modules.base.mapper.ShoppingCartMapper;
 import com.zhongzheng.modules.base.service.IShoppingCartService;
 import com.zhongzheng.modules.base.vo.ShoppingCartVo;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -33,12 +35,20 @@ import java.util.stream.Collectors;
 @Service
 public class ShoppingCartServiceImpl extends ServiceImpl<ShoppingCartMapper, ShoppingCart> implements IShoppingCartService {
 
+    @Autowired
+    private ShoppingCartMapper shoppingCartMapper;
+
     @Override
     public ShoppingCartVo queryById(Long id){
         ShoppingCart db = this.baseMapper.selectById(id);
         return BeanUtil.toBean(db, ShoppingCartVo.class);
     }
 
+    @Override
+    public List<ShoppingCartVo> selectList(ShoppingCartQueryBo bo) {
+        return shoppingCartMapper.selectList(bo);
+    }
+
     @Override
     public List<ShoppingCartVo> queryList(ShoppingCartQueryBo bo) {
         LambdaQueryWrapper<ShoppingCart> lqw = Wrappers.lambdaQuery();
@@ -105,6 +115,12 @@ public class ShoppingCartServiceImpl extends ServiceImpl<ShoppingCartMapper, Sho
         return this.removeByIds(ids);
     }
 
+    @Override
+    public Boolean deleteById(Long id, Long userId) {
+        return this.remove(new LambdaQueryWrapper<ShoppingCart>().eq(ShoppingCart::getUserId,userId).eq(ShoppingCart::getId,id));
+
+    }
+
     private boolean checkUnique(ShoppingCart entity) {
         ShoppingCart info = getOne(new LambdaQueryWrapper<ShoppingCart>()
                 .eq(ShoppingCart::getUserId,entity.getUserId()).eq(ShoppingCart::getGoodsId,entity.getGoodsId()).last("limit 1"));

+ 14 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/base/vo/ShoppingCartVo.java

@@ -5,6 +5,8 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+
+import java.math.BigDecimal;
 import java.util.Date;
 
 
@@ -34,6 +36,17 @@ public class ShoppingCartVo {
 	private Long userId;
 	/** 1 启用 0未启用 -1删除 */
 	@Excel(name = "1 启用 0未启用 -1删除")
-	@ApiModelProperty("1 启用 0未启用 -1删除")
+	@ApiModelProperty("状态 1有效 0无效")
 	private Integer status;
+
+	@ApiModelProperty("商品类型 1视频2题库 3面授 4服务 5组合")
+	private Long goodsType;
+	@ApiModelProperty("商品名称")
+	private String goodsName;
+	@ApiModelProperty("标准价格")
+	private BigDecimal standPrice;
+	@ApiModelProperty("封面地址")
+	private String coverUrl;
+	@ApiModelProperty("1上架 0未上架")
+	private Integer goodsStatus;
 }

+ 3 - 0
zhongzheng-system/src/main/resources/mapper/modules/bank/QuestionMapper.xml

@@ -128,6 +128,9 @@
         <if test="subjectId != null and subjectId != ''">
             AND qb.subject_id = #{subjectId}
         </if>
+        <if test="type != null and type != ''">
+            AND q.type = #{type}
+        </if>
         <if test="businessId != null and businessId != ''">
             AND qb.business_id = #{businessId}
         </if>

+ 27 - 0
zhongzheng-system/src/main/resources/mapper/modules/base/ShoppingCartMapper.xml

@@ -13,5 +13,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="status" column="status"/>
     </resultMap>
 
+    <resultMap type="com.zhongzheng.modules.base.vo.ShoppingCartVo" id="ShoppingCartVoResult">
+        <result property="id" column="id"/>
+        <result property="goodsId" column="goods_id"/>
+        <result property="status" column="status"/>
+
+        <result property="goodsName" column="goods_name"/>
+        <result property="standPrice" column="stand_price"/>
+        <result property="coverUrl" column="cover_url"/>
+        <result property="goodsStatus" column="goods_status"/>
+        <result property="goodsType" column="goods_type"/>
+    </resultMap>
 
+    <select id="selectList" parameterType="com.zhongzheng.modules.base.bo.ShoppingCartQueryBo"  resultMap="ShoppingCartVoResult">
+        SELECT
+            s.id,
+            s.goods_id,
+            g.stand_price,
+            g.cover_url,
+            g.goods_type,
+            g.goods_name,
+            g.`status`,
+            g.goods_status
+        FROM
+            shopping_cart s
+                LEFT JOIN goods g ON s.goods_id = g.goods_id
+        WHERE
+            s.user_id =  #{userId}
+    </select>
 </mapper>