/*
* Copyright (c) ${Company} Corporation ${Year} . All rights reserved.
*
*/
package ${genPackage}.${javaClassRef.getClassName()};

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.northking.cctp.common.http.ResultWrapper;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * ${javaClassRef.getComment()} => Restful 类型 HTTP/HTTPS 接口
 *
 * @author ${Author}
 * @since ${Version}
 */
@Api(tags = "${javaClassRef.getComment()}")
@RequestMapping("/v1/batch/${javaClassRef.getClassName()}s")
@RestController
public class ${javaClassRef.getClassName()}BatchCtrl
{
  /**
   * 日志
   */
  private final static Logger logger = LoggerFactory.getLogger(${javaClassRef.getClassName()}BatchCtrl.class);

  @Autowired
  private ${javaClassRef.getClassName()}ApiService apiService;

  /**
   * Restful接口-post： 批量新增${javaClassRef.getComment()}
   *
   * @param batch 集合
   * @return 主键集合
   */
  @ApiOperation(value = "批量新增：${javaClassRef.getComment()}")
  @PostMapping(
      value = "/insert",
      produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
      consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
  public ResultWrapper<List<String>> addBatch(
      @RequestBody @Validated List<${javaClassRef.getClassName()}AddDto> batch)
  {
    ResultWrapper<List<String>> wrapper = new ResultWrapper<>();
    List<String> result = this.apiService.addBatch(batch);
    return wrapper.success(result);
  }

  /**
   * Restful接口-post： 批量修改${javaClassRef.getComment()}
   *
   * @param batch 集合
   * @return 成功的数量
   */
  @ApiOperation(value = "批量修改：${javaClassRef.getComment()}")
  @PostMapping(
      value = "/update",
      produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
      consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
  public ResultWrapper<Integer> updateBatch(
      @RequestBody @Validated List<${javaClassRef.getClassName()}UpdateDto> batch) throws IllegalAccessException
  {
    ResultWrapper<Integer> wrapper = new ResultWrapper<>();
    Integer count = this.apiService.updateBatch(batch);
    return wrapper.success(count);
  }

  /**
   * Restful接口-post： 批量删除${javaClassRef.getComment()}
   *
   * @param batch 集合
   * @return 成功的数量
   */
  @ApiOperation(value = "批量删除：${javaClassRef.getComment()}")
  @PostMapping(
      value = "/delete",
      produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
      consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
  public ResultWrapper<Integer> deleteBatch(
      @RequestBody @Validated List<Object> batch)
  {
    ResultWrapper<Integer> wrapper = new ResultWrapper<>();
    Integer count = this.apiService.deleteBatch(batch);
    return wrapper.success(count);
  }
}
