增加责任人维护接口

master
cxw 2025-07-23 09:33:18 +08:00
parent 6ff12c4931
commit 6bc5762ef6
2 changed files with 73 additions and 7 deletions

View File

@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapp
import com.whdc.exception.MyException;
import com.whdc.model.dto.WarningResponderDto;
import com.whdc.model.entity.WarningResponder;
import com.whdc.model.group.Insert;
import com.whdc.model.group.Update;
import com.whdc.model.vo.ExcelDataVo;
import com.whdc.model.vo.ExcelOldDataVo;
import com.whdc.service.IWarningResponderService;
@ -21,13 +23,25 @@ import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@ -61,7 +75,7 @@ public class WarningResponderController {
@ApiOperation(value = "查询所有联系人")
@PostMapping(value = "find")
@Cacheable(value = ADDRESS_BOOK_REDIS_KEY, key = "#root.method.name+':'+#dto.toString()")
// @Cacheable(value = ADDRESS_BOOK_REDIS_KEY, key = "#root.method.name+':'+#dto.toString()")
public ResultJson<List<WarningResponder>> find(@RequestBody WarningResponderDto dto) {
LambdaQueryChainWrapper<WarningResponder> query = service.lambdaQuery();
@ -75,10 +89,11 @@ public class WarningResponderController {
if (StringUtils.isNotBlank(phone)){
query.like(WarningResponder::getPhone, phone);
}
// 添加默认排序
query.orderByAsc(WarningResponder::getCtnm).orderByAsc(WarningResponder::getCnnm).orderByAsc(WarningResponder::getName);
List<WarningResponder> data = query.list();
data = data.stream().map(WarningResponder::decryptPhone).collect(Collectors.toList());
data = data.stream().map(vo -> vo.setLevelLabel(dictMappingReverse(vo.getLevel())).decryptPhone()).collect(Collectors.toList());
return ResultJson.ok(data);
@ -194,4 +209,55 @@ public class WarningResponderController {
return null;
}
}
@ApiOperation(value = "添加")
@PostMapping(value = "save")
public ResultJson insert(@RequestBody @Validated(Insert.class) WarningResponder model) {
// 暂时不做数据唯一性校验
// if (CollectionUtils.isNotEmpty(
// service.lambdaQuery()
// .list())
// ) {
// return ResultJson.error("重复新增");
// }
model.setCreateTime(new Date()).encryptPhone();
return ResultJson.ok(service.save(model));
}
@ApiOperation(value = "修改")
@PostMapping(value = "edit")
public ResultJson update(@RequestBody @Validated(Update.class) WarningResponder model) {
// 暂时不做数据唯一性校验
// if (CollectionUtils.isNotEmpty(
// service.lambdaQuery()
// .list())
// ) {
// return ResultJson.error("重复修改");
// }
model.encryptPhone();
return ResultJson.ok(service.updateById(model));
}
@ApiOperation(value = "删除")
@GetMapping(value = "del/{id}")
public ResultJson delete(@PathVariable("id") Integer id) {
if (Objects.isNull(service.getById(id))) {
return ResultJson.error("当前数据不存在");
}
return ResultJson.ok(service.removeById(id));
}
@ApiOperation(value = "预警呼叫等级")
@GetMapping(value = "getWarnCallLevelDict")
public ResultJson getWarnCallLevelDict() {
Map<Integer, String> dictMap = new LinkedHashMap<>();
dictMap.put(4, "书记");
dictMap.put(3, "市(县)长");
dictMap.put(2, "常务副市(县)长");
dictMap.put(1, "分管副市(县)长");
return ResultJson.ok(dictMap);
}
}

View File

@ -86,12 +86,12 @@ public class MyExceptionHandler {
strbuf.append(err.getDefaultMessage());
}
return ResultJson.error(ResultJson.PARAM_ERROR, "参数验证失败1" + strbuf);
return ResultJson.error(ResultJson.PARAM_ERROR, "参数验证失败" + strbuf);
}
return ResultJson.error(ResultJson.PARAM_ERROR, "参数验证失败2");
return ResultJson.error(ResultJson.PARAM_ERROR, "参数验证失败");
} catch (Exception err) {
return ResultJson.error(ResultJson.PARAM_ERROR, "参数验证失败3," + err.getMessage());
return ResultJson.error(ResultJson.PARAM_ERROR, "参数验证失败," + err.getMessage());
}
}