📄 puserserviceimpl.java
字号:
/*
* Created on 2007-6-26
* Last modified on 2007-6-26
* Powered by GamVan.com
*/
package com.yeqiangwei.club.passport.service;
import org.apache.log4j.Logger;
import com.yeqiangwei.club.exception.ClubException;
import com.yeqiangwei.club.passport.dao.PUserDAO;
import com.yeqiangwei.club.passport.dao.PUserImpl;
import com.yeqiangwei.club.passport.model.PUserModel;
import com.yeqiangwei.club.service.model.UserModel;
import com.yeqiangwei.club.service.user.UserServiceImpl;
import com.yeqiangwei.util.BeanUtils;
import com.yeqiangwei.util.FormatDateTime;
import com.yeqiangwei.util.Validator;
/**
* @author gamvan
*/
public class PUserServiceImpl implements PUserService{
private static final Logger logger = Logger.getLogger(PUserServiceImpl.class);
private static PUserDAO PUSER_DAO ;
private static UserServiceImpl USER_SERVICE_IMPL;
static {
PUSER_DAO = new PUserImpl();
USER_SERVICE_IMPL = new UserServiceImpl();
}
public UserModel create(UserModel model) {
if(Validator.isEmpty(model)
|| Validator.isEmpty(model.getUserName())
|| Validator.isEmpty(model.getPassword())
|| Validator.isEmpty(model.getEmailAddress())
){
return null;
}
else{
PUserModel pmodel = new PUserModel();
BeanUtils.copyProperties(pmodel,model);
pmodel = PUSER_DAO.create(pmodel);
}
return model;
}
public UserModel update(UserModel model) {
if(Validator.isEmpty(model)
|| Validator.isEmpty(model.getUserName())
|| Validator.isEmpty(model.getPassword())
|| Validator.isEmpty(model.getEmailAddress())
){
return null;
}else{
PUserModel pmodel = new PUserModel();
BeanUtils.copyProperties(pmodel,model);
pmodel = PUSER_DAO.updateByUserName(pmodel);
}
return model;
}
public UserModel login(String userName, String password) throws ClubException {
PUserModel pmodel = null;
UserModel model = null;
if(Validator.isEmpty(userName)||Validator.isEmpty(password)){
return null;
}else{
pmodel = PUSER_DAO.login(userName,password);
logger.debug("UserName: "+userName);
logger.debug("password: "+password);
if(!Validator.isEmpty(pmodel)){
model = USER_SERVICE_IMPL.findByUserName(userName);
if(!Validator.isEmpty(model)){
model.setPassword(password);
USER_SERVICE_IMPL.update(model);
}else{
model = new UserModel();
BeanUtils.copyProperties(model,pmodel);
model.setRegDateTime(FormatDateTime.now());
model.setLastLoginDateTime(FormatDateTime.now());
model.setRegIp("127.0.0.1");
model = USER_SERVICE_IMPL.create(model);
}
}
}
return model;
}
public UserModel findByUserName(String userName) throws ClubException {
PUserModel pmodel = null;
UserModel model = null;
if(Validator.isEmpty(userName)){
return null;
}else{
pmodel = PUSER_DAO.findByUserName(userName);
if(!Validator.isEmpty(pmodel)){
model = USER_SERVICE_IMPL.findByUserName(userName);
if(Validator.isEmpty(model)){
model = new UserModel();
BeanUtils.copyProperties(model,pmodel);
model.setRegDateTime(FormatDateTime.now());
model.setLastLoginDateTime(FormatDateTime.now());
model = USER_SERVICE_IMPL.create(model);
}
}
}
return model;
}
public UserModel findByEmail(String email) {
return null;
}
public UserModel findByUserId(int userId) {
PUserModel pmodel = null;
UserModel model = null;
if(userId<1){
return null;
}else{
pmodel = PUSER_DAO.findByUserId(userId);
if(!Validator.isEmpty(pmodel)){
}
}
return model;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -