/** * 保存 * * @param bean SysFunction * @return boolean */ public boolean create(SysFunction bean) { boolean ret = false; if (abstractDao.create(bean)) { // 插入记录成功 bean.setSort((int) bean.getId()); // 设置排序号为刚插入的id值 abstractDao.update(bean); ret = true; } return ret; }
/** * 向后移动排序 * * @param bean */ private void sortByForward(SysFunction bean) { Object[] values = new Object[] {bean.getApp(), new Integer(bean.getSort())}; // 查找后一个对象 String query = "from SysFunction a where a.app=? and a.sort<? order by a.sort desc"; List list = abstractDao.getList(query, values, null); if (list != null && list.size() > 0) { // 有记录 SysFunction temp = (SysFunction) list.get(0); int i = bean.getSort(); bean.setSort(temp.getSort()); abstractDao.update(bean); // 更新bean temp.setSort(i); abstractDao.update(temp); // 更新temp } }
public static ObjectNode toObjectNode(SysUser user) { ObjectNode jsonObject = new ObjectMapper().createObjectNode(); jsonObject.put("actorId", user.getAccount()); jsonObject.put("actorId_enc", RequestUtils.encodeString(user.getAccount())); jsonObject.put("userId", user.getAccount()); jsonObject.put("userId_enc", RequestUtils.encodeString(user.getAccount())); jsonObject.put("name", user.getName()); jsonObject.put("locked", user.getStatus()); jsonObject.put("status", user.getStatus()); if (user.getDepartment() != null) { jsonObject.put("deptId", user.getDepartment().getId()); jsonObject.put("deptName", user.getDepartment().getName()); } else { jsonObject.put("deptId", user.getDeptId()); } jsonObject.put("accountType", user.getAccountType()); jsonObject.put("userType", user.getUserType()); jsonObject.put("dumpFlag", user.getDumpFlag()); jsonObject.put("gender", user.getGender()); jsonObject.put("evection", user.getEvection()); jsonObject.put("superiorIds", user.getSuperiorIds()); jsonObject.put("fax", user.getFax()); jsonObject.put("telephone", user.getTelephone()); jsonObject.put("headship", user.getHeadship()); jsonObject.put("adminFlag", user.getAdminFlag()); if (user.getEmail() != null) { jsonObject.put("mail", user.getEmail()); jsonObject.put("email", user.getEmail()); } if (user.getMobile() != null) { jsonObject.put("mobile", user.getMobile()); } if (user.getLastLoginTime() != null) { jsonObject.put("lastLoginDate", DateUtils.getDateTime(user.getLastLoginDate())); jsonObject.put("lastLoginTime", DateUtils.getDateTime(user.getLastLoginDate())); } if (user.getLastLoginIP() != null) { jsonObject.put("loginIP", user.getLastLoginIP()); } if (user.getCreateBy() != null) { jsonObject.put("createBy", user.getCreateBy()); } if (user.getUpdateBy() != null) { jsonObject.put("updateBy", user.getUpdateBy()); } if (user.getUpdateDate() != null) { jsonObject.put("updateDate", DateUtils.getDate(user.getUpdateDate())); jsonObject.put("updateDate_date", DateUtils.getDate(user.getUpdateDate())); jsonObject.put("updateDate_datetime", DateUtils.getDateTime(user.getUpdateDate())); } if (user.getUserRoles() != null && !user.getUserRoles().isEmpty()) { ArrayNode array = new ObjectMapper().createArrayNode(); for (SysUserRole sysUserRole : user.getUserRoles()) { array.add(sysUserRole.toObjectNode()); } jsonObject.set("userRoles", array); } if (user.getRoles() != null && !user.getRoles().isEmpty()) { ArrayNode array = new ObjectMapper().createArrayNode(); for (SysRole sysRole : user.getRoles()) { array.add(sysRole.toObjectNode()); } jsonObject.set("roles", array); } if (user.getFunctions() != null && !user.getFunctions().isEmpty()) { ArrayNode array = new ObjectMapper().createArrayNode(); for (SysFunction sysFunction : user.getFunctions()) { array.add(sysFunction.toObjectNode()); } // jsonObject.set("functions", array); } if (user.getApps() != null && !user.getApps().isEmpty()) { ArrayNode array = new ObjectMapper().createArrayNode(); for (SysApplication app : user.getApps()) { array.add(app.toObjectNode()); } // jsonObject.set("apps", array); } return jsonObject; }