コード例 #1
0
ファイル: AdminDaoImpl.java プロジェクト: fuhongliang/manage
 private Admin getAdminFromResultSet(DBObject object) {
   Admin admin = null;
   try {
     Long id = Long.parseLong(object.get("id").toString());
     Long createId = Long.parseLong(object.get("create_id").toString());
     String username = object.get("username").toString();
     String password = object.get("password").toString();
     int grade = Integer.parseInt(object.get("grade").toString().trim());
     int status = Integer.parseInt(object.get("status").toString().trim());
     String createTime = object.get("create_time").toString();
     int group = Integer.parseInt(object.get("group").toString().trim());
     String position = object.get("position").toString().trim();
     String phone = object.get("phone").toString().trim();
     String email = object.get("email").toString().trim();
     String nickName = object.get("nick_name").toString();
     String grades = object.get("grades").toString();
     String loginTime = object.get("login_time").toString();
     String name = object.get("name").toString();
     Long xiaoshouyiId = null;
     try {
       xiaoshouyiId = Long.parseLong(object.get("xiaoshouyi_id").toString());
     } catch (Exception e) {
     }
     admin =
         new Admin(
             group,
             id,
             username,
             password,
             grade,
             status,
             createTime,
             createId,
             position,
             phone,
             email,
             nickName,
             grades);
     admin.setName(name);
     admin.setLoginTime(loginTime);
     admin.setXiaoshouyiId(xiaoshouyiId);
   } catch (Exception e) {
   }
   return admin;
 }
コード例 #2
0
ファイル: AdminDaoImpl.java プロジェクト: fuhongliang/manage
 public boolean update(Admin admin) {
   try {
     DBObject object = new BasicDBObject();
     object.put("id", admin.getId());
     DBObject value = new BasicDBObject();
     value.put("username", admin.getUsername());
     value.put("password", admin.getPassword());
     value.put("grade", new Integer(admin.getGrade()));
     value.put("status", new Integer(admin.getStatus()));
     value.put("create_id", admin.getCreateId());
     value.put("create_time", admin.getCreateTime());
     value.put("name", admin.getName());
     value.put("login_time", admin.getLoginTime());
     value.put("group", admin.getGroup());
     value.put("grades", admin.getGrades());
     return getDBCollection(TABLE_NAME).update(object, new BasicDBObject("$set", value)).getN()
         > -1;
   } catch (Exception e) {
     LOG.error(e.getMessage(), e);
   }
   return false;
 }