Commit e1dd3cd5 by naan1993

将性别的查询做成和字典关联

parent 19b9ca4b
package com.stylefeng.guns.common.constant.factory;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.stylefeng.guns.common.constant.state.ManagerStatus;
import com.stylefeng.guns.common.constant.state.MenuStatus;
import com.stylefeng.guns.common.constant.state.Sex;
import com.stylefeng.guns.common.persistence.dao.*;
import com.stylefeng.guns.common.persistence.model.*;
import com.stylefeng.guns.core.log.LogObjectHolder;
......@@ -214,11 +214,34 @@ public class ConstantFactory implements IConstantFactory {
}
/**
* 根据字典名称和字典中的值获取对应的名称
*/
@Override
public String getDictsByName(String name, Integer val) {
Dict temp = new Dict();
temp.setName(name);
Dict dict = dictMapper.selectOne(temp);
if (dict == null) {
return null;
} else {
Wrapper<Dict> wrapper = new EntityWrapper<>();
wrapper = wrapper.eq("pid", dict.getId());
List<Dict> dicts = dictMapper.selectList(wrapper);
for (Dict item : dicts) {
if (item.getNum() != null && item.getNum().equals(val)) {
return item.getName();
}
}
return "";
}
}
/**
* 获取性别名称
*/
@Override
public String getSexName(Integer sex) {
return Sex.valueOf(sex);
return getDictsByName("性别", sex);
}
/**
......
......@@ -81,6 +81,11 @@ public interface IConstantFactory {
String getNoticeTitle(Integer dictId);
/**
* 根据字典名称和字典中的值获取对应的名称
*/
String getDictsByName(String name, Integer val);
/**
* 获取性别名称
*/
String getSexName(Integer sex);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment