diff --git a/.classpath b/.classpath index 720fdb1..f67f718 100644 --- a/.classpath +++ b/.classpath @@ -1,7 +1,6 @@ - @@ -9,5 +8,7 @@ + + diff --git a/.myhibernatedata b/.myhibernatedata index 8f24698..de1db5b 100644 --- a/.myhibernatedata +++ b/.myhibernatedata @@ -1,5 +1,5 @@ #MyEclipse Hibernate Properties -#Sat Jan 04 15:25:24 CST 2020 +#Sun Jan 05 17:23:45 CST 2020 sessionFactoryName= genBasicCompId=false profile= diff --git a/WebRoot/WEB-INF/classes/HelloServlet.class b/WebRoot/WEB-INF/classes/HelloServlet.class index ca8d98e..cffafea 100644 Binary files a/WebRoot/WEB-INF/classes/HelloServlet.class and b/WebRoot/WEB-INF/classes/HelloServlet.class differ diff --git a/WebRoot/WEB-INF/classes/NavigationServlet.class b/WebRoot/WEB-INF/classes/NavigationServlet.class new file mode 100644 index 0000000..c11482c Binary files /dev/null and b/WebRoot/WEB-INF/classes/NavigationServlet.class differ diff --git a/WebRoot/WEB-INF/classes/PagingServlet.class b/WebRoot/WEB-INF/classes/PagingServlet.class new file mode 100644 index 0000000..2f2b6da Binary files /dev/null and b/WebRoot/WEB-INF/classes/PagingServlet.class differ diff --git a/WebRoot/WEB-INF/classes/RegisterAction.class b/WebRoot/WEB-INF/classes/RegisterAction.class index d1f925e..c652e2d 100644 Binary files a/WebRoot/WEB-INF/classes/RegisterAction.class and b/WebRoot/WEB-INF/classes/RegisterAction.class differ diff --git a/WebRoot/WEB-INF/classes/SubmitXzAction.class b/WebRoot/WEB-INF/classes/SubmitXzAction.class index fded31d..985f79a 100644 Binary files a/WebRoot/WEB-INF/classes/SubmitXzAction.class and b/WebRoot/WEB-INF/classes/SubmitXzAction.class differ diff --git a/WebRoot/WEB-INF/classes/com/AbstractUserinfo.class b/WebRoot/WEB-INF/classes/com/AbstractUserinfo.class index 384a86b..5a414be 100644 Binary files a/WebRoot/WEB-INF/classes/com/AbstractUserinfo.class and b/WebRoot/WEB-INF/classes/com/AbstractUserinfo.class differ diff --git a/WebRoot/WEB-INF/classes/com/AbstractXz.class b/WebRoot/WEB-INF/classes/com/AbstractXz.class index 0e1661c..e33b85b 100644 Binary files a/WebRoot/WEB-INF/classes/com/AbstractXz.class and b/WebRoot/WEB-INF/classes/com/AbstractXz.class differ diff --git a/WebRoot/WEB-INF/classes/com/AbstractXztype.class b/WebRoot/WEB-INF/classes/com/AbstractXztype.class new file mode 100644 index 0000000..39aafdc Binary files /dev/null and b/WebRoot/WEB-INF/classes/com/AbstractXztype.class differ diff --git a/WebRoot/WEB-INF/classes/com/PageBean.class b/WebRoot/WEB-INF/classes/com/PageBean.class new file mode 100644 index 0000000..f6cb57f Binary files /dev/null and b/WebRoot/WEB-INF/classes/com/PageBean.class differ diff --git a/WebRoot/WEB-INF/classes/com/Xz.class b/WebRoot/WEB-INF/classes/com/Xz.class index 37c8a44..c72a5db 100644 Binary files a/WebRoot/WEB-INF/classes/com/Xz.class and b/WebRoot/WEB-INF/classes/com/Xz.class differ diff --git a/WebRoot/WEB-INF/classes/com/Xz.hbm.xml b/WebRoot/WEB-INF/classes/com/Xz.hbm.xml index 9c8ff51..913fff6 100644 --- a/WebRoot/WEB-INF/classes/com/Xz.hbm.xml +++ b/WebRoot/WEB-INF/classes/com/Xz.hbm.xml @@ -34,5 +34,11 @@ + + + + + + diff --git a/WebRoot/WEB-INF/classes/com/Xztype.class b/WebRoot/WEB-INF/classes/com/Xztype.class new file mode 100644 index 0000000..b1c6ef3 Binary files /dev/null and b/WebRoot/WEB-INF/classes/com/Xztype.class differ diff --git a/WebRoot/WEB-INF/classes/com/Xztype.hbm.xml b/WebRoot/WEB-INF/classes/com/Xztype.hbm.xml new file mode 100644 index 0000000..6efaca8 --- /dev/null +++ b/WebRoot/WEB-INF/classes/com/Xztype.hbm.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + diff --git a/WebRoot/WEB-INF/classes/hibernate.cfg.xml b/WebRoot/WEB-INF/classes/hibernate.cfg.xml index bd907a2..8e0e862 100644 --- a/WebRoot/WEB-INF/classes/hibernate.cfg.xml +++ b/WebRoot/WEB-INF/classes/hibernate.cfg.xml @@ -25,6 +25,7 @@ + diff --git a/WebRoot/WEB-INF/classes/struts.xml b/WebRoot/WEB-INF/classes/struts.xml index 4e55a43..2f8c4e0 100644 --- a/WebRoot/WEB-INF/classes/struts.xml +++ b/WebRoot/WEB-INF/classes/struts.xml @@ -19,7 +19,7 @@ /welcome.jsp /success.jsp - + /welcome.jsp /success.jsp diff --git a/WebRoot/WEB-INF/web.xml b/WebRoot/WEB-INF/web.xml index 90033a2..146af5e 100644 --- a/WebRoot/WEB-INF/web.xml +++ b/WebRoot/WEB-INF/web.xml @@ -12,6 +12,20 @@ HelloServlet HelloServlet + + This is the description of my J2EE component + This is the display name of my J2EE component + NavigationServlet + NavigationServlet + + + This is the description of my J2EE component + This is the display name of my J2EE component + PagingServlet + PagingServlet + + + @@ -19,6 +33,14 @@ HelloServlet /HelloServlet + + NavigationServlet + /NavigationServlet + + + PagingServlet + /PagingServlet + diff --git a/WebRoot/fbxz.jsp b/WebRoot/fbxz.jsp index 85441bd..c755d84 100644 --- a/WebRoot/fbxz.jsp +++ b/WebRoot/fbxz.jsp @@ -184,6 +184,7 @@ width:800px; +
diff --git a/WebRoot/welcome.jsp b/WebRoot/welcome.jsp index 857d2e9..8238964 100644 --- a/WebRoot/welcome.jsp +++ b/WebRoot/welcome.jsp @@ -3,5 +3,7 @@ 登陆成功

欢迎登陆本系统

