package com.ym.mec.web.controller;

import com.ym.mec.auth.api.client.SysUserFeignService;
import com.ym.mec.auth.api.entity.SysUser;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.util.date.DateUtil;
import com.yonge.log.dal.model.OperationLog;
import com.yonge.log.service.OperationLogService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RequestMapping("operationLog")
@Api(tags = "操作手册日志")
@RestController
public class OperationLogController extends BaseController {

	@Autowired
	private OperationLogService operationLogService;
	@Autowired
	private SysUserFeignService sysUserFeignService;

	@GetMapping("/save")
	public Object save(OperationLog operationLog) {
		SysUser sysUser = sysUserFeignService.queryUserInfo();
		operationLog.setUserId(sysUser.getId());
		operationLog.setUsername(sysUser.getRealName());
		operationLog.setOperateTime(DateUtil.format(new Date(),DateUtil.EXPANDED_DATE_TIME_FORMAT));
		operationLogService.insert(operationLog);
		return succeed();
	}

}
