From d168407882309a279228edacad68b30f8815643a Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Mon, 8 Jun 2020 05:25:19 +0800 Subject: [PATCH] =?UTF-8?q?2=E3=80=81=E7=94=B3=E8=AF=B7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebRoot/admin/applylist2.jsp | 129 ++++++++++-------- src/com/app/action/AppAction.java | 15 +- src/com/app/action/ApplyAction.java | 106 +++++++------- src/com/app/bean/Apply.hbm.xml | 2 +- src/com/app/bean/Apply.java | 29 ++-- src/com/app/bean/RefuseApply.java | 59 ++++++++ src/com/app/service/ApplyServiceImpl.java | 3 +- src/com/app/service/RefuseApplyService.java | 7 + .../app/service/RefuseApplyServiceImpl.java | 28 ++++ 9 files changed, 237 insertions(+), 141 deletions(-) create mode 100644 src/com/app/bean/RefuseApply.java create mode 100644 src/com/app/service/RefuseApplyService.java create mode 100644 src/com/app/service/RefuseApplyServiceImpl.java diff --git a/WebRoot/admin/applylist2.jsp b/WebRoot/admin/applylist2.jsp index 1489512..ec307a3 100644 --- a/WebRoot/admin/applylist2.jsp +++ b/WebRoot/admin/applylist2.jsp @@ -26,7 +26,14 @@ String usertype = session.getAttribute("userType")+""; + + @@ -58,15 +65,13 @@ String usertype = session.getAttribute("userType")+""; - - - - - - - - - +<%-- 申请人id、申请人姓名、申请社区、申请房源、申请资料--%> + + + + + + @@ -76,66 +81,40 @@ String usertype = session.getAttribute("userType")+""; - - - - - + ${item.userid} +<%-- ${item.hs.rooname}--%> + + + + + - - - - + +
房源大小类型价格申请人上传资料备注申请时间状态申请人id申请人姓名申请社区申请房源申请资料 操作
- - ${item.hs.rooname} - ${item.hs.size} ${item.hs.cate} ${item.hs.price}元/月 - - ${item.user.username}/ - ${item.user.realname}${USERS_MAP[item.userid].username}${item.name}${item.cate} - - 查看 - +<%-- --%> +<%-- 查看 --%> +<%-- --%> - 查看 - ${item.created} - - - 待街道审核 - - - 街道审核通过 - - - 街道审核不通过 - - - - 市级审核通过 - - - 市级审核不通过 - - - + 通过 - - - 不通过 - + + + 不通过 + - - - - 不通过 - + + + + 不通过 + - + 通过 @@ -209,7 +188,39 @@ $(document).ready(function(){ - + diff --git a/src/com/app/action/AppAction.java b/src/com/app/action/AppAction.java index c2b640b..304b0ed 100644 --- a/src/com/app/action/AppAction.java +++ b/src/com/app/action/AppAction.java @@ -135,22 +135,13 @@ public class AppAction { return "success"; } - public List getInfo(List list) { - if (list.size() > 0) { - for (Apply apply : list) { - apply.setUser(usersService.findById(Integer.parseInt(apply - .getUserid()))); - apply.setHs(houseService.findById(apply.getHid())); - } - } - return list; - } + public String pub() { ActionContext act = ActionContext.getContext(); List list = applyService.list(); act.put("cates", getCate()); - act.put("list", getInfo(list)); + act.put("list", list); return "success"; } public String jb() { @@ -172,7 +163,7 @@ public class AppAction { model.setPid(u.getPid()); model.setCid(Integer.parseInt(u.getCid())); model.setAid(Integer.parseInt(u.getAid())); - model.setUserid(u.getId()+""); + model.setUserid(u.getId()); model.setState("1"); model.setType("1"); model.setCreated(MainUtils.getTime()); diff --git a/src/com/app/action/ApplyAction.java b/src/com/app/action/ApplyAction.java index 9d3c3fd..c61b066 100644 --- a/src/com/app/action/ApplyAction.java +++ b/src/com/app/action/ApplyAction.java @@ -1,18 +1,16 @@ package com.app.action; -import com.app.bean.Apply; -import com.app.bean.House; -import com.app.bean.Report; -import com.app.bean.Users; +import com.app.bean.*; import com.app.service.*; +import com.app.utils.Constants; import com.opensymphony.xwork2.ActionContext; import org.apache.struts2.ServletActionContext; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import java.util.ArrayList; import java.util.List; @Controller @@ -20,6 +18,16 @@ import java.util.List; public class ApplyAction { @Resource ApplyService applyService; + + + @Resource + UsersService usersService; + @Resource + HouseService houseService; + + @Autowired + private RefuseApplyService refuseApplyService; + public int id; public void setId(int id) { @@ -42,13 +50,13 @@ public class ApplyAction { return pid; } - public String userid; + public Integer userid; - public void setUserid(String userid) { + public void setUserid(Integer userid) { this.userid = userid; } - public String getUserid() { + public Integer getUserid() { return userid; } @@ -171,7 +179,7 @@ public class ApplyAction { for (Report report : list) { Apply apply = applyService.findById(Integer.parseInt(report.getMid())); report.setUser(usersService.findById(Integer.parseInt(report.getUserid())).getUsername()); - Users u = usersService.findById(Integer.parseInt(apply.getUserid())); + Users u = usersService.findById(apply.getUserid()); House h = houseService.findById(apply.getHid()); report.setTitle(u.getUsername()+""+h.getRooname()); } @@ -183,7 +191,7 @@ public class ApplyAction { @Resource CatesService catesService; public String report() { - ActionContext act = ActionContext.getContext(); + ActionContext act = ActionContext.getContext(); act.put("n1", usersService.list().size()); act.put("n2", catesService.list().size()); act.put("n3", newsService.list().size()); @@ -195,19 +203,28 @@ public class ApplyAction { public String pass() { ActionContext act = ActionContext.getContext(); + HttpServletRequest request= ServletActionContext.getRequest(); Apply model = applyService.findById(id); House hs = houseService.findById(model.getHid()); - if (statex.equals("6")) + if ("6".equals(statex)) { hs.setState(1); - if (statex.equals("5")) + RefuseApply refuseApply=new RefuseApply(); + refuseApply.setApplyId(id); + refuseApply.setContent(request.getParameter("content")); + refuseApplyService.save(refuseApply); + } + if ("5".equals(statex)) { hs.setState(2); + } houseService.update(hs); model.setState(statex); applyService.update(model); - act.put("message", "ɹ!"); + act.put("url", "admin/apply/" + ret + ".do"); + act.put("message", "ɹ!"); act.put("state", "success"); - return "success"; + return Constants.SUCCESS; + } public String ret; @@ -223,61 +240,42 @@ public class ApplyAction { public String applyList() { ActionContext act = ActionContext.getContext(); Users u = (Users) act.getSession().get("users"); - List list = applyService.list(" FROM Apply where userid=" - + u.getId()); - act.put("list", getInfo(list)); + List list = applyService.list("select a.id as id,a.userid as userid,h.cate as cate,c.name as name,a.state as state " + + "FROM Apply a,House h,Community c,Users u where a.userid="+ u.getId()+"and a.hid=h.id and h.communityId=c.id and a.userid=u.id "); + act.put("list", list); + act.put(Constants.USERS_MAP,ConstantsService.getUsersMap()); return "success"; } public String applyList1() { ActionContext act = ActionContext.getContext(); Users u = (Users) act.getSession().get("users"); - String wh = " pid=" + u.getPid() + " AND cid=" + u.getCid() - + " AND aid=" + u.getAid(); - List list = applyService.list(" FROM Apply where " + wh); + String wh = " a.pid=" + u.getPid() + " AND a.cid=" + u.getCid() + + " AND a.aid=" + u.getAid(); + List list = applyService.list("select a.id as id,a.userid as userid,h.cate as cate,c.name as name,a.state as state FROM " + + "Apply a,House h,Community c,Users u where " + wh+" and a.hid=h.id and h.communityId=c.id and a.userid=u.id "); - act.put("list", getInfo(list)); + act.put("list", list); + act.put(Constants.USERS_MAP,ConstantsService.getUsersMap()); return "success"; } - @Resource - UsersService usersService; - @Resource - HouseService houseService; - - public List getInfo(List list) { - if (list.size() > 0) { - for (Apply apply : list) { - apply.setUser(usersService.findById(Integer.parseInt(apply - .getUserid()))); - apply.setHs(houseService.findById(apply.getHid())); - } - } - //ҳģѯĽ - HttpServletRequest request = ServletActionContext.getRequest(); - String applyname = request.getParameter("applyname"); - if (applyname!=null&&!"".equals(applyname.trim())&&list.size()>0) { - List applyList=new ArrayList(); - for (Apply apply : list) { - Users user = apply.getUser(); - if (user!=null) { - String realname = user.getRealname(); - if (realname!=null&&realname.contains(applyname)) { - applyList.add(apply); - } - } - } - return applyList; - } - return list; - } public String applyList2() { ActionContext act = ActionContext.getContext(); + HttpServletRequest request=ServletActionContext.getRequest(); Users u = (Users) act.getSession().get("users"); - List list = applyService.list(); - act.put("list", getInfo(list)); + String whereSql=""; + if(request.getParameterMap().containsKey("applyname")){ + whereSql=" and u.username like '%"+request.getParameter("applyname")+"%'"; + } + + + List list = applyService.list("select a.id as id,a.userid as userid,h.cate as cate,c.name as name," + + "a.state as state FROM Apply a,House h,Community c,Users u where a.hid=h.id and h.communityId=c.id and a.userid=u.id "+whereSql); + act.put("list", list); + act.put(Constants.USERS_MAP,ConstantsService.getUsersMap()); return "success"; } diff --git a/src/com/app/bean/Apply.hbm.xml b/src/com/app/bean/Apply.hbm.xml index a072549..387402c 100644 --- a/src/com/app/bean/Apply.hbm.xml +++ b/src/com/app/bean/Apply.hbm.xml @@ -7,7 +7,7 @@ - + diff --git a/src/com/app/bean/Apply.java b/src/com/app/bean/Apply.java index 20e12d9..7c1d1fd 100644 --- a/src/com/app/bean/Apply.java +++ b/src/com/app/bean/Apply.java @@ -7,24 +7,25 @@ public class Apply { public int cid; public int aid; public String message; - public Users user; - public House hs; - - public Users getUser() { - return user; + private String cate; + private String name; + + public String getCate() { + return cate; } - public void setUser(Users user) { - this.user = user; + + public void setCate(String cate) { + this.cate = cate; } - public House getHs() { - return hs; + public String getName() { + return name; } - public void setHs(House hs) { - this.hs = hs; + public void setName(String name) { + this.name = name; } public String getMessage() { @@ -69,13 +70,13 @@ public class Apply { return pid; } - public String userid; + public Integer userid; - public void setUserid(String userid) { + public void setUserid(Integer userid) { this.userid = userid; } - public String getUserid() { + public Integer getUserid() { return userid; } diff --git a/src/com/app/bean/RefuseApply.java b/src/com/app/bean/RefuseApply.java new file mode 100644 index 0000000..255c70a --- /dev/null +++ b/src/com/app/bean/RefuseApply.java @@ -0,0 +1,59 @@ +package com.app.bean; + +import javax.persistence.*; +import java.util.Objects; + +@Entity +@Table(name = "refuse_apply", schema = "dbo", catalog = "gzf") +public class RefuseApply { + private Integer id; + private Integer applyId; + private String content; + + @Id + @Column(name = "id") + @SequenceGenerator(name="increment") + @GeneratedValue(strategy=GenerationType.IDENTITY) + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + @Basic + @Column(name = "apply_id") + public Integer getApplyId() { + return applyId; + } + + public void setApplyId(Integer applyId) { + this.applyId = applyId; + } + + @Basic + @Column(name = "content") + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + RefuseApply that = (RefuseApply) o; + return Objects.equals(id, that.id) && + Objects.equals(applyId, that.applyId) && + Objects.equals(content, that.content); + } + + @Override + public int hashCode() { + return Objects.hash(id, applyId, content); + } +} diff --git a/src/com/app/service/ApplyServiceImpl.java b/src/com/app/service/ApplyServiceImpl.java index 9b16573..90be0c3 100644 --- a/src/com/app/service/ApplyServiceImpl.java +++ b/src/com/app/service/ApplyServiceImpl.java @@ -3,6 +3,7 @@ package com.app.service; import com.app.bean.Apply; import org.hibernate.Query; import org.hibernate.SessionFactory; +import org.hibernate.transform.Transformers; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -37,7 +38,7 @@ public class ApplyServiceImpl implements ApplyService { } public List list(String where) { - return factory.getCurrentSession().createQuery(where).list(); + return factory.getCurrentSession().createQuery(where).setResultTransformer(Transformers.aliasToBean(Apply.class)).list(); } public List list(String where, String[] param) { diff --git a/src/com/app/service/RefuseApplyService.java b/src/com/app/service/RefuseApplyService.java new file mode 100644 index 0000000..4c7ce1e --- /dev/null +++ b/src/com/app/service/RefuseApplyService.java @@ -0,0 +1,7 @@ +package com.app.service; + +import com.app.bean.RefuseApply; + +public interface RefuseApplyService { + boolean save(RefuseApply refuseApply); +} diff --git a/src/com/app/service/RefuseApplyServiceImpl.java b/src/com/app/service/RefuseApplyServiceImpl.java new file mode 100644 index 0000000..6f7482f --- /dev/null +++ b/src/com/app/service/RefuseApplyServiceImpl.java @@ -0,0 +1,28 @@ +package com.app.service; + +import com.app.bean.RefuseApply; +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.orm.hibernate3.HibernateTemplate; +import org.springframework.stereotype.Service; + +@Service +public class RefuseApplyServiceImpl implements RefuseApplyService{ + + private static final Logger logger= Logger.getLogger(RefuseApplyServiceImpl.class); + + @Autowired + private HibernateTemplate hibernateTemplate; + + @Override + public boolean save(RefuseApply refuseApply) { + try { + hibernateTemplate.save(refuseApply); + return true; + } catch (Exception e) { + e.printStackTrace(); + logger.error(e); + return false; + } + } +}