Пример #1
0
  @Override
  public Team save(SysUser caller, TeamParam param) {
    Team itemObj = assembleTeamObject(caller, param);
    Date currTime = DateUtil.getTime();
    String teamCode = DateUtil.formatData("yyyyMMddhhmmss", currTime);
    if (StringUtil.isEmptyString(itemObj.getId())) {
      // Create
      itemObj.setDeleted(0); // 正常状态,没有删除为0
      itemObj.setCreatedBy(caller);
      itemObj.setCorporation(caller.getCorporation());
      itemObj.setDepartment(caller.getStaff().getDepartment());
      itemObj.setCreatedAt(currTime);
      itemObj.setCode(teamCode); // 用当前时间作为编号
      itemObj = teamDao.save(itemObj);

    } else {
      // Update
      itemObj = teamDao.findById(Team.class, itemObj.getId());
      itemObj.setName(param.getName());
      itemObj.setDescription(param.getDescription());
      itemObj.setCreatedBy(caller);
      itemObj.setCreatedAt(currTime);
      itemObj = teamDao.update(itemObj);
      removeMembersByTeam(itemObj.getId()); // 修改一律删除人员
    }
    // 增加负责人
    if (param.getFzIds() != null && !param.getFzIds().isEmpty()) {
      saveMembers(caller, itemObj, param.getFzIds(), 1);
    }
    // 增加成员
    if (param.getMembersIds() != null && !param.getMembersIds().isEmpty()) {
      saveMembers(caller, itemObj, param.getMembersIds(), 0);
    }
    return itemObj;
  }
Пример #2
0
 @Override
 public String deleteTeam(String id) throws Exception {
   Team team = teamDao.findById(Team.class, id);
   teamDao.delete(team);
   removeMembersByTeam(id); // 删除人员
   return team.getId();
 }
Пример #3
0
  @Override
  public PageStore<TeamListVo> teamList(SysUser caller, TeamListVo teamVo) {
    PageStore<Team> pageStore = new PageStore<Team>();

    pageStore.setResultCount(teamDao.countTeam(teamVo));
    List<Team> TeamList = teamDao.TeamList(teamVo);
    List<TeamListVo> TeamVoList = new ArrayList<TeamListVo>();
    for (Team team : TeamList) {
      TeamVoList.add(convertFromTeamToVo(team));
    }
    PageStore<TeamListVo> storeVo = new PageStore<TeamListVo>();
    storeVo.setResultCount(pageStore.getResultCount());
    storeVo.setResultList(TeamVoList);

    return storeVo;
  }
Пример #4
0
  private Team assembleTeamObject(SysUser caller, TeamParam param) {
    Team item = new Team();
    if (StringUtil.isEmptyString(param.getId())) {
      item.setId(param.getId());
      item.setCode(param.getCode()); // 用当前时间作为编号
      item.setName(param.getName());
      item.setDescription(param.getDescription());

    } else {
      // Update a existed record
      item = teamDao.findById(Team.class, param.getId());
    }

    return item;
  }
Пример #5
0
 @Override
 public TeamListVo findTeamById(String id) {
   Team team = teamDao.findById(Team.class, id);
   TeamListVo listvo = convertFromTeamToVo(team);
   return listvo;
 }
Пример #6
0
 @Override
 public Team findTeamBoById(String id) {
   return teamDao.findById(Team.class, id);
 }