package com.ym.mec.web.controller;

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

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ym.mec.biz.dal.entity.ChargeTypeSubjectMapper;
import com.ym.mec.biz.dal.page.ChargeTypeSubjectMapperQueryInfo;
import com.ym.mec.biz.service.ChargeTypeSubjectMapperService;
import com.ym.mec.common.controller.BaseController;

@RequestMapping("chargeTypeSubjectMapper")
@Api(tags = "收费类型与科目的关联服务")
@RestController
public class ChargeTypeSubjectMapperController extends BaseController {

    @Autowired
    private ChargeTypeSubjectMapperService chargeTypeSubjectMapperService;

    @ApiOperation(value = "分页查询收费类型列表")
    @GetMapping(value = "/queryPage", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PreAuthorize("@pcs.hasPermissions('chargeTypeSubjectMapper/queryPage')")
    public Object queryPage(ChargeTypeSubjectMapperQueryInfo queryInfo) {
        return succeed(chargeTypeSubjectMapperService.queryPage(queryInfo));
    }

    @ApiOperation(value = "新增对象")
	@PostMapping(value = "/insert", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PreAuthorize("@pcs.hasPermissions('chargeTypeSubjectMapper/insert')")
    public Object insert(@RequestBody List<ChargeTypeSubjectMapper> chargeTypeSubjectMapperList) {
    	chargeTypeSubjectMapperService.batchInsert(chargeTypeSubjectMapperList);
        return succeed();
    }

    @ApiOperation(value = "修改对象")
	@PostMapping(value = "/update", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PreAuthorize("@pcs.hasPermissions('chargeTypeSubjectMapper/update')")
    public Object update(@RequestBody List<ChargeTypeSubjectMapper> chargeTypeSubjectMapperList) {
    	chargeTypeSubjectMapperService.batchUpdate(chargeTypeSubjectMapperList);
        return succeed();
    }

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

}
