package com.mr.webiter;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.ServletRequestAware;
import com.mr.dao.ObjectDao;
import com.mr.model.ArticleInfo;
import com.mr.model.Info;
import com.mr.model.PhotoInfo;
import com.mr.model.ReArticleInfo;
import com.mr.model.UserInfo;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
public class UserInfoAction extends ActionSupport implements ModelDriven<UserInfo>, ServletRequestAware{
private static final long serialVersionUID = 3496418228419922282L;
private UserInfo userInfo = new UserInfo();
private String hql = "";
private ObjectDao<UserInfo> objectDao = null;
protected HttpServletRequest request;
public UserInfo getModel() {
return userInfo;
}
public void setServletRequest(HttpServletRequest request) {
this.request = request;
}
// 删除朋友信息
public String friend_delete() {
String friendsTypes[] = request.getParameterValues("friends");
if (friendsTypes != null) {
String account = (String) request.getSession().getAttribute(
"account");
hql = "from UserInfo where account = '" + account + "'";
objectDao = new ObjectDao<UserInfo>();
UserInfo user = objectDao.queryFrom(hql);
String date_types = user.getFriendType();
for (String type : friendsTypes) {
date_types = com.mr.tools.ValidateExpression.deleteString(
date_types, type);
}
user.setFriendType(date_types);
objectDao.updateT(user);
}
return friend_query();
}
// 后台查询用户
public String friend_query() {
String account = "";
// try {
account = (String) request.getSession().getAttribute("account");
//account = new String(account.getBytes("ISO8859_1"), "gb2312");
System.out.println("AAAAAAAAaa "+account);
// } catch (UnsupportedEncodingException e) {
// e.printStackTrace();
// }
hql = "from UserInfo where account = '" + account + "'";
System.out.println("HQL :"+hql);
objectDao = new ObjectDao<UserInfo>();
userInfo = objectDao.queryFrom(hql);
String friend = userInfo.getFriendType();
if (!friend.equals("")) {
request.setAttribute("friends", friend.split(","));
}
String[] ff = friend.split(",");
System.out.println("FFFFFFFFFFf "+ff.length);
return "friend_query";
}
// 添加好友
public String friend_add() {
boolean flag = true;
objectDao = new ObjectDao<UserInfo>();
String account = (String) request.getSession().getAttribute("account");
UserInfo user = objectDao.queryFrom("from UserInfo where account = '"
+ account + "'");
String friends = user.getFriendType();
System.out.println("Friends "+friends);
UserInfo userInfo = (UserInfo) request.getSession().getAttribute(
"userInfo");
String account1 = userInfo.getAccount(); // 获取访问博客的用户名
if (friends == null || friends.equals("")) {
user.setFriendType(account1);
} else {
String types[] = friends.split(",");
for (String type1 : types) {
if (account1.equals(type1)) {
flag = false;
}
}
user.setFriendType(user.getFriendType() + "," + account1);
}
String result = "该好友已经存在,操作失败!";
if (flag) {
objectDao = new ObjectDao<UserInfo>();
objectDao.updateT(user);
System.out.println("AFTER "+ userInfo.getFriendType() + "," + account1);
result = "加入好友成功!";
}
request.setAttribute("account1", account1);
request.setAttribute("sign", "18");
request.setAttribute("result", result);
return "operationUser";
}
// 删除相册类别操作
public String phtType_delete() {
String phtTypes[] = request.getParameterValues("type");
if (phtTypes != null) {
String account = (String) request.getSession().getAttribute(
"account");
hql = "from UserInfo where account = '" + account + "'";
objectDao = new ObjectDao<UserInfo>();
UserInfo user = objectDao.queryFrom(hql);
String date_phtType = user.getPicType();
for (String phtType : phtTypes) {
date_phtType = com.mr.tools.ValidateExpression.deleteString(
date_phtType, phtType);
hql = "from PhotoInfo where author = '" + account
+ "' and photoType = '" + phtType + "'";
ObjectDao<PhotoInfo> dao = new ObjectDao<PhotoInfo>();
List<PhotoInfo> list = dao.queryList(hql);
for (PhotoInfo photoInfo : list) {
dao.deleteT(photoInfo);
String path = request.getRealPath("/"+ photoInfo.getPhotoAddress());
File file = new File(path);
if (file.exists()) {
file.delete();
}
}
}
user.setPicType(date_phtType);
objectDao.updateT(user);
}
request.setAttribute("sign", "13");
return "operationUser";
}
// 修改相片类别名称
public String phtType_update() {
String oldType = request.getParameter("oldType");
String newsType = request.getParameter("newsType");
String account = (String) request.getSession().getAttribute("account");
hql = "from UserInfo where account = '" + account + "'";
objectDao = new ObjectDao<UserInfo>();
UserInfo user = objectDao.queryFrom(hql);
String date_phtType = user.getPicType();
String arrays[] = date_phtType.split(",");
boolean flag = true;
for (String array : arrays) {
if (array.equals(newsType)) {
flag = false;
}
}
if (flag) {
if (!newsType.equals("")) {
date_phtType = com.mr.tools.ValidateExpression.deleteString(
date_phtType, oldType);
date_phtType = date_phtType.trim();
if (date_phtType.equals("")) {
date_phtType = newsType;
} else {
date_phtType = date_phtType + "," + newsType;
}
user.setPicType(date_phtType);
objectDao.updateT(user);
hql = "from PhotoInfo where author = '" + account
+ "' and photoType = '" + oldType + "'";
ObjectDao<PhotoInfo> dao = new ObjectDao<PhotoInfo>();
List<PhotoInfo> list = dao.queryList(hql);
for (PhotoInfo photoInfo : list) {
photoInfo.setPhotoType(newsType);
System.out.println(newsType);
dao.updateT(photoInfo);
}
}
}
request.setAttribute("sign", "14");
return "operationUser";
}
// 查询并添加相片类别信息
public String phtType_query() {
boolean flag = true;
String account = (String) request.getSession().getAttribute("account");
hql = "from UserInfo where account = '" + account + "'";
objectDao = new ObjectDao<UserInfo>();
UserInfo user = objectDao.queryFrom(hql);
String pht_type = user.getPicType();
// 添加类别
if (!userInfo.getPicType().equals("")) {
String arrays[] = pht_type.split(",");
for (String array : arrays) {
if (array.equals(userInfo.getPicType())) {
this.addFieldError("pht_type", "您输入的相册类别重复,请重新输入!");
flag = false;
}
}
if (null == pht_type || pht_type.equals("")) {
user.setPicType(userInfo.getPicType());
} else {
user
.setPicType(user.getPicType() + ","
+ userInfo.getPicType());
}
if (flag) {
objectDao.updateT(user);
user = objectDao.queryFrom(hql);
pht_type = user.getPicType();
}
}
// 查询类别
pht_type = pht_type.trim();
if (!pht_type.equals("")) {
String pht_types[] = pht_type.split(",");
request.setAttribute("pht_types", pht_types);
}
return SUCCESS;
}
// 转向添加文章的页面,这里需要将文章的类别转换成数组
public String forwardAddArticle() {
String account = (String) request.getSession().getAttribute("account");
hql = "from UserInfo where account = '" + account + "'";
objectDao = new ObjectDao<UserInfo>();
UserInfo userInfo = (UserInfo) objectDao.queryFrom(hql);
String type = userInfo.getArtType();
String types[] = type.split(",");
request.setAttribute("types", types);
return "forwardAddArticle";
}
// 修改文章类别名称
public String artType_update() {
String oldType = request.getParameter("oldType");
String newsType = request.getParameter("newsType");
String account = (String) reque
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
项目仅供参考学习! 项目仅供参考学习! 项目仅供参考学习! 本章的博客系统主要分为:个人博客空间、个人博客管理和博客后台管理3部分。结合目前博客系统的设计方案,本项目具有以下特点:界面设计美观大方、操作简单。功能完善、结构清晰。个人博客浏览。能够实现后台用户管理。能够实现推荐博客操作。能够实现后台文章管理。能够实现后台相册管理 操作注意事项 (2)系统注册页面中提供了验证信息,用户只有添加了合法的信息后,才能注册成功。 操作流程 (1)通过系统首页,可实现浏览系统推荐博客、推荐文章、热门博客、热门文章等内容,也可以通过首页提供的“登录”、“注册”超链接来登录系统或注册新用户。
资源推荐
资源详情
资源评论
收起资源包目录
java之编程爱好者博客地带 (202个子文件)
UserInfoAction.class 21KB
ArticleAction.class 9KB
PhotoAction.class 6KB
InfoAction.class 5KB
AdminAction.class 5KB
UserInfo.class 4KB
ObjectDao.class 4KB
ReArticleAction.class 3KB
ValidateExpression.class 3KB
PhotoInfo.class 3KB
BlogMainAction.class 2KB
ArticleInfo.class 2KB
FileOperation.class 2KB
Info.class 2KB
ReArticleInfo.class 1KB
AdminInfo.class 1KB
A.class 819B
ToChinese.class 713B
.classpath 3KB
org.eclipse.wst.jsdt.ui.superType.container 49B
style.css 2KB
程序使用说明.doc 78KB
fielderror.ftl 1KB
fielderror.ftl 1KB
actionerror.ftl 112B
actionerror.ftl 112B
b_top3.gif 62KB
f_top1.gif 50KB
f_main.gif 37KB
b_b_top.gif 35KB
a_top.gif 34KB
a_land.gif 34KB
b_top2.gif 17KB
f_down2.gif 15KB
b_b_top2.gif 10KB
b_b_top1.gif 9KB
b_top1.gif 5KB
2.gif 3KB
f_top2.gif 3KB
b_l_4.gif 3KB
b_l_1.gif 3KB
11.gif 3KB
f_hot_blog.gif 3KB
f_commend_blog.gif 3KB
16.gif 3KB
f_hot_article.gif 3KB
f_commend_article.gif 3KB
b_l_2.gif 3KB
b_r_4.gif 3KB
b_r_3.gif 3KB
b_top4.gif 3KB
b_r_1.gif 3KB
b_r_5.gif 3KB
4.gif 3KB
1.gif 3KB
6.gif 3KB
9.gif 3KB
8.gif 3KB
15.gif 3KB
5.gif 3KB
7.gif 3KB
12.gif 3KB
14.gif 2KB
13.gif 2KB
10.gif 2KB
3.gif 2KB
17.gif 2KB
f_down1.gif 795B
f_down.gif 500B
f_certer.gif 481B
b_r_2.gif 264B
b_l_3.gif 118B
hibernate3.jar 2.08MB
xwork-core-2.1.6.jar 1.49MB
checkstyle-all.jar 1.15MB
ant-1.6.5.jar 1010KB
freemarker-2.3.15.jar 859KB
struts2-core-2.1.8.1.jar 738KB
mysql-connector-java-5.1.10-bin.jar 707KB
c3p0-0.9.1.2.jar 596KB
commons-collections-3.2.jar 558KB
proxool-0.8.3.jar 465KB
antlr-2.7.6.jar 433KB
jstl-1.2.jar 407KB
log4j-1.2.15.jar 383KB
cglib-nodep-2.1_3.jar 317KB
dom4j-1.6.1.jar 307KB
cglib-2.1.3.jar 276KB
ognl-2.7.3.jar 234KB
jaxen-1.1-beta-7.jar 222KB
commons-beanutils.jar 184KB
commons-collections-2.1.1.jar 171KB
json-lib-2.1.jar 122KB
commons-dbcp.jar 119KB
oscache-2.1.jar 112KB
commons-io-1.3.2.jar 86KB
commons-pool.jar 61KB
commons-fileupload-1.2.1.jar 56KB
commons-logging-api-1.1.jar 44KB
commons-logging-1.0.4.jar 37KB
共 202 条
- 1
- 2
- 3
资源评论
梦回阑珊
- 粉丝: 3564
- 资源: 1164
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功