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.dto.WithdrawDto;
import com.ym.mec.biz.dal.entity.CooperationOrgan;
import com.ym.mec.biz.dal.entity.StudentWithdraw;
import com.ym.mec.biz.service.CooperationOrganService;
import com.ym.mec.biz.service.StudentWithdrawService;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.common.page.QueryInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RequestMapping("studentWithdraw")
@Api(tags = "提现服务")
@RestController
public class StudentWithdrawController extends BaseController {

    @Autowired
    private StudentWithdrawService studentWithdrawService;
    @Autowired
    private SysUserFeignService sysUserFeignService;

    @ApiOperation(value = "新增提现申请")
    @PostMapping("/add")
    public Object add(StudentWithdraw studentWithdraw) throws Exception {
        SysUser sysUser = sysUserFeignService.queryUserInfo();
        if(sysUser == null && sysUser.getId() == null){
            return failed("获取用户信息失败");
        }
        studentWithdraw.setUserId(sysUser.getId());
        studentWithdrawService.add(studentWithdraw);
        return succeed();
    }

    @ApiOperation(value = "分页查询")
    @GetMapping("/queryPage")
    public Object queryPage(WithdrawDto queryInfo) {
        return succeed(studentWithdrawService.queryPage(queryInfo));
    }
}
