|
@@ -1,274 +1,59 @@
|
|
|
-//package com.happy.action;
|
|
|
|
|
-//
|
|
|
|
|
-//import com.google.gson.Gson;
|
|
|
|
|
-//import com.google.gson.reflect.TypeToken;
|
|
|
|
|
-//import com.happy.Model.Admin;
|
|
|
|
|
-//import com.happy.Model.Booking;
|
|
|
|
|
-//import com.happy.Model.House;
|
|
|
|
|
-//import com.happy.Until.GetHttpParam;
|
|
|
|
|
-//import com.happy.Until.PwdDefind;
|
|
|
|
|
-//import com.happy.Until.ResUtil;
|
|
|
|
|
-//import com.happy.Until.ResponseUtil;
|
|
|
|
|
-//import com.happy.service.BookService;
|
|
|
|
|
-//import com.happy.service.HouseService;
|
|
|
|
|
-//import com.opensymphony.xwork2.ActionSupport;
|
|
|
|
|
-//import net.sf.json.JSONObject;
|
|
|
|
|
-//import org.apache.struts2.ServletActionContext;
|
|
|
|
|
-//import org.apache.struts2.interceptor.ServletRequestAware;
|
|
|
|
|
-//
|
|
|
|
|
-//import javax.annotation.Resource;
|
|
|
|
|
-//import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
-//import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
-//import java.util.List;
|
|
|
|
|
-//import java.util.Objects;
|
|
|
|
|
-//
|
|
|
|
|
-//public class houseAction extends ActionSupport implements ServletRequestAware {
|
|
|
|
|
-//
|
|
|
|
|
-// private HttpServletRequest request;
|
|
|
|
|
-// public HttpServletResponse response;
|
|
|
|
|
-//
|
|
|
|
|
-// @Resource
|
|
|
|
|
-// public HouseService houseService;
|
|
|
|
|
-// @Resource
|
|
|
|
|
-// public BookService bookService;
|
|
|
|
|
-//
|
|
|
|
|
-// public Integer id;
|
|
|
|
|
-// public int page; // 当前页
|
|
|
|
|
-// public int rows;// 每页显示的行数rows
|
|
|
|
|
-// public String h_type;
|
|
|
|
|
-//
|
|
|
|
|
-// public HttpServletRequest getRequest() {
|
|
|
|
|
-// return request;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// public void setRequest(HttpServletRequest request) {
|
|
|
|
|
-// this.request = request;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// public void setServletRequest(HttpServletRequest request) {
|
|
|
|
|
-// this.request = request;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// public HttpServletResponse getResponse() {
|
|
|
|
|
-// return response;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// public void setResponse(HttpServletResponse response) {
|
|
|
|
|
-// this.response = response;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// public Integer getId() {
|
|
|
|
|
-// return id;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// public void setId(Integer id) {
|
|
|
|
|
-// this.id = id;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// public int getPage() {
|
|
|
|
|
-// return page;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// public void setPage(int page) {
|
|
|
|
|
-// this.page = page;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// public int getRows() {
|
|
|
|
|
-// return rows;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// public void setRows(int rows) {
|
|
|
|
|
-// this.rows = rows;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// public String getH_type() {
|
|
|
|
|
-// return h_type;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// public void setH_type(String h_type) {
|
|
|
|
|
-// this.h_type = h_type;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// public String insert() {
|
|
|
|
|
-// JSONObject resultjson = new JSONObject();
|
|
|
|
|
-// Gson gson = new Gson();
|
|
|
|
|
-// com.alibaba.fastjson.JSONObject json = GetHttpParam.getHttpParam(request);
|
|
|
|
|
-// System.out.println(json);
|
|
|
|
|
-// if (json == null) {
|
|
|
|
|
-// resultjson.put("message", "请传入参数");
|
|
|
|
|
-// ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
-// return null;
|
|
|
|
|
-// }
|
|
|
|
|
-// House house = null;
|
|
|
|
|
-// try {
|
|
|
|
|
-// house = gson.fromJson(json.toString(), new TypeToken<House>() {}.getType());
|
|
|
|
|
-// if (house == null) {
|
|
|
|
|
-// resultjson.put("message", "数据为空");
|
|
|
|
|
-// resultjson.put("code", 500);
|
|
|
|
|
-// ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
-// return null;
|
|
|
|
|
-// }
|
|
|
|
|
-//// if (house.getH_type()==null || house.getNumber()==null || house.getPrice()==null){
|
|
|
|
|
-//// resultjson.put("message", "各参数不能为空");
|
|
|
|
|
-//// resultjson.put("code", 500);
|
|
|
|
|
-//// ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
-//// return null;
|
|
|
|
|
-//// }
|
|
|
|
|
-//// House listc = houseService.queryByType(house.getH_type());
|
|
|
|
|
-//// if (listc != null) {
|
|
|
|
|
-//// resultjson.put("message", "该户型已存在");
|
|
|
|
|
-//// resultjson.put("code", 500);
|
|
|
|
|
-//// ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
-//// return null;
|
|
|
|
|
-//// }
|
|
|
|
|
-//// int m = houseService.insert(house);
|
|
|
|
|
-//// if (m > 0) {
|
|
|
|
|
-//// resultjson.put("message", "添加成功");
|
|
|
|
|
-//// resultjson.put("code", 200);
|
|
|
|
|
-//// ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
-//// return null;
|
|
|
|
|
-//// } else {
|
|
|
|
|
-//// resultjson.put("message", "添加失败");
|
|
|
|
|
-//// resultjson.put("code", 502);
|
|
|
|
|
-//// ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
-//// return null;
|
|
|
|
|
-//// }
|
|
|
|
|
-//// } catch (Exception e) {
|
|
|
|
|
-//// e.printStackTrace();
|
|
|
|
|
-//// }
|
|
|
|
|
-//// resultjson.put("message", "未知异常");
|
|
|
|
|
-//// resultjson.put("code", 205);
|
|
|
|
|
-//// ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
-// return null;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// public String update() {
|
|
|
|
|
-// JSONObject resultjson = new JSONObject();
|
|
|
|
|
-// Gson gson = new Gson();
|
|
|
|
|
-// com.alibaba.fastjson.JSONObject json = GetHttpParam.getHttpParam(request);
|
|
|
|
|
-// System.out.println(json);
|
|
|
|
|
-// if (json == null) {
|
|
|
|
|
-// resultjson.put("message", "请传入参数");
|
|
|
|
|
-// ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
-// return null;
|
|
|
|
|
-// }
|
|
|
|
|
-// House house = null;
|
|
|
|
|
-// try {
|
|
|
|
|
-// house = gson.fromJson(json.toString(), new TypeToken<House>() {}.getType());
|
|
|
|
|
-// if (house == null) {
|
|
|
|
|
-// resultjson.put("message", "数据为空");
|
|
|
|
|
-// resultjson.put("code", 500);
|
|
|
|
|
-// ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
-// return null;
|
|
|
|
|
-// }
|
|
|
|
|
-// if (house.getH_type()==null || house.getNumber()==null || house.getPrice()==null){
|
|
|
|
|
-// resultjson.put("message", "各参数不能为空");
|
|
|
|
|
-// resultjson.put("code", 500);
|
|
|
|
|
-// ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
-// return null;
|
|
|
|
|
-// }
|
|
|
|
|
-// House listc = houseService.queryByType(house.getH_type());
|
|
|
|
|
-// if (listc!=null && !Objects.equals(listc.getId(), house.getId())){
|
|
|
|
|
-// resultjson.put("message", "户型已存在");
|
|
|
|
|
-// resultjson.put("code", 500);
|
|
|
|
|
-// ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
-// return null;
|
|
|
|
|
-// }
|
|
|
|
|
-// boolean booking = bookService.queryOrdering(house.getH_type(),house.getNumber());
|
|
|
|
|
-// if (!booking){
|
|
|
|
|
-// resultjson.put("message", "修改后的房间数量不能少于已预订的房间数量");
|
|
|
|
|
-// resultjson.put("code", 500);
|
|
|
|
|
-// ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
-// return null;
|
|
|
|
|
-// }
|
|
|
|
|
-// int m = houseService.update(house);
|
|
|
|
|
-// if (m > 0) {
|
|
|
|
|
-// resultjson.put("message", "修改成功");
|
|
|
|
|
-// resultjson.put("code", 200);
|
|
|
|
|
-// ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
-// return null;
|
|
|
|
|
-// } else {
|
|
|
|
|
-// resultjson.put("message", "修改失败");
|
|
|
|
|
-// resultjson.put("code", 502);
|
|
|
|
|
-// ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
-// return null;
|
|
|
|
|
-// }
|
|
|
|
|
-// } catch (Exception e) {
|
|
|
|
|
-// e.printStackTrace();
|
|
|
|
|
-// }
|
|
|
|
|
-// resultjson.put("message", "未知异常");
|
|
|
|
|
-// resultjson.put("code", 205);
|
|
|
|
|
-// ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
-// return null;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// public String del() {
|
|
|
|
|
-// JSONObject resultjson = new JSONObject();
|
|
|
|
|
-// if (id == null) {
|
|
|
|
|
-// resultjson.put("message", "请传入id");
|
|
|
|
|
-// resultjson.put("code", 500);
|
|
|
|
|
-// ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
-// return null;
|
|
|
|
|
-// }
|
|
|
|
|
-// House house = houseService.queryById(id);
|
|
|
|
|
-// if (house==null){
|
|
|
|
|
-// resultjson.put("message", "该房型已删除");
|
|
|
|
|
-// resultjson.put("code", 500);
|
|
|
|
|
-// ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
-// return null;
|
|
|
|
|
-// }
|
|
|
|
|
-// List<Booking> booking = bookService.queryOrderByType(house.getH_type());
|
|
|
|
|
-// if (booking!=null){
|
|
|
|
|
-// resultjson.put("message", "该房型有未完成的订单");
|
|
|
|
|
-// resultjson.put("code", 500);
|
|
|
|
|
-// ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
-// return null;
|
|
|
|
|
-// }
|
|
|
|
|
-// int m = houseService.del(id);
|
|
|
|
|
-// if (m > 0) {
|
|
|
|
|
-// resultjson.put("message", "删除成功");
|
|
|
|
|
-// resultjson.put("code", 200);
|
|
|
|
|
-// ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
-// return null;
|
|
|
|
|
-// }
|
|
|
|
|
-// resultjson.put("message", "未知异常");
|
|
|
|
|
-// resultjson.put("code", 205);
|
|
|
|
|
-// ResUtil.writeJson(ServletActionContext.getResponse(), resultjson.toString());
|
|
|
|
|
-// return null;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// // 查看户型
|
|
|
|
|
-// public String list() {
|
|
|
|
|
-// JSONObject resultJson = new JSONObject();
|
|
|
|
|
-// StringBuilder s1 = new StringBuilder("");
|
|
|
|
|
-// if (h_type!=null){
|
|
|
|
|
-// s1.append(" and h_type like '%").append(this.h_type).append("%' ");
|
|
|
|
|
-// }
|
|
|
|
|
-//// int total = houseService.queryHouseTotal(s1.toString()); // 查询表中的总记录数
|
|
|
|
|
-//// List<House> listPage = houseService.queryHousePage(s1.toString(),page,rows); // 查询分页
|
|
|
|
|
-//
|
|
|
|
|
-//// if (listPage == null) {
|
|
|
|
|
-//// resultJson.put("rows", "");
|
|
|
|
|
-//// resultJson.put("total", 0);
|
|
|
|
|
-//// } else {
|
|
|
|
|
-//// resultJson.put("code", 200);
|
|
|
|
|
-//// resultJson.put("rows", listPage);
|
|
|
|
|
-//// // int total = listAll.size();
|
|
|
|
|
-//// resultJson.put("total", total);// 总记录数
|
|
|
|
|
-//// int totalPage = total % rows == 0 ? (total / rows)
|
|
|
|
|
-//// : (total / rows) + 1;// 总页数
|
|
|
|
|
-//// resultJson.put("totalPage", totalPage);
|
|
|
|
|
-//// resultJson.put("currentPage", page);// 当前页
|
|
|
|
|
-//// resultJson.put("numPerPage", rows);// 每页数
|
|
|
|
|
-//// resultJson.put("nextPage", totalPage - page == 0 ? page : page + 1);// 下一页
|
|
|
|
|
-//// resultJson.put("previousPage", page - 0 == 1 ? page : page - 1);// 上一页
|
|
|
|
|
-//// resultJson.put("hasPreviousPage", true);// 有上一页
|
|
|
|
|
-//// resultJson.put("hasNextPage", true);// 有下一页
|
|
|
|
|
-//// resultJson.put("firstPage", true);// 首页
|
|
|
|
|
-//// resultJson.put("lastPage", true);// 尾页
|
|
|
|
|
-//// }
|
|
|
|
|
-// ResponseUtil.writeJson(ServletActionContext.getResponse(),
|
|
|
|
|
-// resultJson.toString());
|
|
|
|
|
-// return null;
|
|
|
|
|
-// }
|
|
|
|
|
-//}
|
|
|
|
|
|
|
+package com.happy.action;
|
|
|
|
|
+
|
|
|
|
|
+import com.google.gson.Gson;
|
|
|
|
|
+import com.google.gson.reflect.TypeToken;
|
|
|
|
|
+import com.happy.Model.Admin;
|
|
|
|
|
+import com.happy.Model.Booking;
|
|
|
|
|
+import com.happy.Model.House;
|
|
|
|
|
+import com.happy.Until.GetHttpParam;
|
|
|
|
|
+import com.happy.Until.PwdDefind;
|
|
|
|
|
+import com.happy.Until.ResUtil;
|
|
|
|
|
+import com.happy.Until.ResponseUtil;
|
|
|
|
|
+import com.happy.service.BookService;
|
|
|
|
|
+import com.happy.service.HouseService;
|
|
|
|
|
+import com.opensymphony.xwork2.ActionSupport;
|
|
|
|
|
+import net.sf.json.JSONObject;
|
|
|
|
|
+import org.apache.struts2.ServletActionContext;
|
|
|
|
|
+import org.apache.struts2.interceptor.ServletRequestAware;
|
|
|
|
|
+
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
+
|
|
|
|
|
+public class houseAction extends ActionSupport implements ServletRequestAware {
|
|
|
|
|
+
|
|
|
|
|
+ private HttpServletRequest request;
|
|
|
|
|
+ public HttpServletResponse response;
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ public HouseService houseService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ public BookService bookService;
|
|
|
|
|
+
|
|
|
|
|
+ public Integer id;
|
|
|
|
|
+ public int page; // 当前页
|
|
|
|
|
+ public int rows;// 每页显示的行数rows
|
|
|
|
|
+
|
|
|
|
|
+ public HttpServletRequest getRequest() {
|
|
|
|
|
+ return request;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void setRequest(HttpServletRequest request) {
|
|
|
|
|
+ this.request = request;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void setServletRequest(HttpServletRequest request) {
|
|
|
|
|
+ this.request = request;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public HttpServletResponse getResponse() {
|
|
|
|
|
+ return response;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void setResponse(HttpServletResponse response) {
|
|
|
|
|
+ this.response = response;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|