1
Jinquan_Ou
2023-04-24 cc967be03d754403ab4159a7229d50f46e731a2d
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
58
59
60
61
62
63
package com.ruoyi.service.impl;
 
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.MapUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.ZfDoctor;
import com.ruoyi.mapper.ZfDoctorMapper;
import com.ruoyi.service.ZfDoctorService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
 
import java.util.HashMap;
import java.util.List;
 
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ojq
 * @since 2023-03-12
 */
@Service
@Slf4j
public class ZfDoctorServiceImpl extends ServiceImpl<ZfDoctorMapper, ZfDoctor> implements ZfDoctorService {
 
    @Override
    public AjaxResult selectDoctorList(ZfDoctor zfDoctor, Integer pageNum, Integer pageSize) {
        LambdaQueryWrapper<ZfDoctor> lqw = buildCondition(zfDoctor);
        lqw.orderByDesc(ZfDoctor::getId);
 
        Page<ZfDoctor> ZfDoctorPage = new Page<>(pageNum,pageSize);
        Page<ZfDoctor> pageResult = page(ZfDoctorPage, lqw);
 
        HashMap<String, Object> data = MapUtils.getResult(pageResult);
        return AjaxResult.success(data);
    }
 
    @Override
    public List<ZfDoctor> selectByCondition(ZfDoctor zfDoctor) {
        LambdaQueryWrapper<ZfDoctor> lambdaQueryWrapper = buildCondition(zfDoctor);
        List<ZfDoctor> list = list(lambdaQueryWrapper);
        log.info("返回的数据为:{}",list);
        return list;
    }
 
    private LambdaQueryWrapper<ZfDoctor> buildCondition(ZfDoctor zfDoctor) {
        LambdaQueryWrapper<ZfDoctor> lqw = new LambdaQueryWrapper<>();
        lqw.like(StringUtils.isNotEmpty(zfDoctor.getType()),ZfDoctor::getType,zfDoctor.getType());
        lqw.like(StringUtils.isNotEmpty(zfDoctor.getSymptom()),ZfDoctor::getSymptom,zfDoctor.getSymptom());
        lqw.like(StringUtils.isNotEmpty(zfDoctor.getDuration()),ZfDoctor::getDuration,zfDoctor.getDuration());
        lqw.like(StringUtils.isNotEmpty(zfDoctor.getCmedical()),ZfDoctor::getCmedical,zfDoctor.getCmedical());
        lqw.like(StringUtils.isNotEmpty(zfDoctor.getWmedical()),ZfDoctor::getWmedical,zfDoctor.getWmedical());
        lqw.like(StringUtils.isNotEmpty(zfDoctor.getEffect()),ZfDoctor::getEffect,zfDoctor.getEffect());
        lqw.like(StringUtils.isNotEmpty(zfDoctor.getSuitable()),ZfDoctor::getSuitable,zfDoctor.getSuitable());
        lqw.like(StringUtils.isNotEmpty(zfDoctor.getRemark()),ZfDoctor::getRemark,zfDoctor.getRemark());
        return lqw;
    }
}