package com.chenyang.nse.bussiness.dao.table.core.dataproject;

import com.chenyang.nse.bussiness.dao.BaseDao;
import com.chenyang.nse.bussiness.entity.orm.table.core.dataproject.TCoreFileSysGroup;
import com.chenyang.nse.bussiness.entity.vo.ComboboxVO;
import java.util.List;
import org.hibernate.transform.Transformers;
import org.springframework.stereotype.Repository;

@Repository
public class TCoreFileSysGroupDao extends BaseDao<TCoreFileSysGroup, String> {
   public List<ComboboxVO> getFileSysGroup(String id) {
      String sql = "";
      if (null != id && !"".equals(id)) {
         sql = "select  s.id value, s.filestructuregroup text,ifnull(g.filegroupid,'0') flag from t_core_file_structure s  left join  (select * from t_core_filesys_group where systemid ='" + id + "') g on s.filestructuregroup=g.filegroupid group by s.filestructuregroup order by s.filestructuregroup";
      } else {
         sql = "select  s.id value, s.filestructuregroup text,'0' flag from t_core_file_structure s  group by s.filestructuregroup order by s.filestructuregroup";
      }

      List<ComboboxVO> list = this.getSession().createNativeQuery(sql).setResultTransformer(Transformers.aliasToBean(ComboboxVO.class)).getResultList();
      return list;
   }
}
