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 +