From a6a3d670c2c519930164c7555aa607ee25043a09 Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Mon, 8 Jun 2020 02:24:33 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=20=E6=88=BF=E6=BA=90=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=8A=9F=E8=83=BD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + WebRoot/admin/communitylist.jsp | 20 +- WebRoot/admin/houseadd.jsp | 105 +--- WebRoot/admin/houseedit.jsp | 211 +++----- WebRoot/admin/houselist.jsp | 50 +- src/beans.xml | 1 - src/com/app/action/AppAction.java | 8 +- src/com/app/action/ApplyAction.java | 4 +- src/com/app/action/CommunityAction.java | 19 +- src/com/app/action/HouseAction.java | 139 +++-- src/com/app/bean/Community.java | 34 ++ src/com/app/bean/House.hbm.xml | 31 -- src/com/app/bean/House.java | 481 ++++++++++-------- src/com/app/service/CommunityServiceImpl.java | 42 +- src/com/app/servlet/RegionServlet.java | 2 +- src/log4j-config.properties | 21 +- src/struts.xml | 15 +- 17 files changed, 600 insertions(+), 584 deletions(-) delete mode 100644 src/com/app/bean/House.hbm.xml diff --git a/.gitignore b/.gitignore index 40f5227..f221d07 100644 --- a/.gitignore +++ b/.gitignore @@ -100,3 +100,4 @@ hs_err_pid* /WebRoot/uploadFile/ /WebRoot/WEB-INF/classes/ *.iml +/WebRoot/logs/ diff --git a/WebRoot/admin/communitylist.jsp b/WebRoot/admin/communitylist.jsp index 26032b0..72f3874 100644 --- a/WebRoot/admin/communitylist.jsp +++ b/WebRoot/admin/communitylist.jsp @@ -35,7 +35,7 @@ { //sel=="city"?$("#area").html(""):false $("#"+sel).html(""); - $.get("<%=basePath%>rg.sl?id="+parentId,function(e){ + $.get("<%=basePath%>rg.sl?flag=1&id="+parentId,function(e){ $("#"+sel).html(e); sel==="city"?reload():false; }) @@ -64,11 +64,11 @@
- +
- +
@@ -103,16 +103,16 @@ - ${item.name} + ${item.name} - ${item.pid}-${item.cid}-${item.aid} - ${item.userId} - ${item.address} - ${item.houseType} - 0/0 - + ${item.pid}-${item.cid}-${item.aid} + ${item.userId} + ${item.address} + ${item.houseType} + ${item.remain}/${item.total} + 编辑 diff --git a/WebRoot/admin/houseadd.jsp b/WebRoot/admin/houseadd.jsp index dc74dfa..361915c 100644 --- a/WebRoot/admin/houseadd.jsp +++ b/WebRoot/admin/houseadd.jsp @@ -39,34 +39,35 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
- + + - + @@ -83,7 +84,7 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request. + 单价 @@ -93,61 +94,10 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request. - - - - - - - - - - - - - - - - - - - - - - - @@ -167,50 +117,42 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request. - - - + + - - - + - - - - - - -
+ 户型 - +
+ 面积
- - - - - - -
- - - - - - - -
-
- - - - - -
+
+ 总量 - + +
+ + 余量 - + +
@@ -296,17 +238,6 @@ $().ready(function(){ - - - - diff --git a/WebRoot/admin/houseedit.jsp b/WebRoot/admin/houseedit.jsp index b28f37d..fb96bcf 100644 --- a/WebRoot/admin/houseedit.jsp +++ b/WebRoot/admin/houseedit.jsp @@ -38,219 +38,124 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
- + + - - - - - - + - - + - 房源大小 + + + - - - + - - - - + - + + + - - - - + - - + 单价 - - - + - - - + + - - + - - - - + - - - + - 地址经纬度 + + + 点击上传 + + - - - -
- + - - - - - + - + - - + - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
- - +
- - - - -
+ 户型 - - +
- + + - - - - - -
+
- 价格 + + -
+
+
-
+ 图片 - - +
- + + - + +
- - - -查看 - -
- - 点击上传 -
- - + 余量 - + +
- - - - - -
- - + +
diff --git a/WebRoot/admin/houselist.jsp b/WebRoot/admin/houselist.jsp index 29ada9d..a1605fe 100644 --- a/WebRoot/admin/houselist.jsp +++ b/WebRoot/admin/houselist.jsp @@ -34,9 +34,10 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request. +
- +
@@ -52,20 +53,18 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request. - - - - - - - + + + + + @@ -74,31 +73,25 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request. - - - - + + + + - - - + @@ -145,8 +138,6 @@ $(document).ready(function(){ loadRegion(sel,$(this).val()); }); - - }) function loadRegion(sel,parentId) @@ -169,11 +160,8 @@ $(document).ready(function(){ diff --git a/src/beans.xml b/src/beans.xml index 075dd5e..c04375b 100644 --- a/src/beans.xml +++ b/src/beans.xml @@ -38,7 +38,6 @@ com/app/bean/Ads.hbm.xmlcom/app/bean/Apply.hbm.xmlcom/app/bean/Cates.hbm.xml - com/app/bean/House.hbm.xmlcom/app/bean/News.hbm.xmlcom/app/bean/Region.hbm.xmlcom/app/bean/Report.hbm.xml diff --git a/src/com/app/action/AppAction.java b/src/com/app/action/AppAction.java index 79292ab..c2b640b 100644 --- a/src/com/app/action/AppAction.java +++ b/src/com/app/action/AppAction.java @@ -86,11 +86,11 @@ public class AppAction { Iterator iterator = houses.iterator(); while(iterator.hasNext()) { House next = iterator.next(); - String userid = next.getUserid(); - if (userid==null||userid.trim().equals("")) { + Integer userid = next.getUserid(); + if (userid==null) { iterator.remove(); }else { - Users users = usersService.findById(Integer.parseInt(userid)); + Users users = usersService.findById(userid); if (users==null||(!areaid.equals(users.getAid()))) { iterator.remove(); } @@ -181,7 +181,7 @@ public class AppAction { model.setMessage(messagex); applyService.save(model); - model1.setState("2"); + model1.setState(2); houseService.update(model1); act.put("message", "ύɹ"); act.put("state", "success"); diff --git a/src/com/app/action/ApplyAction.java b/src/com/app/action/ApplyAction.java index 9d5b1c5..9d3c3fd 100644 --- a/src/com/app/action/ApplyAction.java +++ b/src/com/app/action/ApplyAction.java @@ -198,9 +198,9 @@ public class ApplyAction { Apply model = applyService.findById(id); House hs = houseService.findById(model.getHid()); if (statex.equals("6")) - hs.setState("1"); + hs.setState(1); if (statex.equals("5")) - hs.setState("2"); + hs.setState(2); houseService.update(hs); model.setState(statex); applyService.update(model); diff --git a/src/com/app/action/CommunityAction.java b/src/com/app/action/CommunityAction.java index d049246..73afbfd 100644 --- a/src/com/app/action/CommunityAction.java +++ b/src/com/app/action/CommunityAction.java @@ -78,11 +78,23 @@ public class CommunityAction { */ public String list() throws UnsupportedEncodingException { ActionContext act = ActionContext.getContext(); - act.put(Constants.LIST,communityService.list(community,type.getType())); HttpServletRequest request=ServletActionContext.getRequest(); + if(!request.getParameterMap().containsKey("community.name")){ + community.setName(null); + } + if(!request.getParameterMap().containsKey("community.pid")){ + community.setPid(null); + } + if(!request.getParameterMap().containsKey("community.cid")){ + community.setCid(null); + } + if(!request.getParameterMap().containsKey("community.aid")){ + community.setAid(null); + } + act.put(Constants.LIST,communityService.list(community,type.getType())); - this.setState(request.getParameter("state")==null?null:StateType.valueOf(request.getParameter("state"))); - this.setMessage(request.getParameter("message")); + this.setState(request.getParameter(Constants.STATE)==null?null:StateType.valueOf(request.getParameter(Constants.STATE))); + this.setMessage(request.getParameter(Constants.MESSAGE)); return Constants.SUCCESS; } @@ -122,7 +134,6 @@ public class CommunityAction { } public String update() throws IOException { - ActionContext act = ActionContext.getContext(); Community update=communityService.findById(community.getId()); update.setName(community.getName()); update.setImage(community.getImage()); diff --git a/src/com/app/action/HouseAction.java b/src/com/app/action/HouseAction.java index e3913f7..8c95ef2 100644 --- a/src/com/app/action/HouseAction.java +++ b/src/com/app/action/HouseAction.java @@ -1,12 +1,17 @@ package com.app.action; +import com.app.bean.Community; import com.app.bean.House; import com.app.bean.Users; +import com.app.service.CommunityService; import com.app.service.HouseService; import com.app.service.UsersService; +import com.app.utils.Constants; import com.app.utils.MainUtils; +import com.app.utils.StateType; import com.opensymphony.xwork2.ActionContext; import org.apache.struts2.ServletActionContext; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller; @@ -23,13 +28,13 @@ public class HouseAction { @Resource UsersService usersService; - public int id; + public Integer id; - public void setId(int id) { + public void setId(Integer id) { this.id = id; } - public int getId() { + public Integer getId() { return id; @@ -185,6 +190,56 @@ public class HouseAction { return state; } + private Integer communityId; + + private Integer total; + + private Integer remain; + + public Integer getCommunityId() { + return communityId; + } + + public void setCommunityId(Integer communityId) { + this.communityId = communityId; + } + + public Integer getTotal() { + return total; + } + + public void setTotal(Integer total) { + this.total = total; + } + + public Integer getRemain() { + return remain; + } + + public void setRemain(Integer remain) { + this.remain = remain; + } + + private StateType stateType; + + private String message; + + public StateType getStateType() { + return stateType; + } + + public void setStateType(StateType stateType) { + this.stateType = stateType; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + public String add() { return "success"; } @@ -198,6 +253,10 @@ public String cate; public void setCate(String cate) { this.cate = cate; } + + @Autowired + private CommunityService communityService; + public String addHouse() { ActionContext act = ActionContext.getContext(); Users u = (Users) act.getSession().get("users"); @@ -205,24 +264,29 @@ public String cate; model.setRooname(rooname); model.setSize(size); model.setThunb(thunb); - model.setPrice(price); + model.setPrice(0); model.setCate(cate); model.setDescription(description); model.setCreated(MainUtils.getTime()); model.setContent(content); model.setLat(lat); model.setLng(lng); - model.setUserid(u.getId()+""); + model.setUserid(u.getId()); model.setUsername(u.getUsername()); - model.setPid(u.getPid()+""); - model.setCid(u.getCid()+""); - model.setAid(u.getAid()+""); - model.setState("1"); + + Community community= communityService.findById(communityId); + model.setPid(community.getPid()); + model.setCid(community.getCid()); + model.setAid(community.getAid()); + model.setState(1); model.setAddress(address); + model.setCommunityId(communityId); + model.setTotal(total); + model.setRemain(remain); houseService.save(model); - act.put("message", "ϴԴɹ!"); - act.put("state", "success"); - act.put("url", "admin/house/list.do"); + this.setMessage("ϴԴɹ!"); + this.setStateType(StateType.success); + this.setCommunityId(communityId); return "success"; } @@ -234,37 +298,36 @@ public String cate; } public String updateHouse() { - ActionContext act = ActionContext.getContext(); House model = houseService.findById(id); - model.setRooname(rooname); + model.setCate(cate); model.setSize(size); - model.setAddress(address); - model.setThunb(thunb);model.setCate(cate); - model.setPrice(price); - model.setDescription(description); - model.setContent(content); - model.setLat(lat); - model.setState(state); - model.setLng(lng); + model.setPrice(0); + model.setThunb(thunb); + model.setTotal(total); + model.setRemain(remain); houseService.update(model); - act.put("message", "·Դɹ!"); - act.put("url", "admin/house/edit.do?id=" + id); - act.put("state", "success"); + + this.setMessage("·Դɹ!"); + this.setStateType(StateType.success); + this.setCommunityId(communityId); return "success"; } public String houseList() { HttpServletRequest request = ServletActionContext.getRequest(); - String housename = request.getParameter("housename"); ActionContext act = ActionContext.getContext(); - //ѯ - if (housename==null||"".equals(housename.trim())) { - List list = houseService.list(); - act.put("list", list); - }else { - List list = houseService.list("from House where rooname like '%"+housename+"%' "); - act.put("list", list); + + String query=""; + if(request.getParameterMap().containsKey("cate")){ + query=" and cate like '%"+this.cate+"%'"; } + //ѯ + List list = houseService.list("from House where community_id="+this.communityId+query); + act.put("list", list); + + this.setStateType(request.getParameter(Constants.STATE)==null?null:StateType.valueOf(request.getParameter(Constants.STATE))); + this.setMessage(request.getParameter(Constants.MESSAGE)); + return "success"; } @@ -286,12 +349,10 @@ public String cate; } public String delete() { - Integer id = this.id; - houseService.delete(id); - ActionContext act = ActionContext.getContext(); - act.put("message", "ɾԴɹ!"); - act.put("state", "success"); - act.put("url", "admin/house/"+ret+".do"); + houseService.delete(this.id); + this.setMessage("ɾԴɹ!"); + this.setStateType(StateType.success); + this.setCommunityId(communityId); return "success"; } diff --git a/src/com/app/bean/Community.java b/src/com/app/bean/Community.java index 85fedbd..9550fe3 100644 --- a/src/com/app/bean/Community.java +++ b/src/com/app/bean/Community.java @@ -1,6 +1,7 @@ package com.app.bean; import javax.persistence.*; +import java.util.List; @Entity public class Community { @@ -18,6 +19,11 @@ public class Community { private Integer userId; private Integer type; + private Integer total; + private Integer remain; + + private List houseList; + @Id @Column(name = "id") @SequenceGenerator(name="increment") @@ -149,4 +155,32 @@ public class Community { public void setType(Integer type) { this.type = type; } + + @Transient + public Integer getTotal() { + return total; + } + + public void setTotal(Integer total) { + this.total = total; + } + + @Transient + public Integer getRemain() { + return remain; + } + + public void setRemain(Integer remain) { + this.remain = remain; + } + + @OneToMany(cascade=CascadeType.ALL,targetEntity = House.class) + @JoinColumn(name="community_id",referencedColumnName = "id") + public List getHouseList() { + return houseList; + } + + public void setHouseList(List houseList) { + this.houseList = houseList; + } } diff --git a/src/com/app/bean/House.hbm.xml b/src/com/app/bean/House.hbm.xml deleted file mode 100644 index 6a533d8..0000000 --- a/src/com/app/bean/House.hbm.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/com/app/bean/House.java b/src/com/app/bean/House.java index 519338a..4a5b273 100644 --- a/src/com/app/bean/House.java +++ b/src/com/app/bean/House.java @@ -1,213 +1,274 @@ package com.app.bean; -public class House { - public int id; - public String rooname; - public String address; - public String cate; - - private Integer communityId; - - private Integer total; - - private Integer remain; - - public Integer getCommunityId() { - return communityId; - } - - public void setCommunityId(Integer communityId) { - this.communityId = communityId; - } - - public Integer getTotal() { - return total; - } - - public void setTotal(Integer total) { - this.total = total; - } - - public Integer getRemain() { - return remain; - } - - public void setRemain(Integer remain) { - this.remain = remain; - } - - public String getCate() { - return cate; - } - - public void setCate(String cate) { - this.cate = cate; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - public void setRooname(String rooname) { - this.rooname = rooname; - } - - public String getRooname() { - return rooname; - } - - public String size; - - public void setSize(String size) { - this.size = size; - } - - public String getSize() { - return size; - } - - public String thunb; - - public void setThunb(String thunb) { - this.thunb = thunb; - } - - public String getThunb() { - return thunb; - } - - public String price; - - public void setPrice(String price) { - this.price = price; - } - - public String getPrice() { - return price; - } - - public String description; - - public void setDescription(String description) { - this.description = description; - } - - public String getDescription() { - return description; - } - - public String created; - - public void setCreated(String created) { - this.created = created; - } - - public String getCreated() { - return created; - } - - public String content; +import javax.persistence.*; +import java.util.Objects; - public void setContent(String content) { - this.content = content; - } - - public String getContent() { - return content; - } - - public String lat; - - public void setLat(String lat) { - this.lat = lat; - } - - public String getLat() { - return lat; - } - - public String lng; - - public void setLng(String lng) { - this.lng = lng; - } - - public String getLng() { - return lng; - } - - public String userid; - - public void setUserid(String userid) { - this.userid = userid; - } - - public String getUserid() { - return userid; - } - - public String username; - - public void setUsername(String username) { - this.username = username; - } - - public String getUsername() { - return username; - } - - public String pid; - - public void setPid(String pid) { - this.pid = pid; - } - - public String getPid() { - return pid; - } - - public String cid; - - public void setCid(String cid) { - this.cid = cid; - } - - public String getCid() { - return cid; - } - - public String aid; - - public void setAid(String aid) { - this.aid = aid; - } - - public String getAid() { - return aid; - } - - public String state; - - public void setState(String state) { - this.state = state; - } - - public String getState() { - return state; - } - - public void setId(int id) { - this.id = id; - } - - public int getId() { - - return id; - - } - -} \ No newline at end of file +@Entity +public class House { + private Integer id; + private String rooname; + private String size; + private String thunb; + private Integer price; + private String description; + private String created; + private String content; + private String lat; + private String lng; + private Integer userid; + private String username; + private Integer pid; + private Integer cid; + private Integer aid; + private Integer state; + private String address; + private String cate; + private Integer communityId; + private Integer total; + private Integer remain; + + @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 = "rooname") + public String getRooname() { + return rooname; + } + + public void setRooname(String rooname) { + this.rooname = rooname; + } + + @Basic + @Column(name = "size") + public String getSize() { + return size; + } + + public void setSize(String size) { + this.size = size; + } + + @Basic + @Column(name = "thunb") + public String getThunb() { + return thunb; + } + + public void setThunb(String thunb) { + this.thunb = thunb; + } + + @Basic + @Column(name = "price") + public Integer getPrice() { + return price; + } + + public void setPrice(Integer price) { + this.price = price; + } + + @Basic + @Column(name = "description") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Basic + @Column(name = "created") + public String getCreated() { + return created; + } + + public void setCreated(String created) { + this.created = created; + } + + @Basic + @Column(name = "content") + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + @Basic + @Column(name = "lat") + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + @Basic + @Column(name = "lng") + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + @Basic + @Column(name = "userid") + public Integer getUserid() { + return userid; + } + + public void setUserid(Integer userid) { + this.userid = userid; + } + + @Basic + @Column(name = "username") + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + @Basic + @Column(name = "pid") + public Integer getPid() { + return pid; + } + + public void setPid(Integer pid) { + this.pid = pid; + } + + @Basic + @Column(name = "cid") + public Integer getCid() { + return cid; + } + + public void setCid(Integer cid) { + this.cid = cid; + } + + @Basic + @Column(name = "aid") + public Integer getAid() { + return aid; + } + + public void setAid(Integer aid) { + this.aid = aid; + } + + @Basic + @Column(name = "state") + public Integer getState() { + return state; + } + + public void setState(Integer state) { + this.state = state; + } + + @Basic + @Column(name = "address") + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + @Basic + @Column(name = "cate") + public String getCate() { + return cate; + } + + public void setCate(String cate) { + this.cate = cate; + } + + @Basic + @Column(name = "community_id") + public Integer getCommunityId() { + return communityId; + } + + public void setCommunityId(Integer communityId) { + this.communityId = communityId; + } + + @Basic + @Column(name = "total") + public Integer getTotal() { + return total; + } + + public void setTotal(Integer total) { + this.total = total; + } + + @Basic + @Column(name = "remain") + public Integer getRemain() { + return remain; + } + + public void setRemain(Integer remain) { + this.remain = remain; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + House house = (House) o; + return Objects.equals(id, house.id) && + Objects.equals(rooname, house.rooname) && + Objects.equals(size, house.size) && + Objects.equals(thunb, house.thunb) && + Objects.equals(price, house.price) && + Objects.equals(description, house.description) && + Objects.equals(created, house.created) && + Objects.equals(content, house.content) && + Objects.equals(lat, house.lat) && + Objects.equals(lng, house.lng) && + Objects.equals(userid, house.userid) && + Objects.equals(username, house.username) && + Objects.equals(pid, house.pid) && + Objects.equals(cid, house.cid) && + Objects.equals(aid, house.aid) && + Objects.equals(state, house.state) && + Objects.equals(address, house.address) && + Objects.equals(cate, house.cate) && + Objects.equals(communityId, house.communityId) && + Objects.equals(total, house.total) && + Objects.equals(remain, house.remain); + } + + @Override + public int hashCode() { + return Objects.hash(id, rooname, size, thunb, price, description, created, content, lat, lng, userid, username, pid, cid, aid, state, address, cate, communityId, total, remain); + } +} diff --git a/src/com/app/service/CommunityServiceImpl.java b/src/com/app/service/CommunityServiceImpl.java index 51238b2..9a9c604 100644 --- a/src/com/app/service/CommunityServiceImpl.java +++ b/src/com/app/service/CommunityServiceImpl.java @@ -5,6 +5,7 @@ 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; import org.springframework.orm.hibernate3.HibernateTemplate; @@ -69,7 +70,7 @@ public class CommunityServiceImpl implements CommunityService{ @Override public List list(Community community,Integer type) { - DetachedCriteria criteria= DetachedCriteria.forClass(Community.class,"c"); + DetachedCriteria criteria= DetachedCriteria.forClass(Community.class); criteria.add(Restrictions.eq("type",type)); if(community!=null) { if (community.getName() != null && community.getName().length() > 0) { @@ -85,12 +86,41 @@ public class CommunityServiceImpl implements CommunityService{ criteria.add(Restrictions.eq("aid", community.getAid())); } } -// DetachedCriteria house = DetachedCriteria.forClass(House.class,"h"); -// house.add(Restrictions.eq("h.communityId","c.id")); -// criteria.add(Subqueries.exists(house.setProjection(Projections.rowCount()))); + + String sql= "select community.id,\n" + + " community.name,\n" + + " community.image,\n" + + " community.pid,\n" + + " community.cid,\n" + + " community.aid,\n" + + " community.address,\n" + + " community.longitude,\n" + + " community.latitude,\n" + + " community.house_type as houseType,\n" + + " community.description,\n" + + " community.type as type,\n" + + " community.user_id as userId,\n" + + " b.total,\n" + + " b.remain\n" + + "from community,\n" + + " (select community.id,\n" + + " sum(house.total) as total,\n" + + " sum(house.remain) as remain\n" + + " from community,\n" + + " house\n" + + " where community.id = house.community_id\n" + + " group by community.id) b\n" + + "where community.id = b.id" + + (community.getName() != null && community.getName().length() > 0?" and community.name like '%"+community.getName()+"%'":"") + + (community.getPid() != null?" and community.pid="+community.getPid():"")+ + (community.getCid() != null?" and community.cid="+community.getCid():"")+ + (community.getAid() != null?" and community.aid="+community.getAid():""); + + List communities=hibernateTemplate.getSessionFactory().getCurrentSession().createSQLQuery(sql).setResultTransformer(Transformers.aliasToBean(Community.class)).list(); + try { - return hibernateTemplate.findByCriteria(criteria); - } catch (DataAccessException e) { + return communities; + } catch (Exception e) { e.printStackTrace(); logger.error(e); return new ArrayList<>(); diff --git a/src/com/app/servlet/RegionServlet.java b/src/com/app/servlet/RegionServlet.java index 87b6e60..0dd8422 100644 --- a/src/com/app/servlet/RegionServlet.java +++ b/src/com/app/servlet/RegionServlet.java @@ -45,7 +45,7 @@ public class RegionServlet extends HttpServlet { String flag = request.getParameter("flag"); DB db = new DB(); db.open(); - String html = ""; + String html = ""; if (!"1".equals(flag)) { html=""; } diff --git a/src/log4j-config.properties b/src/log4j-config.properties index a25e1a3..3e5de14 100644 --- a/src/log4j-config.properties +++ b/src/log4j-config.properties @@ -1,5 +1,5 @@ log4j.rootLogger = debug,Console,D - +log4j.logger.org.hibernate.type.descriptor.sql.BasicBinder=TRACE #控制日志的输出等级和分类 # log4j.rootLogger = [ level ] , appenderName, appenderName, … @@ -22,7 +22,24 @@ log4j.appender.Console.layout = org.apache.log4j.PatternLayout log4j.appender.Console.layout.ConversionPattern= [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n -  +########### hibernate +log4j.logger.org.hibernate=debug +log4j.logger.org.hibernate.hql.ast.AST=DEBUG + +#下面的两条配置非常重要,设置为trace后,将可以看到打印出sql中 ? 占位符的实际内容 +#this is the most important config for showing parames like ? +log4j.logger.org.hibernate.SQL=trace +log4j.logger.org.hibernate.type=trace +#above two configs +log4j.logger.org.hibernate.tool.hbm2ddl=DEBUG +log4j.logger.org.hibernate.hql=DEBUG +log4j.logger.org.hibernate.cache=debug + + +log4j.logger.org.hibernate.transaction=DEBUG +log4j.logger.org.hibernate.jdbc=DEBUG +log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace + ### 输出DEBUG 级别以上的日志到服务器/logs/debug.log ### diff --git a/src/struts.xml b/src/struts.xml index 2432f5c..f580611 100644 --- a/src/struts.xml +++ b/src/struts.xml @@ -183,13 +183,19 @@ - /admin/houseadd.jsp + + list.do?state=${stateType}&message=${message}&communityId=${communityId} + true + /admin/houseedit.jsp - /admin/houseedit.jsp + + list.do?state=${stateType}&message=${message}&communityId=${communityId} + true + /admin/houselist.jsp @@ -198,7 +204,10 @@ /admin/myhouselist.jsp - /admin/houselist.jsp + + list.do?state=${stateType}&message=${message}&communityId=${communityId} + true +
房源名称发布人大小位置 价格房源类型状态户型面积单价图片余量/总量 操作
- - ${item.rooname} ${item.username}${item.size}${item.address}${item.price}${item.cate}${item.size}${item.price}${item.cate} - 闲置 - 使用中 - + ${item.remain}/${item.total} - + 编辑 - + 移除