@Transactional(value = "rest_tm") public void add(String clientId, EmlGroupVo groupVo) { groupVo.setClientId(clientId); // 그룹 설정 초기화 groupVo.setServerConfig(new EmlGroupConfigVo()); // 엔티티 생성 EmlGroup group = new EmlGroup(groupVo); // 아이디 생성 group.setId(idProvider.next()); StringWriter writer = new StringWriter(); try { objectMapper.writeValue(writer, groupVo.getServerConfig()); } catch (IOException e) { e.printStackTrace(); } group.setServerConfig(writer.toString()); // 그룹 엔티티 추가 logger.debug("그룹을 추가합니다.: " + group); groupDao.insert(group); groupVo.setId(group.getId()); }
@Transactional(value = "rest_tm") public EmlGroupVo getQuotaUsage(String clientId, String groupId) { long usage = 0; List<EmlUser> userList = userDao.list(groupId); for (EmlUser userVo : userList) { usage += userVo.getQuota(); } EmlGroupVo groupVo = new EmlGroupVo(); groupVo.setQuota(usage); return groupVo; }
public EmlGroupVo get(String clientId, String groupId) { EmlGroup emlGroup = groupDao.selectGroup(groupId); EmlGroupVo emlGroupVo = new EmlGroupVo(emlGroup); try { EmlGroupConfigVo emlGroupConfigVo = objectMapper.readValue(emlGroup.getServerConfig(), EmlGroupConfigVo.class); emlGroupVo.setServerConfig(emlGroupConfigVo); } catch (IOException e) { e.printStackTrace(); } return emlGroupVo; }
public List<EmlGroupVo> list(String clientId) { List<EmlGroup> emlGroupList = groupDao.list(clientId); List<EmlGroupVo> emlGroupVoList = new ArrayList<EmlGroupVo>(); for (EmlGroup emlGroup : emlGroupList) { EmlGroupVo emlGroupVo = new EmlGroupVo(emlGroup); try { EmlGroupConfigVo emlGroupConfigVo = objectMapper.readValue(emlGroup.getServerConfig(), EmlGroupConfigVo.class); emlGroupVo.setServerConfig(emlGroupConfigVo); } catch (IOException e) { e.printStackTrace(); } emlGroupVoList.add(emlGroupVo); } return emlGroupVoList; }