123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- package com.yihu.hos.system.dao;
- import com.yihu.hos.core.datatype.StringUtil;
- import com.yihu.hos.system.model.SystemDict;
- import com.yihu.hos.system.model.SystemDictList;
- import com.yihu.hos.web.framework.dao.SQLGeneralDAO;
- import com.yihu.hos.web.framework.model.DataGridResult;
- import com.yihu.hos.web.framework.model.DictItem;
- import com.yihu.hos.web.framework.model.DictionaryResult;
- import org.springframework.stereotype.Repository;
- import java.util.ArrayList;
- import java.util.List;
- /**
- * Created by hzp on 2016/1/11.
- */
- @Repository("BaseDictDao")
- public class BaseDictDao extends SQLGeneralDAO {
- public static final String BEAN_ID = "BaseDictDao";
- /**
- * 获取系统字典列表
- * @return
- */
-
- public DataGridResult getSystemDictList(String condition,Integer page, Integer pageSize) throws Exception {
- return null;
- }
- /**
- * 通过ID获取系统字典信息
- * @return
- */
-
- public SystemDictList getSystemDictInfoById(String id) throws Exception {
- String sql = "select * from system_dict_list where id = '"+id+"'";
- return super.queryObjBySql(sql,SystemDictList.class);
- }
- /**
- * 通过dictName获取字典信息
- * @return
- */
-
- public SystemDictList getSystemDictInfoByName(String dictName) throws Exception {
- String sql = "select * from system_dict_list where dict_name = '"+dictName+"'";
- return super.queryObjBySql(sql,SystemDictList.class);
- }
- /**
- * 获取某字典数据
- * @return
- */
-
- public DictionaryResult getSystemDict(String dictName) throws Exception
- {
- String sql = "select * from system_dict where dict_name = '"+dictName+"' order by sort";
- List<SystemDict> list = super.queryListBySql(sql,SystemDict.class);
- DictionaryResult re = new DictionaryResult(dictName);
- if(list!=null&&list.size()>0)
- {
- List<DictItem> dictList = new ArrayList<>();
- for(SystemDict item:list){
- DictItem dict = new DictItem();
- dict.setCode(item.getCode());
- dict.setValue(item.getValue());
- dict.setExtend(item.getPyCode());
- dictList.add(dict);
- }
- re.setDetailModelList(dictList);
- }
- return re;
- }
- /**
- * 获取某字典数据
- * @return
- */
-
- public DictionaryResult getRelationDict(String tableName,String codeCol,String valueCole,String extendCol,String Where) throws Exception
- {
- String sql = "select "+ codeCol+" as code,"+valueCole +" as value";
- if(!StringUtil.isEmpty(extendCol))
- {
- sql +=","+extendCol +" as extend";
- }
- else{
- sql+=",'' as extend";
- }
- sql += " from "+tableName;
- if(!StringUtil.isEmpty(Where))
- {
- sql +=" where " + Where;
- }
- sql += " order by " + valueCole;
- List<DictItem> list = super.queryListBySql(sql,DictItem.class);
- DictionaryResult re = new DictionaryResult(tableName);
- re.setDetailModelList(list);
- return re;
- }
- /**
- * 获取标准字典数据
- * @return
- */
- public DictionaryResult getStdDict(String code) throws Exception
- {
- return null;
- }
- }
|