街道政府管理员只能增删查改自己地区的社区

master
pan 4 years ago
parent d168407882
commit a97d216194
  1. 52
      WebRoot/admin/applylist.jsp
  2. 14
      WebRoot/admin/applylist2.jsp
  3. 54
      WebRoot/admin/communitylist.jsp
  4. 19
      WebRoot/admin/index.jsp
  5. 8
      WebRoot/admin/jblist.jsp
  6. 66
      WebRoot/admin/myhouselist.jsp
  7. 24
      src/com/app/action/AdminAction.java
  8. 4
      src/com/app/action/AppAction.java
  9. 6
      src/com/app/action/ApplyAction.java
  10. 82
      src/com/app/action/CommunityAction.java
  11. 18
      src/com/app/action/LoginAction.java
  12. 26
      src/com/app/action/UsersAction.java
  13. 3
      src/com/app/bean/Apply.hbm.xml
  14. 18
      src/com/app/bean/Apply.java
  15. 6
      src/com/app/bean/News.hbm.xml
  16. 18
      src/com/app/bean/News.java
  17. 6
      src/com/app/bean/Users.hbm.xml
  18. 18
      src/com/app/bean/Users.java
  19. 31
      src/com/app/service/CommunityServiceImpl.java
  20. 19
      src/struts.xml

@ -58,15 +58,13 @@ String usertype = session.getAttribute("userType")+"";
<table id="example" class="data display datatable">
<thead>
<tr>
<th>房源</th>
<th>大小</th>
<th>类型</th>
<th>价格</th>
<th>申请人</th>
<th>上传资料</th>
<th>备注</th>
<th>申请时间</th>
<th>状态</th>
<th>申请人id</th>
<th>申请人姓名</th>
<th>申请社区</th>
<th>申请房源</th>
<th>申请资料</th>
<th>状态</th>
<th style="width: 150px;">操作</th>
</tr>
</thead>
<tbody>
@ -74,27 +72,11 @@ String usertype = session.getAttribute("userType")+"";
<c:forEach items="${list}" var="item">
<tr class="even gradeA">
<td>
${item.hs.rooname}
</td>
<td>${item.hs.size} </td>
<td>${item.hs.cate} </td>
<td>${item.hs.price}元/月 </td>
<td>
${item.user.username}/
${item.user.realname}</td>
<td>
<a target="_blank" href="<%=basePath%>${item.attachfile}">
查看
</a>
</td>
<td>
<span class="bz badge badge-info" txt="${item.message }">查看</span>
</td>
<td>${item.created}</td>
<td>${item.userid}</td>
<td>${USERS_MAP[item.userid].username}</td>
<td>${item.name}</td>
<td>${item.cate}</td>
<td>上传文件</td>
<td>
<c:if test="${item.state eq '1' }">
@ -116,6 +98,16 @@ String usertype = session.getAttribute("userType")+"";
<span class="badge badge-danger">市级审核不通过</span>
</c:if>
</td>
<td>
<a style="margin-left: 10px" class="" href="<%=basePath%>admin/apply/edit.do?ret=list&id=${item.id}">
<i class="icon-pencil"></i>
修改
</a>
<a style="margin-left: 10px" class="" href="<%=basePath%>admin/apply/delete.do?ret=list&id=${item.id}">
<i class="icon-pencil"></i>
删除
</a>
</td>
</tr>

@ -65,8 +65,6 @@ String usertype = session.getAttribute("userType")+"";
<table id="example" class="data display datatable">
<thead>
<tr>
<%-- 申请人id、申请人姓名、申请社区、申请房源、申请资料--%>
<th>申请人id</th>
<th>申请人姓名</th>
<th>申请社区</th>
@ -80,19 +78,11 @@ String usertype = session.getAttribute("userType")+"";
<c:forEach items="${list}" var="item">
<tr class="even gradeA">
<td>
${item.userid}
<%-- ${item.hs.rooname}--%>
</td>
<td>${item.userid}</td>
<td>${USERS_MAP[item.userid].username}</td>
<td>${item.name}</td>
<td>${item.cate}</td>
<td>
<%-- <a target="_blank" href="<%=basePath%>${item.attachfile}">--%>
<%-- 查看 --%>
<%-- </a> --%>
</td>
<td>上传文件</td>
<td>

