package com.pnkx.system.service.impl;

import com.pnkx.common.utils.DateUtils;
import com.pnkx.common.utils.SecurityUtils;
import com.pnkx.system.domain.SysAppUpdateLog;
import com.pnkx.system.mapper.SysAppMapper;
import com.pnkx.system.service.ISysAppService;
import org.springframework.stereotype.Service;

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

/**
 * @author PHY
 * @classname PxAppServiceImol
 * @data 2021/12/1 9:51
 * @description 描述
 */
@Service
public class SysAppServiceImpl implements ISysAppService {

    @Resource
    SysAppMapper sysAppMapper;

    /**
     * 获取最新版app信息
     *
     * @return 最新版app信息
     */
    @Override
    public SysAppUpdateLog getNewestAppInfo() {
        return sysAppMapper.getNewestAppInfo();
    }


    /**
     * 查询app更新日志列表
     *
     * @param appUpdateLog app更新日志
     * @return app更新日志
     */
    @Override
    public List<SysAppUpdateLog> selectAppUpdateLogList(SysAppUpdateLog appUpdateLog) {
        return sysAppMapper.selectAppUpdateLogList(appUpdateLog);
    }

    /**
     * 查询app更新日志
     *
     * @param id app更新日志ID
     * @return app更新日志
     */
    @Override
    public SysAppUpdateLog selectAppUpdateLogById(Long id) {
        return sysAppMapper.selectAppUpdateLogById(id);
    }
    
    /**
     * 新增app更新日志
     *
     * @param appUpdateLog app更新日志
     * @return 结果
     */
    @Override
    public int insertAppUpdateLog(SysAppUpdateLog appUpdateLog) {
        appUpdateLog.setCreateTime(DateUtils.getNowDate());
        appUpdateLog.setCreateBy(SecurityUtils.getUserId().toString());
        return sysAppMapper.insertAppUpdateLog(appUpdateLog);
    }

    /**
     * 修改app更新日志
     *
     * @param appUpdateLog app更新日志
     * @return 结果
     */
    @Override
    public int updateAppUpdateLog(SysAppUpdateLog appUpdateLog) {
        appUpdateLog.setUpdateTime(DateUtils.getNowDate());
        appUpdateLog.setUpdateBy(SecurityUtils.getUserId().toString());
        return sysAppMapper.updateAppUpdateLog(appUpdateLog);
    }

    /**
     * 批量删除app更新日志
     *
     * @param ids 需要删除的app更新日志ID
     * @return 结果
     */
    @Override
    public int deleteAppUpdateLogByIds(Long[] ids) {
        return sysAppMapper.deleteAppUpdateLogByIds(ids);
    }

    /**
     * 删除app更新日志信息
     *
     * @param id app更新日志ID
     * @return 结果
     */
    @Override
    public int deleteAppUpdateLogById(Long id) {
        return sysAppMapper.deleteAppUpdateLogById(id);
    }
}
