package com.yeejoin.amos.boot.module.hygf.biz.controller;

import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.DeleteMapping;
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.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.hygf.api.dto.JpInvertorElecHistoryAllDto;
import com.yeejoin.amos.boot.module.hygf.api.dto.JpInvertorElecHistoryMonthDto;
import com.yeejoin.amos.boot.module.hygf.api.dto.JpInvertorElecHistoryYearDto;
import com.yeejoin.amos.boot.module.hygf.api.dto.TdHygfJpInvertorElecHistoryDto;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.TdHygfJpInvertorElecHistoryServiceImpl;

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

/**
 * 户用光伏监盘逆变器电能历史表
 *
 * @author system_generator
 * @date 2023-09-19
 */
@RestController
@Api(tags = "户用光伏监盘逆变器电能历史表Api")
@RequestMapping(value = "/td-hygf-jp-invertor-elec-history")
public class TdHygfJpInvertorElecHistoryController extends BaseController {

	@Autowired
	TdHygfJpInvertorElecHistoryServiceImpl tdHygfJpInvertorElecHistoryServiceImpl;

	/**
	 * 新增户用光伏监盘逆变器电能历史表
	 *
	 * @return
	 */
	@TycloudOperation(ApiLevel = UserType.AGENCY)
	@PostMapping(value = "/save")
	@ApiOperation(httpMethod = "POST", value = "新增户用光伏监盘逆变器电能历史表", notes = "新增户用光伏监盘逆变器电能历史表")
	public ResponseModel<TdHygfJpInvertorElecHistoryDto> save(@RequestBody TdHygfJpInvertorElecHistoryDto model) {
		model = tdHygfJpInvertorElecHistoryServiceImpl.createWithModel(model);
		return ResponseHelper.buildResponse(model);
	}

	/**
	 * 根据sequenceNbr更新
	 *
	 * @param sequenceNbr 主键
	 * @return
	 */
	@TycloudOperation(ApiLevel = UserType.AGENCY)
	@PutMapping(value = "/{sequenceNbr}")
	@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新户用光伏监盘逆变器电能历史表", notes = "根据sequenceNbr更新户用光伏监盘逆变器电能历史表")

	public ResponseModel<TdHygfJpInvertorElecHistoryDto> updateBySequenceNbrTdHygfJpInvertorElecHistory(
			@RequestBody TdHygfJpInvertorElecHistoryDto model, @PathVariable(value = "sequenceNbr") Long sequenceNbr) {
		return ResponseHelper.buildResponse(tdHygfJpInvertorElecHistoryServiceImpl.updateWithModel(model));

	}

