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
没有合适的资源?快使用搜索试试~ 我知道了~
实战突击:Java Web项目整合开发 1-6 源码
共1090个文件
jsp:191个
gif:185个
class:161个
5星 · 超过95%的资源 需积分: 38 1.6k 下载量 126 浏览量
2012-05-18
12:14:00
上传
评论 29
收藏 56.92MB RAR 举报
温馨提示
很多计算机的书,有源码就够了!呵呵这本书就是 第1篇 SSH2框架应用篇 第1章 都市供求信息网 第2章 物流配货网 第3章 编程爱好者博客地带 第4章 明日知道 第5章 天下淘网络商城 第2篇 SSH框架应用篇 第6章 成长在线考试网 第7章 企业物资管理系统 第8章 办公自动化管理系统 第9章 校园管理系统 第10章 高校学生选课系统 第3篇 JSP项目实战篇 第11章 网络购物中心 第12章 博研图书馆管理系统 第13章 讯友网络相册 第14章 企业门户网站 第15章 芝麻开门博客网 第16章 进销存管理系统 第17章 网上淘书吧 第18章 新奥家电连锁网络系统 第19章 大学生就业求职网 第20章 华奥汽车销售集团网 第21章 科研成果申报管理系统
资源推荐
资源详情
资源评论
收起资源包目录
实战突击:Java Web项目整合开发 1-6 源码 (1090个子文件)
UserInfoAction.class 21KB
ProductAction.class 12KB
InfoAction.class 10KB
AdminAction.class 9KB
ArticleAction.class 9KB
DefaultDaoImpl.class 8KB
DaoSupport.class 7KB
ArticleDaoImpl.class 7KB
ActicleAction.class 7KB
OrderAction.class 7KB
StartExam.class 7KB
StudentDAO.class 6KB
PhotoAction.class 6KB
JSONKit.class 6KB
QuestionsDAO.class 6KB
OpDB.class 5KB
StartExamDAO.class 5KB
Student.class 5KB
InfoAction.class 5KB
QuestionsForm.class 5KB
AdminAction.class 5KB
BaseAction.class 5KB
UserInfo.class 4KB
ObjectDao.class 4KB
Manager.class 4KB
Article.class 4KB
TaoTiDAO.class 4KB
Questions.class 4KB
LessonDAO.class 4KB
Lesson.class 4KB
TaoTi.class 4KB
ProductInfo.class 4KB
UserAction.class 4KB
GoodsAndLogDao.class 4KB
EnumType.class 3KB
CarAction.class 3KB
ProductCategoryAction.class 3KB
ManagerDAO.class 3KB
ReArticleAction.class 3KB
ConnDB.class 3KB
User.class 3KB
ArticleType.class 3KB
Order.class 3KB
GoodsAction.class 3KB
ValidateExpression.class 3KB
CartAction.class 3KB
MyPagination.class 3KB
CreatePage.class 3KB
StuResultDAO.class 3KB
DefaultAction.class 3KB
DaoSupport$2.class 3KB
CustomerAction.class 3KB
IndexAction.class 3KB
AdminAction.class 3KB
DB.class 3KB
PhotoInfo.class 3KB
IndexAction.class 3KB
StudentForm.class 3KB
JDBConnection.class 3KB
CarDao.class 3KB
InfoSingle.class 3KB
UserDaoImpl.class 2KB
StuResult.class 2KB
BlogMainAction.class 2KB
ProductCategory.class 2KB
CustomerDao.class 2KB
ProductDaoImpl.class 2KB
CustomerAction.class 2KB
UserAction.class 2KB
LogInOutAction.class 2KB
OrderItem.class 2KB
PageModel.class 2KB
ArticleInfo.class 2KB
GoodsForm.class 2KB
CustomerDaoImpl.class 2KB
PageUtil.class 2KB
HibernateUtils.class 2KB
CarForm.class 2KB
UserDaoImpl.class 2KB
OrderState.class 2KB
Customer.class 2KB
StuResultForm.class 2KB
ChStr.class 2KB
ReplyAction.class 2KB
Sex.class 2KB
TaoTiForm.class 2KB
FileOperation.class 2KB
StringUitl.class 2KB
Reply.class 2KB
HibernateUtil.class 2KB
LogForm.class 2KB
Info.class 2KB
OrderDaoImpl.class 1KB
DaoSupportTest.class 1KB
ReArticleInfo.class 1KB
AdminInfo.class 1KB
temp.class 1KB
PaymentWay.class 1KB
IArticleDao.class 1KB
AdminDao.class 1KB
共 1090 条
- 1
- 2
- 3
- 4
- 5
- 6
- 11
好名字占了
- 粉丝: 1466
- 资源: 362
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 技术资料分享TF卡资料很好的技术资料.zip
- 技术资料分享TF介绍很好的技术资料.zip
- 10、安徽省大学生学科和技能竞赛A、B类项目列表(2019年版).xlsx
- 9、教育主管部门公布学科竞赛(2015版)-方喻飞
- C语言-leetcode题解之83-remove-duplicates-from-sorted-list.c
- C语言-leetcode题解之79-word-search.c
- C语言-leetcode题解之78-subsets.c
- C语言-leetcode题解之75-sort-colors.c
- C语言-leetcode题解之74-search-a-2d-matrix.c
- C语言-leetcode题解之73-set-matrix-zeroes.c
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页