<file_sep>package net.blf2.service.impl;

import net.blf2.dao.IUserDao;
import net.blf2.entity.UserInfo;
import net.blf2.service.IUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by blf2 on 17-2-4.
 */
@Service("UserService")
public class UserService implements IUserService {

    @Resource
    private IUserDao userDao;

    public IUserDao getUserDao() {
        return userDao;
    }

    public void setUserDao(IUserDao userDao) {
        this.userDao = userDao;
    }

    public UserInfo findUserInfoByUserId(String userId) {
        return userDao.queryUserInfoById(userId);
    }

    public List<UserInfo> findAllUserInfos() {
        return userDao.queryUserInfoAll();
    }

    public boolean registerUserInfo(UserInfo userInfo) {
        try {
            userDao.insertUserInfo(userInfo);
        }catch (Exception ex){
            return false;
        }
        return true;
    }

    public boolean updateUserInfo(UserInfo userInfo) {
        try {
            userDao.updateUserInfo(userInfo);
        }catch (Exception ex){
            return false;
        }
        return true;
    }
    //TODO:delete all infomation of user infomation
    public boolean deleteUserInfoByUserId(String userId) {
        return false;
    }

    public boolean checkLoginInfo(String userNum, String userPswd) {
        return false;
    }

    public boolean checkUserPhoneHasExist(String userPhone) {
        return userDao.queryUserIdByUserPhone(userPhone) != null;
    }

    public boolean checkUserNumHasExist(String userNum) {
        return userDao.queryUserIdByUserNum(userNum) != null;
    }
}
<file_sep>CREATE DATABASE collector DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

use collector;

create table UserInfo(
userId varchar(100) primary key,
userNum varchar(20) not null,
userPswd varchar(20),
userPhone varchar(20),
userGrade varchar(30) not null,
userRoleId varchar(100) not null,
userNote varchar(512)
);

create table ClassInfo(
classId varchar(100) primary key,
majorName varchar(30) not null,
classGrade varchar(10) not null,
classNum varchar(10) not null,
monitorId varchar(100) not null,
classNote varchar(512)
);

create table UserRoleInfo(
roleId varchar(100) primary key,
roleName varchar(30) not null,
roleRule varchar(512),
roleNote varchar(512)
);
<file_sep>package net.blf2.util;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Map;
import java.util.Properties;

/**
 * Created by blf2 on 17-1-8.
 */
public class Consts {
    private static Properties properties;
    static{
        properties = new Properties();
        try {
            properties.load(Consts.class.getClassLoader().getResourceAsStream("consts.properties"));
        }catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    public static int CONNECTIONS_PER_HOST = properties.getProperty("CONNECTIONS_PER_HOST") != null ? Integer.parseInt(properties.getProperty("CONNECTIONS_PER_HOST")) : 50;
    public static int THREADS_ALLOWED_TO_BLOCK_FOR_CONNECTION_MULTIPLIER = properties.getProperty("THREADS_ALLOWED_TO_BLOCK_FOR_CONNECTION_MULTIPLIER") != null ? Integer.parseInt(properties.getProperty("THREADS_ALLOWED_TO_BLOCK_FOR_CONNECTION_MULTIPLIER")) : 50;
    public static int CONNECT_TIMEOUT = properties.getProperty("CONNECT_TIMEOUT") != null ? Integer.parseInt(properties.getProperty("CONNECT_TIMEOUT")) : 60000;
    public static int MAX_WAIT_TIME = properties.getProperty("MAX_WAIT_TIME") != null ? Integer.parseInt(properties.getProperty("MAX_WAIT_TIME")) : 120000;
    public static String MONGODB_HOST = properties.getProperty("MONGODB_HOST") != null ? properties.getProperty("MONGODB_HOST") : "127.0.0.1";
    public static int SOCKET_TIME_OUT = properties.getProperty("SOCKET_TIME_OUT") != null ? Integer.parseInt(properties.getProperty("SOCKET_TIME_OUT")) : 5000;
    public static int MONGODB_PORT = properties.getProperty("MONGODB_PORT") != null ? Integer.parseInt(properties.getProperty("MONGODB_PORT")) : 27017;
    public static boolean SOCKET_KEEP_ALIVE = properties.getProperty("SOCKET_KEEP_ALIVE") != null ? Boolean.parseBoolean(properties.getProperty("SOCKET_KEEP_ALIVE")) : false;
    public static String MONGO_DATABASE_NAME = properties.getProperty("MONGO_DATABASE_NAME") != null ? properties.getProperty("MONGO_DATABASE_NAME") : "app";
    public static String MONGO_COLLECTION_FOR_CLASS = properties.getProperty("MONGO_COLLECTION_FOR_CLASS") != null ? properties.getProperty("MONGO_COLLECTION_FOR_CLASS") : "app_data";
    public static String MONGO_PRIMARY_KEY_NAME = properties.getProperty("MONGO_PRIMARY_KEY_NAME") != null ? properties.getProperty("MONGO_PRIMARY_KEY_NAME") : "objectId";
}
<file_sep>CONNECTIONS_PER_HOST=50
THREADS_ALLOWED_TO_BLOCK_FOR_CONNECTION_MULTIPLIER=50
CONNECT_TIMEOUT=60000
MAX_WAIT_TIME=120000
MONGODB_HOST=127.0.0.1
MONGODB_PORT=27017
SOCKET_TIME_OUT=5000
SOCKET_KEEP_ALIVE=false
MONGO_DATABASE_NAME=app
MONGO_COLLECTION_FOR_CLASS=app_data
MONGO_PRIMARY_KEY_NAME=objectId