	/**
	 * 根据sequenceNbr删除
	 *
	 * @param sequenceNbr 主键
	 * @return
	 */
	@TycloudOperation(ApiLevel = UserType.AGENCY)
	@DeleteMapping(value = "/{sequenceNbr}")
	@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除户用光伏监盘逆变器电能历史表", notes = "根据sequenceNbr删除户用光伏监盘逆变器电能历史表")
	public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request,
			@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
		return ResponseHelper.buildResponse(tdHygfJpInvertorElecHistoryServiceImpl.removeById(sequenceNbr));
	}

	/**
	 * 根据sequenceNbr查询
	 *
	 * @param sequenceNbr 主键
	 * @return
	 */
	@TycloudOperation(ApiLevel = UserType.AGENCY)
	@GetMapping(value = "/{sequenceNbr}")
	@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个户用光伏监盘逆变器电能历史表", notes = "根据sequenceNbr查询单个户用光伏监盘逆变器电能历史表")
	public ResponseModel<TdHygfJpInvertorElecHistoryDto> selectOne(@PathVariable Long sequenceNbr) {
		return ResponseHelper.buildResponse(tdHygfJpInvertorElecHistoryServiceImpl.queryBySeq(sequenceNbr));
	}

	/**
	 * 列表分页查询
	 *
	 * @param current 当前页
	 * @param current 每页大小
	 * @return
	 */
	@TycloudOperation(ApiLevel = UserType.AGENCY)
	@GetMapping(value = "/page")
	@ApiOperation(httpMethod = "GET", value = "户用光伏监盘逆变器电能历史表分页查询", notes = "户用光伏监盘逆变器电能历史表分页查询")
	public ResponseModel<Page<TdHygfJpInvertorElecHistoryDto>> queryForPage(
			@RequestParam(value = "current") int current, @RequestParam(value = "size") int size) {
		Page<TdHygfJpInvertorElecHistoryDto> page = new Page<TdHygfJpInvertorElecHistoryDto>();
		page.setCurrent(current);
		page.setSize(size);
		return ResponseHelper
				.buildResponse(tdHygfJpInvertorElecHistoryServiceImpl.queryForTdHygfJpInvertorElecHistoryPage(page));
	}

	/**
	 * 列表全部数据查询
	 *
	 * @return
	 */
	@TycloudOperation(ApiLevel = UserType.AGENCY)
	@ApiOperation(httpMethod = "GET", value = "户用光伏监盘逆变器电能历史表列表全部数据查询", notes = "户用光伏监盘逆变器电能历史表列表全部数据查询")
	@GetMapping(value = "/list/day")
	public ResponseModel<List<TdHygfJpInvertorElecHistoryDto>> dayList(@RequestParam(value = "id") long id,
			@RequestParam(value = "day") @DateTimeFormat(pattern = "yyyy-MM-dd") Date day) {
		return ResponseHelper.buildResponse(tdHygfJpInvertorElecHistoryServiceImpl.dayList(id, day));
	}
	
	/**
	 * 列表全部数据查询
	 *
	 * @return
	 */
	@TycloudOperation(ApiLevel = UserType.AGENCY)
	@ApiOperation(httpMethod = "GET", value = "户用光伏监盘采集器历史表列表全部数据查询", notes = "户用光伏监盘采集器历史表列表全部数据查询")
	@GetMapping(value = "/list/month")
	public ResponseModel<List<JpInvertorElecHistoryMonthDto>> monthList(@RequestParam(value = "id") long id,
			@RequestParam(value = "month") @DateTimeFormat(pattern = "yyyy-MM") Date month) {
		return ResponseHelper.buildResponse(tdHygfJpInvertorElecHistoryServiceImpl.monthList(id, month));
	}

	/**
	 * 列表全部数据查询
	 *
	 * @return
	 */
	@TycloudOperation(ApiLevel = UserType.AGENCY)
	@ApiOperation(httpMethod = "GET", value = "户用光伏监盘采集器历史表列表全部数据查询", notes = "户用光伏监盘采集器历史表列表全部数据查询")
	@GetMapping(value = "/list/year")
	public ResponseModel<List<JpInvertorElecHistoryYearDto>> yearList(@RequestParam(value = "id") long id,
			@RequestParam(value = "year") @DateTimeFormat(pattern = "yyyy") Date year) {
		return ResponseHelper.buildResponse(tdHygfJpInvertorElecHistoryServiceImpl.yearList(id, year));
	}

	/**
	 * 列表全部数据查询
	 *
	 * @return
	 */
	@TycloudOperation(ApiLevel = UserType.AGENCY)
	@ApiOperation(httpMethod = "GET", value = "户用光伏监盘采集器历史表列表全部数据查询", notes = "户用光伏监盘采集器历史表列表全部数据查询")
	@GetMapping(value = "/list/all")
	public ResponseModel<List<JpInvertorElecHistoryAllDto>> allList(@RequestParam(value = "id") long id) {
		return ResponseHelper.buildResponse(tdHygfJpInvertorElecHistoryServiceImpl.allList(id));
	}
	
	/**
	 * 列表全部数据查询
	 *
	 * @return
	 */
	@TycloudOperation(ApiLevel = UserType.AGENCY)
	@ApiOperation(httpMethod = "GET", value = "户用光伏监盘采集器历史表列表全部数据查询", notes = "户用光伏监盘采集器历史表列表全部数据查询")
	@GetMapping(value = "/syncData")
	public ResponseModel<Object> syncData() {
		return ResponseHelper.buildResponse(tdHygfJpInvertorElecHistoryServiceImpl.syncData());
	}
}
