BaseDictDao.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. package com.yihu.hos.system.dao;
  2. import com.yihu.hos.core.datatype.StringUtil;
  3. import com.yihu.hos.system.model.SystemDict;
  4. import com.yihu.hos.system.model.SystemDictList;
  5. import com.yihu.hos.web.framework.dao.SQLGeneralDAO;
  6. import com.yihu.hos.web.framework.model.DataGridResult;
  7. import com.yihu.hos.web.framework.model.DictItem;
  8. import com.yihu.hos.web.framework.model.DictionaryResult;
  9. import org.springframework.stereotype.Repository;
  10. import java.util.ArrayList;
  11. import java.util.List;
  12. /**
  13. * Created by hzp on 2016/1/11.
  14. */
  15. @Repository("BaseDictDao")
  16. public class BaseDictDao extends SQLGeneralDAO {
  17. public static final String BEAN_ID = "BaseDictDao";
  18. /**
  19. * 获取系统字典列表
  20. * @return
  21. */
  22. public DataGridResult getSystemDictList(String condition,Integer page, Integer pageSize) throws Exception {
  23. return null;
  24. }
  25. /**
  26. * 通过ID获取系统字典信息
  27. * @return
  28. */
  29. public SystemDictList getSystemDictInfoById(String id) throws Exception {
  30. String sql = "select * from system_dict_list where id = '"+id+"'";
  31. return super.queryObjBySql(sql,SystemDictList.class);
  32. }
  33. /**
  34. * 通过dictName获取字典信息
  35. * @return
  36. */
  37. public SystemDictList getSystemDictInfoByName(String dictName) throws Exception {
  38. String sql = "select * from system_dict_list where dict_name = '"+dictName+"'";
  39. return super.queryObjBySql(sql,SystemDictList.class);
  40. }
  41. /**
  42. * 获取某字典数据
  43. * @return
  44. */
  45. public DictionaryResult getSystemDict(String dictName) throws Exception
  46. {
  47. String sql = "select * from system_dict where dict_name = '"+dictName+"' order by sort";
  48. List<SystemDict> list = super.queryListBySql(sql,SystemDict.class);
  49. DictionaryResult re = new DictionaryResult(dictName);
  50. if(list!=null&&list.size()>0)
  51. {
  52. List<DictItem> dictList = new ArrayList<>();
  53. for(SystemDict item:list){
  54. DictItem dict = new DictItem();
  55. dict.setCode(item.getCode());
  56. dict.setValue(item.getValue());
  57. dict.setExtend(item.getPyCode());
  58. dictList.add(dict);
  59. }
  60. re.setDetailModelList(dictList);
  61. }
  62. return re;
  63. }
  64. /**
  65. * 获取某字典数据
  66. * @return
  67. */
  68. public DictionaryResult getRelationDict(String tableName,String codeCol,String valueCole,String extendCol,String Where) throws Exception
  69. {
  70. String sql = "select "+ codeCol+" as code,"+valueCole +" as value";
  71. if(!StringUtil.isEmpty(extendCol))
  72. {
  73. sql +=","+extendCol +" as extend";
  74. }
  75. else{
  76. sql+=",'' as extend";
  77. }
  78. sql += " from "+tableName;
  79. if(!StringUtil.isEmpty(Where))
  80. {
  81. sql +=" where " + Where;
  82. }
  83. sql += " order by " + valueCole;
  84. List<DictItem> list = super.queryListBySql(sql,DictItem.class);
  85. DictionaryResult re = new DictionaryResult(tableName);
  86. re.setDetailModelList(list);
  87. return re;
  88. }
  89. /**
  90. * 获取标准字典数据
  91. * @return
  92. */
  93. public DictionaryResult getStdDict(String code) throws Exception
  94. {
  95. return null;
  96. }
  97. }