package com.ym.mec.web.controller;


import com.ym.mec.biz.dal.page.DegreeQueryInfo;
import com.ym.mec.biz.service.DegreeRegistrationService;
import com.ym.mec.biz.service.OrganizationService;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.common.entity.HttpResponseResult;
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.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("degree")
@Api(tags = "考级报名服务")
@RestController
public class DegreeController extends BaseController { ;

    @Autowired
    private DegreeRegistrationService degreeRegistrationService;
    @Autowired
    private OrganizationService organizationService;

    @ApiOperation(value = "查询收费列表")
    @GetMapping("/queryPage")
    @PreAuthorize("@pcs.hasPermissions('degree/queryPage')")
    public HttpResponseResult queryPage(DegreeQueryInfo queryInfo) {
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        queryInfo.setSort("create_time_");
        queryInfo.setOrder("DESC");
        return succeed(degreeRegistrationService.getPageList(queryInfo));
    }

    @ApiOperation(value = "退费")
    @PostMapping("/refund")
    @PreAuthorize("@pcs.hasPermissions('degree/refund')")
    public HttpResponseResult refund(Integer degreeRegistrationId) {
        return succeed(degreeRegistrationService.refund(degreeRegistrationId));
    }

}
