99 lines
3.5 KiB
Java
99 lines
3.5 KiB
Java
|
|
package com.whdc.controller;
|
||
|
|
|
||
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||
|
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||
|
|
import com.whdc.exception.MyException;
|
||
|
|
import com.whdc.model.dto.ShCallsDto;
|
||
|
|
import com.whdc.model.entity.ShAddressBook;
|
||
|
|
import com.whdc.model.entity.ShCallWord;
|
||
|
|
import com.whdc.model.entity.ShCalls;
|
||
|
|
import com.whdc.model.group.Insert;
|
||
|
|
import com.whdc.model.vo.ShCallsTodayVo;
|
||
|
|
import com.whdc.service.ShAddressBookService;
|
||
|
|
import com.whdc.service.ShCallsService;
|
||
|
|
import com.whdc.utils.ResultJson;
|
||
|
|
import io.swagger.v3.oas.annotations.Operation;
|
||
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||
|
|
import org.apache.commons.lang3.StringUtils;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.validation.annotation.Validated;
|
||
|
|
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 java.util.Date;
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.Objects;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 描述: 抽查日志
|
||
|
|
* author: xusan
|
||
|
|
* date: 2024-07-29 17:27:25
|
||
|
|
*/
|
||
|
|
@Tag(name = "抽查日志")
|
||
|
|
@RestController
|
||
|
|
@RequestMapping(value="/shCalls")
|
||
|
|
public class ShCallsController {
|
||
|
|
|
||
|
|
@Autowired
|
||
|
|
private ShCallsService service;
|
||
|
|
|
||
|
|
@Autowired
|
||
|
|
private ShAddressBookService shAddressBookService;
|
||
|
|
|
||
|
|
|
||
|
|
@Operation(summary = "新增")
|
||
|
|
@PostMapping("/insert")
|
||
|
|
public ResultJson<ShCallWord> insert(@Validated(Insert.class) @RequestBody ShCalls dto) {
|
||
|
|
if (shAddressBookService.lambdaQuery().eq(ShAddressBook::getId, dto.getShAbId()).count() != 1){
|
||
|
|
throw new MyException("当前通讯录不存在");
|
||
|
|
}
|
||
|
|
|
||
|
|
dto.setCallTime(new Date());
|
||
|
|
if (StringUtils.isNotBlank(dto.getStatus()) && "0".equals(dto.getCallType())){
|
||
|
|
boolean update = shAddressBookService.lambdaUpdate()
|
||
|
|
.set(ShAddressBook::getCallStatus, dto.getCallType())
|
||
|
|
.eq(ShAddressBook::getId, dto.getShAbId())
|
||
|
|
.update();
|
||
|
|
if (!update){
|
||
|
|
throw new MyException("更新通讯录状态失败");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
boolean result = service.save(dto);
|
||
|
|
return ResultJson.ok(result ? dto : null);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Operation(summary = "列表")
|
||
|
|
@PostMapping("/list")
|
||
|
|
public ResultJson<List<ShCalls>> list(@RequestBody ShCallsDto dto) {
|
||
|
|
LambdaQueryChainWrapper<ShCalls> query = service.lambdaQuery();
|
||
|
|
if (Objects.nonNull(dto.getDate())){
|
||
|
|
|
||
|
|
query.between(ShCalls::getCallTime, dto.getDate() + " 00:00:00",dto.getDate() + " 23:59:59");
|
||
|
|
}
|
||
|
|
if (Objects.nonNull(dto.getShAbId())){
|
||
|
|
query.eq(ShCalls::getShAbId, dto.getShAbId());
|
||
|
|
}else{
|
||
|
|
throw new RuntimeException("山洪通讯录编号不能为空");
|
||
|
|
}
|
||
|
|
return ResultJson.ok(query.list());
|
||
|
|
}
|
||
|
|
|
||
|
|
@Operation(summary = "今日抽查分页")
|
||
|
|
@PostMapping("/pageToday")
|
||
|
|
public ResultJson<IPage<ShCallsTodayVo>> pageToday(@RequestBody ShCallsDto dto) {
|
||
|
|
return ResultJson.ok(service.page(dto));
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
@Operation(summary = "抽查日志分页")
|
||
|
|
@PostMapping("/page")
|
||
|
|
public ResultJson<Page<ShCalls>> page(@RequestBody ShCallsDto dto) {
|
||
|
|
LambdaQueryChainWrapper<ShCalls> query = service.lambdaQuery();
|
||
|
|
return ResultJson.ok(service.page(dto.getPage(), query));
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|