|
@@ -16,27 +16,33 @@
|
|
|
*/
|
|
*/
|
|
|
package org.springblade.sing.goods.controller;
|
|
package org.springblade.sing.goods.controller;
|
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
import io.swagger.annotations.ApiParam;
|
|
|
-import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
-import javax.validation.Valid;
|
|
|
|
|
-
|
|
|
|
|
|
|
+import org.springblade.core.boot.ctrl.BladeController;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
-import org.springblade.sing.user.entity.LoginUser;
|
|
|
|
|
-import org.springblade.sing.user.service.ILoginUserService;
|
|
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
|
|
+import org.springblade.sing.goods.entity.ActiveIdAndGoodsId;
|
|
|
import org.springblade.sing.goods.entity.PointGoods;
|
|
import org.springblade.sing.goods.entity.PointGoods;
|
|
|
|
|
+import org.springblade.sing.goods.service.IActiveIdAndGoodsIdService;
|
|
|
|
|
+import org.springblade.sing.goods.service.IPointGoodsService;
|
|
|
import org.springblade.sing.goods.vo.PointGoodsVO;
|
|
import org.springblade.sing.goods.vo.PointGoodsVO;
|
|
|
import org.springblade.sing.goods.wrapper.PointGoodsWrapper;
|
|
import org.springblade.sing.goods.wrapper.PointGoodsWrapper;
|
|
|
-import org.springblade.sing.goods.service.IPointGoodsService;
|
|
|
|
|
-import org.springblade.core.boot.ctrl.BladeController;
|
|
|
|
|
|
|
+import org.springblade.sing.user.entity.LoginUser;
|
|
|
|
|
+import org.springblade.sing.user.service.ILoginUserService;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+
|
|
|
|
|
+import javax.validation.Valid;
|
|
|
|
|
+import java.util.Arrays;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 积分商城 控制器
|
|
* 积分商城 控制器
|
|
@@ -52,6 +58,7 @@ public class PointGoodsController extends BladeController {
|
|
|
|
|
|
|
|
private final IPointGoodsService pointGoodsService;
|
|
private final IPointGoodsService pointGoodsService;
|
|
|
private final ILoginUserService loginUserService;
|
|
private final ILoginUserService loginUserService;
|
|
|
|
|
+ private final IActiveIdAndGoodsIdService activeIdAndGoodsIdService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 详情
|
|
* 详情
|
|
@@ -114,7 +121,8 @@ public class PointGoodsController extends BladeController {
|
|
|
@ApiOperationSupport(order = 6)
|
|
@ApiOperationSupport(order = 6)
|
|
|
@ApiOperation(value = "新增或修改", notes = "传入pointGoods")
|
|
@ApiOperation(value = "新增或修改", notes = "传入pointGoods")
|
|
|
public R submit(@Valid @RequestBody PointGoods pointGoods) {
|
|
public R submit(@Valid @RequestBody PointGoods pointGoods) {
|
|
|
- return R.status(pointGoodsService.saveOrUpdate(pointGoods));
|
|
|
|
|
|
|
+ return R.status(updatePointGoodsAndActiveId(pointGoods.getActiveId(),pointGoods.getId())
|
|
|
|
|
+ && pointGoodsService.saveOrUpdate(pointGoods));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -124,8 +132,13 @@ public class PointGoodsController extends BladeController {
|
|
|
@PostMapping("/remove")
|
|
@PostMapping("/remove")
|
|
|
@ApiOperationSupport(order = 7)
|
|
@ApiOperationSupport(order = 7)
|
|
|
@ApiOperation(value = "逻辑删除", notes = "传入ids")
|
|
@ApiOperation(value = "逻辑删除", notes = "传入ids")
|
|
|
|
|
+ @Transactional
|
|
|
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
- return R.status(pointGoodsService.deleteLogic(Func.toLongList(ids)));
|
|
|
|
|
|
|
+ List<Long> longs = Func.toLongList(ids);
|
|
|
|
|
+ for (Long aLong : longs) {
|
|
|
|
|
+ deletePointGoodsAndActiveId(aLong);
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.status(pointGoodsService.deleteLogic(longs));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -137,4 +150,26 @@ public class PointGoodsController extends BladeController {
|
|
|
return R.data(loginUser);
|
|
return R.data(loginUser);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 修改积分商品的活动ID
|
|
|
|
|
+ * @param activeIds
|
|
|
|
|
+ * @param goodsId
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean updatePointGoodsAndActiveId(String activeIds,Long goodsId){
|
|
|
|
|
+ //先删除原有的,再添加新的
|
|
|
|
|
+ return deletePointGoodsAndActiveId(goodsId)
|
|
|
|
|
+ && activeIdAndGoodsIdService.saveBatch(Arrays.stream(activeIds.split(",")).map(activeId -> new ActiveIdAndGoodsId() {{
|
|
|
|
|
+ setActiveId(Long.valueOf(activeId));
|
|
|
|
|
+ setGoodsId(goodsId);
|
|
|
|
|
+ }}).collect(Collectors.toList()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 修改积分商品的活动ID
|
|
|
|
|
+ * @param goodsId
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean deletePointGoodsAndActiveId(Long goodsId){
|
|
|
|
|
+ return activeIdAndGoodsIdService.remove(Wrappers.<ActiveIdAndGoodsId>lambdaUpdate()
|
|
|
|
|
+ .eq(ActiveIdAndGoodsId::getGoodsId,goodsId));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|