View Javadoc
1   /**
2    * Copyright By Grandsoft Company Limited.  
3    * 2013-7-15 下午10:56:59
4    */
5   package gboat2.web.service.impl;
6   
7   import gboat2.base.core.dao.Page;
8   import gboat2.base.core.dao.PageBean;
9   import gboat2.web.business.ISystemConfigBusiness;
10  import gboat2.web.model.Organ;
11  import gboat2.web.model.SystemConfig;
12  import gboat2.web.service.IOrganizationService;
13  
14  import java.util.LinkedList;
15  import java.util.List;
16  
17  import org.springframework.beans.factory.annotation.Autowired;
18  import org.springframework.stereotype.Service;
19  
20  
21  /**
22   * 
23   * 系统配置的组织机构实现
24   * @author lysming
25   * @since jdk1.6
26   * @date 2013-7-15
27   *  
28   */
29  @Service
30  public class SystemOrganServiceImpl implements IOrganizationService {
31  	@Autowired
32  	ISystemConfigBusiness systemService;
33  	/** 
34  	  * {@inheritDoc}   
35  	  * @see gboat2.web.service.IOrganizationService#deleteUserByLoginId(java.lang.String) 
36  	  */
37  	@Override
38  	public boolean deleteUserByLoginId(String loginId) {
39  		// TODO Auto-generated method stub
40  		return false;
41  	}
42  
43  	/** 
44  	  * {@inheritDoc}   
45  	  * @see gboat2.web.service.IOrganizationService#getOrgan(java.lang.String) 
46  	  */
47  	@Override
48  	public Organ getOrgan(String organId) {
49  		Organ organ = new Organ();
50  		SystemConfig system = systemService.getSystemConfig(organId);
51  		organ.setOrganId(system.getSystemId());
52  		organ.setOrganName(system.getSystemName());
53  		organ.setOrganType(SystemConfig.class.getName());
54  		
55  		return organ;
56  	}
57  
58  	/** 
59  	  * {@inheritDoc}   
60  	  * @see gboat2.web.service.IOrganizationService#getOrgans(int, int) 
61  	  */
62  	@Override
63  	public Page<Organ> getOrgans(int pageIndex, int pageSize) {
64  		List<SystemConfig> systems = systemService.getAllSysCfg();
65  		Organ organ;
66  		List<Organ> organs = new LinkedList<Organ>();
67  		for(SystemConfig sys : systems){
68  			organ = new Organ();
69  			organ.setOrganId(sys.getSystemId());
70  			organ.setOrganName(sys.getSystemName());
71  			organ.setOrganType(SystemConfig.class.getName());
72  			organs.add(organ);
73  		}
74  		PageBean bean = new PageBean();
75  		bean.setPage(pageIndex);
76  		bean.setCount(organs.size());
77  		return new Page(organs.subList((bean.getStartNo()-1), bean.getEndNo()),bean);
78  	}
79  
80  	/** 
81  	  * {@inheritDoc}   
82  	  * @see gboat2.web.service.IOrganizationService#searchOrgans(int, int, java.lang.String) 
83  	  */
84  	@Override
85  	public Page<Organ> searchOrgans(int pageIndex, int pageSize, String organName) {
86  		String[][] params = {
87  				{SystemConfig.class.getName()},
88  				{"_systemName_like",organName}
89  		};
90  		List<SystemConfig> systems = (List<SystemConfig>)systemService.query(params);
91  		Organ organ;
92  		List<Organ> organs = new LinkedList<Organ>();
93  		for(SystemConfig sys : systems){
94  			organ = new Organ();
95  			organ.setOrganId(sys.getSystemId());
96  			organ.setOrganName(sys.getSystemName());
97  			organ.setOrganType(SystemConfig.class.getName());
98  			organs.add(organ);
99  		}
100 		PageBean bean = new PageBean();
101 		bean.setPage(pageIndex);
102 		bean.setCount(organs.size());
103 		return new Page(organs.subList(bean.getStartNo()-1, bean.getEndNo()),bean);
104 	}
105 
106 }