package org.springblade.bignet.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.bignet.dto.query.BladeBignetReportPageQuery;
import org.springblade.bignet.entity.BladeBignetReport;
import org.springblade.bignet.service.IBladeBignetReportService;
import org.springblade.complaints.entity.BladeCustomerComplaintsReport;
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;
import java.util.Date;

/**
 * <p>
 * 大网数据报表管理表 前端控制器
 * </p>
 *
 * @author zbc
 * @since 2021-04-19
 */
@RestController
@AllArgsConstructor
@RequestMapping("Bignet/bladeBignetReport")
@Api(value = "大网数据报表管理", tags = "大网数据报表管理接口")
public class BladeBignetReportController {


	private final IBladeBignetReportService bladeBignetReportService;


	@PostMapping("/save")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "新增", notes = "传入bladeBignetReport")
	public R save(@Valid @RequestBody BladeBignetReport bladeBignetReport) {
		bladeBignetReport.setCreateTime(new Date());
		return R.status(bladeBignetReportService.save(bladeBignetReport));
	}


	@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(bladeBignetReportService.removeByIds(Func.toLongList(ids)));
	}


	@PostMapping("/update")
	@ApiOperationSupport(order = 3)
	@ApiOperation(value = "修改", notes = "传入bladeBignetReport")
	public R update(@Valid @RequestBody BladeBignetReport bladeBignetReport) {
		bladeBignetReport.setUpdateTime(new Date());
		return R.status(bladeBignetReportService.updateById(bladeBignetReport));
	}


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


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


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

}

