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