package com.yunzhupaas.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yunzhupaas.base.service.SuperServiceImpl;
import com.yunzhupaas.entity.ProductclassifyEntity;
import com.yunzhupaas.mapper.ProductclassifyMapper;
import com.yunzhupaas.service.ProductclassifyService;
import com.yunzhupaas.util.RandomUtil;
import com.yunzhupaas.util.UserProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 *
 * 产品分类
 * 版本： V3.1.0
 * 版权： 深圳市乐程软件有限公司（http://www.szlecheng.cn）
 * 作者： 云筑产品开发平台组
 * 日期： 2021-07-10 14:34:04
 */
@Service
public class ProductclassifyServiceImpl extends SuperServiceImpl<ProductclassifyMapper, ProductclassifyEntity> implements ProductclassifyService {

    

    @Override
    public List<ProductclassifyEntity> getList(){
        QueryWrapper<ProductclassifyEntity> queryWrapper=new QueryWrapper<>();
        return list(queryWrapper);
    }

    @Override
    public ProductclassifyEntity getInfo(String id){
        QueryWrapper<ProductclassifyEntity> queryWrapper=new QueryWrapper<>();
        queryWrapper.lambda().eq(ProductclassifyEntity::getId,id);
        return this.getOne(queryWrapper);
    }

    @Override
    public void create(ProductclassifyEntity entity){
        entity.setId(RandomUtil.uuId());
        entity.setCreatorUserId(UserProvider.getUser().getUserId());
        entity.setCreatorTime(new Date());
        this.save(entity);
    }

    @Override
    public boolean update(String id, ProductclassifyEntity entity){
        entity.setId(id);
        entity.setLastModifyUserId(UserProvider.getUser().getUserId());
        entity.setLastModifyTime(new Date());
        return this.updateById(entity);
    }
    @Override
    public void delete(ProductclassifyEntity entity){
        if(entity!=null){
            this.removeById(entity.getId());
        }
    }

}

