package com.cweb.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.HighBrand;
import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel;
import com.hai.service.HighBrandService;
import com.hai.service.HighGoodsTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @Auther: 袁野
 * @Description:
 * @Date: 2021/3/26 23:08
 */
@Controller
@RequestMapping(value = "/highBrand")
@Api(value = "品牌接口")
public class HighBrandController {

    private static Logger log = LoggerFactory.getLogger(HighMerchantStoreController.class);


    @Resource
    private HighBrandService highBrandService;

    @RequestMapping(value = "/getBrandByList", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取品牌列表")
    public ResponseData getBrandByList(@RequestParam(name = "pageNum", required = true) Integer pageNum,
                                       @RequestParam(name = "pageSize", required = true) Integer pageSize,
                                       @RequestParam(name = "title", required = false) String title,
                                       @RequestParam(name = "goodTypeId", required = false) String goodTypeId,
                                       HttpServletRequest request) {
        try {

            Map<String,String> map = new HashMap<>();
            map.put("title", title);
            map.put("goodTypeId", goodTypeId);

            PageHelper.startPage(pageNum,pageSize);
            return ResponseMsgUtil.success(new PageInfo<>(highBrandService.getListBand(map)));

        } catch (Exception e) {
            log.error("HighOrderController --> getUserOrderList() error!", e);
            return ResponseMsgUtil.exception(e);
        }
    }
}
