package com.ym.mec.web.controller;

import com.ym.mec.biz.dal.entity.ChargeTypeOrganizationFee;
import com.ym.mec.biz.service.ChargeTypeOrganizationFeeService;
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 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;

import java.util.Date;

/** 
 * 系统配置控制层
 */
@RestController
@Api(tags = "收费类型对应分部的课程费用表")
@RequestMapping(value = "chargeTypeOrganizationFee")
public class ChargeTypeOrganizationFeeController extends BaseController {

	@Autowired
	private ChargeTypeOrganizationFeeService chargeTypeOrganizationFeeService;

	@ApiOperation(value = "新增")
	@PostMapping(value = "add")
    @PreAuthorize("@pcs.hasPermissions('chargeTypeOrganizationFee/add')")
	public Object add(ChargeTypeOrganizationFee chargeTypeOrganizationFee) {
		chargeTypeOrganizationFeeService.add(chargeTypeOrganizationFee);
		return succeed();
	}

	@ApiOperation(value = "获取收费类型分部关联的默认课程费用")
	@GetMapping(value = "findByOrganId")
    @PreAuthorize("@pcs.hasPermissions('chargeTypeOrganizationFee/findByOrganId')")
	public Object findByOrganId(Integer chargeTypeId,Integer organId) {
		return succeed(chargeTypeOrganizationFeeService.findByOrganId(chargeTypeId,organId));
	}

	@ApiOperation(value = "删除")
	@PostMapping(value = "delete")
    @PreAuthorize("@pcs.hasPermissions('chargeTypeOrganizationFee/delete')")
	public Object delete(Integer id) {
		return succeed(chargeTypeOrganizationFeeService.delete(id));
	}

	@ApiOperation(value = "修改")
	@PostMapping(value = "update")
    @PreAuthorize("@pcs.hasPermissions('chargeTypeOrganizationFee/update')")
	public Object update(ChargeTypeOrganizationFee chargeTypeOrganizationFee) {
		chargeTypeOrganizationFee.setUpdateTime(new Date());
		chargeTypeOrganizationFeeService.updateFee(chargeTypeOrganizationFee);
		return succeed();
	}

	@ApiOperation(value = "分页查询")
	@GetMapping(value = "queryPage")
    @PreAuthorize("@pcs.hasPermissions('chargeTypeOrganizationFee/queryPage')")
	public Object queryPage(QueryInfo queryInfo) {
		return succeed(chargeTypeOrganizationFeeService.queryPage(queryInfo));
	}
}
