package com.ym.mec.web.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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;

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

    @Autowired
    private ChargeTypeService chargeTypeService;

    @ApiOperation(value = "新增收费类型")
    @PostMapping("/add")
    public Object add(ChargeType chargeType) {
        chargeTypeService.insert(chargeType);
        return succeed();
    }

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

    @ApiOperation(value = "修改收费类型")
    @PostMapping("/update")
    public Object update(ChargeType chargeType) {
        chargeType.setUpdateTime(new Date());
        chargeTypeService.update(chargeType);
        return succeed();
    }

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

}
