/*
* Copyright (c) 京北方信息技术股份有限公司 Corporation 2022 . All rights reserved.
*
*/
package net.northking.cctp.device.api.brand;

import cn.gjing.tools.auth.annotation.RequiredPermissions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.northking.cctp.common.db.Pagination;
import net.northking.cctp.common.http.QueryByPage;
import net.northking.cctp.common.http.ResultWrapper;
import net.northking.cctp.device.api.brand.service.CdMobileBrandApiService;
import net.northking.cctp.device.db.entity.CdMobileBrand;
import net.northking.cctp.device.dto.brand.CdMobileBrandDetailDto;
import net.northking.cctp.device.dto.brand.CdMobileBrandQueryDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "移动设备品牌表")
@RequestMapping("/v1")
@RestController
public class CdMobileBrandQueryCtrl
{
  /**
   * 日志
   */
  private final static Logger logger = LoggerFactory.getLogger(CdMobileBrandQueryCtrl.class);

  @Autowired
  private CdMobileBrandApiService apiService;

  /**
   * 查询用户列表
   *
   * @param queryByPage  查询条件
   * @return 数据列表
   */
  @ApiOperation(value = "分页查询列表")
  @RequiredPermissions({"mobileDeviceBrand","sassDeviceBrand"})
  @PostMapping(value = "/paging/query/brands",
      produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
      consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
  public ResultWrapper<Pagination<CdMobileBrandDetailDto>> pagingQuery(
      @RequestBody QueryByPage<CdMobileBrandQueryDto> queryByPage)
  {
    ResultWrapper<Pagination<CdMobileBrandDetailDto>> wrapper = new ResultWrapper<>();
    Pagination<CdMobileBrandDetailDto> page = apiService.pagingQuery(queryByPage);

    return wrapper.success(page);
  }

  @ApiOperation(value = "查询所有品牌")
  @PostMapping(value = "/query/all/brands")
  public ResultWrapper<List<CdMobileBrand>> queryAllBrand(){
    ResultWrapper<List<CdMobileBrand>> wrapper = new ResultWrapper<>();
    List<CdMobileBrand> result = this.apiService.queryAllBrand();
    return wrapper.success(result);
  }

}


