刘光辉
6 小时以前 06f314545ac3514d7ce28939920866ae8188d31c
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
package jnpf.tmsService.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import jnpf.tmsEntity.TmsTrainerEntity;
import jnpf.tmsEntity.trainer.TmsTrainerOption;
import jnpf.tmsEntity.enums.TmsValidRevoked;
import jnpf.tmsMapper.TmsTrainerMapper;
import jnpf.tmsService.TmsTrainerService;
import jnpf.util.StringUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.List;
 
@Service
@RequiredArgsConstructor
public class TmsTrainerServiceImpl implements TmsTrainerService {
 
    private final TmsTrainerMapper trainerMapper;
    /**
     * 培训师:查询下拉选项
     */
    @Override
    public List<TmsTrainerOption> listOptions() {
        LambdaQueryWrapper<TmsTrainerEntity> qw = new LambdaQueryWrapper<>();
        qw.eq(TmsTrainerEntity::getBizStatus, TmsValidRevoked.VALID.getCode());
        qw.isNotNull(TmsTrainerEntity::getUserId);
        qw.ne(TmsTrainerEntity::getUserId, "");
        qw.orderByAsc(TmsTrainerEntity::getArchiveNo);
        List<TmsTrainerEntity> rows = trainerMapper.selectList(qw);
        List<TmsTrainerOption> list = new ArrayList<>(rows.size());
        for (TmsTrainerEntity row : rows) {
            if (StringUtil.isEmpty(row.getUserId())) {
                continue;
            }
            TmsTrainerOption opt = new TmsTrainerOption();
            // 任务 teacher_id 约定存系统用户,与详情回显、排期冲突校验一致
            opt.setId(row.getUserId());
            opt.setArchiveId(row.getId());
            opt.setArchiveNo(row.getArchiveNo());
            String name = StringUtil.isNotEmpty(row.getTrainerName()) ? row.getTrainerName() : row.getUserId();
            if (StringUtil.isNotEmpty(row.getArchiveNo())) {
                opt.setFullName(name + "(" + row.getArchiveNo() + ")");
            } else {
                opt.setFullName(name);
            }
            list.add(opt);
        }
        return list;
    }
}