package	com.sw.mes.yb.printer.service.impl;


import com.sw.mes.core.base.BaseServiceImpl;
import com.sw.mes.core.context.BaseContextHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.sw.mes.yb.printer.entity.PrinterLog;
import com.sw.mes.yb.printer.dao.PrinterLogDao;
import com.sw.mes.yb.printer.service.PrinterLogService;

import java.lang.reflect.Field;
import java.util.Date;
import java.util.List;


/**
* @Author
* @Description：
* @Date: Create in
* @Modified By:
*/
@Service
@Transactional
public class PrinterLogServiceImpl extends BaseServiceImpl<PrinterLog> implements PrinterLogService {


    PrinterLogDao dao;
	@Autowired
    public void setDao(PrinterLogDao dao) {
        super.setBaseDao(dao);
        this.dao=dao;
    }


    @Override
    public void saveAll(List<PrinterLog> printerLogList) {
        dao.saveAll(printerLogList);
    }

    @Override
    public void softDelete(Long id) {
        PrinterLog entity=get(id);
       if (entity==null){
           throw new RuntimeException("记录不存在") ;
       }
       entity.setDeleteTime(new Date());
       entity.setDeleteUser(BaseContextHandler.getUsername());
       entity.setDeleteUserId(BaseContextHandler.getUserID());
       entity.setIsDelete(true);
       dao.save(entity);
    }
}