- +
  • + 失物招领 +
  • \ No newline at end of file diff --git a/secondHandcode/action/AdminAction.java b/secondHandcode/action/AdminAction.java deleted file mode 100644 index 1dce94f..0000000 --- a/secondHandcode/action/AdminAction.java +++ /dev/null @@ -1,340 +0,0 @@ -package action; - - -import java.util.Date; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; - -import model.Admin; -import model.Classify; -import model.PageBean; -import model.Product; -import model.User; -import model.UserAndAdmin; - -import org.apache.struts2.ServletActionContext; - -import service.IAdminInfoService; -import service.ILoginService; - -import com.opensymphony.xwork2.ActionContext; -import com.opensymphony.xwork2.ActionSupport; -import com.opensymphony.xwork2.ModelDriven; - -public class AdminAction extends ActionSupport implements ModelDriven{ - - Admin admin=new Admin(); - @Override - public Admin getModel() { - return admin; - } - - ILoginService iLoginService; - public void setiLoginService(ILoginService iLoginService) { - this.iLoginService = iLoginService; - } - - IAdminInfoService iAdminInfoService; - public void setiAdminInfoService(IAdminInfoService iAdminInfoService) { - this.iAdminInfoService = iAdminInfoService; - } - - - /** - * 管理员登录 - */ - public String AdminLogin(){ - HttpServletRequest req=ServletActionContext.getRequest(); - if(admin==null){ - this.addActionError("请输入账号和密码!"); - return "adminLogin"; - } - Admin a=this.iLoginService.findByAdmin(admin); - if(a==null){ - this.addActionError("管理员帐户或密码错误!"); - return "adminLogin"; - }else{ - req.getSession().setAttribute("Admin", admin); - return "adminIndex"; - } - } - - /** - * 注销登录 - */ - public String Exitlogin(){ - HttpServletRequest req=ServletActionContext.getRequest(); - req.getSession().removeAttribute("Admin"); - return "adminLogin"; - } - - private int currPage=1;//当前页 - - public void setCurrPage(int currPage) { - this.currPage = currPage; - } - - - /** - * 查询所有管理员 - */ - public String findAllAdminInfo(){ - PageBean pageBean=this.iAdminInfoService.findAllAdminInfo(currPage); - if(pageBean!=null){ - ActionContext.getContext().getValueStack().push(pageBean); - } - return "adminList"; - - } - - /** - * 查询所有用户 - */ - public String findAllUserInfo(){ - HttpServletRequest req=ServletActionContext.getRequest(); - String name=req.getParameter("userName"); - if(name==null){ - name=""; - } - PageBean pageBean=this.iAdminInfoService.findAllUserInfo(currPage,name); - if(pageBean!=null){ - ActionContext.getContext().getValueStack().push(pageBean); - } - return "userList"; - - } - /** - * 查询所有分类 - */ - public String findAllCateInfo(){ - HttpServletRequest req=ServletActionContext.getRequest(); - String name=req.getParameter("classifyName"); - if(name==null){ - name=""; - } - PageBean pageBean=this.iAdminInfoService.findAllCateInfo(currPage,name); - if(pageBean!=null){ - ActionContext.getContext().getValueStack().push(pageBean); - } - return "cateList"; - - } - - /** - * 查询所有商品 - */ - public String findAllProductInfo(){ - HttpServletRequest req=ServletActionContext.getRequest(); - String name=req.getParameter("proName"); - String cate=req.getParameter("select_class"); - String type=req.getParameter("select_type"); - int cate1=0; - int type1=2; - if(name==null){ - name=""; - } - if(cate!=null&&cate!=""){ - cate1=Integer.parseInt(req.getParameter("select_class")); - } - if(type!=null&&type!=""){ - type1=Integer.parseInt(req.getParameter("select_type")); - } - PageBean pageBean=this.iAdminInfoService.findAllProductInfo(currPage,name,cate1,type1); - if(pageBean!=null){ - ActionContext.getContext().getValueStack().push(pageBean); - } - List cateList=this.iAdminInfoService.findAllCateList(); - if(cateList!=null){ - ActionContext.getContext().put("cateList", cateList); - } - return "productList"; - - } - - - /** - * 查询单个商品详情信息 - */ - public String searchProductDetail(){ - HttpServletRequest req=ServletActionContext.getRequest(); - int pid=Integer.parseInt(req.getParameter("id")); - Product product=this.iAdminInfoService.searchProductDetail(pid); - if(product!=null){ - ActionContext.getContext().put("product", product); - } - return "productDetail"; - } - /** - * 根据id删除单个商品 - */ - public String delectProductById(){ - HttpServletRequest req=ServletActionContext.getRequest(); - int pid=Integer.parseInt(req.getParameter("id")); - Product p=this.iAdminInfoService.searchProductDetail(pid); - this.iAdminInfoService.delectProductById(pid); - Admin admin=(Admin) req.getSession().getAttribute("Admin"); - UserAndAdmin uaa=new UserAndAdmin(); - uaa.setAdminId(admin.getAid()); - uaa.setCreateTime(new Date()); - uaa.setStatus(0); - uaa.setUserId(p.getUser().getUid()); - uaa.setMessage("您的商品【"+p.getTitle()+"】违反本网站的规章制度,已被管理员删除!"); - this.iAdminInfoService.saveSystemMessage(uaa); - return "success"; - } - - /** - * 查询用户详情信息 - * @return - */ - public String searchUserDetail(){ - HttpServletRequest req=ServletActionContext.getRequest(); - int uid=Integer.parseInt(req.getParameter("uid")); - User user=this.iAdminInfoService.searchUserDetail(uid); - if(user!=null){ - ActionContext.getContext().put("user", user); - } - return "userDetail"; - } - - /** - * 根据id删除分类 - */ - public String delectCateById(){ - HttpServletRequest req=ServletActionContext.getRequest(); - int id=Integer.parseInt(req.getParameter("id")); - this.iAdminInfoService.delectCateById(id); - return "delCatesuccess"; - } - - /** - * 根据id删除管理员 - */ - public String delectAdminById(){ - HttpServletRequest req=ServletActionContext.getRequest(); - int id=Integer.parseInt(req.getParameter("id")); - this.iAdminInfoService.delectAdminById(id); - return "delAdminsuccess"; - } - - /** - * 新增管理员 - */ - public String addAdmin(){ - Admin a=this.iAdminInfoService.findAdminByName(admin.getName()); - if(a!=null){ - this.addActionError("该账号已存在!"); - return "addAdminFail"; - } - this.iAdminInfoService.addAdmin(admin); - return "addAdminSucess"; - } - /** - * 管理员修改前回显内容 - */ - public String findAdminById(){ - admin=this.iAdminInfoService.findAdminById(admin.getAid()); - ActionContext.getContext().put("admin", admin); - return "findAdminSuccess"; - } - /** - * 管理员修改 - */ - public String updateAdmin(){ - /*Admin a=this.iAdminInfoService.findAdminByName(admin.getName()); - if(a!=null){ - this.addActionError("该账号已存在!"); - return "updateAdminFail"; - }*/ - this.iAdminInfoService.updateAdmin(admin); - return "updateAdminSuccess"; - - } - - - Classify cassify=new Classify(); - - public Classify getCassify() { - return cassify; - } - - public void setCassify(Classify cassify) { - this.cassify = cassify; - } - - private String classifyName; - private Integer classifySort; - private Integer cid; - public String getClassifyName() { - return classifyName; - } - - public void setClassifyName(String classifyName) { - this.classifyName = classifyName; - } - - public Integer getClassifySort() { - return classifySort; - } - - public void setClassifySort(Integer classifySort) { - this.classifySort = classifySort; - } - - - public Integer getCid() { - return cid; - } - - - public void setCid(Integer cid) { - this.cid = cid; - } - - - /** - * 新增分类 - */ - public String addCate(){ - cassify.setClassifyName(classifyName); - cassify.setClassifySort(classifySort); - Classify c=this.iAdminInfoService.findCateByName(classifyName); - if(c!=null){ - this.addActionError("该分类已存在!"); - return "addCateFail"; - } - this.iAdminInfoService.addCate(cassify); - return "addCateSucess"; - } - - /** - * 修改分类前回显 - */ - public String findCateByName(){ - HttpServletRequest req=ServletActionContext.getRequest(); - String cname=req.getParameter("cname"); - Classify c=this.iAdminInfoService.findCateByName(cname); - ActionContext.getContext().put("cate", c); - return "findCateSuccess"; - } - /** - * 修改分类 - */ - public String updateCate(){ - /*Classify c=this.iAdminInfoService.findCateByName(classifyName); - if(c!=null){ - this.addActionError("该分类已存在!"); - return "updateCateFail"; - }*/ - cassify.setCid(cid); - cassify.setClassifyName(classifyName); - cassify.setClassifySort(classifySort); - this.iAdminInfoService.updateCate(cassify); - return "updateCateSuccess"; - - } - - - -} diff --git a/secondHandcode/action/ProductAction.java b/secondHandcode/action/ProductAction.java deleted file mode 100644 index bf8ef5e..0000000 --- a/secondHandcode/action/ProductAction.java +++ /dev/null @@ -1,307 +0,0 @@ -package action; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.servlet.http.HttpServletRequest; - -import model.Classify; -import model.PageBean; -import model.Product; -import model.User; -import model.UserAndAdmin; - -import org.apache.struts2.ServletActionContext; -import org.aspectj.util.FileUtil; - -import service.IUserService; -import util.AddJson; - -import com.opensymphony.xwork2.ActionContext; -import com.opensymphony.xwork2.ActionSupport; -import com.opensymphony.xwork2.ModelDriven; - -public class ProductAction extends ActionSupport implements ModelDriven{ - - IUserService iUserService; - public void setiUserService(IUserService iUserService) { - this.iUserService = iUserService; - } - - - Product product=new Product(); - @Override - public Product getModel() { - return product; - } - HttpServletRequest req=ServletActionContext.getRequest(); - AddJson json=new AddJson(); - private int currPage=1;//当前页 - - public void setCurrPage(int currPage) { - this.currPage = currPage; - } - private File proPictureFile; - private String proPictureFileFileName; - private String proPictureContentType; - private final int BUFFER_SIZE=16*1024; - private Integer classifyId; - - public Integer getClassifyId() { - return classifyId; - } - public void setClassifyId(Integer classifyId) { - this.classifyId = classifyId; - } - public File getProPictureFile() { - return proPictureFile; - } - public void setProPictureFile(File proPictureFile) { - this.proPictureFile = proPictureFile; - } - - public String getProPictureContentType() { - return proPictureContentType; - } - public void setProPictureContentType(String proPictureContentType) { - this.proPictureContentType = proPictureContentType; - } - public String getProPictureFileFileName() { - return proPictureFileFileName; - } - public void setProPictureFileFileName(String proPictureFileFileName) { - this.proPictureFileFileName = proPictureFileFileName; - } - /** - * 发布供求信息 - */ - public String addProduct() throws Exception{ - String newFileName=new Date().getTime()+getExtention(proPictureFileFileName); - String path=ServletActionContext.getServletContext().getRealPath("/upload"); - File picFile=new File(path); - if(!picFile.exists()){ - picFile.mkdir(); - } - FileUtil.copyFile(proPictureFile, new File(picFile,newFileName)); - //copy(proPictureFile,picFile);将上传的图片存储到picFile - product.setPicture(newFileName); - product.setCreateTime(new Date()); - Classify c=this.iUserService.getClassifyById(product.getClassifyId()); - User u=this.iUserService.getUserById(product.getCreatorId()); - product.setClassify(c); - product.setUser(u); - this.iUserService.saveProduct(product); - this.addActionMessage("发布成功!"); - return "uploadSuccess"; - - } - /** - * 上传文件(io流实现) - * @param src - * @param dst - * @throws Exception - */ - private void copy(File src, File dst)throws Exception { - InputStream in=null; - OutputStream out=null; - try { - in=new BufferedInputStream(new FileInputStream(src),BUFFER_SIZE); - out=new BufferedOutputStream(new FileOutputStream(dst),BUFFER_SIZE); - byte[] buffer=new byte[BUFFER_SIZE]; - while(in.read(buffer)>0){ - out.write(buffer); - } - } catch (Exception e) { - throw e; - }finally{ - try { - in.close(); - } catch (Exception e2) { - - } - try { - out.close(); - } catch (Exception e2) { - - } - } - - } - /** - * 截图文件后缀名称 - * @param filename - * @return - */ - private String getExtention(String filename) { - int pos=filename.lastIndexOf("."); - return filename.substring(pos); - } - /** - * 查询分类列表 - * @throws IOException - */ - public void searchClassifyList() throws IOException{ - List list=this.iUserService.searchClassifyList(); - this.json.toJsonArray(list); - } - - /** - * 查询商品列表 - */ - public void searchProductList() throws Exception{ - String keyword=req.getParameter("keyword");//输入框关键字 - String cid=req.getParameter("cid");//判断分类 - String conditon=req.getParameter("condition");//判断按什么查询 - Map map=new HashMap(); - if(keyword!=null&&keyword!=""){ - map.put("keyword", keyword); - } - if(cid!=null&&cid!=""){ - map.put("cid", cid); - } - if(conditon!=null&&conditon!=""){ - map.put("conditon", conditon); - } - map.put("currPage", currPage+""); - PageBean proList=this.iUserService.searchProductList(map); - this.json.toJsonObj(proList); - } - - /** - * 查询商品详情 - */ - public void getProductDetail() throws Exception{ - String id=req.getParameter("id"); - Product product=this.iUserService.getProductDetail(id); - this.json.toJson(product); - /*int clickNum=product.getProClicknum(); - product.setProClicknum(clickNum+1); - this.iUserService.updateProduct(product);*/ - } - - - /** - * 分页查询我发布的商品列表信息 - * @throws Exception - */ - public void searchMyProductByPage() throws Exception{ - User user=(User) req.getSession().getAttribute("User"); - if(user==null){ - throw new Exception("用户帐户为空,请重新登录!"); - }else{ - Map map=new HashMap(); - map.put("currPage", currPage+""); - map.put("userId", user.getUid()+""); - PageBean myproList=this.iUserService.searchMyProductByPage(map); - this.json.toJson(myproList); - } - } - - - private String repContent; - private String content; - - public String getRepContent() { - return repContent; - } - public void setRepContent(String repContent) { - this.repContent = repContent; - } - public String getContent() { - return content; - } - public void setContent(String content) { - this.content = content; - } - - - /** - * - *

    Description: 删除我的商品

    - * @throws Exception - */ - public void deleteMyProductById() throws Exception{ - User user=(User) req.getSession().getAttribute("User"); - if(user==null){ - throw new Exception("用户帐户为空,请重新登录!"); - }else{ - int pid=Integer.parseInt(req.getParameter("id")); - this.iUserService.delectProductById(pid); - } - } - - - - /** - * 分页消息 - * @throws Exception - * @param flag 0系统消息,1用户消息 - */ - public String searchMessageByPage() throws Exception{ - User user=(User) req.getSession().getAttribute("User"); - String flag=""; - if(user==null){ - throw new Exception("用户帐户为空,请重新登录!"); - }else{ - flag=req.getParameter("flag");//0系统消息,1用户消息 - Map map=new HashMap(); - map.put("currPage", currPage+""); - map.put("userId", user.getUid()+""); - map.put("flag", flag); - PageBean message=this.iUserService.searchMessageByPage(map); - if(message!=null){ - ActionContext.getContext().getValueStack().push(message); - } - } - if(flag=="0"||"0".equals(flag)){ - return "sysmessage"; - }else{ - return "usermessage"; - } - } - private String flag; - - public String getFlag() { - return flag; - } - public void setFlag(String flag) { - this.flag = flag; - } - /** - * 删除消息 - * @return - * @throws Exception - */ - public String deleteMessage() throws Exception{ - User user=(User) req.getSession().getAttribute("User"); - //String flag=req.getParameter("flag"); - if(user==null){ - throw new Exception("用户帐户为空,请重新登录!"); - }else{ - String id=req.getParameter("id"); - this.iUserService.deleteMessage(Integer.parseInt(id)); - } - if(flag=="0"||"0".equals(flag)){ - return "sysmsgDelete"; - }else{ - return "usermsgDelete"; - } - } - - - -} diff --git a/secondHandcode/action/UserAction.java b/secondHandcode/action/UserAction.java deleted file mode 100644 index 588e66a..0000000 --- a/secondHandcode/action/UserAction.java +++ /dev/null @@ -1,165 +0,0 @@ -package action; - -import javax.servlet.http.HttpServletRequest; -import org.apache.struts2.ServletActionContext; -import service.ILoginService; -import util.AddJson; -import model.User; - -import com.opensymphony.xwork2.ActionSupport; -import com.opensymphony.xwork2.ModelDriven; - -public class UserAction extends ActionSupport implements ModelDriven{ - - User user=new User(); - @Override - public User getModel() { - return user; - } - - ILoginService iLoginService; - public void setiLoginService(ILoginService iLoginService) { - this.iLoginService = iLoginService; - } - - - HttpServletRequest req=ServletActionContext.getRequest(); - - /** - * 用户登录 - * @return - */ - public String UserLogin(){ - //HttpServletRequest req=ServletActionContext.getRequest(); - if(user==null){ - this.addActionError("请输入账号和密码!"); - return "login"; - } - - User u=this.iLoginService.findByUser(user); - if(u==null){ - this.addActionError("用户名或密码错误!"); - return "login"; - }else{ - req.getSession().setAttribute("User", u); - return "index"; - } - } - - /** - * 用户注册 - */ - public String userRegister(){ - //通过用户名先查询该用户是否已经注册 - User u=this.iLoginService.findUserByName(user.getUserName()); - if(u!=null){ - this.addActionError("该用户已被注册!"); - return "registerFail"; - } - //user.setHeadPic("images/logo-s.jpg"); - this.iLoginService.saveUser(user); - return "registerSuccess"; - } - - /** - * 通过账号找回密码步骤1 - */ - public String forgetPwd(){ - //HttpServletRequest req=ServletActionContext.getRequest(); - String userName=req.getParameter("userName"); - User u=this.iLoginService.findUserByName(userName); - if(u==null){ - this.addFieldError(userName, "用户名错误!"); - return "getPwdFail"; - } - if(u.getQusetion()==null){ - this.addActionError("抱歉!你没有设置问题和密码!"); - return "getPwdFail"; - } - req.getSession().setAttribute("User", u); - return "getPwdSuccess"; - - } - /** - * 提交问题2 - */ - public String checkAnswer(){ - //HttpServletRequest req=ServletActionContext.getRequest(); - String answertext=req.getParameter("answer"); - User u=this.iLoginService.findUserByName(user.getUserName()); - if(u!=null){ - String answer=u.getAnswer(); - if(!answer.equals(answertext)){ - this.addActionError("抱歉!回答错误!"); - return "answerFalse"; - } - } - req.getSession().setAttribute("User", u); - return "answerTrue"; - - } - - /** - * 重新设置密码3 - */ - public String updatePwd(){ - this.iLoginService.updatePed(user); - return "updatePwdSuccess"; - - } - - /** - * 查询用户账号信息 - * @throws Exception - */ - public void searchPersonalInfo() throws Exception{ - //HttpServletRequest req=ServletActionContext.getRequest(); - int uid=Integer.parseInt(req.getParameter("uid")); - if(uid==0){ - throw new Exception("用户不存在!"); - } - user=this.iLoginService.searchUserInfoById(uid); - AddJson json=new AddJson(); - json.toJson(user); - //return "findUserInfoSuccess"; - - } - - /** - * 修改用户信息 - */ - public void updateUserInfoById(){ - int uid=Integer.parseInt(req.getParameter("uid")); - String uname=req.getParameter("userName"); - String pass=req.getParameter("password"); - String uclass=req.getParameter("schoolClass"); - String address=req.getParameter("address"); - String phone=req.getParameter("phone"); - String qusetion=req.getParameter("qusetion"); - String answer=req.getParameter("answer"); - int sex=Integer.parseInt(req.getParameter("sex")); - User uu=new User(); - //uu.setAddress(address); - uu.setAnswer(answer); - uu.setPassword(pass); - uu.setPhone(phone); - uu.setUid(uid); - uu.setUserName(uname); - uu.setQusetion(qusetion); - uu.setSex(sex); - this.iLoginService.updateUser(uu); - - } - - /** - * 用户退出的登录 - */ - public String userExitLogin(){ - req.getSession().removeAttribute("User"); - return "UserexitSuccess"; - } - - - - -} diff --git a/secondHandcode/dao/IAdminInfoDao.java b/secondHandcode/dao/IAdminInfoDao.java deleted file mode 100644 index 218a131..0000000 --- a/secondHandcode/dao/IAdminInfoDao.java +++ /dev/null @@ -1,168 +0,0 @@ -package dao; - -import java.util.List; - -import model.Admin; -import model.Classify; -import model.Product; -import model.User; -import model.UserAndAdmin; - -public interface IAdminInfoDao { - - /** - * 查询管理员数量 - * @return - */ - int findAdminCount(); - - /** - * 分页查询管理员列表 - * @param begin - * @param pageSize - * @return - */ - List findAllAdminInfo(int begin, int pageSize); - - /** - * 查询用户数量 - * @param name - * @return - */ - int findUserCount(String name); - - /** - * 分页查询用户列表 - * @param begin - * @param pageSize - * @param name - * @return - */ - List findAllUserInfo(int begin, int pageSize,String name); - - /** - * 查询分类数量 - * @param name - * @return - */ - int findCateCount(String name); - - /** - * 分页查询分类列表 - * @param begin - * @param pageSize - * @param name - * @return - */ - List findAllCateInfo(int begin, int pageSize, String name); - - /** - * 查询商品数量 - * @param name - * @param cate - * @param type - * @return - */ - int findProductCount(String name, int cate, int type); - - /** - * 查询商品列表 - * @param begin - * @param pageSize - * @param name - * @param cate - * @param type - * @return - */ - List findAllProductInfo(int begin, int pageSize, String name, int cate, int type); - - /** - * 分类列表查询 - * @return - */ - List findAllCateList(); - - /** - * 查询商品详情 - * @param pid - * @return - */ - Product searchProductDetail(int pid); - - /** - * 删除商品 - * @param pid - */ - void delectProductById(int pid); - - /** - * 查询用户详情 - * @param uid - * @return - */ - User searchUserDetail(int uid); - - /** - * 删除分类 - * @param id - */ - void delectCateById(int id); - - /** - * 删除管理员 - * @param id - */ - void delectAdminById(int id); - - /** - * 新增管理员 - * @param admin - */ - void addAdmin(Admin admin); - - /** - * 通过管理员帐户查询 - * @param name - * @return - */ - Admin findAdminByName(String name); - - /** - * 通过id查询管理员信息 - * @param aid - * @return - */ - Admin findAdminById(Integer aid); - - /** - * 修改管理员 - * @param admin - */ - void updateAdmin(Admin admin); - - /** - * 根据分类名称查询分类信息 - * @param classifyName - * @return - */ - Classify findCateByName(String classifyName); - - /** - * 新增分类 - * @param cassify - */ - void addCate(Classify cassify); - - /** - * 修改分类 - * @param cassify - */ - void updateCate(Classify cassify); - - /** - *

    Description: 后台删除商品发送通知给用户

    - * @param uaa - */ - void saveSystemMessage(UserAndAdmin uaa); - -} diff --git a/secondHandcode/dao/ILoginDao.java b/secondHandcode/dao/ILoginDao.java deleted file mode 100644 index f9ea8ce..0000000 --- a/secondHandcode/dao/ILoginDao.java +++ /dev/null @@ -1,53 +0,0 @@ -package dao; - -import model.Admin; -import model.User; - -public interface ILoginDao { - - /** - * 通过用户名和密码查询用户 - * @param user - * @return - */ - User findByUser(User user); - - /** - * 通过账号和密码查询管理员 - * @param admin - * @return - */ - Admin findByAdmin(Admin admin); - - /** - * 通过用户名查询用户 - * @param userName - * @return - */ - User findUserByName(String userName); - - /** - * 保存用户信息 - * @param user - */ - void saveUser(User user); - - /** - * 修改用户密码 - * @param user - */ - void updatePed(User user); - - /** - * 通过用户id查询用户信息 - * @param uid - * @return - */ - User searchUserInfoById(int uid); - - /** - * 修改用户信息 - * @param user - */ - void updateUser(User user); -} diff --git a/secondHandcode/dao/IUserDao.java b/secondHandcode/dao/IUserDao.java deleted file mode 100644 index b345000..0000000 --- a/secondHandcode/dao/IUserDao.java +++ /dev/null @@ -1,111 +0,0 @@ -package dao; - -import java.util.List; -import java.util.Map; - -import model.Classify; -import model.Product; -import model.User; -import model.UserAndAdmin; - -public interface IUserDao { - - /** - * 发布供求信息 - * @param product - */ - void saveProduct(Product product); - - /** - * 查询分类列表 - * @return - */ - List searchClassifyList(); - - /** - * 查询商品 - * @param map - * @return - */ - List searchProductList(Map map); - - /** - * 查询商品数量 - * @param map - * @return - */ - int searchProductCount(Map map); - - /** - * 查询商品详情 - * @param id - * @return - */ - Product getProductDetail(String id); - - - /** - * 通过分类id获取分类信息 - * @param classifyId - */ - Classify getClassifyById(Integer classifyId); - - User getUserById(Integer creatorId); - - void updateProduct(Product product); - - - /** - *

    Description: 查询我发布的商品列表数量

    - * @param parseInt - * @return - */ - int searchMyProductCount(int parseInt); - - /** - *

    Description: 查询我发布的商品列表信息

    - * @param map - * @return - */ - List getMyProductList(Map map); - - - - /** - *

    Description: 删除我发布的商品

    - * @param pid - */ - void delectProductById(int pid); - - - - - /** - *

    Description: 保存用户消息

    - * @param map - * @return - */ - void saveUserMessage(UserAndAdmin uaa); - - /** - *

    Description: 保存用户消息数量

    - * @param map - * @return - */ - int searchMessageCount(int uid, String flag); - - /** - *

    Description: 保存用户消息

    - * @param map - * @return - */ - List getMessageList(Map map); - - /** - * 通过id删除消息 - */ - void deleteMessage(int id); - - - -} diff --git a/secondHandcode/dao/impl/AdminInfoDao.java b/secondHandcode/dao/impl/AdminInfoDao.java deleted file mode 100644 index e7de93e..0000000 --- a/secondHandcode/dao/impl/AdminInfoDao.java +++ /dev/null @@ -1,269 +0,0 @@ -package dao.impl; - -import java.util.List; - -import model.Admin; -import model.Classify; -import model.Product; -import model.User; -import model.UserAndAdmin; - -import org.hibernate.criterion.DetachedCriteria; -import org.hibernate.criterion.MatchMode; -import org.hibernate.criterion.Order; -import org.hibernate.criterion.Restrictions; -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; - -import dao.IAdminInfoDao; - -public class AdminInfoDao extends HibernateDaoSupport implements IAdminInfoDao { - - @Override - public List findAllAdminInfo(int begin, int pageSize) { - DetachedCriteria dc=DetachedCriteria.forClass(Admin.class); - @SuppressWarnings("unchecked") - List list=this.getHibernateTemplate().findByCriteria(dc, begin, pageSize); - return list; - } - - @Override - public int findAdminCount() { - String hql="select count(*) from Admin"; - @SuppressWarnings("unchecked") - List list=this.getHibernateTemplate().find(hql); - if(list.size()>0){ - return list.get(0).intValue(); - } - return 0; - - } - - @Override - public int findUserCount(String name) { - StringBuffer br=new StringBuffer(); - - String hql="select count(*) from User " ; - if(name!=null){ - String uname="%"+name+"%"; - br.append("where userName like '"+uname+"'"); - } - @SuppressWarnings("unchecked") - List list=this.getHibernateTemplate().find(hql+br.toString()); - if(list.size()>0){ - return list.get(0).intValue(); - } - return 0; - } - - @Override - public List findAllUserInfo(int begin, int pageSize,String name) { - String uname="%"+name+"%"; - DetachedCriteria dc=DetachedCriteria.forClass(User.class) - .add(Restrictions.like("userName", uname, MatchMode.ANYWHERE)) - .addOrder(Order.desc("uid")); - @SuppressWarnings("unchecked") - List list=this.getHibernateTemplate().findByCriteria(dc, begin, pageSize); - return list; - } - - @Override - public int findCateCount(String name) { - StringBuffer br=new StringBuffer(); - String hql="select count(*) from Classify"; - if(name!=null){ - String uname="%"+name+"%"; - br.append(" where classifyName like '"+uname+"'"); - } - @SuppressWarnings("unchecked") - List list=this.getHibernateTemplate().find(hql+br.toString()); - if(list.size()>0){ - return list.get(0).intValue(); - } - return 0; - } - - @Override - public List findAllCateInfo(int begin, int pageSize, String name) { - String uname="%"+name+"%"; - DetachedCriteria dc=DetachedCriteria.forClass(Classify.class) - .add(Restrictions.like("classifyName", uname, MatchMode.ANYWHERE)) - .addOrder(Order.asc("ClassifySort"));; - @SuppressWarnings("unchecked") - List list=this.getHibernateTemplate().findByCriteria(dc,begin,pageSize); - return list; - } - - @Override - public int findProductCount(String name,int cate,int type) { - StringBuffer br=new StringBuffer(); - String hql="select count(*) from Product p where 1=1"; - if(name!=""){ - String uname="%"+name+"%"; - br.append(" and p.proName like '"+uname+"'"); - } - if(cate!=0){ - br.append(" and p.classify.cid ='"+cate+"'"); - } - if(type!=2){ - br.append(" and p.type ='"+type+"'"); - } - @SuppressWarnings("unchecked") - List list=this.getHibernateTemplate().find(hql+br.toString()); - if(list.size()>0){ - return list.get(0).intValue(); - } - return 0; - } - - @Override - public List findAllProductInfo(int begin, int pageSize, String name,int cate,int type) { - String uname="%"+name+"%"; - - DetachedCriteria dc=DetachedCriteria.forClass(Product.class,"p") - .add(Restrictions.like("p.proName", uname, MatchMode.ANYWHERE)); - if(cate!=0){ - dc.add(Restrictions.eq("p.classify.cid", cate)); - } - if(type!=2){ - dc.add(Restrictions.eq("p.type", type)); - } - dc.addOrder(Order.desc("p.createTime")); - @SuppressWarnings("unchecked") - List list=this.getHibernateTemplate().findByCriteria(dc,begin,pageSize); - return list; - } - - @Override - public List findAllCateList() { - String hql="from Classify"; - @SuppressWarnings("unchecked") - List cateList=this.getHibernateTemplate().find(hql); - return cateList; - } - - @Override - public Product searchProductDetail(int pid) { - String hql=" from Product p where p.id=? "; - - @SuppressWarnings("unchecked") - List list=this.getHibernateTemplate().find(hql,pid); - if(list.size()>0){ - Product p=list.get(0); - return p; - } - return null; - } - - @Override - public void delectProductById(int pid) { - Product product=this.getHibernateTemplate().get(Product.class, pid); - if(product!=null){ - this.getHibernateTemplate().delete(product); - } - - - } - - @Override - public User searchUserDetail(int uid) { - User user=this.getHibernateTemplate().get(User.class, uid); - return user; - } - - @Override - public void delectCateById(int id) { - Classify c=this.getHibernateTemplate().get(Classify.class, id); - if(c!=null){ - this.getHibernateTemplate().delete(c); - } - - } - - @Override - public void delectAdminById(int id) { - Admin a=this.getHibernateTemplate().get(Admin.class, id); - if(a!=null){ - this.getHibernateTemplate().delete(a); - } - - } - - @Override - public void addAdmin(Admin admin) { - this.getHibernateTemplate().save(admin); - - } - - @Override - public Admin findAdminByName(String name) { - String hql="from Admin where name=?"; - @SuppressWarnings("unchecked") - List a=this.getHibernateTemplate().find(hql,name); - if(a.size()>0){ - return a.get(0); - } - return null; - } - - @Override - public Admin findAdminById(Integer aid) { - return this.getHibernateTemplate().get(Admin.class, aid); - } - - /** - * 修改管理员 - * @param admin - */ - @Override - public void updateAdmin(Admin admin) { - this.getHibernateTemplate().update(admin); - - } - - /** - * 根据分类名称查询分类信息 - * @param classifyName - * @return - */ - @Override - public Classify findCateByName(String classifyName) { - String hql="from Classify where classifyName=?"; - @SuppressWarnings("unchecked") - List list=this.getHibernateTemplate().find(hql,classifyName); - if(list.size()>0){ - return list.get(0); - } - return null; - } - - /** - * 新增分类 - * @param cassify - */ - @Override - public void addCate(Classify cassify) { - this.getHibernateTemplate().save(cassify); - - } - - /** - * 修改分类 - * @param cassify - */ - @Override - public void updateCate(Classify cassify) { - this.getHibernateTemplate().update(cassify); - } - - /** - *

    Description: 后台删除商品发送通知给用户

    - * @param uaa - */ - @Override - public void saveSystemMessage(UserAndAdmin uaa) { - this.getHibernateTemplate().save(uaa); - } - - - -} diff --git a/secondHandcode/dao/impl/LoginDao.java b/secondHandcode/dao/impl/LoginDao.java deleted file mode 100644 index d08fbcf..0000000 --- a/secondHandcode/dao/impl/LoginDao.java +++ /dev/null @@ -1,96 +0,0 @@ -package dao.impl; - -import java.util.List; -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; -import model.Admin; -import model.User; -import dao.ILoginDao; - -public class LoginDao extends HibernateDaoSupport implements ILoginDao { - - /** - * 通过账号和密码查询用户 - */ - @Override - public User findByUser(User user) { - String hql="from User u where u.userName=? and u.password=?"; - - @SuppressWarnings("unchecked") - - List list=this.getHibernateTemplate().find(hql,user.getUserName(),user.getPassword()); - if(list.size()>0){ - return list.get(0); - }else{ - return null; - } - } - - /** - * 通过账号和密码查询管理员 - */ - @Override - public Admin findByAdmin(Admin admin) { - String hql="from Admin a where a.name=? and a.password=?"; - @SuppressWarnings("unchecked") - List list=this.getHibernateTemplate().find(hql, admin.getName(),admin.getPassword()); - if(list.size()>0){ - return list.get(0); - }else{ - return null; - } - } - - /** - * 通过用户名查询用户 - */ - @Override - public User findUserByName(String userName) { - String hql="from User where userName=?"; - @SuppressWarnings("unchecked") - List list=this.getHibernateTemplate().find(hql,userName); - if(list.size()>0){ - return list.get(0); - } - return null; - } - - /** - * 保存用户信息 - */ - @Override - public void saveUser(User user) { - this.getHibernateTemplate().save(user); - } - - /** - * 修改用户密码 - */ - @Override - public void updatePed(User user) { - User u=this.getHibernateTemplate().get(User.class, user.getUid()); - u.setPassword(user.getPassword()); - this.getHibernateTemplate().update(u); - - } - - /** - * 通过用户id查询用户信息 - */ - @Override - public User searchUserInfoById(int uid) { - User u=this.getHibernateTemplate().get(User.class, uid); - return u; - } - - /** - * 修改用户信息 - */ - @Override - public void updateUser(User user) { - this.getHibernateTemplate().update(user); - - } - - - -} diff --git a/secondHandcode/dao/impl/UserDao.java b/secondHandcode/dao/impl/UserDao.java deleted file mode 100644 index 1545f26..0000000 --- a/secondHandcode/dao/impl/UserDao.java +++ /dev/null @@ -1,297 +0,0 @@ -package dao.impl; - -import java.util.List; -import java.util.Map; - -import model.Classify; -import model.Product; -import model.User; -import model.UserAndAdmin; - -import org.hibernate.Query; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.criterion.DetachedCriteria; -import org.hibernate.criterion.MatchMode; -import org.hibernate.criterion.Order; -import org.hibernate.criterion.Restrictions; -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; - -import dao.IUserDao; - -public class UserDao extends HibernateDaoSupport implements IUserDao { - - /** - * 发布供求信息 - */ - @Override - public void saveProduct(Product product) { - this.getHibernateTemplate().saveOrUpdate (product); - - } - - /** - * 查询分类列表 - */ - @SuppressWarnings("unchecked") - @Override - public List searchClassifyList() { - String hql="from Classify"; - return this.getHibernateTemplate().find(hql); - } - - /** - * 查询商品 - */ - @SuppressWarnings("unchecked") - @Override - public List searchProductList(Map map) { - String proName=map.get("keyword");//输入框输入 - String cid=map.get("cid");//分类 - String condition=map.get("conditon");//按人气或价格升、降或供、求查询 - //DetachedCriteria 是离线的,创建时无需 Session,DetachedCriteria 提供了 2 个静态方法 forClass(Class) 或 forEntityName(Name) 进行DetachedCriteria 实例的创建。 - //Spring 的框架提供了getHibernateTemplate ().findByCriteria(detachedCriteria) 方法可以很方便地根据DetachedCriteria 来返回查询结 果。 - DetachedCriteria dc=DetachedCriteria.forClass(Product.class); - //dc.addOrder(Order.desc("createTime")); - //dc.add(Restrictions.ne("proHassum", 0)); - if(proName!=null){ - proName="%"+map.get("keyword")+"%"; - dc.add(Restrictions.like("proName",proName, MatchMode.ANYWHERE)); - } - if(cid!=null){ - dc.add(Restrictions.eq("classify.cid",Integer.parseInt(cid))); - } - if(condition!=null){ - int con=Integer.parseInt(condition); - switch(con){ - case 5: - dc.add(Restrictions.eq("type",1)); - break; - case 4: - dc.add(Restrictions.eq("type",0)); - break; - /*case "1": - dc.addOrder(Order.desc("proClicknum")); - break;*/ - case 2: - dc.addOrder(Order.asc("sep")); - break; - case 3: - dc.addOrder(Order.desc("sep")); - break; - } - } - - List list=this.getHibernateTemplate().findByCriteria(dc,Integer.parseInt(map.get("begin")),Integer.parseInt(map.get("pageSize"))); - return list; - } - - - /** - * 查询商品数量 - */ - @SuppressWarnings("unchecked") - @Override - public int searchProductCount(Map map) { - StringBuffer br=new StringBuffer(); - StringBuffer order=new StringBuffer(); - String proName=map.get("keyword"); - String cid=map.get("cid"); - String condition=map.get("conditon"); - String count_hql="select count(*) from Product where 1=1"; - if(proName!=null){ - proName="%"+map.get("keyword")+"%"; - br.append(" and proName like '"+proName+"'"); - } - if(cid!=null){ - br.append(" and classify.cid='"+Integer.parseInt(cid)+"'"); - } - if(condition!=null){ - order.append(" order by createTime DESC"); - int con=Integer.parseInt(condition); - switch(con){ - /*case 1: - order.append(" ,proClicknum DESC"); - break;*/ - case 2: - order.append(" ,proPrice ASC"); - break; - case 3: - order.append(" ,proPrice DESC"); - break; - case 4: - br.append(" and type=0"); - break; - case 5: - br.append(" and type=1"); - break; - - } - } - List list=this.getHibernateTemplate().find(count_hql+br.toString()+order.toString()); - if(list.size()>0){ - return list.get(0).intValue(); - } - return 0; - } - - - /** - * 查询商品详情 - */ - @SuppressWarnings("unchecked") - @Override - public Product getProductDetail(String id) { - int pid=0; - if(id!=null&&id!=""){ - pid=Integer.parseInt(id); - } - String hql=" from Product where id=?"; - List list=this.getHibernateTemplate().find(hql,pid); - if(list.size()>0){ - Product p=list.get(0); - return p; - } - return null; - } - - - - @Override - public Classify getClassifyById(Integer classifyId) { - String hql="from Classify where cid=?"; - @SuppressWarnings("unchecked") - List c=this.getHibernateTemplate().find(hql, classifyId); - if(c.size()>0){ - Classify cla=c.get(0); - return cla; - } - return null; - } - - @Override - public User getUserById(Integer creatorId) { - String hql="from User where uid=?"; - @SuppressWarnings("unchecked") - List u=this.getHibernateTemplate().find(hql, creatorId); - if(u.size()>0){ - User user=u.get(0); - return user; - } - return null; - } - - @Override - public void updateProduct(Product product) { - this.getHibernateTemplate().update(product); - - } - - - -/** - *

    Description: 查询我发布的商品列表数量

    - * @param parseInt - * @return - */ -@Override -public int searchMyProductCount(int uid) { - String hql="select count(*) from Product where user.uid = ?"; - List list=this.getHibernateTemplate().find(hql,uid); - if(list.size()>0){ - return list.get(0).intValue(); - } - return 0; -} - -/** - *

    Description: 查询我发布的商品列表信息

    - * @param map - * @return - */ -@Override -public List getMyProductList(Map map) { - DetachedCriteria dc=DetachedCriteria.forClass(model.Product.class); - dc.add(Restrictions.eq("user.uid",Integer.parseInt(map.get("userId")))); - dc.addOrder(Order.desc("createTime")); - List list=this.getHibernateTemplate().findByCriteria(dc,Integer.parseInt(map.get("begin")),Integer.parseInt(map.get("pageSize"))); - return list; -} - - -/** - *

    Description: 删除我发布的商品

    - * @param pid - */ -@Override -public void delectProductById(int pid) { - Product product=this.getHibernateTemplate().get(Product.class, pid); - if(product!=null){ - this.getHibernateTemplate().delete(product); - } - -} - - - - - -/** - *

    Description: 保存用户消息

    - * @param map - * @return - */ -@Override -public void saveUserMessage(UserAndAdmin uaa) { - this.getHibernateTemplate().save(uaa); -} - -@Override -public int searchMessageCount(int uid, String flag) { - StringBuffer sb=new StringBuffer(); - String hql="select count(*) from UserAndAdmin where 1=1 "; - if(flag=="0"||"0".equals(flag)){ - sb.append(" and status='0' and userId="+uid); - }else{ - sb.append(" and status='1' and userId="+uid); - } - List list=this.getHibernateTemplate().find(hql+sb.toString()); - if(list.size()>0){ - return list.get(0).intValue(); - } - return 0; -} - -@Override -public List getMessageList(Map map) { - DetachedCriteria dc=DetachedCriteria.forClass(model.UserAndAdmin.class); - String flag=map.get("flag"); - if(flag=="0"||"0".equals(flag)){ - dc.add(Restrictions.eq("userId",Integer.parseInt( map.get("userId")))); - dc.add(Restrictions.eq("status",0)); - }else{ - dc.add(Restrictions.eq("userId",Integer.parseInt( map.get("userId")))); - dc.add(Restrictions.eq("status",1)); - } - List list=this.getHibernateTemplate().findByCriteria(dc,Integer.parseInt(map.get("begin")),Integer.parseInt(map.get("pageSize"))); - return list; -} - -/** - * 通过id删除消息 - */ -@Override -public void deleteMessage(int id) { - String hql="delete from UserAndAdmin where id="+id; - SessionFactory factory=this.getHibernateTemplate().getSessionFactory(); - Session session=factory.openSession(); - Query query=session.createQuery(hql); - query.executeUpdate(); - session.close(); - -} - - - - -} diff --git a/secondHandcode/model/Admin.java b/secondHandcode/model/Admin.java deleted file mode 100644 index 66bcfa4..0000000 --- a/secondHandcode/model/Admin.java +++ /dev/null @@ -1,38 +0,0 @@ -package model; - -public class Admin { - - private Integer aid; - private java.lang.String name; - private java.lang.String password; - private java.lang.Integer role;//角色,0超级管理员 1系统管理员 - - public Admin() { - } - public Integer getAid() { - return aid; - } - public void setAid(Integer aid) { - this.aid = aid; - } - public java.lang.String getName() { - return name; - } - public void setName(java.lang.String name) { - this.name = name; - } - public java.lang.String getPassword() { - return password; - } - public void setPassword(java.lang.String password) { - this.password = password; - } - public java.lang.Integer getRole() { - return role; - } - public void setRole(java.lang.Integer role) { - this.role = role; - } - - -} diff --git a/secondHandcode/model/Classify.java b/secondHandcode/model/Classify.java deleted file mode 100644 index 7a546e7..0000000 --- a/secondHandcode/model/Classify.java +++ /dev/null @@ -1,34 +0,0 @@ -package model; - -public class Classify { - - private Integer cid; - private java.lang.String classifyName;//分类名称 - private Integer ClassifySort;//分类排序 - - public Classify() { - } - public Integer getCid() { - return cid; - } - public void setCid(Integer cid) { - this.cid = cid; - } - public java.lang.String getClassifyName() { - return classifyName; - } - public void setClassifyName(java.lang.String classifyName) { - this.classifyName = classifyName; - } - public Integer getClassifySort() { - return ClassifySort; - } - public void setClassifySort(Integer classifySort) { - ClassifySort = classifySort; - } - - - - - -} diff --git a/secondHandcode/model/Product.java b/secondHandcode/model/Product.java deleted file mode 100644 index beeb746..0000000 --- a/secondHandcode/model/Product.java +++ /dev/null @@ -1,106 +0,0 @@ -package model; - -import java.util.Date; -import java.util.HashSet; -import java.util.Set; - -import com.alibaba.fastjson.annotation.JSONField; - -public class Product { - - private Integer id; - private java.lang.String title;//商品名称 - private java.lang.String picture;//商品图片 - @JSONField(format = "yyyy-MM-dd") - private Date createTime;//发布时间 - private Double sep;//现在商品单价 - private Double orp;//原来商品单价 - private java.lang.String miao;//商品描述 - private Integer creatorId;//发布者id - private Integer classifyId;//分类id - private Integer type;//0供信息,1求信息 - private Classify classify;//关联实体类 - private User user;//关联实体类 - - - public Product() { - } - - public Integer getCreatorId() { - return creatorId; - } - - public void setCreatorId(Integer creatorId) { - this.creatorId = creatorId; - } - - public Integer getClassifyId() { - return classifyId; - } - - public void setClassifyId(Integer classifyId) { - this.classifyId = classifyId; - } - - - public Classify getClassify() { - return classify; - } - public void setClassify(Classify classify) { - this.classify = classify; - } - public User getUser() { - return user; - } - public void setUser(User user) { - this.user = user; - } - - public Integer getId() { - return id; - } - public void setId(Integer id) { - this.id = id; - } - public java.lang.String getTitle() { - return title; - } - public void setTitle(java.lang.String title) { - this.title = title; - } - public java.lang.String getPicture() { - return picture; - } - public void setPicture(java.lang.String picture) { - this.picture = picture; - } - public Date getCreateTime() { - return createTime; - } - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - public Double getSep() { - return sep; - } - public void setProPrice(Double sep) { - this.sep = sep; - } - public Double getOrg() { - return orp; - } - public void setOrg(Double orp) { - this.orp = orp; - } - - public Integer getType() { - return type; - } - public void setType(Integer type) { - this.type = type; - } - - - - -} diff --git a/secondHandcode/model/User.java b/secondHandcode/model/User.java deleted file mode 100644 index 8656715..0000000 --- a/secondHandcode/model/User.java +++ /dev/null @@ -1,72 +0,0 @@ -package model; - - -public class User { - - private java.lang.Integer uid; - private java.lang.String userName; - //private java.lang.String headPic; - private java.lang.Integer sex;//性别(男:0 女:1) - private java.lang.String phone; - private java.lang.String qq; - private java.lang.String password; - private java.lang.String qusetion;//密码找回的设置问题 - private java.lang.String answer;//密码找回设置答案 - - - public User() { - } - public java.lang.Integer getUid() { - return uid; - } - public void setUid(java.lang.Integer uid) { - this.uid = uid; - } - public java.lang.String getUserName() { - return userName; - } - public void setUserName(java.lang.String userName) { - this.userName = userName; - } - /*public java.lang.String getHeadPic() { - return headPic; - } - public void setHeadPic(java.lang.String headPic) { - this.headPic = headPic; - }*/ - - public java.lang.Integer getSex() { - return sex; - } - public void setSex(java.lang.Integer sex) { - this.sex = sex; - } - - public java.lang.String getPhone() { - return phone; - } - public void setPhone(java.lang.String phone) { - this.phone = phone; - } - public java.lang.String getPassword() { - return password; - } - public void setPassword(java.lang.String password) { - this.password = password; - } - public java.lang.String getQusetion() { - return qusetion; - } - public void setQusetion(java.lang.String qusetion) { - this.qusetion = qusetion; - } - public java.lang.String getAnswer() { - return answer; - } - public void setAnswer(java.lang.String answer) { - this.answer = answer; - } - - - -} diff --git a/secondHandcode/model/UserAndAdmin.java b/secondHandcode/model/UserAndAdmin.java deleted file mode 100644 index e30ef36..0000000 --- a/secondHandcode/model/UserAndAdmin.java +++ /dev/null @@ -1,54 +0,0 @@ -package model; - -import java.util.Date; - -public class UserAndAdmin { - - private Integer id; - private Integer userId;//接收消息者 - private Integer adminId;//发消息者 - private java.lang.String message; - private Date createTime; - private Integer status;//0系统消息,1用户消息 - - public UserAndAdmin() { - } - public Integer getId() { - return id; - } - public void setId(Integer id) { - this.id = id; - } - public Integer getUserId() { - return userId; - } - public void setUserId(Integer userId) { - this.userId = userId; - } - public Integer getAdminId() { - return adminId; - } - public void setAdminId(Integer adminId) { - this.adminId = adminId; - } - public java.lang.String getMessage() { - return message; - } - public void setMessage(java.lang.String message) { - this.message = message; - } - public Date getCreateTime() { - return createTime; - } - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - public Integer getStatus() { - return status; - } - public void setStatus(Integer status) { - this.status = status; - } - - -} diff --git a/secondHandcode/service/IAdminInfoService.java b/secondHandcode/service/IAdminInfoService.java deleted file mode 100644 index c3c249c..0000000 --- a/secondHandcode/service/IAdminInfoService.java +++ /dev/null @@ -1,135 +0,0 @@ -package service; -import java.util.List; - -import model.Admin; -import model.Classify; -import model.PageBean; -import model.Product; -import model.User; -import model.UserAndAdmin; - -public interface IAdminInfoService { - - /** - * 查询管理员列表 - * @param currPage - * @return - */ - PageBean findAllAdminInfo(int currPage); - - /** - * 查询用户列表 - * @param currPage - * @param name - * @return - */ - PageBean findAllUserInfo(int currPage,String name); - - /** - * 查询分类列表 - * @param currPage - * @param name - * @return - */ - PageBean findAllCateInfo(int currPage, String name); - - /** - * 查询商品列表 - * @param currPage - * @param name - * @param cate - * @param type - * @return - */ - PageBean findAllProductInfo(int currPage, String name, int cate, int type); - - /** - * 分类列表查询 - * @return - */ - List findAllCateList(); - - /** - * 查询商品详情 - * @param pid - * @return - */ - Product searchProductDetail(int pid); - - /** - * 删除商品 - * @param pid - */ - void delectProductById(int pid); - - /** - * 查询用户详情 - * @param uid - * @return - */ - User searchUserDetail(int uid); - - /** - * 删除分类 - * @param id - */ - void delectCateById(int id); - - /** - * 删除管理员 - * @param id - */ - void delectAdminById(int id); - - /** - * 新增管理员 - * @param admin - */ - void addAdmin(Admin admin); - - /** - * 通过账号查询管理员信息 - * @param name - * @return - */ - Admin findAdminByName(String name); - - /** - * 通过id查询管理员信息 - * @param aid - * @return - */ - Admin findAdminById(Integer aid); - - /** - * 修改管理员 - * @param admin - */ - void updateAdmin(Admin admin); - - /** - * 根据分类名称查询分类信息 - * @param classifyName - * @return - */ - Classify findCateByName(String classifyName); - - /** - * 新增分类 - * @param cassify - */ - void addCate(Classify cassify); - - /** - * 修改分类 - * @param cassify - */ - void updateCate(Classify cassify); - - /** - *

    Description: 后台删除商品发送通知给用户

    - * @param uaa - */ - void saveSystemMessage(UserAndAdmin uaa); - -} diff --git a/secondHandcode/service/ILoginService.java b/secondHandcode/service/ILoginService.java deleted file mode 100644 index 406d075..0000000 --- a/secondHandcode/service/ILoginService.java +++ /dev/null @@ -1,53 +0,0 @@ -package service; - -import model.Admin; -import model.User; - -public interface ILoginService { - - /** - * 通过用户名和密码查询用户 - * @param user - * @return - */ - User findByUser(User user); - - /** - * 通过管理员帐户和密码查询管理员 - * @param admin - * @return - */ - Admin findByAdmin(Admin admin); - - /** - * 通过用户名查询用户 - * @param userName - * @return - */ - User findUserByName(String userName); - - /** - * 保存用户信息 - * @param user - */ - void saveUser(User user); - - /** - * 修改用户密码 - * @param user - */ - void updatePed(User user); - - /** - * 通过用户id查询用户信息 - * @param uid - * @return - */ - User searchUserInfoById(int uid); - - /** - * 修改用户信息 - * @param user - */ - void updateUser(User user); -} diff --git a/secondHandcode/service/IUserService.java b/secondHandcode/service/IUserService.java deleted file mode 100644 index fa58922..0000000 --- a/secondHandcode/service/IUserService.java +++ /dev/null @@ -1,94 +0,0 @@ -package service; - -import java.util.List; -import java.util.Map; - -import model.Classify; -import model.PageBean; -import model.Product; -import model.User; -import model.UserAndAdmin; - -public interface IUserService { - - /** - * 发布供求信息 - * @param product - */ - void saveProduct(Product product); - - /** - * 查询分类列表 - * @return - */ - List searchClassifyList(); - - /** - * 查询商品 - * @param map - * @return - */ - PageBean searchProductList(Map map); - - /** - * 查询商品详情 - * @param id - * @return - */ - Product getProductDetail(String id); - - - /** - * 通过分类id获取分类信息 - * @param classifyId - */ - Classify getClassifyById(Integer classifyId); - - User getUserById(Integer creatorId); - - void updateProduct(Product product); - - - - /** - *

    Description: 查询我发布的商品列表信息

    - * @param map - * @return - */ - PageBean searchMyProductByPage(Map map); - - - - /** - *

    Description: 删除我发布的商品

    - * @param pid - */ - void delectProductById(int pid); - - - /** - * 保存用户消息 - * @param uaa - */ - void saveUserMessage(UserAndAdmin uaa); - - /** - * 分页消息 - * @throws Exception - * @param flag 0系统消息,1用户消息 - */ - PageBean searchMessageByPage(Map map); - - /** - * 通过id删除消息 - * @param parseInt - */ - void deleteMessage(int id); - - - - - - - -} diff --git a/secondHandcode/service/impl/AdminInfoService.java b/secondHandcode/service/impl/AdminInfoService.java deleted file mode 100644 index 7f80e10..0000000 --- a/secondHandcode/service/impl/AdminInfoService.java +++ /dev/null @@ -1,279 +0,0 @@ -package service.impl; - -import java.util.List; - -import model.Admin; -import model.Classify; -import model.PageBean; -import model.Product; -import model.User; -import model.UserAndAdmin; - -import org.springframework.transaction.annotation.Transactional; - -import service.IAdminInfoService; -import dao.IAdminInfoDao; -@Transactional -public class AdminInfoService implements IAdminInfoService { - - IAdminInfoDao iAdminInfoDao; - public void setiAdminInfoDao(IAdminInfoDao iAdminInfoDao) { - this.iAdminInfoDao = iAdminInfoDao; - } - /** - * 分页查询管理员列表 - * @param currPage - * @return - */ - @Override - public PageBean findAllAdminInfo(int currPage) { - PageBean pageBean=new PageBean(); - //封装当前页 - pageBean.setCurrPage(currPage); - //封装每页记录数 - int pageSize=3; - pageBean.setPageSize(pageSize); - //封装总记录数 - int totalCount=this.iAdminInfoDao.findAdminCount(); - pageBean.setTotalCount(totalCount); - //封装总页数 - double tc=totalCount; - Double num=Math.ceil(tc/pageSize); - if(num==0){ - num=(double) 1; - } - pageBean.setTotalPage(num.intValue()); - //封装每页显示的数据 - int begin=(currPage-1)*pageSize; - List list=this.iAdminInfoDao.findAllAdminInfo(begin,pageSize); - pageBean.setList(list); - return pageBean; - } - /** - * 分页查询用户列表 - * @param currPage - * @param name - * @return - */ - @Override - public PageBean findAllUserInfo(int currPage,String name) { - PageBean pageBean=new PageBean(); - //封装当前页 - pageBean.setCurrPage(currPage); - //封装每页记录数 - int pageSize=10; - pageBean.setPageSize(pageSize); - //封装总记录数 - int totalCount=this.iAdminInfoDao.findUserCount(name); - pageBean.setTotalCount(totalCount); - //封装总页数 - double tc=totalCount; - Double num=Math.ceil(tc/pageSize); - if(num==0){ - num=(double) 1; - } - pageBean.setTotalPage(num.intValue()); - //封装每页显示的数据 - int begin=(currPage-1)*pageSize; - List list=this.iAdminInfoDao.findAllUserInfo(begin,pageSize,name); - pageBean.setList(list); - return pageBean; - } - /** - * 分页查询分类列表 - * @param currPage - * @param name - * @return - */ - @Override - public PageBean findAllCateInfo(int currPage, String name) { - PageBean pageBean=new PageBean(); - //封装当前页 - pageBean.setCurrPage(currPage); - //封装每页记录数 - int pageSize=5; - pageBean.setPageSize(pageSize); - //封装总记录数 - int totalCount=this.iAdminInfoDao.findCateCount(name); - pageBean.setTotalCount(totalCount); - //封装总页数 - double tc=totalCount; - Double num=Math.ceil(tc/pageSize); - if(num==0){ - num=(double) 1; - } - pageBean.setTotalPage(num.intValue()); - //封装每页显示的数据 - int begin=(currPage-1)*pageSize; - List list=this.iAdminInfoDao.findAllCateInfo(begin,pageSize,name); - pageBean.setList(list); - return pageBean; - } - /** - * 分页 查询商品列表 - * @param currPage - * @param name - * @param cate - * @param type - * @return - */ - @Override - public PageBean findAllProductInfo(int currPage, String name,int cate,int type) { - PageBean pageBean=new PageBean(); - //封装当前页 - pageBean.setCurrPage(currPage); - //封装每页记录数 - int pageSize=10; - pageBean.setPageSize(pageSize); - //封装总记录数 - int totalCount=this.iAdminInfoDao.findProductCount(name,cate,type); - pageBean.setTotalCount(totalCount); - //封装总页数 - double tc=totalCount; - Double num=Math.ceil(tc/pageSize); - if(num==0){ - num=(double) 1; - } - pageBean.setTotalPage(num.intValue()); - //封装每页显示的数据 - int begin=(currPage-1)*pageSize; - List list=this.iAdminInfoDao.findAllProductInfo(begin,pageSize,name,cate,type); - pageBean.setList(list); - return pageBean; - } - - /** - * 分类列表查询,用于下列展示 - * @return - */ - @Override - public List findAllCateList() { - List cateList=this.iAdminInfoDao.findAllCateList(); - return cateList; - } - /** - * 通过id查询商品详情 - * @param pid - * @return - */ - @Override - public Product searchProductDetail(int pid) { - Product product=this.iAdminInfoDao.searchProductDetail(pid); - return product; - } - /** - * 通过id删除商品 - * @param pid - */ - @Override - public void delectProductById(int pid) { - this.iAdminInfoDao.delectProductById(pid); - - } - /** - * 通过id查询用户详情 - * @param uid - * @return - */ - @Override - public User searchUserDetail(int uid) { - User u=this.iAdminInfoDao.searchUserDetail(uid); - return u; - } - /** - * 通过id删除分类 - * @param id - */ - @Override - public void delectCateById(int id) { - this.iAdminInfoDao.delectCateById(id); - - } - /** - * 通过id删除管理员 - * @param id - */ - @Override - public void delectAdminById(int id) { - this.iAdminInfoDao.delectAdminById(id); - - } - /** - * 新增管理员 - * @param admin - */ - @Override - public void addAdmin(Admin admin) { - this.iAdminInfoDao.addAdmin(admin); - - } - /** - * 通过管理员账号查询管理员信息 - * @param name - * @return - */ - @Override - public Admin findAdminByName(String name) { - - return this.iAdminInfoDao.findAdminByName(name); - } - /** - * 通过id查询管理员信息 - * @param aid - * @return - */ - @Override - public Admin findAdminById(Integer aid) { - - return this.iAdminInfoDao.findAdminById(aid); - } - /** - * 修改管理员 - * @param admin - */ - @Override - public void updateAdmin(Admin admin) { - this.iAdminInfoDao.updateAdmin(admin); - - } - /** - * 根据分类名称查询分类信息 - * @param classifyName - * @return - */ - @Override - public Classify findCateByName(String classifyName) { - Classify c=this.iAdminInfoDao.findCateByName(classifyName); - return c; - } - /** - * 新增分类 - * @param cassify - */ - @Override - public void addCate(Classify cassify) { - this.iAdminInfoDao.addCate(cassify); - - } - /** - * 修改分类 - * @param cassify - */ - @Override - public void updateCate(Classify cassify) { - this.iAdminInfoDao.updateCate(cassify); - - } - /** - *

    Description: 后台删除商品发送通知给用户

    - * @param uaa - */ - @Override - public void saveSystemMessage(UserAndAdmin uaa) { - this.iAdminInfoDao.saveSystemMessage(uaa); - - } - - - -} diff --git a/secondHandcode/service/impl/LoginService.java b/secondHandcode/service/impl/LoginService.java deleted file mode 100644 index 5f96342..0000000 --- a/secondHandcode/service/impl/LoginService.java +++ /dev/null @@ -1,79 +0,0 @@ -package service.impl; - -import org.springframework.transaction.annotation.Transactional; - -import dao.ILoginDao; -import model.Admin; -import model.User; -import service.ILoginService; -@Transactional -public class LoginService implements ILoginService{ - - private ILoginDao iLoginDao; - - public void setiLoginDao(ILoginDao iLoginDao) { - this.iLoginDao = iLoginDao; - } - - /** - * 通过用户帐户和密码查询用户 - */ - @Override - public User findByUser(User user) { - return iLoginDao.findByUser(user); - } - - /** - * 通过管理员帐户和密码查询管理员 - */ - @Override - public Admin findByAdmin(Admin admin) { - return iLoginDao.findByAdmin(admin); - } - - /** - * 通过用户名查询用户 - */ - @Override - public User findUserByName(String userName) { - return this.iLoginDao.findUserByName(userName); - } - - /** - * 保存用户信息 - */ - @Override - public void saveUser(User user) { - this.iLoginDao.saveUser(user); - } - - /** - * 修改用户密码 - */ - @Override - public void updatePed(User user) { - this.iLoginDao.updatePed(user); - - } - - /** - * 通过用户id查询用户信息 - */ - @Override - public User searchUserInfoById(int uid) { - - return this.iLoginDao.searchUserInfoById(uid); - } - - /** - * 修改用户信息 - */ - @Override - public void updateUser(User user) { - this.iLoginDao.updateUser(user); - - } - - - -} diff --git a/secondHandcode/service/impl/UserService.java b/secondHandcode/service/impl/UserService.java deleted file mode 100644 index 56d77f3..0000000 --- a/secondHandcode/service/impl/UserService.java +++ /dev/null @@ -1,210 +0,0 @@ -package service.impl; - -import java.util.List; -import java.util.Map; - -import model.Classify; -import model.PageBean; -import model.Product; -import model.User; -import model.UserAndAdmin; - -import org.springframework.transaction.annotation.Transactional; - -import service.IUserService; -import dao.IUserDao; -@Transactional -public class UserService implements IUserService { - - private IUserDao iUserDao; - - public void setiUserDao(IUserDao iUserDao) { - this.iUserDao = iUserDao; - } - Integer currPage=1; - /** - * 发布供求信息 - */ - @Override - public void saveProduct(Product product) { - this.iUserDao.saveProduct(product); - - } - - /** - * 查询分类列表 - */ - @Override - public List searchClassifyList() { - - return this.iUserDao.searchClassifyList(); - } - - /** - * 查询商品 - */ - @Override - public PageBean searchProductList(Map map) { - PageBean pageBean=new PageBean(); - //封装当前页 - currPage=Integer.parseInt(map.get("currPage")); - pageBean.setCurrPage(currPage); - //封装每页记录数 - int pageSize=12; - pageBean.setPageSize(pageSize); - //封装总记录数 - int totalCount=this.iUserDao.searchProductCount(map); - pageBean.setTotalCount(totalCount); - //封装总页数 - double tc=totalCount; - Double num=Math.ceil(tc/pageSize); - if(num==0){ - num=(double) 1; - } - pageBean.setTotalPage(num.intValue()); - //封装每页显示的数据 - int begin=(currPage-1)*pageSize; - map.put("begin", begin+""); - map.put("pageSize", pageSize+""); - List list=this.iUserDao.searchProductList(map); - pageBean.setList(list); - return pageBean; - - } - - /** - * 查询商品详情 - */ - @Override - public Product getProductDetail(String id) { - - return this.iUserDao.getProductDetail(id); - } - - - - @Override - public Classify getClassifyById(Integer classifyId) { - return this.iUserDao.getClassifyById(classifyId); - - } - - @Override - public User getUserById(Integer creatorId) { - - return this.iUserDao.getUserById(creatorId); - } - - @Override - public void updateProduct(Product product) { - this.iUserDao.updateProduct(product); - - } - - - - - /** - *

    Description: 查询我发布的商品列表信息

    - * @param map - * @return - */ - @Override - public PageBean searchMyProductByPage(Map map) { - PageBean pageBean=new PageBean(); - //封装当前页 - currPage=Integer.parseInt(map.get("currPage")); - pageBean.setCurrPage(currPage); - //封装每页记录数 - int pageSize=5; - pageBean.setPageSize(pageSize); - //封装总记录数 - int totalCount=this.iUserDao.searchMyProductCount(Integer.parseInt(map.get("userId"))); - pageBean.setTotalCount(totalCount); - //封装总页数 - double tc=totalCount; - Double num=Math.ceil(tc/pageSize); - if(num==0){ - num=(double) 1; - } - pageBean.setTotalPage(num.intValue()); - //封装每页显示的数据 - int begin=(currPage-1)*pageSize; - map.put("begin", begin+""); - map.put("pageSize", pageSize+""); - List list=this.iUserDao.getMyProductList(map); - pageBean.setList(list); - return pageBean; - } - - - - /** - *

    Description: 删除我发布的商品

    - * @param pid - */ - @Override - public void delectProductById(int pid) { - this.iUserDao.delectProductById(pid); - - } - - - - /** - * 保存用户消息 - * @param uaa - */ - @Override - public void saveUserMessage(UserAndAdmin uaa) { - this.iUserDao.saveUserMessage(uaa); - } - - /** - * 分页消息 - * @throws Exception - * @param flag 0系统消息,1用户消息 - */ - @Override - public PageBean searchMessageByPage(Map map) { - PageBean pageBean=new PageBean(); - //封装当前页 - currPage=Integer.parseInt(map.get("currPage")); - pageBean.setCurrPage(currPage); - //封装每页记录数 - int pageSize=10; - pageBean.setPageSize(pageSize); - //封装总记录数 - int totalCount=this.iUserDao.searchMessageCount(Integer.parseInt(map.get("userId")),map.get("flag")); - pageBean.setTotalCount(totalCount); - //封装总页数 - double tc=totalCount; - Double num=Math.ceil(tc/pageSize); - if(num==0){ - num=(double) 1; - } - pageBean.setTotalPage(num.intValue()); - //封装每页显示的数据 - int begin=(currPage-1)*pageSize; - map.put("begin", begin+""); - map.put("pageSize", pageSize+""); - List list=this.iUserDao.getMessageList(map); - pageBean.setList(list); - return pageBean; - } - - /** - * 通过id删除消息 - */ - @Override - public void deleteMessage(int id) { - this.iUserDao.deleteMessage(id); - - } - - - - - - -} diff --git a/secondHandcode/util/AddJson.java b/secondHandcode/util/AddJson.java deleted file mode 100644 index dc248f6..0000000 --- a/secondHandcode/util/AddJson.java +++ /dev/null @@ -1,99 +0,0 @@ -package util; - -import java.io.IOException; -import java.io.Writer; -import java.util.List; - -import javax.servlet.http.HttpServletResponse; - -import org.apache.struts2.ServletActionContext; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.serializer.SerializerFeature; -import com.alibaba.fastjson.serializer.ValueFilter; -import com.opensymphony.xwork2.ActionSupport; - -/** - * 将数据转成json数据格式 - * - */ -public class AddJson extends ActionSupport{ - - private static final long serialVersionUID = 1L; - - private static ValueFilter filter = new ValueFilter() { - @Override - public Object process(Object obj, String s, Object v) { - if (v == null) - return ""; - return v; - } - }; - /** - * 将JavaBean序列化为JSON文本 - * @param str - * @throws IOException - */ - public void toJson(Object str) throws IOException{ - HttpServletResponse response=ServletActionContext.getResponse(); - response.setHeader("Cache-Control", "no-cache"); - response.setHeader("Pragma", "no-cache"); - response.setDateHeader("Expires", 0); - response.setContentType("text/html;charset=utf-8"); - - String responseStr = JSON.toJSONString(str,filter,SerializerFeature.WriteNullStringAsEmpty); - Writer writer = response.getWriter(); - writer.write(responseStr); - writer.flush(); - } - /** - * 将JavaBean转换为JSONObject - * @param str - * @throws IOException - */ - public void toJsonObj(Object str) throws IOException{ - HttpServletResponse response=ServletActionContext.getResponse(); - response.setHeader("Cache-Control", "no-cache"); - response.setHeader("Pragma", "no-cache"); - response.setDateHeader("Expires", 0); - response.setContentType("text/html;charset=utf-8"); - - Object responseStr = JSON.toJSON(str); - Writer writer = response.getWriter(); - writer.write(responseStr.toString()); - writer.flush(); - } - /** - * 将JavaBean转换为JSONArray - * @param list - * @throws IOException - */ - public void toJsonArray(List list) throws IOException{ - HttpServletResponse response=ServletActionContext.getResponse(); - response.setHeader("Cache-Control", "no-cache"); - response.setHeader("Pragma", "no-cache"); - response.setDateHeader("Expires", 0); - response.setContentType("text/html;charset=utf-8"); - - Object obj = JSON.toJSON(list); - Writer writer = response.getWriter(); - writer.write("{\"length\":"+list.size()+" ,"); - writer.write("\"data\":"+obj.toString()+"}"); - writer.flush(); - } - - public void toJsonList(int len,List list) throws IOException{ - HttpServletResponse response=ServletActionContext.getResponse(); - response.setHeader("Cache-Control", "no-cache"); - response.setHeader("Pragma", "no-cache"); - response.setDateHeader("Expires", 0); - response.setContentType("text/html;charset=utf-8"); - - String responseStr = JSON.toJSONString(list,filter); - Writer writer = response.getWriter(); - //writer.write(responseStr); - writer.write("{\"length\":"+len+" ,"); - writer.write("\"data\":"+responseStr+"}"); - writer.flush(); - } -} diff --git a/src/HelloServlet.java b/src/HelloServlet.java index 3b0a586..5706580 100644 --- a/src/HelloServlet.java +++ b/src/HelloServlet.java @@ -41,6 +41,8 @@ public class HelloServlet extends HttpServlet { }catch(NumberFormatException e){ }*/ Session session=HibernateSessionFactory.getSession(); + + Transaction tx=null; List xz=null; try{ diff --git a/src/NavigationServlet.java b/src/NavigationServlet.java new file mode 100644 index 0000000..d0c2b0b --- /dev/null +++ b/src/NavigationServlet.java @@ -0,0 +1,59 @@ +import java.io.IOException; + + +import java.io.PrintWriter; +import java.util.List; +import java.util.Map; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.Xztype; + +import org.hibernate.HibernateException; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; + +import com.HibernateSessionFactory; +import com.Xz; + + +public class NavigationServlet extends HttpServlet { + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + navigate( request, response); + } + + public void navigate(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + int xtid=Integer.parseInt(request.getParameter("id")); + /* try{ + xid=Integer.parseInt(request.getParameter("id")); + }catch(NumberFormatException e){ + }*/ + Session session=HibernateSessionFactory.getSession(); + Transaction tx=null; + List xztype=null; + try{ + tx=session.beginTransaction(); + Query query=session.createQuery("FROM Xztype xztype where xztype.id=:xtid"); + query.setParameter("xtid", Integer.parseInt(request.getParameter("id"))); + xztype=query.list(); + tx.commit(); + }catch(HibernateException e){ + if(tx!=null) tx.rollback(); + e.printStackTrace(); + }finally{ + session.close(); + } + if(xztype!=null){ + request.setAttribute("xztype", xztype); + RequestDispatcher rd=request.getRequestDispatcher("ckxz.jsp"); + rd.forward(request, response); + } + } +} diff --git a/src/PagingServlet.java b/src/PagingServlet.java new file mode 100644 index 0000000..665704d --- /dev/null +++ b/src/PagingServlet.java @@ -0,0 +1,88 @@ +import java.io.IOException; + +import java.io.PrintWriter; +import java.util.List; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.hibernate.HibernateException; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.Transaction; + +import com.HibernateSessionFactory; +import com.Xztype; +import com.Xz; + + +public class PagingServlet extends HttpServlet { + + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + paging( request, response); + } + + public void paging(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // int typeid=Integer.parseInt(request.getParameter("typeid")); + // int pageid=Integer.parseInt(request.getParameter("pageid")); + + /* try{ + xid=Integer.parseInt(request.getParameter("id")); + }catch(NumberFormatException e){ + }*/ + Session session=HibernateSessionFactory.getSession(); + Transaction tx=null; + + int typeid;//ǰ˴id + int pageid;//ǰ˴ҳid + int xzCount=0;//ظǰбƷ + List xz=null;//ظǰбƷб + + //ijxzƷselect count(*) from xz where typeid=:typeid + //ijijΧҳ-1*ÿҳƷϢselect * from xz where typeid=:typeid limit (pageid-1)*10,(pageid-1)*10+9 + + try{ + tx=session.beginTransaction(); +// Query queryXzCount=session.createQuery("SELECT count(*) FROM Xz xz where typeid=:typeid"); +// queryXzCount.setParameter("typeid", Integer.parseInt(request.getParameter("typeid"))); +// queryXzCount.setParameter("typeid", 1); +// xzCount=((Number)queryXzCount.uniqueResult()).intValue();//ǿת + + +// Query queryXz=session.createQuery("SELECT * FROM Xz xz where typeid=:typeid limit (:pageid-1)*10,(:pageid-1)*10+9"); + + +// String hql = "SELECT * FROM Xz xz where typeid=:typeid"; + + Query queryXz = session.createQuery("FROM Xz xz where typeid=:typeid"); + + queryXz.setParameter("typeid", 1); + queryXz.setMaxResults(10); //ûȡ + queryXz.setFirstResult(0); //ôӵڼʼȡ + +// queryXz.setParameter("pageid", Integer.parseInt(request.getParameter("pageid"))); +// queryXz.setParameter("pageid", 1); + xz=queryXz.list(); + + tx.commit(); + }catch(HibernateException e){ + if(tx!=null) tx.rollback(); + e.printStackTrace(); + }finally{ + session.close(); + } + if(xzCount!=0){ +// request.setAttribute("xzCount", xzCount); +// request.setAttribute("xz", xz); +System.out.println(xz); + RequestDispatcher rd=request.getRequestDispatcher("ckxz.jsp"); + rd.forward(request, response); + } + } + +} diff --git a/src/RegisterAction.java b/src/RegisterAction.java index 91f672c..b146bdc 100644 --- a/src/RegisterAction.java +++ b/src/RegisterAction.java @@ -3,14 +3,21 @@ import java.util.List; + + import javax.persistence.Entity; import javax.persistence.ManyToOne; +import javax.servlet.http.HttpSession; +import javax.servlet.http.HttpServletRequest; + +import org.apache.struts2.ServletActionContext; import org.hibernate.Transaction; import org.hibernate.Query; import org.hibernate.Session; import com.HibernateSessionFactory; import com.Userinfo; +import com.Xz; import com.opensymphony.xwork2.ActionSupport; @@ -18,7 +25,11 @@ import com.opensymphony.xwork2.ActionSupport; public class RegisterAction extends ActionSupport { @ManyToOne private Userinfo user; + static int getUserid; +//HttpServletRequest request = ServletActionContext.getRequest(); + +//HttpSession session2; public Userinfo getUser() { return user; } @@ -27,6 +38,15 @@ public class RegisterAction extends ActionSupport { this.user = user; } + private Xz xz; + + public Xz getXz() { + return xz; + } + + public void setXz(Xz xz) { + this.xz = xz; + } @Override public String execute() throws Exception { // TODO Auto-generated method stub @@ -53,11 +73,19 @@ public class RegisterAction extends ActionSupport { Query query = session.createQuery("from Userinfo where username=:uname and password=:upassword"); query.setParameter("uname", user.getUsername()); query.setParameter("upassword", user.getPassword()); - List list=query.list(); - + List list=query.list(); + System.out.println(list); tx.commit(); if(list.size()>0){ + // Session session=HibernateSessionFactory.getSession(); + for(int i=0;i { - private int currPage;//当前页 - private int pageSize;//每页记录数 + private int currPage;//当前? + private int pageSize;//每页记录? private int totalCount;//总记录数 - private int totalPage;//总页数 - List list;//每页显示的数据 + private int totalPage;//总页? + List list;//每页显示的数? public PageBean() { } diff --git a/src/com/Xz.hbm.xml b/src/com/Xz.hbm.xml index 9c8ff51..913fff6 100644 --- a/src/com/Xz.hbm.xml +++ b/src/com/Xz.hbm.xml @@ -34,5 +34,11 @@ + + + + + + diff --git a/src/com/Xz.java b/src/com/Xz.java index b3a5ab5..d2c23d2 100644 --- a/src/com/Xz.java +++ b/src/com/Xz.java @@ -12,14 +12,14 @@ public class Xz extends AbstractXz implements java.io.Serializable { } /** minimal constructor */ - public Xz(Integer id, String title, Integer sep) { - super(id, title, sep); + public Xz(Integer id, String title, Integer sep,Integer userid) { + super(id, title, sep,userid); } /** full constructor */ public Xz(String title, String miao, Integer sep, Integer orp, - String postage, String wx, String tel, String qq) { - super(title, miao, sep, orp, postage, wx, tel, qq); + String postage, String wx, String tel, String qq,Integer userid,Integer typeid) { + super(title, miao, sep, orp, postage, wx, tel, qq,userid,typeid); } } diff --git a/src/com/Xztype.hbm.xml b/src/com/Xztype.hbm.xml new file mode 100644 index 0000000..6efaca8 --- /dev/null +++ b/src/com/Xztype.hbm.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + diff --git a/src/com/Xztype.java b/src/com/Xztype.java new file mode 100644 index 0000000..7f2e7f1 --- /dev/null +++ b/src/com/Xztype.java @@ -0,0 +1,19 @@ +package com; + +/** + * Xztype entity. @author MyEclipse Persistence Tools + */ +public class Xztype extends AbstractXztype implements java.io.Serializable { + + // Constructors + + /** default constructor */ + public Xztype() { + } + + /** full constructor */ + public Xztype(String name) { + super(name); + } + +} diff --git a/src/hibernate.cfg.xml b/src/hibernate.cfg.xml index bd907a2..8e0e862 100644 --- a/src/hibernate.cfg.xml +++ b/src/hibernate.cfg.xml @@ -25,6 +25,7 @@ + diff --git a/src/struts.xml b/src/struts.xml index 4e55a43..2f8c4e0 100644 --- a/src/struts.xml +++ b/src/struts.xml @@ -19,7 +19,7 @@ /welcome.jsp /success.jsp - + /welcome.jsp /success.jsp