View Javadoc
1   /**
2    * Copyright By Grandsoft Company Limited.  
3    * 2012-3-6 下午03:18:21
4    */
5   package gboat2.web.business.impl;
6   
7   import gboat2.base.core.dao.QuerySupport;
8   import gboat2.base.core.service.BaseService;
9   import gboat2.web.business.IGroupOrganBusiness;
10  import gboat2.web.model.GroupOrganMapper;
11  
12  import java.util.HashMap;
13  import java.util.Iterator;
14  import java.util.List;
15  import java.util.Map;
16  
17  import org.springframework.stereotype.Service;
18  import org.springframework.transaction.annotation.Transactional;
19  
20  /**
21   * 
22   * @author wangsr
23   * @since jdk1.6
24   * @date 2012-3-6
25   *
26   */
27  @Transactional
28  @Service
29  public class GroupOrganBusinessImpl extends BaseService implements IGroupOrganBusiness {
30  	
31  	@Override
32  	public boolean deleteAllByGroupId(String groupId) {
33  		String hql = "delete from GroupOrganMapper as g where g.groupId = :groupId";
34  		Map<String, Object> parameters = new HashMap<String, Object>();
35  		parameters.put("groupId", groupId);
36  		super.baseDAO.deleteByQuery(hql, parameters);
37  		return true;
38  	}
39  	
40  	@Override
41  	public boolean saveGroupOrgan(String groupId, String organId) {
42  		GroupOrganMapper groupOrgan = new GroupOrganMapper();
43  		groupOrgan.setGroupId(groupId);
44  		groupOrgan.setOrganId(organId);
45  		super.save(groupOrgan);
46  		return true;
47  	}
48  
49  	@Override
50      public List<GroupOrganMapper> findAllByGroupId(String groupId) {
51  		List<GroupOrganMapper> result = null;
52  		Map<String, Object> params = new HashMap<String, Object>();
53  		params.put(QuerySupport.PARAM_TABLENAME, GroupOrganMapper.class);
54  		params.put("_groupId", groupId);
55  		result = (List<GroupOrganMapper>) super.query(params);
56  	    return result;
57      }
58  
59  	@Override
60      public Map<String, GroupOrganMapper> findAllByGroupIdToMap(String groupId) {
61  		Map<String, GroupOrganMapper> result = new HashMap<String, GroupOrganMapper>();
62  		List<GroupOrganMapper> list = this.findAllByGroupId(groupId);
63  		if (list != null && list.size() > 0){
64  			Iterator<GroupOrganMapper> iter = list.iterator();
65  			while (iter.hasNext()){
66  				GroupOrganMapper g = iter.next();
67  				result.put(g.getOrganId(), g);
68  			}
69  		}
70  	    return result;
71      }
72  }