package com.ruoyi.web.controller.monitor;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.basic.PageInfo;
|
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.framework.web.service.TokenService;
|
import com.ruoyi.system.model.TCrmClinic;
|
import com.ruoyi.system.model.TCrmSupplier;
|
import com.ruoyi.system.query.SysOperLogQuery;
|
import com.ruoyi.system.service.ISysOperLogService;
|
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.TCrmClinicService;
|
import com.ruoyi.system.service.TCrmSupplierService;
|
import com.ruoyi.system.vo.SysOperLogVO;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.Objects;
|
|
/**
|
* 操作日志记录
|
*
|
* @author ruoyi
|
*/
|
@Slf4j
|
@Api(tags = "操作日志记录")
|
@RestController
|
@RequestMapping("/monitor/operlog")
|
public class SysOperlogController extends BaseController
|
{
|
@Autowired
|
private ISysOperLogService operLogService;
|
@Autowired
|
private TokenService tokenService;
|
@Autowired
|
private TCrmSupplierService crmSupplierService;
|
@Autowired
|
private TCrmClinicService crmClinicService;
|
@Autowired
|
private ISysUserService userService;
|
@ApiOperation(value = "操作日志分页列表")
|
@PostMapping("/list")
|
public AjaxResult list(@RequestBody SysOperLogQuery query)
|
{
|
Integer roleType = tokenService.getLoginUser().getUser().getRoleType();
|
Long userId = tokenService.getLoginUser().getUserId();
|
if(roleType == 4 || roleType == 5){
|
query.setRoleType(roleType);
|
}
|
if(roleType == 4){
|
// 查询供应商
|
TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class)
|
.eq(TCrmSupplier::getUserId, userId)
|
.last("LIMIT 1"));
|
// ***
|
if(Objects.isNull(crmSupplier)){
|
SysUser sysUser = userService.selectUserById(userId);
|
crmSupplier = crmSupplierService.getById(sysUser.getObjectId());
|
}
|
query.setObjectId(crmSupplier.getId());
|
}
|
if(roleType == 5){
|
// 查询诊所
|
TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class)
|
.eq(TCrmClinic::getUserId, userId)
|
.last("LIMIT 1"));
|
// ---
|
if(Objects.isNull(crmClinic)){
|
SysUser sysUser = userService.selectUserById(userId);
|
crmClinic = crmClinicService.getById(sysUser.getObjectId());
|
}
|
query.setObjectId(crmClinic.getId());
|
}
|
PageInfo<SysOperLogVO> list = operLogService.selectOperLogPageList(query);
|
return AjaxResult.success(list);
|
}
|
|
@Log(title = "删除操作日志", businessType = BusinessType.DELETE)
|
@DeleteMapping("/deleteById/{operIds}")
|
public AjaxResult remove(@PathVariable String operIds)
|
{
|
String[] split = operIds.split(",");
|
List<Long> id = new ArrayList<>();
|
for (String s : split) {
|
id.add(Long.valueOf(s));
|
}
|
return AjaxResult.success(operLogService.deleteOperLogByIds(id));
|
}
|
|
@Log(title = "清除操作日志", businessType = BusinessType.CLEAN)
|
@DeleteMapping("/clean")
|
public AjaxResult clean()
|
{
|
operLogService.cleanOperLog();
|
return success();
|
}
|
}
|