|
@@ -1,17 +1,27 @@
|
|
|
package com.template.controller;
|
|
package com.template.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.template.api.BlacklistControllerAPI;
|
|
import com.template.api.BlacklistControllerAPI;
|
|
|
import com.template.model.dto.BlacklistDeleteDto;
|
|
import com.template.model.dto.BlacklistDeleteDto;
|
|
|
|
|
+import com.template.model.pojo.Blacklist;
|
|
|
|
|
+import com.template.model.pojo.BlacklistOrder;
|
|
|
import com.template.model.result.CommonResult;
|
|
import com.template.model.result.CommonResult;
|
|
|
import com.template.services.BlacklistOrderService;
|
|
import com.template.services.BlacklistOrderService;
|
|
|
import com.template.services.BlacklistService;
|
|
import com.template.services.BlacklistService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* <p>
|
|
* <p>
|
|
|
- * 前端控制器
|
|
|
|
|
|
|
+ * 前端控制器
|
|
|
* </p>
|
|
* </p>
|
|
|
*
|
|
*
|
|
|
* @author ceshi
|
|
* @author ceshi
|
|
@@ -29,12 +39,55 @@ public class BlacklistController implements BlacklistControllerAPI {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public CommonResult list(Integer page, Integer size, String reserveName, String phone, String cardNumber, String startTime, String endTime) {
|
|
public CommonResult list(Integer page, Integer size, String reserveName, String phone, String cardNumber, String startTime, String endTime) {
|
|
|
- return null;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ LambdaQueryWrapper<Blacklist> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapper.eq(ObjectUtils.isNotEmpty(reserveName), Blacklist::getReserveName, reserveName)
|
|
|
|
|
+ .eq(ObjectUtils.isNotEmpty(phone), Blacklist::getPhone, phone)
|
|
|
|
|
+ .eq(ObjectUtils.isNotEmpty(cardNumber), Blacklist::getCardNumber, cardNumber)
|
|
|
|
|
+ .between(ObjectUtils.isNotEmpty(startTime) && ObjectUtils.isNotEmpty(endTime), Blacklist::getCreateTime, startTime, endTime);
|
|
|
|
|
+
|
|
|
|
|
+ IPage<Blacklist> iPage = blacklistService.page(new Page<>(page, size), wrapper);
|
|
|
|
|
+
|
|
|
|
|
+ return CommonResult.ok(iPage);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public CommonResult delete(BlacklistDeleteDto dto) {
|
|
public CommonResult delete(BlacklistDeleteDto dto) {
|
|
|
- return null;
|
|
|
|
|
|
|
+ List<Integer> ids = dto.getIds();
|
|
|
|
|
+ if (ObjectUtils.isEmpty(ids)) {
|
|
|
|
|
+ return CommonResult.fail("参数异常");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ LambdaQueryWrapper<Blacklist> wrapperB = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapperB.in(Blacklist::getId, ids);
|
|
|
|
|
+ List<Blacklist> blacklists = blacklistService.list(wrapperB);
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+ for (Blacklist blacklist : blacklists) {
|
|
|
|
|
+ Integer reserveUserId = blacklist.getReserveUserId();
|
|
|
|
|
+
|
|
|
|
|
+ LambdaQueryWrapper<BlacklistOrder> wrapperBO = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapperBO.eq(BlacklistOrder::getReserveUserId, reserveUserId);
|
|
|
|
|
+ List<BlacklistOrder> list = blacklistOrderService.list(wrapperBO);
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
|
|
+ ArrayList<Integer> blacklistOrders = new ArrayList<>();
|
|
|
|
|
+ for (BlacklistOrder blacklistOrder : list) {
|
|
|
|
|
+ blacklistOrders.add(blacklistOrder.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ blacklistOrderService.removeByIds(blacklistOrders);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ blacklistService.removeByIds(ids);
|
|
|
|
|
+ return CommonResult.ok();
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return CommonResult.fail();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|