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.biz.dal.entity.ReplacementInstrument;
import com.ym.mec.biz.dal.page.ReplacementInstrumentQueryInfo;
import com.ym.mec.biz.service.ReplacementInstrumentService;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.common.entity.HttpResponseResult;
import com.ym.mec.common.exception.BizException;
import com.ym.mec.common.page.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RequestMapping("replacementInstrument")
@Api(tags = "乐器置换-乐器服务")
@RestController
public class ReplacementInstrumentController extends BaseController {

    @Autowired
    private ReplacementInstrumentService replacementInstrumentService;
    @Autowired
    private SysUserFeignService sysUserFeignService;

    @ApiOperation(value = "分页查询列表")
    @GetMapping("/queryPage")
    public HttpResponseResult<PageInfo<ReplacementInstrument>> queryPage(ReplacementInstrumentQueryInfo queryInfo) {
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if (sysUser == null) {
            return failed("用户信息获取失败");
        }
        if(queryInfo.getOrganId() == null){
            throw new BizException("参数校验失败：学员分部为空");
        }
        return succeed(replacementInstrumentService.getPageList(queryInfo));
    }

}
