package com.ym.mec.web.controller;

import com.ym.mec.biz.dal.entity.ChargeType;
import com.ym.mec.biz.service.ChargeTypeService;
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.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RequestMapping("chargeType")
@Api(tags = "收费类型服务")
@RestController
public class ChargeTypeController extends BaseController {

    @Autowired
    private ChargeTypeService chargeTypeService;

    @ApiOperation(value = "新增、修改收费类型")
    @PostMapping("/upSet")
    @PreAuthorize("@pcs.hasPermissions('chargeType/upSet')")
    public Object upSet(@RequestBody ChargeType chargeType) {
        chargeTypeService.upSet(chargeType);
        return succeed();
    }

    @ApiOperation(value = "删除收费类型")
    @PostMapping("/del/{id}")
    @PreAuthorize("@pcs.hasPermissions('chargeType/del')")
    public Object del(@ApiParam(value = "收费类型编号", required = true) @PathVariable("id") Integer id) {
        chargeTypeService.del(id);
        return succeed();
    }

    @ApiOperation(value = "分页查询收费类型列表")
    @GetMapping("/queryPage")
    @PreAuthorize("@pcs.hasPermissions('chargeType/queryPage')")
    public Object queryPage(QueryInfo queryInfo) {
        return succeed(chargeTypeService.queryPage(queryInfo));
    }

}
