Ver código fonte

修改查询空值判断

raojiaolong@163.com 2 anos atrás
pai
commit
c61bf767b5

+ 13 - 0
mhotel/src/com/happy/Model/AdminManager.java

@@ -43,6 +43,11 @@ public class AdminManager {
 	private String hotelTownship;
 	private String hotelTownship;
 
 
 	/**
 	/**
+	 * 所属乡镇
+	 */
+	private String hotelTownshipName;
+
+	/**
 	 * 法人姓名
 	 * 法人姓名
 	 */
 	 */
 	private String corpnName;
 	private String corpnName;
@@ -157,6 +162,14 @@ public class AdminManager {
 		this.hotelTownship = hotelTownship;
 		this.hotelTownship = hotelTownship;
 	}
 	}
 
 
+	public String getHotelTownshipName() {
+		return hotelTownshipName;
+	}
+
+	public void setHotelTownshipName(String hotelTownshipName) {
+		this.hotelTownshipName = hotelTownshipName;
+	}
+
 	public String getCorpnName() {
 	public String getCorpnName() {
 		return corpnName;
 		return corpnName;
 	}
 	}

+ 9 - 4
mhotel/src/com/happy/action/adminAction.java

@@ -60,18 +60,23 @@ public class adminAction extends ActionSupport implements ServletRequestAware {
     public String loginAdmin() {
     public String loginAdmin() {
         JSONObject resultJson = new JSONObject();
         JSONObject resultJson = new JSONObject();
         StringBuilder getOneSqlx = new StringBuilder("");
         StringBuilder getOneSqlx = new StringBuilder("");
-        getOneSqlx.append(" and admin_name = '").append(adminName).append("'")
-                .append(" and password = '").append(password).append("'");
+        getOneSqlx.append(" and admin_name = '").append(adminName).append("'");
         Admin login = adminService.getOen(getOneSqlx.toString());
         Admin login = adminService.getOen(getOneSqlx.toString());
         if (login != null) {
         if (login != null) {
-            login.setPassword("********");
+            if(!login.getPassword().equals(password)){
+                resultJson.put("message", "用户名或密码错误");
+                resultJson.put("code", 205);
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            }
+            //login.setPassword("********");
             resultJson.put("message", "登录成功");
             resultJson.put("message", "登录成功");
             resultJson.put("code", 200);
             resultJson.put("code", 200);
             resultJson.put("data", login);
             resultJson.put("data", login);
             ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
             ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
             return null;
             return null;
         }
         }
-        resultJson.put("message", "用户名或密码错误");
+        resultJson.put("message", "该账户不存在");
         resultJson.put("code", 205);
         resultJson.put("code", 205);
         ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
         ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
         return null;
         return null;

+ 8 - 3
mhotel/src/com/happy/action/adminManagerAction.java

@@ -80,10 +80,15 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
     public String loginAdmin() {
     public String loginAdmin() {
         JSONObject resultJson = new JSONObject();
         JSONObject resultJson = new JSONObject();
         StringBuilder getOneSqlx = new StringBuilder("");
         StringBuilder getOneSqlx = new StringBuilder("");
-        getOneSqlx.append(" and admin_name = '").append(adminName).append("'")
-                .append(" and password = '").append(password).append("'");
+        getOneSqlx.append(" and admin_name = '").append(adminName).append("'");
         AdminManager login = adminManagerService.getOen(getOneSqlx.toString());
         AdminManager login = adminManagerService.getOen(getOneSqlx.toString());
         if (login != null) {
         if (login != null) {
+            if(!login.getPassword().equals(password)){
+                resultJson.put("message", "用户名或密码错误");
+                resultJson.put("code", 205);
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            }
             if(login.getStatus()==2){
             if(login.getStatus()==2){
                 resultJson.put("message", "账号已冻结请联系管理员");
                 resultJson.put("message", "账号已冻结请联系管理员");
                 resultJson.put("code", 205);
                 resultJson.put("code", 205);
@@ -105,7 +110,7 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
                 return null;
                 return null;
             }
             }
         }
         }
-        resultJson.put("message", "用户名或密码错误");
+        resultJson.put("message", "该账户不存在");
         resultJson.put("code", 205);
         resultJson.put("code", 205);
         ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
         ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
         return null;
         return null;

+ 16 - 12
mhotel/src/com/happy/action/hotelAction.java

@@ -144,7 +144,7 @@ public class hotelAction extends ActionSupport implements ServletRequestAware {
         if (managerId!=null){
         if (managerId!=null){
             s1.append(" and manager_id = '").append(managerId).append("'");
             s1.append(" and manager_id = '").append(managerId).append("'");
         }else{
         }else{
-            resultJson.put("message", "请传入登陆人账号Id");
+            resultJson.put("message", "请传入managerId");
             ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
             ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
             return null;
             return null;
         }
         }
@@ -155,24 +155,28 @@ public class hotelAction extends ActionSupport implements ServletRequestAware {
         AdminManager adminManager = adminManagerService.getById(managerId);
         AdminManager adminManager = adminManagerService.getById(managerId);
         //查询民宿信息
         //查询民宿信息
         Hotel hotel = hotelService.getOen(s1.toString());
         Hotel hotel = hotelService.getOen(s1.toString());
-        //获取有效民宿配置
-        if(hotel.getHconfig() != null && !"".equals(hotel.getHconfig())){
-            hotel.setHconfig(hotelDictService.setConfig(hotel.getHconfig()));
-        }
+
         HotelEto hotelEto = new HotelEto();
         HotelEto hotelEto = new HotelEto();
         if(adminManager!=null){
         if(adminManager!=null){
             BeanUtils.copyProperties(adminManager,hotelEto);
             BeanUtils.copyProperties(adminManager,hotelEto);
         }
         }
         if(hotel!=null){
         if(hotel!=null){
+            //获取有效民宿配置
+            if(hotel.getHconfig() != null && !"".equals(hotel.getHconfig())){
+                hotel.setHconfig(hotelDictService.setConfig(hotel.getHconfig()));
+            }
             BeanUtils.copyProperties(hotel,hotelEto);
             BeanUtils.copyProperties(hotel,hotelEto);
+            StringBuilder fileSqlx = new StringBuilder("");
+            fileSqlx.append("and link_id = '").append(hotel.getId()).append("'");
+            List<FileInfo> fileList = fileService.queryList(fileSqlx.toString());
+            hotelEto.setFileInfoList(fileList);
+            resultJson.put("message", "查询成功");
+            resultJson.put("code", 200);
+            resultJson.put("data", hotelEto);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
         }
         }
-        StringBuilder fileSqlx = new StringBuilder("");
-        fileSqlx.append("and link_id = '").append(hotel.getId()).append("'");
-        List<FileInfo> fileList = fileService.queryList(fileSqlx.toString());
-        hotelEto.setFileInfoList(fileList);
-        resultJson.put("message", "查询成功");
-        resultJson.put("code", 200);
-        resultJson.put("data", hotelEto);
+        resultJson.put("message", "未查到数据");
+        resultJson.put("code", 500);
         ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
         ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
         return null;
         return null;
     }
     }

+ 5 - 4
mhotel/src/com/happy/action/houseAction.java

@@ -256,15 +256,16 @@ public class houseAction extends ActionSupport implements ServletRequestAware {
             return null;
             return null;
         }
         }
         House house = houseService.getById(id);
         House house = houseService.getById(id);
-        //获取有效房型服务
-        if(house.gethConfig() != null && !"".equals(house.gethConfig())){
-            house.sethConfig(hotelDictService.setConfig(house.gethConfig()));
-        }
+
         StringBuilder fileSqlx = new StringBuilder("");
         StringBuilder fileSqlx = new StringBuilder("");
         fileSqlx.append("and link_id = '").append(id).append("'");
         fileSqlx.append("and link_id = '").append(id).append("'");
         List<FileInfo> fileInfoList = fileService.queryList(fileSqlx.toString());
         List<FileInfo> fileInfoList = fileService.queryList(fileSqlx.toString());
         house.setFileInfoList(fileInfoList);
         house.setFileInfoList(fileInfoList);
         if (house != null) {
         if (house != null) {
+            //获取有效房型服务
+            if(house.gethConfig() != null && !"".equals(house.gethConfig())){
+                house.sethConfig(hotelDictService.setConfig(house.gethConfig()));
+            }
             resultJson.put("message", "查询成功");
             resultJson.put("message", "查询成功");
             resultJson.put("code", 200);
             resultJson.put("code", 200);
             resultJson.put("data", house);
             resultJson.put("data", house);

+ 8 - 6
mhotel/src/com/happy/dao/impl/AdminManagerImplDao.java

@@ -28,9 +28,11 @@ public class AdminManagerImplDao implements AdminManagerDao {
         this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
         this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
     }
     }
 
 
-    public String selectSql="select " +
-            "id, manager_id, admin_name, password, hotel_name, hotel_township, corpn_name, corpn_phone, level, admin_power, bank_card, card_name, bank_name, create_id, DATE_FORMAT(create_date,'%Y-%m-%d %T') create_date,DATE_FORMAT(modify_date,'%Y-%m-%d %T') modify_date,status,remark,openid" +
-            " from `admin_manager` ";
+    public String selectSql =
+        "select " +
+        "a.id, a.manager_id, a.admin_name, a.password, a.hotel_name, a.hotel_township, b.name hotel_township_name, a.corpn_name, a.corpn_phone, a.level, a.admin_power, a.bank_card, a.card_name, a.bank_name, a.create_id, DATE_FORMAT(a.create_date,'%Y-%m-%d %T') create_date,DATE_FORMAT(a.modify_date,'%Y-%m-%d %T') modify_date,a.status,a.remark,a.openid " +
+        "from `admin_manager` a " +
+        "left join hotel_dict b on a.hotel_township = b.id";
 
 
 
 
     @Override
     @Override
@@ -105,7 +107,7 @@ public class AdminManagerImplDao implements AdminManagerDao {
 
 
     @Override
     @Override
     public AdminManager getById(int id) {
     public AdminManager getById(int id) {
-        String sql = selectSql + " WHERE id = :id ";
+        String sql = selectSql + " WHERE a.id = :id ";
         MapSqlParameterSource sps = new MapSqlParameterSource();
         MapSqlParameterSource sps = new MapSqlParameterSource();
         sps.addValue("id",id);
         sps.addValue("id",id);
         List<AdminManager> list = null;
         List<AdminManager> list = null;
@@ -122,7 +124,7 @@ public class AdminManagerImplDao implements AdminManagerDao {
     @Override
     @Override
     public List<AdminManager> queryPage(String sqlx, int page, int rows) {
     public List<AdminManager> queryPage(String sqlx, int page, int rows) {
         int start = (page - 1) * rows;// 每页的起始下标
         int start = (page - 1) * rows;// 每页的起始下标
-        String sql = selectSql + " WHERE status!=0 "+sqlx+" ORDER BY id DESC limit :start,:rows ";
+        String sql = selectSql + " WHERE a.status!=0 "+sqlx+" ORDER BY a.id DESC limit :start,:rows ";
         MapSqlParameterSource sps = new MapSqlParameterSource();
         MapSqlParameterSource sps = new MapSqlParameterSource();
         sps.addValue("start", start);
         sps.addValue("start", start);
         sps.addValue("rows", rows);
         sps.addValue("rows", rows);
@@ -141,7 +143,7 @@ public class AdminManagerImplDao implements AdminManagerDao {
 
 
     @Override
     @Override
     public List<AdminManager> queryList(String sqlx) {
     public List<AdminManager> queryList(String sqlx) {
-        String sql = selectSql + " WHERE status!=0 "+sqlx;
+        String sql = selectSql + " WHERE a.status!=0 "+sqlx ;
         List<AdminManager> list = null;
         List<AdminManager> list = null;
         try{
         try{
             list = namedParameterJdbcTemplate.query(sql, new BeanPropertyRowMapper<>(AdminManager.class));
             list = namedParameterJdbcTemplate.query(sql, new BeanPropertyRowMapper<>(AdminManager.class));

+ 1 - 1
mhotel/src/com/happy/dao/impl/UserDaoImpl.java

@@ -14,7 +14,7 @@ import org.springframework.stereotype.Repository;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 
 
-@Repository("UserDao")
+@Repository("UsersDao")
 public class UserDaoImpl implements UserDao {
 public class UserDaoImpl implements UserDao {
 
 
     @Autowired
     @Autowired

+ 1 - 0
mhotel/src/com/happy/service/impl/HotelDictImplService.java

@@ -62,6 +62,7 @@ public class HotelDictImplService implements HotelDictService {
 
 
     @Override
     @Override
     public String setConfig(String ids) {
     public String setConfig(String ids) {
+        if("".equals(ids)) return "";
         return hotelDictDao.setConfig(ids);
         return hotelDictDao.setConfig(ids);
     }
     }