@ -20,9 +20,14 @@
<script>
$(function () {
$("form").removeAttr("style");
loadRegion("province",1);
<c:if test="${sessionScope.users.type eq 3}">
loadRegion("province",1);
loadRegion("city",${sessionScope.users.pid});
loadRegion("area",${sessionScope.users.cid});
</c:if>
<c:if test="${!empty state }">
toastr.${state}('${message}', '提示');
@ -56,25 +61,39 @@
<div class="input-group-prepend">
<label class="input-group-text">社区名称:</label>
</div>
<input class="form-control"
<input class="form-control ${sessionScope.users.type eq 3?'':'col-3'}"
name="community.name" type="text" placeholder="请输入社区名称">
<div class="input-group-prepend">
<label class="input-group-text">地区:</label>
</div>
<div class="input-group-prepend">
<label class="input-group-text">省:</label>
</div>
<select id="province" class="custom-select" name="community.pid" onchange="loadRegion('city',province.value)"></select>
<div class="input-group-prepend">
<label class="input-group-text">市:</label>
</div>
<select id="city" class="custom-select" name="community.cid" onchange="loadRegion('area',city.value)"></select>
<div class="input-group-prepend">
<label class="input-group-text">区:</label>
</div>
<select id="area" class="custom-select" name="community.aid"></select>
<c:choose>
<c:when test="${sessionScope.users.type eq 3}">
<div class="input-group-prepend">
<label class="input-group-text">地区:</label>
</div>
<div class="input-group-prepend">
<label class="input-group-text">省:</label>
</div>
<select id="province" class="custom-select" name="community.pid" onchange="loadRegion('city',province.value)"></select>
<div class="input-group-prepend">
<label class="input-group-text">市:</label>
</div>
<select id="city" class="custom-select" name="community.cid" onchange="loadRegion('area',city.value)"></select>
<div class="input-group-prepend">
<label class="input-group-text">区:</label>
</div>
<select id="area" class="custom-select" name="community.aid"></select>
</c:when>
<c:otherwise>
<input id="province" type="hidden" name="community.pid" value="${param['community.pid']}"/>
<input id="city" type="hidden" name="community.cid" value="${param['community.cid']}"/>
<input id="area" type="hidden" name="community.aid" value="${param['community.aid']}"/>
</c:otherwise>
</c:choose>
<div class="input-group-append">
<button type="submit" class="btn btn-primary">查询</button>
</div>
@ -87,6 +106,7 @@
<h2>数据列表</h2>
<div>
<a class="btn btn-primary" href="<%=basePath%>admin/community/toAdd.do?type=${param.type}">新增社区</a>
</div>
</div>

@ -161,12 +161,12 @@ background-image: linear-gradient(160deg, #80D0C7 0%, #0093E9 100%);
</a>
<ul class="nav-second-level" aria-expanded="false">
<li>
<a target="rightFrame" href="<%=basePath%>admin/house/mylist.do">房源管理</a>
</li>
<li>
<a target="rightFrame" href="<%=basePath%>admin/house/add.do">发布房源</a>
</li>
<c:forEach items="<%=CommunityType.values()%>" var="type">
<li>
<a target="rightFrame" href="<%=basePath%>admin/community/list.do?community.pid=${pid}&community.cid=${cid}&community.aid=${aid}&type=${type.name()}">${type.desc}</a>
</li>
</c:forEach>
</ul>
</li>
@ -269,9 +269,6 @@ background-image: linear-gradient(160deg, #80D0C7 0%, #0093E9 100%);
<ul class="nav-second-level" aria-expanded="false">
<li>
<a target="rightFrame" href="<%=basePath%>admin/house/list.do">房源管理</a>
</li>
<c:forEach items="<%=CommunityType.values()%>" var="type">
<li>
@ -279,9 +276,7 @@ background-image: linear-gradient(160deg, #80D0C7 0%, #0093E9 100%);
</li>
</c:forEach>
<li>
<a target="rightFrame" href="<%=basePath%>admin/house/add.do">发布房源</a>
</li>
</ul>
</li>

@ -47,10 +47,10 @@ String usertype = session.getAttribute("userType")+"";
<table id="example" class="data display datatable">
<thead>
<tr>
<th>举报</th>
<th>举报事宜</th>
<th>详细缘由</th>
<th>举报时间</th>
<th>举报用户id</th>
<th>举报用户的姓名</th>
<th>举报人id</th>
<th>举报人事宜</th>
</tr>
</thead>
<tbody>

@ -59,13 +59,11 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
<table id="example" class="data display datatable">
<thead>
<tr>
<th>房源名称</th>
<th>发布人</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>
</tr>
</thead>
@ -73,36 +71,30 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
<c:forEach items="${list}" var="item">
<tr class="even gradeA">
<td>
${item.rooname}</td> <td>${item.username}</td>
<td>${item.size}</td>
<td>${item.address}</td>
<td>${item.price}</td>
<td>${item.cate}</td>
<td>
<c:if test="${item.state==1 }">闲置</c:if>
<c:if test="${item.state==2 }">使用中</c:if>
</td>
<td>
<a href="<%=basePath%>admin/house/edit.do?id=${item.id}">
<i class="icon-pencil"></i>
编辑
</a>
<a class="deletemodal" href="<%=basePath%>admin/house/delete.do?ret=mylist&id=${item.id}"><i class="icon-remove"></i>
移除
</a>
</td>
</tr>
<tr class="even gradeA">
<td class="align-middle">${item.cate}</td>
<td class="align-middle">${item.size}</td>
<td class="align-middle">${item.price}</td>
<td class="align-middle"><img style="width: 100px;height: 100px" src="<%=basePath%>${item.thunb}"/></td>
<td class="align-middle">${item.remain}/${item.total}</td>
<td class="align-middle">
<a href="<%=basePath%>admin/house/edit.do?id=${item.id}&communityId=${param.communityId}">
<i class="icon-pencil"></i>
编辑
</a>
<a class="deletemodal" href="<%=basePath%>admin/house/delete.do?id=${item.id}&communityId=${param.communityId}"><i class="icon-remove"></i>
移除
</a>
</td>
</tr>
</c:forEach>

@ -51,9 +51,9 @@ public class AdminAction {
model = userService.findById(userId);
}
Region r = rService.findById(Integer.parseInt(model.getPid()));
Region r1 = rService.findById(Integer.parseInt(model.getCid()));
Region r2 = rService.findById(Integer.parseInt(model.getAid()));
Region r = rService.findById(model.getPid());
Region r1 = rService.findById(model.getCid());
Region r2 = rService.findById(model.getAid());
model.setProvinceName(r.getRegion_name());
model.setAreaName(r2.getRegion_name());
model.setCityName(r1.getRegion_name());
@ -383,33 +383,33 @@ public class AdminAction {
return signature;
}
public String pid;
public Integer pid;
public void setPid(String pid) {
public void setPid(Integer pid) {
this.pid = pid;
}
public String getPid() {
public Integer getPid() {
return pid;
}
public String cid;
public Integer cid;
public void setCid(String cid) {
public void setCid(Integer cid) {
this.cid = cid;
}
public String getCid() {
public Integer getCid() {
return cid;
}
public String aid;
public Integer aid;
public void setAid(String aid) {
public void setAid(Integer aid) {
this.aid = aid;
}
public String getAid() {
public Integer getAid() {
return aid;
}

@ -161,8 +161,8 @@ public class AppAction {
Apply model = new Apply();
model.setPid(u.getPid());
model.setCid(Integer.parseInt(u.getCid()));
model.setAid(Integer.parseInt(u.getAid()));
model.setCid(u.getCid());
model.setAid(u.getAid());
model.setUserid(u.getId());
model.setState("1");
model.setType("1");

@ -40,13 +40,13 @@ public class ApplyAction {
}
public String pid;
public Integer pid;
public void setPid(String pid) {
public void setPid(Integer pid) {
this.pid = pid;
}
public String getPid() {
public Integer getPid() {
return pid;
}

@ -75,29 +75,30 @@ public class CommunityAction {
/**
* 查询社区列表
*
* @return 返回社区列表
*/
public String list() throws UnsupportedEncodingException {
ActionContext act = ActionContext.getContext();
HttpServletRequest request=ServletActionContext.getRequest();
if(community!=null&&!request.getParameterMap().containsKey("community.name")){
HttpServletRequest request = ServletActionContext.getRequest();
if (community != null && !request.getParameterMap().containsKey("community.name")) {
community.setName(null);
}
if(community!=null&&!request.getParameterMap().containsKey("community.pid")){
if (community != null && !request.getParameterMap().containsKey("community.pid")) {
community.setPid(null);
}
if(community!=null&&!request.getParameterMap().containsKey("community.cid")){
if (community != null && !request.getParameterMap().containsKey("community.cid")) {
community.setCid(null);
}
if(community!=null&&!request.getParameterMap().containsKey("community.aid")){
if (community != null && !request.getParameterMap().containsKey("community.aid")) {
community.setAid(null);
}
act.put(Constants.LIST,communityService.list(community,type.getType()));
act.put(Constants.LIST, communityService.list(community, type.getType()));
act.put(Constants.REGION_MAP,ConstantsService.getRegionMap());
act.put(Constants.USERS_MAP,ConstantsService.getUsersMap());
act.put(Constants.REGION_MAP, ConstantsService.getRegionMap());
act.put(Constants.USERS_MAP, ConstantsService.getUsersMap());
this.setState(request.getParameter(Constants.STATE)==null?null:StateType.valueOf(request.getParameter(Constants.STATE)));
this.setState(request.getParameter(Constants.STATE) == null ? null : StateType.valueOf(request.getParameter(Constants.STATE)));
this.setMessage(request.getParameter(Constants.MESSAGE));
return Constants.SUCCESS;
@ -105,15 +106,16 @@ public class CommunityAction {
/**
* 添加社区
*
* @return 返回添加结果
*/
public String add(){
public String add() {
ActionContext act = ActionContext.getContext();
if(act.getSession().containsKey(Constants.USERS) && act.getSession().get(Constants.USERS) instanceof Users) {
Users users= (Users) act.getSession().get(Constants.USERS);
community.setPid(Integer.valueOf(users.getPid()));
community.setCid(Integer.valueOf(users.getCid()));
community.setAid(Integer.valueOf(users.getAid()));
if (act.getSession().containsKey(Constants.USERS) && act.getSession().get(Constants.USERS) instanceof Users) {
Users users = (Users) act.getSession().get(Constants.USERS);
community.setPid(users.getPid());
community.setCid(users.getCid());
community.setAid(users.getAid());
community.setUserId(users.getId());
community.setType(type.getType());
if (communityService.add(community)) {
@ -124,13 +126,14 @@ public class CommunityAction {
this.setMessage("添加社区失败");
}
// act.put(Constants.URL, "admin/community/list.do?type"+type.name());
return Constants.SUCCESS;
}{
return "3".equals(users.getType()) ? "admin" : "other";
}
{
return Constants.ERROR;
}
}
public String toUpdate(){
public String toUpdate() {
Community model = communityService.findById(community.getId());
ActionContext act = ActionContext.getContext();
act.put(Constants.MODEL, model);
@ -138,7 +141,7 @@ public class CommunityAction {
}
public String update() throws IOException {
Community update=communityService.findById(community.getId());
Community update = communityService.findById(community.getId());
update.setName(community.getName());
update.setImage(community.getImage());
update.setAddress(community.getAddress());
@ -146,26 +149,35 @@ public class CommunityAction {
update.setLatitude(community.getLatitude());
update.setHouseType(community.getHouseType());
update.setDescription(community.getDescription());
if(communityService.update(update)){
this.setState(StateType.success);
this.setMessage("更新社区成功");
}else{
this.setState(StateType.error);
this.setMessage("更新社区失败");
if (communityService.update(update)) {
ActionContext act = ActionContext.getContext();
if (act.getSession().containsKey(Constants.USERS) && act.getSession().get(Constants.USERS) instanceof Users) {
Users users = (Users) act.getSession().get(Constants.USERS);
this.setState(StateType.success);
this.setMessage("更新社区成功");
return "3".equals(users.getType()) ? "admin" : "other";
}
}
return Constants.SUCCESS;
this.setState(StateType.error);
this.setMessage("更新社区失败");
return Constants.ERROR;
}
public String delete(){
public String delete() {
ActionContext act = ActionContext.getContext();
if(communityService.delete(community)){
this.setState(StateType.success);
this.setMessage("删除社区成功");
}else{
this.setState(StateType.success);
this.setMessage("删除社区失败");
if (communityService.delete(community)) {
if (act.getSession().containsKey(Constants.USERS) && act.getSession().get(Constants.USERS) instanceof Users) {
Users users = (Users) act.getSession().get(Constants.USERS);
this.setState(StateType.success);
this.setMessage("删除社区成功");
return "3".equals(users.getType()) ? "admin" : "other";
}
}
act.put(Constants.URL,"admin/community/list.do?type="+community.getType());
return Constants.SUCCESS;
this.setState(StateType.success);
this.setMessage("删除社区失败");
return Constants.ERROR;
}
}

@ -402,33 +402,33 @@ public class LoginAction {
return signature;
}
public String pid;
public Integer pid;
public void setPid(String pid) {
public void setPid(Integer pid) {
this.pid = pid;
}
public String getPid() {
public Integer getPid() {
return pid;
}
public String cid;
public Integer cid;
public void setCid(String cid) {
public void setCid(Integer cid) {
this.cid = cid;
}
public String getCid() {
public Integer getCid() {
return cid;
}
public String aid;
public Integer aid;
public void setAid(String aid) {
public void setAid(Integer aid) {
this.aid = aid;
}
public String getAid() {
public Integer getAid() {
return aid;
}

@ -266,33 +266,33 @@ public class UsersAction {
return signature;
}
public String pid;
public Integer pid;
public void setPid(String pid) {
public void setPid(Integer pid) {
this.pid = pid;
}
public String getPid() {
public Integer getPid() {
return pid;
}
public String cid;
public Integer cid;
public void setCid(String cid) {
public void setCid(Integer cid) {
this.cid = cid;
}
public String getCid() {
public Integer getCid() {
return cid;
}
public String aid;
public Integer aid;
public void setAid(String aid) {
public void setAid(Integer aid) {
this.aid = aid;
}
public String getAid() {
public Integer getAid() {
return aid;
}
@ -448,7 +448,7 @@ public class UsersAction {
if ((loginname==null||"".equals(loginname.trim()))&&(username==null||"".equals(username.trim()))) {
list=usersService.list();
}else{
String whereString=new String("FROM Users WHERE 1=1 ");
String whereString= "FROM Users WHERE 1=1 ";
if (loginname!=null&&!"".equals(loginname.trim())) {
whereString+=" and username like '%"+loginname+"%' ";
}
@ -458,9 +458,9 @@ public class UsersAction {
list=usersService.list(whereString);
}
for (Users model : list) {
Region r = rService.findById(Integer.parseInt(model.getPid()));
Region r1 = rService.findById(Integer.parseInt(model.getCid()));
Region r2 = rService.findById(Integer.parseInt(model.getAid()));
Region r = rService.findById(model.getPid());
Region r1 = rService.findById(model.getCid());
Region r2 = rService.findById(model.getAid());
model.setProvinceName(r.getRegion_name());
model.setAreaName(r2.getRegion_name());
model.setCityName(r1.getRegion_name());

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

@ -2,10 +2,10 @@ package com.app.bean;
public class Apply {
public int id;
public String pid;
public Integer pid;
public int hid;
public int cid;
public int aid;
public Integer cid;
public Integer aid;
public String message;
private String cate;
@ -44,29 +44,29 @@ public class Apply {
this.hid = hid;
}
public int getCid() {
public Integer getCid() {
return cid;
}
public void setCid(int cid) {
public void setCid(Integer cid) {
this.cid = cid;
}
public int getAid() {
public Integer getAid() {
return aid;
}
public void setAid(int aid) {
public void setAid(Integer aid) {
this.aid = aid;
}
public void setPid(String pid) {
public void setPid(Integer pid) {
this.pid = pid;
}
public String getPid() {
public Integer getPid() {
return pid;
}

@ -14,9 +14,9 @@
<property name="cateid" not-null="false" type="java.lang.String" />
<property name="created" not-null="false" type="java.lang.String" />
<property name="click" not-null="false" type="java.lang.String" />
<property name="province" not-null="false" type="java.lang.String" />
<property name="city" not-null="false" type="java.lang.String" />
<property name="area" not-null="false" type="java.lang.String" />
<property name="province" not-null="false" type="java.lang.Integer" />
<property name="city" not-null="false" type="java.lang.Integer" />
<property name="area" not-null="false" type="java.lang.Integer" />
<property name="userid" not-null="false" type="java.lang.String" />
<property name="address" not-null="false" type="java.lang.String" />
<property name="zan" not-null="false" type="java.lang.String" />

@ -92,33 +92,33 @@ public class News {
return click;
}
public String province;
public Integer province;
public void setProvince(String province) {
public void setProvince(Integer province) {
this.province = province;
}
public String getProvince() {
public Integer getProvince() {
return province;
}
public String city;
public Integer city;
public void setCity(String city) {
public void setCity(Integer city) {
this.city = city;
}
public String getCity() {
public Integer getCity() {
return city;
}
public String area;
public Integer area;
public void setArea(String area) {
public void setArea(Integer area) {
this.area = area;
}
public String getArea() {
public Integer getArea() {
return area;
}

@ -29,8 +29,8 @@
<property name="realname" not-null="false" type="java.lang.String" />
<property name="position" not-null="false" type="java.lang.String" />
<property name="signature" not-null="false" type="java.lang.String" />
<property name="pid" not-null="false" type="java.lang.String" />
<property name="cid" not-null="false" type="java.lang.String" />
<property name="aid" not-null="false" type="java.lang.String" />
<property name="pid" not-null="false" type="java.lang.Integer" />
<property name="cid" not-null="false" type="java.lang.Integer" />
<property name="aid" not-null="false" type="java.lang.Integer" />
</class></hibernate-mapping>

@ -259,33 +259,33 @@ public class Users {
return signature;
}
public String pid;
public Integer pid;
public void setPid(String pid) {
public void setPid(Integer pid) {
this.pid = pid;
}
public String getPid() {
public Integer getPid() {
return pid;
}
public String cid;
public Integer cid;
public void setCid(String cid) {
public void setCid(Integer cid) {
this.cid = cid;
}
public String getCid() {
public Integer getCid() {
return cid;
}
public String aid;
public Integer aid;
public void setAid(String aid) {
public void setAid(Integer aid) {
this.aid = aid;
}
public String getAid() {
public Integer getAid() {
return aid;
}

@ -2,9 +2,6 @@ package com.app.service;
import com.app.bean.Community;
import org.apache.log4j.Logger;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.hibernate.transform.Transformers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
@ -22,7 +19,7 @@ import java.util.List;
@Transactional
public class CommunityServiceImpl implements CommunityService{
private static Logger logger= Logger.getLogger(CommunityServiceImpl.class);
private static final Logger logger= Logger.getLogger(CommunityServiceImpl.class);
@Autowired
private HibernateTemplate hibernateTemplate;
@ -70,22 +67,6 @@ public class CommunityServiceImpl implements CommunityService{
@Override
public List<Community> list(Community community,Integer type) {
DetachedCriteria criteria= DetachedCriteria.forClass(Community.class);
criteria.add(Restrictions.eq("type",type));
if(community!=null) {
if (community.getName() != null && community.getName().length() > 0) {
criteria.add(Restrictions.like("name", community.getName(), MatchMode.ANYWHERE));
}
if (community.getPid() != null) {
criteria.add(Restrictions.eq("pid", community.getPid()));
}
if (community.getCid() != null) {
criteria.add(Restrictions.eq("cid", community.getCid()));
}
if (community.getAid() != null) {
criteria.add(Restrictions.eq("aid", community.getAid()));
}
}
StringBuffer sql=new StringBuffer();
sql.append("select community.id,\n")
@ -110,7 +91,11 @@ public class CommunityServiceImpl implements CommunityService{
.append(" from community,\n")
.append(" house\n")
.append(" where community.id = house.community_id\n")
.append(" group by community.id) b\n")
.append(" group by community.id\n")
.append("union all\n")
.append("select id,0,0\n")
.append("from community\n")
.append("where id not in(select community_id from house)) b\n")
.append("where community.id = b.id");
if(community!=null){
@ -121,9 +106,13 @@ public class CommunityServiceImpl implements CommunityService{
sql.append(" and community.pid=").append(community.getPid());
}
if(community.getCid()!=null){
sql.append(" and community.cid=").append(community.getCid());
}
if(community.getAid()!=null){
sql.append(" and community.aid=").append(community.getAid());
}
}
sql.append(" and community.type=").append(type);
List<Community> communities=hibernateTemplate.getSessionFactory().getCurrentSession().createSQLQuery(sql.toString()).setResultTransformer(Transformers.aliasToBean(Community.class)).list();

@ -219,10 +219,15 @@
</action>
<action name="add" method="add" class="communityAction">
<result type="redirect">
<result name="admin" type="redirect">
<param name="location">list.do?type=${type}&amp;state=${state}&amp;message=${message}</param>
<param name="encode">true</param>
</result>
<result name="other" type="redirect">
<param name="location">list.do?community.pid=${community.pid}&amp;community.cid=${community.cid}&amp;community.aid=${community.aid}&amp;type=${type}&amp;state=${state}&amp;message=${message}</param>
<param name="encode">true</param>
</result>
</action>
<!-- 编辑-->
@ -230,10 +235,14 @@
<result>/admin/communityedit.jsp</result>
</action>
<action name="update" method="update" class="communityAction">
<result type="redirect">
<result name="admin" type="redirect">
<param name="location">list.do?type=${type}&amp;state=${state}&amp;message=${message}</param>
<param name="encode">true</param>
</result>
<result name="other" type="redirect">
<param name="location">list.do?community.pid=${community.pid}&amp;community.cid=${community.cid}&amp;community.aid=${community.aid}&amp;type=${type}&amp;state=${state}&amp;message=${message}</param>
<param name="encode">true</param>
</result>
</action>
<!-- 列表-->
@ -243,10 +252,14 @@
<!-- 删除-->
<action name="delete" method="delete" class="communityAction">
<result type="redirect">
<result name="admin" type="redirect">
<param name="location">list.do?type=${type}&amp;state=${state}&amp;message=${message}</param>
<param name="encode">true</param>
</result>
<result name="other" type="redirect">
<param name="location">list.do?community.pid=${community.pid}&amp;community.cid=${community.cid}&amp;community.aid=${community.aid}&amp;type=${type}&amp;state=${state}&amp;message=${message}</param>
<param name="encode">true</param>
</result>
</action>
</package>

Loading…
Cancel
Save