@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; }
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; }