package com.esoft.blog.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.esoft.blog.dao.AdminImagsDAO;
import com.esoft.blog.dao.AdminTypesDAO;
import com.esoft.blog.dao.CircleDAO;
import com.esoft.blog.dao.CircleMemberDAO;
import com.esoft.blog.dao.FriendLinkDAO;
import com.esoft.blog.dao.InfoDAO;
import com.esoft.blog.dao.MessageDAO;
import com.esoft.blog.dao.NewsDirDAO;
import com.esoft.blog.dao.NewsDocDAO;
import com.esoft.blog.dao.PhotoDirDAO;
import com.esoft.blog.dao.ReviewDAO;
import com.esoft.blog.dao.UserLogDAO;
import com.esoft.blog.dao.UserinfoDAO;
import com.esoft.blog.dao.hibernate.NewsDocDAOImpl;
import com.esoft.blog.model.BAdminImags;
import com.esoft.blog.model.BAdminTypes;
import com.esoft.blog.model.BCircle;
import com.esoft.blog.model.BCircleMember;
import com.esoft.blog.model.BFriendlink;
import com.esoft.blog.model.BInfo;
import com.esoft.blog.model.BMessage;
import com.esoft.blog.model.BNewsDir;
import com.esoft.blog.model.BNewsDoc;
import com.esoft.blog.model.BPhotoDir;
import com.esoft.blog.model.BReview;
import com.esoft.blog.model.BUserLog;
import com.esoft.blog.model.BUserinfo;
import com.esoft.blog.service.UserManager;
public class UserManagerImpl implements UserManager {
private UserinfoDAO userinfoDAO;
private UserLogDAO userLogDAO;
private InfoDAO infoDAO;
private NewsDirDAO newsDirDAO;
private NewsDocDAO newsDocDAO;
private ReviewDAO reviewDAO;
private PhotoDirDAO photoDirDAO;
private CircleDAO circleDAO;
private CircleMemberDAO circleMemberDAO;
private AdminTypesDAO adminTypesDAO;
private AdminImagsDAO adminImagsDAO;
private FriendLinkDAO friendLinkDAO;
private MessageDAO messageDAO;
public void setAdminImagsDAO(AdminImagsDAO adminImagsDAO) {
this.adminImagsDAO = adminImagsDAO;
}
//messageDAO
public void setMessageDAO(MessageDAO messageDAO) {
this.messageDAO = messageDAO;
}
//friendLinkDAO的注入
public void setFriendLinkDAO(FriendLinkDAO friendLinkDAO) {
this.friendLinkDAO = friendLinkDAO;
}
//ReviewDAO的注入
public void setReviewDAO(ReviewDAO reviewDAO) {
this.reviewDAO = reviewDAO;
}
// CircleMemberDAO的注入
public void setCircleMemberDAO(CircleMemberDAO circleMemberDAO) {
this.circleMemberDAO = circleMemberDAO;
}
// AdminTypesDAO的注入
public void setAdminTypesDAO(AdminTypesDAO adminTypesDAO) {
this.adminTypesDAO = adminTypesDAO;
}
// CircleDAO的注入
public void setCircleDAO(CircleDAO circleDAO) {
this.circleDAO = circleDAO;
}
// photoDirDAO的注入
public void setPhotoDirDAO(PhotoDirDAO photoDirDAO) {
this.photoDirDAO = photoDirDAO;
}
// 对newsDocDAO的注入
public void setNewsDocDAO(NewsDocDAOImpl newsDocDAO) {
this.newsDocDAO = newsDocDAO;
}
// 对newsDirDAO的注入
public void setNewsDirDAO(NewsDirDAO newsDirDAO) {
this.newsDirDAO = newsDirDAO;
}
// //对infoDAO的注入
public void setInfoDAO(InfoDAO infoDAO) {
this.infoDAO = infoDAO;
}
// 对UserinfoDAO的注入
public void setUserinfoDAO(UserinfoDAO userinfoDAO) {
this.userinfoDAO = userinfoDAO;
}
// 对的注入UserLogDAO
public void setUserLogDAO(UserLogDAO userLogDAO) {
this.userLogDAO = userLogDAO;
}
public BUserLog getUserLog(int id) {
return userLogDAO.getUserLog(id);
}
public BUserinfo getUserLogin(String userName, String password) {
return userinfoDAO.loginUserinfo(userName, password);
}
public BUserinfo getUserinfo(int id) {
return userinfoDAO.getUserinfo(id);
}
public void saveUserLog(BUserLog userLog) {
userLogDAO.saveUserLog(userLog);
}
public void saveUserReg(BUserinfo userinfo) {
userinfoDAO.saveUserinfo(userinfo);
}
public void activeInfo(BInfo info) {
infoDAO.saveInfo(info);
}
public boolean isActive(int id) {
return infoDAO.isActive(id);
}
public BInfo getInfo(int id) {
return infoDAO.getInfo(id);
}
public BNewsDir getNewsDir(int id) {
return newsDirDAO.getNewsDir(id);
}
public BNewsDoc getNewsDoc(int id) {
return newsDocDAO.getNewsDoc(id);
}
public List<BNewsDir> getNewsDirByUserID(int userID) {
return newsDirDAO.getNewsDirByUserID(userID);
}
public int getNewsDocCountByNewsDirID(int newsDirID) {
return newsDocDAO.getNewsDocCountByNewsDirID(newsDirID);
}
public BInfo getInfobyUserID(int userID) {
return infoDAO.getInfobyUserID(userID);
}
public List<BPhotoDir> getPhotoDirByUserID(int userID) {
return photoDirDAO.getPhotoDirByUserID(userID);
}
public List<BCircle> getAllCircleByUserID(int userID) {
return circleDAO.getAllCircleByUserID(userID);
}
public List<BNewsDoc> getNewsDocDirByDirID(int newsDirID) {
return newsDocDAO.getNewsDocDirByDirID(newsDirID);
}
public List<BNewsDoc> getNewsDocDirByUserID(int userID) {
return newsDocDAO.getNewsDocDirByUserID(userID);
}
public void saveOrUpdateUserLog(int userID, BUserLog userLog) {
BUserLog b = userLogDAO.getUserLogByUserID(userID);
if (b != null) {
b.setLastLoginIp(userLog.getLastLoginIp());
b.setLastLoginTime(userLog.getLastLoginTime());
userLogDAO.updateUserLog(b);
} else {
userLogDAO.saveUserLog(userLog);
}
}
public BUserLog getUserLogByUserID(int userID) {
return userLogDAO.getUserLogByUserID(userID);
}
public void updateUserinfoByUserID(int userID, BUserinfo userinfo) {
BUserinfo u = userinfoDAO.getUserinfo(userID);
u.setUserName(userinfo.getUserName());
u.setNickName(userinfo.getNickName());
u.setEmail(userinfo.getEmail());
u.setSex(userinfo.getSex());
userinfoDAO.updateUserinfo(u);
}
public void updateInfoByUserID(int userID, BInfo info,BAdminTypes adminTypes) {
BInfo bi = infoDAO.getInfobyUserID(userID);
bi.setNickName(info.getNickName());
bi.setDomain(info.getDomain());
bi.setSubtitle(info.getSubtitle());
bi.setIntro(info.getIntro());
bi.setBAdminTypes(adminTypes);
bi.setBAdminImags(info.getBAdminImags());
infoDAO.updateInfo(bi);
}
public List<BAdminTypes> getAllAdminTypes() {
return adminTypesDAO.getAllAdminTypes();
}
public BAdminTypes getAdminTypes(int id) {
return adminTypesDAO.getAdminTypes(id);
}
public void save(int userID, BNewsDir newsDir) {
newsDirDAO.saveNewsDir(newsDir);
}
public void delNewsDir(int id) {
newsDirDAO.delNewsDir(id);
}
public void updateNewsDirByID(int id, BNewsDir newsDir) {
BNewsDir d = newsDirDAO.getNewsDir(id);
d.setTitle(newsDir.getTitle());
d.setIntro(newsDir.getIntro());
d.setState(newsDir.getState());
newsDirDAO.saveNewsDir(d);
}
public void delNewsDoc(int id) {
newsDocDAO.delNewsDoc(id);
}
//分页newsDoc
public List<BNewsDoc> getNewsDocPage(int userID,int rows,int MaxResults) {
return newsDocDAO.getNewsDocPage(userID,rows,MaxResults);
}
public List<BNewsDoc> getNewsDocPage(int userID) {
return newsDocDAO.getNewsDocPage(userID);
}
//根据circleMemberDAO获取circle的id,然后查出对应的博客圈信息
public List<BCircle> getCircleByCircleID(int userID) {
List<BCircleMember> list = circleMemberDAO.getCircleIDByUserID(userID);
List<BCircle> listCircle = new ArrayList<BCircle>();
if (list.size()==0){
return null;
} else {
for (int i=0;i<list.size();i++) {
BCircleMember c =(BCircleMember)list.get(i);
//System.out.println(c.getBCircle().getId());
int id = c.getBCircle().getId();
BCircle bc =(BCircle)circleDAO.getCircle(id);
listCircle.add(bc);
}
}
return listCircle;
}
public BNewsDoc getMaxNewsDocbyDirID(int dirID) {
int maxNewsDocID = newsDocDAO.getMaxNewsDocbyDirID(dirID);
if (maxNewsDocID > 0) {
return newsDocDAO.getNewsDoc(maxNewsDocID);
} else {
return null;
}
}
public void saveReview(BReview review) {
reviewDAO.saveReview(review);
}
public List<BReview> getAllReviewByDocID(int docID) {
return reviewDAO.getAllReviewByDoc
- 1
- 2
前往页