package com.backendsys.modules.b2c.good.service.impl;

import cn.hutool.core.util.StrUtil;
import com.backendsys.modules.b2c.good.dao.GoodUnitDao;
import com.backendsys.modules.b2c.good.entity.GoodUnit;
import com.backendsys.modules.b2c.good.service.GoodUnitService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodUnitServiceImpl implements GoodUnitService {

    @Autowired
    private GoodUnitDao goodUnitDao;

    /**
     * 获取商品单位
     *   分类:
     *   - 基础单位: general
     *   - 包装类: packaging
     *   - 液体容器: liquid
     *   - 成套商品: set
     *   - 服装穿戴: clothing
     *   - 电子设备: electronics
     *   - 食品计量: food
     *   - 建材五金: construction
     *   - 其他单位: other
     */
    @Override
    public List<GoodUnit> selectGoodUnitList(String unit_category) {
        LambdaQueryWrapper<GoodUnit> wrapper = new LambdaQueryWrapper<>();
        if (StrUtil.isNotEmpty(unit_category)) {
            wrapper.eq(GoodUnit::getUnit_category, unit_category);
        }
        wrapper.orderByAsc(GoodUnit::getSort);
        return goodUnitDao.selectList(wrapper);
    }

}
