From 49720af638ea420b44f5d2c47051de81388f1572 Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Wed, 10 Jun 2020 18:42:14 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=B8=BE=E6=8A=A5=E7=AE=A1=E7=90=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=BF=AE=E6=94=B9=202.=E5=A2=9E=E5=8A=A0=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E8=B5=84=E6=96=99=E6=A8=A1=E5=9D=97=203.=E4=B8=BB?= =?UTF-8?q?=E9=A1=B5-=E6=88=BF=E6=BA=90=E6=A8=A1=E5=9D=97=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=204.=E4=B8=BB=E9=A1=B5-=E5=85=AC=E7=A4=BA=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebRoot/admin/applylist.jsp | 7 +- WebRoot/admin/applylist1.jsp | 14 ++- WebRoot/admin/applylist2.jsp | 52 ++--------- WebRoot/admin/refuse.jsp | 48 ++++++++++ WebRoot/ui/apply.jsp | 12 +-- src/com/app/action/AppAction.java | 2 +- src/com/app/action/ApplyAction.java | 93 ++++++++++++++----- src/com/app/service/CommunityServiceImpl.java | 4 + src/com/app/service/ConstantsService.java | 8 +- src/com/app/service/HouseService.java | 2 + src/com/app/service/HouseServiceImpl.java | 7 ++ src/struts.xml | 15 ++- 12 files changed, 171 insertions(+), 93 deletions(-) create mode 100644 WebRoot/admin/refuse.jsp diff --git a/WebRoot/admin/applylist.jsp b/WebRoot/admin/applylist.jsp index 0a863ad..ff0c1e6 100644 --- a/WebRoot/admin/applylist.jsp +++ b/WebRoot/admin/applylist.jsp @@ -31,7 +31,7 @@ String usertype = session.getAttribute("userType")+""; function edit(id,content) { $('#editDialog input[name=id]').val(id) $('#editDialog textarea[name=content]').val(content) - $("#editDialog form").removeAttr("style").attr("action",'<%=basePath%>admin/apply/updateApply.do') + $("#editDialog form").removeAttr("style").attr("action",'<%=basePath%>admin/apply/updateapply.do') } @@ -110,7 +110,7 @@ String usertype = session.getAttribute("userType")+""; 修改 - + 删除 @@ -155,9 +155,6 @@ String usertype = session.getAttribute("userType")+""; @@ -169,9 +170,6 @@ String usertype = session.getAttribute("userType")+""; - + @@ -109,7 +104,7 @@ String usertype = session.getAttribute("userType")+""; - + 通过 @@ -120,20 +115,20 @@ String usertype = session.getAttribute("userType")+""; - + 不通过 - + 通过 - + 删除 @@ -176,9 +171,6 @@ String usertype = session.getAttribute("userType")+""; - + diff --git a/WebRoot/admin/refuse.jsp b/WebRoot/admin/refuse.jsp new file mode 100644 index 0000000..f5ba37e --- /dev/null +++ b/WebRoot/admin/refuse.jsp @@ -0,0 +1,48 @@ +<%-- + Created by IntelliJ IDEA. + User: pan + Date: 2020/6/10 0010 + Time: 17:12 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + diff --git a/WebRoot/ui/apply.jsp b/WebRoot/ui/apply.jsp index 86fe016..8cd03d8 100644 --- a/WebRoot/ui/apply.jsp +++ b/WebRoot/ui/apply.jsp @@ -161,19 +161,19 @@
- +
- ${item.value.materialName} + ${item.materialName}
- - + + - + + name="${item.formName}"> 点击上传 diff --git a/src/com/app/action/AppAction.java b/src/com/app/action/AppAction.java index e583619..4dd6a24 100644 --- a/src/com/app/action/AppAction.java +++ b/src/com/app/action/AppAction.java @@ -141,7 +141,7 @@ public class AppAction { act.put("model", model); act.put("communityType",community.getType()); act.put("address",community.getAddress()); - act.put("materialMap",ConstantsService.materialMap); + act.put("materialList",ConstantsService.materialList); if (applyService.list(" FROM Apply where userid=" + u.getId()).size() > 0) { act.put("message", ":Ѿ"); diff --git a/src/com/app/action/ApplyAction.java b/src/com/app/action/ApplyAction.java index d49e534..fc58cc6 100644 --- a/src/com/app/action/ApplyAction.java +++ b/src/com/app/action/ApplyAction.java @@ -3,6 +3,7 @@ package com.app.action; import com.app.bean.*; import com.app.service.*; import com.app.utils.Constants; +import com.app.utils.StateType; import com.opensymphony.xwork2.ActionContext; import org.apache.struts2.ServletActionContext; import org.springframework.beans.factory.annotation.Autowired; @@ -25,15 +26,48 @@ public class ApplyAction { @Autowired private MaterialService materialService; + private String action; + @Autowired private RefuseApplyService refuseApplyService; public int id; + public StateType state; + + private String message; + + private String content; + + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public StateType getState() { + return state; + } + + public void setState(StateType state) { + this.state = state; + } + public void setId(int id) { this.id = id; } + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + public int getId() { return id; @@ -148,25 +182,15 @@ public class ApplyAction { public String updateApply() { ActionContext act = ActionContext.getContext(); + HttpServletRequest request=ServletActionContext.getRequest(); Apply model = applyService.findById(id); - - model.setPid(pid); - - model.setUserid(userid); - - model.setState(statex); - - model.setType(type); - - model.setCreated(created); - - model.setAttachfile(attachfile); - + model.setMessage(content); model.setStateid(stateid); applyService.update(model); - act.put("message", "Update Data Success!"); - act.put("url", "admin/apply/edit?id=" + id); - act.put("state", "success"); + + this.setMessage("³ɹ"); + this.setState(StateType.success); + return "success"; } @@ -235,17 +259,21 @@ public class ApplyAction { public String applyList() { ActionContext act = ActionContext.getContext(); + HttpServletRequest request=ServletActionContext.getRequest(); Users u = (Users) act.getSession().get("users"); List list = applyService.transformList("select a.id as id,a.userid as userid,h.cate " + "as cate,c.name as name,a.state as state,a.message as message " + "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.usersMap); + this.setState(request.getParameter(Constants.STATE) == null ? null : StateType.valueOf(request.getParameter(Constants.STATE))); + this.setMessage(request.getParameter(Constants.MESSAGE)); return "success"; } public String applyList1() { ActionContext act = ActionContext.getContext(); + HttpServletRequest request=ServletActionContext.getRequest(); Users u = (Users) act.getSession().get("users"); String wh = " a.pid=" + u.getPid() + " AND a.cid=" + u.getCid() + " AND a.aid=" + u.getAid(); @@ -254,6 +282,8 @@ public class ApplyAction { act.put("list", list); act.put(Constants.USERS_MAP,ConstantsService.usersMap); + this.setState(request.getParameter(Constants.STATE) == null ? null : StateType.valueOf(request.getParameter(Constants.STATE))); + this.setMessage(request.getParameter(Constants.MESSAGE)); return "success"; } @@ -273,17 +303,36 @@ public class ApplyAction { "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.usersMap); + this.setState(request.getParameter(Constants.STATE) == null ? null : StateType.valueOf(request.getParameter(Constants.STATE))); + this.setMessage(request.getParameter(Constants.MESSAGE)); return "success"; } public String delete() { ActionContext act = ActionContext.getContext(); Users u = (Users) act.getSession().get("users"); - applyService.delete(this.id); - materialService.deleteUserMaterial(u.getId()); - act.put("message", "ɾɹ!"); - act.put("state", "success"); - act.put("url", "admin/apply/"+ret+".do"); - return "success"; + Apply apply=applyService.findById(this.id); + if(apply!=null) { + applyService.delete(this.id); + materialService.deleteUserMaterial(u.getId()); + House house=houseService.findById(apply.getHid()); + house.setState(1); + houseService.update(house); + this.setMessage("ɾɹ!"); + this.setState(StateType.success); + return Constants.SUCCESS; + }else{ + this.setMessage("ɾʧ!"); + this.setState(StateType.error); + return Constants.ERROR; + } + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; } } \ No newline at end of file diff --git a/src/com/app/service/CommunityServiceImpl.java b/src/com/app/service/CommunityServiceImpl.java index 46162ca..eaebd45 100644 --- a/src/com/app/service/CommunityServiceImpl.java +++ b/src/com/app/service/CommunityServiceImpl.java @@ -24,6 +24,9 @@ public class CommunityServiceImpl implements CommunityService{ @Autowired private HibernateTemplate hibernateTemplate; + @Autowired + private HouseService houseService; + @Override public boolean add(Community community) { try { @@ -51,6 +54,7 @@ public class CommunityServiceImpl implements CommunityService{ @Override public boolean delete(Community community) { try { + houseService.deleteWithCommunityId(community.getId()); hibernateTemplate.delete(community); return true; } catch (DataAccessException e) { diff --git a/src/com/app/service/ConstantsService.java b/src/com/app/service/ConstantsService.java index 6d6218d..6cab304 100644 --- a/src/com/app/service/ConstantsService.java +++ b/src/com/app/service/ConstantsService.java @@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -20,6 +21,8 @@ public class ConstantsService { public static final Map materialMap=new HashMap<>(); + public static final List materialList=new ArrayList<>(); + @Autowired private RegionService regionService; @@ -56,8 +59,9 @@ public class ConstantsService { public void initMaterial(){ materialMap.clear(); - List applicationMaterials=materialService.materialList(); - for(ApplicationMaterial material:applicationMaterials){ + materialList.clear(); + materialList.addAll(materialService.materialList()); + for(ApplicationMaterial material:materialList){ materialMap.put(material.getFormName(),material); } } diff --git a/src/com/app/service/HouseService.java b/src/com/app/service/HouseService.java index 3ee0193..8e3a8dc 100644 --- a/src/com/app/service/HouseService.java +++ b/src/com/app/service/HouseService.java @@ -22,4 +22,6 @@ public interface HouseService { List transformList(String where); List list(String where, String[] param); + + boolean deleteWithCommunityId(int id); } \ No newline at end of file diff --git a/src/com/app/service/HouseServiceImpl.java b/src/com/app/service/HouseServiceImpl.java index aaaac3a..8c91c9f 100644 --- a/src/com/app/service/HouseServiceImpl.java +++ b/src/com/app/service/HouseServiceImpl.java @@ -65,4 +65,11 @@ public class HouseServiceImpl implements HouseService { } return q.list(); } + + @Override + public boolean deleteWithCommunityId(int id) { + Query query=factory.getCurrentSession().createQuery("delete from House where communityId=?"); + query.setInteger(0,id); + return query.executeUpdate()>0; + } } \ No newline at end of file diff --git a/src/struts.xml b/src/struts.xml index 277b9d2..f19b679 100644 --- a/src/struts.xml +++ b/src/struts.xml @@ -130,7 +130,10 @@ /admin/applyedit.jsp - /message.jsp + + list.do?state=${state}&message=${message} + true + /admin/applylist.jsp @@ -148,10 +151,16 @@ /admin/report.jsp - /admin/applylist1.jsp + + ${action}.do?state=${state}&message=${message} + true + - /admin/applylist1.jsp + + ${action}.do?state=${state}&message=${message} + true +