Commit 8548f1e4 by HlQ

[chg] 代码优化,TODO 解决

1 parent c3e92131
......@@ -51,7 +51,6 @@ public class AccountController {
@DeleteMapping("/account/{id}")
@SaCheckPermission(value = "account:remove", orRole = "admin")
public String remove(@PathVariable(name = "id") Integer id) {
// todo 删除时,得判断集团下是否关联其他东西
accountService.removeById(id);
return "集团删除成功";
}
......
......@@ -47,7 +47,7 @@ public class DeviceController {
}
@PostMapping("/circulate")
@SaCheckPermission(value = "device:circulateBatch", orRole = "admin")
@SaCheckPermission(value = "device:circulate", orRole = "admin")
public String circulateBatch(@RequestBody List<DeviceDTO> dtoList) {
return deviceService.circulateBatch(dtoList);
}
......
package vion.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.dromara.hutool.core.lang.Assert;
import org.dromara.hutool.core.data.id.IdUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import org.dromara.hutool.core.data.id.IdUtil;
import org.dromara.hutool.core.lang.Assert;
import org.redisson.api.RMap;
import org.redisson.api.RedissonClient;
import org.springframework.web.bind.annotation.*;
import vion.constant.RedisKeyEnum;
import vion.dto.ServiceOrderDTO;
import vion.model.Dictionary;
import vion.model.ServiceOrder;
import vion.service.IDictionaryService;
import vion.service.IServiceOrderService;
import vion.vo.ServiceOrderVO;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 服务单
*
......@@ -30,7 +27,7 @@ import java.util.stream.Collectors;
public class ServiceOrderController {
private final IServiceOrderService serviceOrderService;
private final IDictionaryService dictionaryService;
private final RedissonClient redissonClient;
private final Converter converter;
@GetMapping("/orders")
......@@ -71,9 +68,7 @@ public class ServiceOrderController {
@GetMapping("/order/sign/{unid}")
public ServiceOrderVO getOrderByUnid(@PathVariable String unid) {
// todo 字典加入缓存
List<Dictionary> dictionaryList = dictionaryService.lambdaQuery().eq(Dictionary::getType, "service_type").list();
Map<Integer, String> serviceTypeMap = dictionaryList.stream().collect(Collectors.toMap(Dictionary::getKey, Dictionary::getValue));
RMap<Integer, String> serviceTypeMap = redissonClient.getMap(RedisKeyEnum.DICT_PREFIX.getVal() + RedisKeyEnum.SERVICE_TYPE.getVal());
ServiceOrder order = serviceOrderService.lambdaQuery().eq(ServiceOrder::getUnid, unid).one();
ServiceOrderVO vo = converter.convert(order, ServiceOrderVO.class);
vo.setServiceType(serviceTypeMap.get(order.getServiceType()));
......
......@@ -93,6 +93,7 @@ public class DeliveryRecordServiceImpl extends MPJBaseServiceImpl<DeliveryRecord
@Override
public String saveBatch(List<DeliveryRecordDTO> dto) {
List<DeliveryRecord> records = converter.convert(dto, DeliveryRecord.class);
// todo 合同编号如何和合同id关联起来
if (this.saveBatch(records)) {
records.forEach(this::updStatusAndPushMsg);
return "新增成功";
......
......@@ -331,8 +331,10 @@ public class PointInfoServiceImpl extends MPJBaseServiceImpl<PointInfoMapper, Po
@Transactional(rollbackFor = Exception.class)
public String delById(Long id) {
if (this.removeById(id)) {
// todo 文件删除
fileService.lambdaUpdate().eq(FileInfo::getSourceId, id).in(FileInfo::getSourceType, ListUtil.of(5, 16, 17, 18, 19, 20)).remove();
var fileList = fileService.lambdaQuery().eq(FileInfo::getSourceId, id).in(FileInfo::getSourceType,
ListUtil.of(5, 16, 17, 18, 19, 20)).list();
fileList.forEach(f -> FileUtil.del(f.getUrl()));
fileService.removeBatchByIds(fileList.stream().map(FileInfo::getId).collect(Collectors.toList()));
pointWxService.lambdaUpdate().eq(RPointWx::getPointId, id).remove();
rejectInfoService.lambdaUpdate().eq(RejectInfo::getPointId, id).remove();
pointDeviceService.lambdaUpdate().eq(RPointDevice::getPointId, id).remove();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!