Lius
2025-03-12 da82d77c6773f65aadfde810233615b602da655a
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
64
65
66
67
68
69
70
71
72
73
package org.jeecg.modules.mdc.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.modules.mdc.entity.MdcEquipmentType;
import org.jeecg.modules.mdc.mapper.MdcEquipmentTypeMapper;
import org.jeecg.modules.mdc.service.IMdcEquipmentTypeService;
import org.springframework.stereotype.Service;
 
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.List;
 
/**
 * @Description: 设备类型
 * @Author: Sake
 * @Date: 2023-03-28 15:30
 */
@Service
public class MdcEquipmentTypeServiceImpl extends ServiceImpl<MdcEquipmentTypeMapper, MdcEquipmentType> implements IMdcEquipmentTypeService {
    @Override
    public MdcEquipmentType queryById(String id) {
        return this.getById(id);
    }
 
    @Override
    public List<MdcEquipmentType> queryEquipmentType() {
        //创建查询器
        QueryWrapper<MdcEquipmentType> queryWrapper = new QueryWrapper<>();
        //只查询表内指定字段
        queryWrapper.select("id", "equipment_type_name");
        List<MdcEquipmentType> mdcEquipmentTypes = baseMapper.selectList(queryWrapper);
        return mdcEquipmentTypes;
    }
 
    @Override
    public IPage<MdcEquipmentType> queryPageList(Page page, HttpServletRequest req) {
        QueryWrapper<MdcEquipmentType> queryWrapper = new QueryWrapper();
        //检查请求体中是否存在设备类型的字段 存在则返回true
        if(req.getParameterMap().containsKey("equipmentTypeName")){
            //获取设备类型的值 不为空则添加到查询
            String equipmentTypeName = req.getParameterMap().get("equipmentTypeName")[0];
            queryWrapper.eq(StringUtils.isNotBlank(equipmentTypeName), "equipment_type_name", equipmentTypeName);
        }
        //根据设备类型排序
        queryWrapper.orderByAsc("equipment_type_name");
        return this.page(page, queryWrapper);
    }
 
    @Override
    public boolean addEquipmentType(MdcEquipmentType mdcEquipmentType) {
        return this.save(mdcEquipmentType);
    }
 
    @Override
    public boolean editEquipmentType(MdcEquipmentType mdcEquipmentType) {
        return this.updateById(mdcEquipmentType);
    }
 
    @Override
    public boolean deleteEquipmentType(String id) {
        return this.removeById(id);
    }
 
    @Override
    public boolean deleteBatchEquipmentType(String ids) {
        return this.removeByIds(Arrays.asList(ids.split(",")));
    }
 
}