package com.ssyf.module.logger.controller.auth;

import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.PageInfo;
import com.ssyf.common.core.util.EntityUtil;
import com.ssyf.module.logger.domain.entity.LogInfo;
import com.ssyf.module.logger.domain.query.LogInfoQuery;
import com.ssyf.module.logger.domain.vo.LogInfoVo;
import com.ssyf.module.logger.service.LogInfoService;
import com.ssyf.plugs.mysql.helper.PageEnhanceHelper;
import com.ssyf.common.web.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
* com.ssyf.auth.entity.LogInfo模型开放接口
*
* @author: auth
* @date: 2022-12-12
*/
@Api(tags="日志-日志信息")
@RestController
@RequestMapping("/auth/LogInfo")
public class LogInfoAuthController {

    @Autowired
    private LogInfoService baseService;

    @ApiOperation(value = "/查询指定数据" ,notes = "uid查询")
    @PostMapping(value = "/getOneById/{id}")
    public Result<PageInfo<LogInfoVo>> getOneByUid(@PathVariable Long id) {
        return Result.success(BeanUtil.toBean(this.baseService.getOneById(id) ,LogInfoVo.class));
    }

    @ApiOperation(value = "/查询分页数据", notes = "分页查询")
    @PostMapping(value = "/queryPage")
    public Result<PageInfo<LogInfoVo>> queryPage(@Validated @RequestBody LogInfoQuery query) {
        PageInfo<LogInfo> temp = this.baseService.getPage(query);
        return Result.success(PageEnhanceHelper.switchPageInfo(temp ,LogInfoVo.class));
    }

    @ApiOperation(value = "/查询所有数据")
    @PostMapping(value = "/queryList")
    public Result<PageInfo<LogInfoVo>> queryList(@Validated @RequestBody LogInfoQuery query) {
        List<LogInfo> menuLogInfoList = this.baseService.getList(query);
        List<LogInfoVo> t = EntityUtil.copyProperties(menuLogInfoList, LogInfoVo.class);
        return Result.success(t);
    }

}
