package com.ruoyi.system.service.impl;


import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.JsonUtils;
import com.ruoyi.system.domain.SysLinks;
import com.ruoyi.system.mapper.SysLinksMapper;
import com.ruoyi.system.service.ISysLinksService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

 /**
 * <pre>
 * - 链接业务逻辑接口实现类
 * </pre>
 * @author J.L.Zhou<12020042> - <151 1104 7708>
 * @since 2023-11-06 12:56
 * @version 1.0
 */
@RequiredArgsConstructor
@Service
@Slf4j
public class SysLinksServiceImpl extends ServiceImpl<SysLinksMapper, SysLinks> implements ISysLinksService {


    @Override
    public QueryWrapper<SysLinks> where(SysLinks links) {
        if (log.isTraceEnabled()) {
            log.trace("${xxxx}条件参数：{}", JsonUtils.toJsonString(links));
        }
        QueryWrapper<SysLinks> wq = where();
        if (links == null) {
            return wq;
        }
        wq.lambda()
			.eq(links.getId() != null,SysLinks::getId, links.getId())
			.eq(links.getSortNum() != null,SysLinks::getSortNum, links.getSortNum())
			.eq(StrUtil.isNotBlank(links.getTitle()),SysLinks::getTitle, links.getTitle())
			.eq(StrUtil.isNotBlank(links.getUrl()),SysLinks::getUrl, links.getUrl())
			.eq(StrUtil.isNotBlank(links.getImg()),SysLinks::getImg, links.getImg())
			.eq(links.getTypeId() != null,SysLinks::getTypeId, links.getTypeId())
			.eq(links.getStatus() != null,SysLinks::getStatus, links.getStatus())
			.eq(StrUtil.isNotBlank(links.getRemark()),SysLinks::getRemark, links.getRemark())
        ;
        return wq;
    }

    @Override
    public QueryWrapper<SysLinks> where() {
        return Wrappers.query();
    }
}
