public static void companyRegister(Company company,String password){
String msg = "";
if(company != null ){
CompanyModel model = new CompanyModel();
model.setUsername(company.username);
model.setPassword(company.password);
model.setDpassword(password);
model.setEmail(company.email);
model.setContactname(company.contactname);
model.setContactmobile(company.contactmobile);
if(model.getUsername() == null || model.getUsername().equals("")){
msg = "用户名不能为空";
render("Application/register.html",msg,model);
}
if(model.getPassword() == null || model.getPassword().equals("")){
msg = "密码不能为空";
render("Application/register.html",msg,model);
}
if(password == null ||password.equals("")){
msg = "确认密码不能为空";
render("Application/register.html",msg,model);
}
if(!model.getPassword().equals(password)){
msg = "密码和确认密码不一致请重新输入";
render("Application/register.html",msg,model);
}
if(model.getEmail() == null || model.getEmail().equals("")){
msg = "邮箱不能为空";
render("Application/register.html",msg,model);
}
if(!CommonUtils.checkEmail(model.getEmail())){
msg = "邮箱不合法请重新输入";
render("Application/register.html",msg,model);
}
if(model.getContactname() == null || model.getContactname().equals("")){
msg = "联系人不能为空";
render("Application/register.html",msg,model);
}
if(model.getContactmobile() == null || model.getContactmobile().equals("")){
msg = "手机号码不能为空";
render("Application/register.html",msg,model);
}
if(!CommonUtils.isMobileNO(model.getContactmobile())){
msg = "手机号码不合法请重新输入";
render("Application/register.html",msg,model);
}
List<Company> listname = Company.q().filter("username",company.username.trim()).asList();
if(listname.size() > 0){
msg = "用户名已存在,请重新输入";
render("Application/register.html",msg,model);
}
List<Company> listeamil = Company.q().filter("email",company.email.trim()).asList();
if(listeamil.size() > 0){
msg = "此邮箱已经注册,请重新输入";
render("Application/register.html",msg,model);
}
List<Company> listmobile = Company.q().filter("contactmobile",company.contactmobile.trim()).asList();
if(listmobile.size() > 0){
msg = "此手机已注册,请重新输入";
render("Application/register.html",msg,model);
}
company.created = new Date();
company.level = 1;
company.save();
//
session.put("companyid", company.getId().toString());
// session.put("groupid", company.groupid);
session.put("username", company.username);
// showMemberList(company.groupid, null);
grouplist(null);
}else {
msg = "请填写注册信息!";
render("Application/register.html",msg);
}
}