package com.ruoyi.dxp.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.dxp.mapper.UserResourceItemMapper;
import com.ruoyi.dxp.domain.UserResourceItem;
import com.ruoyi.dxp.service.IUserResourceItemService;

/**
 * 用户订购资源明细Service业务层处理
 * 
 * @author jy
 * @date 2022-12-26
 */
@Service
public class UserResourceItemServiceImpl implements IUserResourceItemService 
{
    @Autowired
    private UserResourceItemMapper userResourceItemMapper;

    /**
     * 查询用户订购资源明细
     * 
     * @param id 用户订购资源明细主键
     * @return 用户订购资源明细
     */
    @Override
    public UserResourceItem selectUserResourceItemById(Long id)
    {
        return userResourceItemMapper.selectUserResourceItemById(id);
    }

    /**
     * 查询用户订购资源明细列表
     * 
     * @param userResourceItem 用户订购资源明细
     * @return 用户订购资源明细
     */
    @Override
    public List<UserResourceItem> selectUserResourceItemList(UserResourceItem userResourceItem)
    {
        return userResourceItemMapper.selectUserResourceItemList(userResourceItem);
    }

    /**
     * 新增用户订购资源明细
     * 
     * @param userResourceItem 用户订购资源明细
     * @return 结果
     */
    @Override
    public int insertUserResourceItem(UserResourceItem userResourceItem)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        userResourceItem.setCreateBy(loginUser.getUsername());
        userResourceItem.setCreateTime(DateUtils.getNowDate());
        return userResourceItemMapper.insertUserResourceItem(userResourceItem);
    }

    /**
     * 修改用户订购资源明细
     * 
     * @param userResourceItem 用户订购资源明细
     * @return 结果
     */
    @Override
    public int updateUserResourceItem(UserResourceItem userResourceItem)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        userResourceItem.setUpdateBy(loginUser.getUsername());
        userResourceItem.setUpdateTime(DateUtils.getNowDate());
        return userResourceItemMapper.updateUserResourceItem(userResourceItem);
    }

    /**
     * 批量删除用户订购资源明细
     * 
     * @param ids 需要删除的用户订购资源明细主键
     * @return 结果
     */
    @Override
    public int deleteUserResourceItemByIds(Long[] ids)
    {
        return userResourceItemMapper.deleteUserResourceItemByIds(ids);
    }

    /**
     * 删除用户订购资源明细信息
     * 
     * @param id 用户订购资源明细主键
     * @return 结果
     */
    @Override
    public int deleteUserResourceItemById(Long id)
    {
        return userResourceItemMapper.deleteUserResourceItemById(id);
    }
}
