package org.springblade.community.feign;

import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import javax.validation.Valid;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import org.springblade.community.entity.PlatformBills;
import org.springblade.community.vo.PlatformBillsVO;
import org.springblade.community.wrapper.PlatformBillsWrapper;
import org.springblade.community.service.IPlatformBillsService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 * 园区平台账单 client
 *
 * @author lianghanqiang
 * @since 2021-09-14
 */

@AllArgsConstructor
@RestController
@RequestMapping("/feign/platformbills")

public class PlatformBillsClient implements IPlatformBillsClient {

	private final IPlatformBillsService platformBillsService;

	/**
	 * 详情
	 */
	@Override
	@GetMapping("/detail")
	public PlatformBillsVO detail(PlatformBills platformBills) {
		PlatformBills detail = platformBillsService.getOne(Condition.getQueryWrapper(platformBills));
		return PlatformBillsWrapper.build().entityVO(detail);
	}

	/**
	 * 查询 园区平台账单
	 */
	@Override
	@GetMapping("/list")
	public List<PlatformBillsVO> list(PlatformBills platformBills) {
		return PlatformBillsWrapper.build().listVO(platformBillsService.list(Condition.getQueryWrapper(platformBills)));
	}



	/**
	 * 新增 园区平台账单
	 */
	@Override
	@PostMapping("/save")
	public boolean save(@Valid @RequestBody PlatformBills platformBills) {
		return platformBillsService.save(platformBills);
	}

	/**
	 * 修改 园区平台账单
	 */
	@Override
	@PostMapping("/update")
	public boolean update(@Valid @RequestBody PlatformBills platformBills) {
		return platformBillsService.updateById(platformBills);
	}

	/**
	 * 新增或修改 园区平台账单
	 */
	@Override
	@PostMapping("/submit")
	public boolean submit(@Valid @RequestBody PlatformBills platformBills) {
		return platformBillsService.saveOrUpdate(platformBills);
	}


	/**
	 * 删除 园区平台账单
	 */
	@Override
	@PostMapping("/remove")
	public boolean remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
		return platformBillsService.deleteLogic(Func.toLongList(ids));
	}


}
