package com.nantian.cloud.jly.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nantian.cloud.jly.entity.TOperatingLog;
import com.nantian.cloud.jly.service.TOperatingLogService;
import com.nantian.sc.cloud.common.core.util.R;
import com.nantian.sc.cloud.common.security.service.ScUser;
import com.nantian.sc.cloud.common.security.util.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Date;


/**
 *审查报告操作日志
 * @since 2021-01-28
 */
@RestController
@AllArgsConstructor
@Api(value = "TOperatingLog",tags = "审查报告操作日志")
@RequestMapping("/tOperatingLog")
public class TOperatingLogController {
	private final TOperatingLogService tOperatingLogService;

	/**
	 * 分页查询审查报告操作日志
	 */
	@GetMapping("/page")
	@ApiOperation(value = "分页查询审查报告操作日志",notes = "分页查询审查报告操作日志")
    @ApiImplicitParams({
            @ApiImplicitParam(name ="TOperatingLog",value = "审查报告操作日志",required = false,dataType = "json",paramType = "path"),
            @ApiImplicitParam(name ="Page",value = "分页对象",required = false,dataType = "json",paramType = "path")
    })
	public R getTOperatingLogPage(Page page, TOperatingLog TOperatingLog) {
		TOperatingLog.setDelFlag("1"); //查询未删除数据
		return R.ok(tOperatingLogService.getPageScope(page, TOperatingLog));
	}

	/**
	 * 新增审查报告操作日志
	 */
	@PostMapping("/save")
	@ApiOperation(value = "新增审查报告操作日志",notes = "新增审查报告操作日志")
	@ApiImplicitParam(name ="TOperatingLog",value = "审查报告操作日志",required = true,paramType = "path",dataType = "json")
	public R save(@RequestBody TOperatingLog TOperatingLog) {
		TOperatingLog.setDelFlag("1");
		TOperatingLog.setUpdateTime(new Date());
		TOperatingLog.setCreatTime(new Date());
		ScUser u= SecurityUtils.getUser();
		TOperatingLog.setUserid(u.getId());
		TOperatingLog.setDeptId(u.getDeptId());
		TOperatingLog.setName(u.getUsername());
		return R.ok(tOperatingLogService.save(TOperatingLog));
	}
}
