All Downloads are FREE. Search and download functionalities are using the official Maven repository.

k.e.book.ddh.service.CcCreatorService Maven / Gradle / Ivy


package k.e.book.ddh.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import k.e.book.ddh.entity.CcCreatorDO;
import k.e.book.ddh.entity.CcCreatorQueryDTO;
import k.e.book.ddh.mapper.CcCreatorMapper;
import org.redisson.api.RedissonClient;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

/**
 * @author kk
 * @date 2023-05-21 11:04
 */
@Service
public class CcCreatorService extends ServiceImpl {

    @Resource
    private RedissonClient redissonClient;

    private static final String key = "ddh:creator:";

    public CcCreatorDO getByCache(Integer id) {
        String k = String.format("%s%d", key, id);
        Object o = redissonClient.getBucket(k).get();
        if (o != null) {
            return (CcCreatorDO) o;
        }
        CcCreatorDO od = this.getById(id);
        redissonClient.getBucket(k).set(od, 1, TimeUnit.HOURS);
        return od;
    }

    public IPage selectProductPage(CcCreatorQueryDTO dto) {
        LambdaQueryWrapper qr = new LambdaQueryWrapper<>();

        if (dto.getId() != null) {
            qr.eq(CcCreatorDO::getId, dto.getId());
        }
        if (dto.getUserId() != null) {
            qr.eq(CcCreatorDO::getUserId, dto.getUserId());
        }
        if (dto.getAvatar() != null) {
            qr.eq(CcCreatorDO::getAvatar, dto.getAvatar());
        }
        if (dto.getName() != null) {
            qr.eq(CcCreatorDO::getName, dto.getName());
        }
        if (dto.getIntro() != null) {
            qr.eq(CcCreatorDO::getIntro, dto.getIntro());
        }
        if (dto.getFlag() != null) {
            qr.eq(CcCreatorDO::getFlag, dto.getFlag());
        }
        if (dto.getContract() != null) {
            qr.eq(CcCreatorDO::getContract, dto.getContract());
        }
        if (dto.getContractAbi() != null) {
            qr.eq(CcCreatorDO::getContractAbi, dto.getContractAbi());
        }
        if (dto.getCreatetime() != null) {
            qr.eq(CcCreatorDO::getCreatetime, dto.getCreatetime());
        }
        if (dto.getUpdatetime() != null) {
            qr.eq(CcCreatorDO::getUpdatetime, dto.getUpdatetime());
        }
        if (dto.getDeletetime() != null) {
            qr.eq(CcCreatorDO::getDeletetime, dto.getDeletetime());
        }
        if (dto.getPurchaselimit() != null) {
            qr.eq(CcCreatorDO::getPurchaselimit, dto.getPurchaselimit());
        }
        if (dto.getStatus() != null) {
            qr.eq(CcCreatorDO::getStatus, dto.getStatus());
        }
        if (dto.getCheckstatus() != null) {
            qr.eq(CcCreatorDO::getCheckstatus, dto.getCheckstatus());
        }
        if (dto.getCategoryIds() != null) {
            qr.eq(CcCreatorDO::getCategoryIds, dto.getCategoryIds());
        }
        if (dto.getType() != null) {
            qr.eq(CcCreatorDO::getType, dto.getType());
        }
        if (dto.getCreatedAt() != null) {
            qr.eq(CcCreatorDO::getCreatedAt, dto.getCreatedAt());
        }
        if (dto.getUpdatedAt() != null) {
            qr.eq(CcCreatorDO::getUpdatedAt, dto.getUpdatedAt());
        }
        if (dto.getDeletedAt() != null) {
            qr.eq(CcCreatorDO::getDeletedAt, dto.getDeletedAt());
        }

        qr.orderByDesc(CcCreatorDO::getId);
        IPage page = new Page<>();
        page.setCurrent(dto.getPage());
        page.setSize(dto.getLimit());
        return baseMapper.selectPage(page, qr);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy