Jinquan_Ou
2023-04-12 a64372663b31715ccbb1048eb03deb172dad2773
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.ruoyi.service.impl;
 
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.ZfMaster;
import com.ruoyi.mapper.ZfMasterMapper;
import com.ruoyi.service.ZfMasterService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
/**
 * <p>
 * 魅宠主人表 服务实现类
 * </p>
 *
 * @author ojq
 * @since 2023-03-12
 */
@Service
@Slf4j
public class ZfMasterServiceImpl extends ServiceImpl<ZfMasterMapper, ZfMaster> implements ZfMasterService {
 
    @Override
    public AjaxResult getMasterInfoByPetId(Long pid) {
        LambdaQueryWrapper<ZfMaster> lqw = new LambdaQueryWrapper<>();
        lqw.eq(ZfMaster::getPetId,pid);
        ZfMaster master = getOne(lqw);
        return AjaxResult.success(master);
    }
 
    @Override
    public List<ZfMaster> selectByCondition(ZfMaster zfMaster) {
        LambdaQueryWrapper<ZfMaster> lambdaQueryWrapper = buildCondition(zfMaster);
        List<ZfMaster> list = list(lambdaQueryWrapper);
        log.info("返回的数据为:{}",list);
        return list;
    }
 
    private LambdaQueryWrapper<ZfMaster> buildCondition(ZfMaster zfMaster) {
        LambdaQueryWrapper<ZfMaster> lqw = new LambdaQueryWrapper<>();
        lqw.like(zfMaster.getPetId()!=null,ZfMaster::getPetId,zfMaster.getPetId());
        lqw.like(StringUtils.isNotEmpty(zfMaster.getName()),ZfMaster::getName,zfMaster.getName());
        lqw.like(StringUtils.isNotEmpty(zfMaster.getCertificateType()),ZfMaster::getCertificateType,zfMaster.getCertificateType());
        lqw.like(StringUtils.isNotEmpty(zfMaster.getFixedNo()),ZfMaster::getFixedNo,zfMaster.getFixedNo());
        lqw.like(StringUtils.isNotEmpty(zfMaster.getPhoneNo()),ZfMaster::getPhoneNo,zfMaster.getPhoneNo());
        lqw.eq(zfMaster.getMany()!=null,ZfMaster::getMany,zfMaster.getMany());
        lqw.like(StringUtils.isNotEmpty(zfMaster.getAddress()),ZfMaster::getAddress,zfMaster.getAddress());
        lqw.like(StringUtils.isNotEmpty(zfMaster.getProperty()),ZfMaster::getProperty,zfMaster.getProperty());
        lqw.like(StringUtils.isNotEmpty(zfMaster.getEmail()),ZfMaster::getEmail,zfMaster.getEmail());
        return lqw;
    }
}