2、申请管理功能修改

master
pan 5 years ago
parent c6e0894bcc
commit d168407882
  1. 129
      WebRoot/admin/applylist2.jsp
  2. 15
      src/com/app/action/AppAction.java
  3. 106
      src/com/app/action/ApplyAction.java
  4. 2
      src/com/app/bean/Apply.hbm.xml
  5. 29
      src/com/app/bean/Apply.java
  6. 59
      src/com/app/bean/RefuseApply.java
  7. 3
      src/com/app/service/ApplyServiceImpl.java
  8. 7
      src/com/app/service/RefuseApplyService.java
  9. 28
      src/com/app/service/RefuseApplyServiceImpl.java

@ -26,7 +26,14 @@ String usertype = session.getAttribute("userType")+"";
<link href="<%=basePath %>static/assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="<%=basePath %>static/assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath %>static/assets/css/icons.min.css" rel="stylesheet" type="text/css" /> <link href="<%=basePath %>static/assets/css/icons.min.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath %>static/assets/css/app.min.css" rel="stylesheet" type="text/css" /> <link href="<%=basePath %>static/assets/css/app.min.css" rel="stylesheet" type="text/css" />
<script src="<%=basePath %>static/bootstrap-4.4.1/js/bootstrap.min.js"></script>
<script>
function refuse(id) {
$('#refuseDialog input[name=id]').val(id)
$('#refuseDialog form').removeAttr("style").attr('action','<%=basePath%>admin/apply/pass.do')
}
</script>
</head> </head>
@ -58,15 +65,13 @@ String usertype = session.getAttribute("userType")+"";
<table id="example" class="data display datatable"> <table id="example" class="data display datatable">
<thead> <thead>
<tr> <tr>
<th>房源</th> <%-- 申请人id、申请人姓名、申请社区、申请房源、申请资料--%>
<th>大小</th>
<th>类型</th> <th>申请人id</th>
<th>价格</th> <th>申请人姓名</th>
<th>申请人</th> <th>申请社区</th>
<th>上传资料</th> <th>申请房源</th>
<th>备注</th> <th>申请资料</th>
<th>申请时间</th>
<th>状态</th>
<th style="width: 150px;">操作</th> <th style="width: 150px;">操作</th>
</tr> </tr>
</thead> </thead>
@ -76,66 +81,40 @@ String usertype = session.getAttribute("userType")+"";
<tr class="even gradeA"> <tr class="even gradeA">
<td> <td>
${item.userid}
${item.hs.rooname} <%-- ${item.hs.rooname}--%>
</td> </td>
<td>${USERS_MAP[item.userid].username}</td>
<td>${item.hs.size} </td> <td>${item.name}</td>
<td>${item.hs.cate} </td> <td>${item.cate}</td>
<td>${item.hs.price}元/月 </td>
<td>
${item.user.username}/
${item.user.realname}</td>
<td> <td>
<a target="_blank" href="<%=basePath%>${item.attachfile}"> <%-- <a target="_blank" href="<%=basePath%>${item.attachfile}">--%>
查看 <%-- 查看 --%>
</a> <%-- </a> --%>
</td> </td>
<td>
<span class="bz badge badge-info" txt="${item.message }">查看</span>
</td>
<td>${item.created}</td>
<td>
<c:if test="${item.state eq '1' }">
<span class="badge badge-warning">待街道审核</span>
</c:if>
<c:if test="${item.state eq '2' }">
<span class="badge badge-success">街道审核通过</span>
</c:if>
<c:if test="${item.state eq '3' }">
<span class="badge badge-danger">街道审核不通过</span>
</c:if>
<c:if test="${item.state eq '5' }">
<span class="badge badge-success">市级审核通过</span>
</c:if>
<c:if test="${item.state eq '6' }">
<span class="badge badge-danger">市级审核不通过</span>
</c:if>
</td>
<td> <td>
<c:if test="${item.state eq '2' }"> <c:if test="${item.state eq 2 }">
<a class="" href="<%=basePath%>admin/apply/pass.do?ret=list2&statex=5&id=${item.id}"> <a class="" href="<%=basePath%>admin/apply/pass.do?ret=list2&statex=5&id=${item.id}">
<i class="icon-pencil"></i> <i class="icon-pencil"></i>
通过 通过
</a> </a>
<a class="" href="<%=basePath%>admin/apply/pass.do?ret=list2&statex=6&id=${item.id}"> <a class="" data-toggle="modal" data-target="#refuseDialog" style="cursor:pointer" onclick="refuse(${item.id})">
<i class="icon-pencil"></i> <i class="icon-pencil"></i>
不通过 不通过
</a> </a>
</c:if> </c:if>
<c:if test="${item.state eq '5' }"> <c:if test="${item.state eq 5 }">
<a class="" href="<%=basePath%>admin/apply/pass.do?ret=list2&statex=6&id=${item.id}"> <a class="" data-toggle="modal" data-target="#refuseDialog"style="cursor:pointer" onclick="refuse(${item.id})">
<i class="icon-pencil"></i> <i class="icon-pencil"></i>
不通过 不通过
</a> </a>
</c:if> </c:if>
<c:if test="${item.state eq '6' }"> <c:if test="${item.state eq 6 }">
<a class="" href="<%=basePath%>admin/apply/pass.do?ret=list2&statex=5&id=${item.id}"> <a class="" href="<%=basePath%>admin/apply/pass.do?ret=list2&statex=5&id=${item.id}">
<i class="icon-pencil"></i> <i class="icon-pencil"></i>
通过 通过
@ -209,7 +188,39 @@ $(document).ready(function(){
</script> </script>
</html> <div class="modal fade" id="refuseDialog" tabindex="-1" role="dialog" aria-labelledby="refuseDialogTitle" aria-hidden="true">
<div class="modal-dialog " role="document">
<div class="modal-content">
<form method="post">
<input type="hidden" name="id"/>
<input type="hidden" name="ret" value="list2"/>
<input type="hidden" name="statex" value="6"/>
<div class="modal-header">
<h5 class="modal-title" id="refuseDialogTitle">不通过</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">理由</span>
</div>
<textarea class="form-control" name="content" aria-label="With textarea"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
<button type="submit" class="btn btn-primary">提交</button>
</div>
</form>
</div>
</div>
</div>
</body> </body>
</html> </html>

@ -135,22 +135,13 @@ public class AppAction {
return "success"; return "success";
} }
public List<Apply> getInfo(List<Apply> 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() { public String pub() {
ActionContext act = ActionContext.getContext(); ActionContext act = ActionContext.getContext();
List<Apply> list = applyService.list(); List<Apply> list = applyService.list();
act.put("cates", getCate()); act.put("cates", getCate());
act.put("list", getInfo(list)); act.put("list", list);
return "success"; return "success";
} }
public String jb() { public String jb() {
@ -172,7 +163,7 @@ public class AppAction {
model.setPid(u.getPid()); model.setPid(u.getPid());
model.setCid(Integer.parseInt(u.getCid())); model.setCid(Integer.parseInt(u.getCid()));
model.setAid(Integer.parseInt(u.getAid())); model.setAid(Integer.parseInt(u.getAid()));
model.setUserid(u.getId()+""); model.setUserid(u.getId());
model.setState("1"); model.setState("1");
model.setType("1"); model.setType("1");
model.setCreated(MainUtils.getTime()); model.setCreated(MainUtils.getTime());

@ -1,18 +1,16 @@
package com.app.action; package com.app.action;
import com.app.bean.Apply; import com.app.bean.*;
import com.app.bean.House;
import com.app.bean.Report;
import com.app.bean.Users;
import com.app.service.*; import com.app.service.*;
import com.app.utils.Constants;
import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionContext;
import org.apache.struts2.ServletActionContext; import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Controller @Controller
@ -20,6 +18,16 @@ import java.util.List;
public class ApplyAction { public class ApplyAction {
@Resource @Resource
ApplyService applyService; ApplyService applyService;
@Resource
UsersService usersService;
@Resource
HouseService houseService;
@Autowired
private RefuseApplyService refuseApplyService;
public int id; public int id;
public void setId(int id) { public void setId(int id) {
@ -42,13 +50,13 @@ public class ApplyAction {
return pid; return pid;
} }
public String userid; public Integer userid;
public void setUserid(String userid) { public void setUserid(Integer userid) {
this.userid = userid; this.userid = userid;
} }
public String getUserid() { public Integer getUserid() {
return userid; return userid;
} }
@ -171,7 +179,7 @@ public class ApplyAction {
for (Report report : list) { for (Report report : list) {
Apply apply = applyService.findById(Integer.parseInt(report.getMid())); Apply apply = applyService.findById(Integer.parseInt(report.getMid()));
report.setUser(usersService.findById(Integer.parseInt(report.getUserid())).getUsername()); 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()); House h = houseService.findById(apply.getHid());
report.setTitle(u.getUsername()+"ÉêÇë×âÁÞ"+h.getRooname()); report.setTitle(u.getUsername()+"ÉêÇë×âÁÞ"+h.getRooname());
} }
@ -183,7 +191,7 @@ public class ApplyAction {
@Resource @Resource
CatesService catesService; CatesService catesService;
public String report() { public String report() {
ActionContext act = ActionContext.getContext(); ActionContext act = ActionContext.getContext();
act.put("n1", usersService.list().size()); act.put("n1", usersService.list().size());
act.put("n2", catesService.list().size()); act.put("n2", catesService.list().size());
act.put("n3", newsService.list().size()); act.put("n3", newsService.list().size());
@ -195,19 +203,28 @@ public class ApplyAction {
public String pass() { public String pass() {
ActionContext act = ActionContext.getContext(); ActionContext act = ActionContext.getContext();
HttpServletRequest request= ServletActionContext.getRequest();
Apply model = applyService.findById(id); Apply model = applyService.findById(id);
House hs = houseService.findById(model.getHid()); House hs = houseService.findById(model.getHid());
if (statex.equals("6")) if ("6".equals(statex)) {
hs.setState(1); 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); hs.setState(2);
}
houseService.update(hs); houseService.update(hs);
model.setState(statex); model.setState(statex);
applyService.update(model); applyService.update(model);
act.put("message", "操作成功!");
act.put("url", "admin/apply/" + ret + ".do"); act.put("url", "admin/apply/" + ret + ".do");
act.put("message", "²Ù×÷³É¹¦!");
act.put("state", "success"); act.put("state", "success");
return "success"; return Constants.SUCCESS;
} }
public String ret; public String ret;
@ -223,61 +240,42 @@ public class ApplyAction {
public String applyList() { public String applyList() {
ActionContext act = ActionContext.getContext(); ActionContext act = ActionContext.getContext();
Users u = (Users) act.getSession().get("users"); Users u = (Users) act.getSession().get("users");
List<Apply> list = applyService.list(" FROM Apply where userid=" List<Apply> list = applyService.list("select a.id as id,a.userid as userid,h.cate as cate,c.name as name,a.state as state " +
+ u.getId()); "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", getInfo(list)); act.put("list", list);
act.put(Constants.USERS_MAP,ConstantsService.getUsersMap());
return "success"; return "success";
} }
public String applyList1() { public String applyList1() {
ActionContext act = ActionContext.getContext(); ActionContext act = ActionContext.getContext();
Users u = (Users) act.getSession().get("users"); Users u = (Users) act.getSession().get("users");
String wh = " pid=" + u.getPid() + " AND cid=" + u.getCid() String wh = " a.pid=" + u.getPid() + " AND a.cid=" + u.getCid()
+ " AND aid=" + u.getAid(); + " AND a.aid=" + u.getAid();
List<Apply> list = applyService.list(" FROM Apply where " + wh); List<Apply> 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"; return "success";
} }
@Resource
UsersService usersService;
@Resource
HouseService houseService;
public List<Apply> getInfo(List<Apply> 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<Apply> applyList=new ArrayList<Apply>();
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() { public String applyList2() {
ActionContext act = ActionContext.getContext(); ActionContext act = ActionContext.getContext();
HttpServletRequest request=ServletActionContext.getRequest();
Users u = (Users) act.getSession().get("users"); Users u = (Users) act.getSession().get("users");
List<Apply> list = applyService.list(); String whereSql="";
act.put("list", getInfo(list)); if(request.getParameterMap().containsKey("applyname")){
whereSql=" and u.username like '%"+request.getParameter("applyname")+"%'";
}
List<Apply> 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"; return "success";
} }

@ -7,7 +7,7 @@
<id name="id" column="ID" type="int"> <id name="id" column="ID" type="int">
<generator class="identity" /> <generator class="identity" />
</id><property name="pid" not-null="false" type="java.lang.String" /> </id><property name="pid" not-null="false" type="java.lang.String" />
<property name="userid" not-null="false" type="java.lang.String" /> <property name="userid" not-null="false" type="java.lang.Integer" />
<property name="state" not-null="false" type="java.lang.String" /> <property name="state" not-null="false" type="java.lang.String" />
<property name="type" not-null="false" type="java.lang.String" /> <property name="type" not-null="false" type="java.lang.String" />
<property name="created" not-null="false" type="java.lang.String" /> <property name="created" not-null="false" type="java.lang.String" />

@ -7,24 +7,25 @@ public class Apply {
public int cid; public int cid;
public int aid; public int aid;
public String message; public String message;
public Users user;
public House hs;
public Users getUser() { private String cate;
return user; 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() { public String getName() {
return hs; return name;
} }
public void setHs(House hs) { public void setName(String name) {
this.hs = hs; this.name = name;
} }
public String getMessage() { public String getMessage() {
@ -69,13 +70,13 @@ public class Apply {
return pid; return pid;
} }
public String userid; public Integer userid;
public void setUserid(String userid) { public void setUserid(Integer userid) {
this.userid = userid; this.userid = userid;
} }
public String getUserid() { public Integer getUserid() {
return userid; return userid;
} }

@ -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);
}
}

@ -3,6 +3,7 @@ package com.app.service;
import com.app.bean.Apply; import com.app.bean.Apply;
import org.hibernate.Query; import org.hibernate.Query;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.hibernate.transform.Transformers;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -37,7 +38,7 @@ public class ApplyServiceImpl implements ApplyService {
} }
public List<Apply> list(String where) { public List<Apply> list(String where) {
return factory.getCurrentSession().createQuery(where).list(); return factory.getCurrentSession().createQuery(where).setResultTransformer(Transformers.aliasToBean(Apply.class)).list();
} }
public List<Apply> list(String where, String[] param) { public List<Apply> list(String where, String[] param) {

@ -0,0 +1,7 @@
package com.app.service;
import com.app.bean.RefuseApply;
public interface RefuseApplyService {
boolean save(RefuseApply refuseApply);
}

@ -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;
}
}
}
Loading…
Cancel
Save