package com.fzm.mall.server.admin.system.service.impl;

import com.fzm.mall.server.admin.constant.MallResponseError;
import com.fzm.mall.server.admin.exception.MyException;
import com.fzm.mall.server.admin.system.model.AdminLog;
import com.fzm.mall.server.admin.system.dao.AdminLogMapper;
import com.fzm.mall.server.admin.system.service.IAdminLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author wangp
 * @date 2021/3/1 14:33
 * @description 管理员操作日志服务实现类
 * @since JDK 1.8
 */
@Service
@Transactional
public class AdminLogServiceImpl extends ServiceImpl<AdminLogMapper, AdminLog> implements IAdminLogService {

    @Override
    public void add(String adminId, Integer type, String operateLog, String note) {
        AdminLog log = new AdminLog();
        log.setAdminId(adminId);
        log.setType(type);
        log.setOperateLog(operateLog);
        log.setNote(note);
        if (!save(log)) {
            throw new MyException(MallResponseError.SAVE_ERROR);
        }
    }
}
