package org.springblade.complaints.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.complaints.dto.query.CustomerComplaintsReportPageQuery;
import org.springblade.complaints.entity.BladeCustomerComplaintsReport;
import org.springblade.complaints.service.IBladeCustomerComplaintsReportService;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 客诉报表管理 前端控制器
 * </p>
 *
 * @author zbc
 * @since 2021-04-09
 */
@RestController
@AllArgsConstructor
@RequestMapping("complaints/bladeCustomerComplaintsReport")
@Api(value = "客诉报表管理", tags = "客诉报表管理接口")
public class BladeCustomerComplaintsReportController extends BladeController {

	private final IBladeCustomerComplaintsReportService bladeCustomerComplaintsReportService;


	@PostMapping("/save")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "新增", notes = "传入bladeCustomerComplaintsReport")
	public R save(@Valid @RequestBody BladeCustomerComplaintsReport bladeCustomerComplaintsReport) {
		return R.status(bladeCustomerComplaintsReportService.save(bladeCustomerComplaintsReport));
	}


	@PostMapping("/remove")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "删除", notes = "传入ids")
	public R remove(@ApiParam(value = "主键集合  1,2,3", required = true) @RequestParam String ids) {
		return R.status(bladeCustomerComplaintsReportService.removeByIds(Func.toLongList(ids)));
	}


	@PostMapping("/update")
	@ApiOperationSupport(order = 3)
	@ApiOperation(value = "修改", notes = "传入bladeCustomerComplaints")
	public R update(@Valid @RequestBody BladeCustomerComplaintsReport bladeCustomerComplaintsReport) {
		return R.status(bladeCustomerComplaintsReportService.updateById(bladeCustomerComplaintsReport));
	}


	@GetMapping("/list")
	@ApiOperationSupport(order = 4)
	@ApiOperation(value = "列表", notes = "传入bladeCustomerComplaints")
	public R<IPage<BladeCustomerComplaintsReport>> list(BladeCustomerComplaintsReport bladeCustomerComplaintsReport, Query query) {
		IPage<BladeCustomerComplaintsReport> pages = bladeCustomerComplaintsReportService.page(Condition.getPage(query), Condition.getQueryWrapper(bladeCustomerComplaintsReport));
		return R.data(pages);
	}


	@GetMapping("/page")
	@ApiOperationSupport(order = 5)
	@ApiOperation(value = "分页", notes = "传入bladeCustomerComplaints")
	public R<IPage<BladeCustomerComplaintsReport>> page(CustomerComplaintsReportPageQuery pageQuery, Query query) {
		IPage<BladeCustomerComplaintsReport> page = Condition.getPage(query);
		IPage<BladeCustomerComplaintsReport> pages = bladeCustomerComplaintsReportService.getPageByQuery(page, pageQuery);
		return R.data(pages);
	}


	@GetMapping("/detail")
	@ApiOperationSupport(order = 6)
	@ApiOperation(value = "详情", notes = "传入bladeCustomerComplaints")
	public R<BladeCustomerComplaintsReport> detail(BladeCustomerComplaintsReport bladeCustomerComplaintsReport) {
		BladeCustomerComplaintsReport detail = bladeCustomerComplaintsReportService.getOne(Condition.getQueryWrapper(bladeCustomerComplaintsReport));
		return R.data(detail);
	}


}

