package org.sky.core.log.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.AllArgsConstructor;
import org.sky.core.log.model.LogUsual;
import org.sky.core.log.pojo.vo.LogUsualVO;
import org.sky.core.log.service.ILogUsualService;
import org.sky.core.log.wrapper.LogUsualWrapper;
import org.sky.core.mp.support.Condition;
import org.sky.core.mp.support.Query;
import org.sky.core.tenant.annotation.NonDS;
import org.sky.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 控制器
 *
 */
@NonDS
@RestController
@AllArgsConstructor
@RequestMapping("/usual")
public class LogUsualController {

	private final ILogUsualService logService;

	/**
	 * 查询单条
	 */
 	@GetMapping("/detail")
	public R<LogUsual> detail(LogUsual log) {
		return R.data(logService.getOne(Condition.getQueryWrapper(log)));
	}

	/**
	 * 查询多条(分页)
	 */
 	@GetMapping("/list")
	public R<IPage<LogUsualVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> log, Query query) {
		IPage<LogUsual> pages = logService.page(Condition.getPage(query), Condition.getQueryWrapper(log, LogUsual.class));
		return R.data(LogUsualWrapper.build().pageVO(pages));
	}

}
