xufenglei
2019-02-13 1bd6a5e7678477f5b1fab449c6d618aae9041611
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 com.moral.service.impl;
 
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
 
import com.moral.common.util.StringUtils;
import com.moral.entity.Profession;
import com.moral.mapper.ProfessionMapper;
import com.moral.service.ProfessionService;
 
import tk.mybatis.mapper.entity.Example;
 
@Service
public class ProfessionServiceImpl implements ProfessionService {
 
    @Resource
    private ProfessionMapper professionMapper;
    @Override
    public List<Profession> queryByName(String nameLike){
        Example example = new Example(Profession.class);
        if(!StringUtils.isNullOrEmpty(nameLike)){
            example.or().andLike("name",nameLike);
        }
        return professionMapper.selectByExample(example);
    }
    @Override
    public List<Profession> getProfessiontList() {
 
        return professionMapper.selectAll();
    }
 
    @Override
    public List<Profession> getProfessiontList(Map<String, Object> parameters) {
        List<Profession> professions = null;
        if (parameters.containsKey("provinceCode")) {
            Profession profession = new Profession();
            profession.setProvinceCode(parameters.get("provinceCode").toString());
            professions = professionMapper.select(profession);
        }
        if (ObjectUtils.isEmpty(professions)) {
            Example example = new Example(Profession.class);
            example.and().andIsNull("provinceCode");
            professions = professionMapper.selectByExample(example);
        }
        return professions;
    }
}