package com.hai.service.impl;

import com.hai.dao.HighBrandMapper;
import com.hai.entity.HighBrand;
import com.hai.entity.HighBrandExample;
import com.hai.entity.HighOrder;
import com.hai.service.HighBrandService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Auther: 袁野
 * @Description:
 * @Date: 2021/3/26 23:06
 */
@Service("highBrandService")
public class HighBrandServiceImpl implements HighBrandService {

    @Resource
    private HighBrandMapper highBrandMapper;

    @Override
    public List<HighBrand> getListBand(Map<String, String> map) {

        HighBrandExample example = new HighBrandExample();
        HighBrandExample.Criteria criteria = example.createCriteria();

        if (MapUtils.getString(map, "title") != null) {
            criteria.andTitleLike("%" + MapUtils.getString(map, "title") + "%");
        }

        criteria.andStatusEqualTo(1);

        example.setOrderByClause("created_time desc");

        return highBrandMapper.selectByExample(example);
    }

    @Override
    public HighBrand findByOrderId(Integer id) {
        return highBrandMapper.selectByPrimaryKey(id);
    }

    @Override
    public void insertBrand(HighBrand highBrand) {
        highBrandMapper.insert(highBrand);
    }

    @Override
    public void updateBrand(HighBrand highBrand) {
        highBrandMapper.updateByPrimaryKey(highBrand);
    }
}
