|
|
@@ -1,11 +1,10 @@
|
|
|
package com.happy.action;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
+import com.happy.Model.*;
|
|
|
import com.happy.Model.AdminManager;
|
|
|
-import com.happy.Model.AdminManager;
|
|
|
-import com.happy.Model.AdminPower;
|
|
|
-import com.happy.Model.File;
|
|
|
import com.happy.Until.GetHttpParam;
|
|
|
import com.happy.Until.PwdDefind;
|
|
|
import com.happy.Until.ResUtil;
|
|
|
@@ -14,6 +13,7 @@ import com.happy.dto.IPage;
|
|
|
import com.happy.service.AdminManagerService;
|
|
|
import com.happy.service.AdminService;
|
|
|
import com.happy.service.FileService;
|
|
|
+import com.happy.service.HotelService;
|
|
|
import com.opensymphony.xwork2.ActionSupport;
|
|
|
import net.sf.json.JSONObject;
|
|
|
import org.apache.struts2.ServletActionContext;
|
|
|
@@ -36,6 +36,9 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
|
|
|
public AdminManagerService adminManagerService;
|
|
|
|
|
|
@Resource
|
|
|
+ public HotelService hotelService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
public FileService fileService;
|
|
|
|
|
|
public String adminName;
|
|
|
@@ -76,6 +79,13 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
|
|
|
.append(" and password = '").append(password).append("'");
|
|
|
AdminManager login = adminManagerService.getOen(getOneSqlx.toString());
|
|
|
if (login != null) {
|
|
|
+ //是否首次登录
|
|
|
+ Hotel hotel = hotelService.getOen("and manager_id = '"+login.getId()+"'");
|
|
|
+ if(hotel==null){
|
|
|
+ resultJson.put("isLogin",1);
|
|
|
+ }else{
|
|
|
+ resultJson.put("isLogin",0);
|
|
|
+ }
|
|
|
login.setPassword("********");
|
|
|
resultJson.put("message", "登录成功");
|
|
|
resultJson.put("code", 200);
|
|
|
@@ -90,7 +100,7 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 描述:新增民宿端账号
|
|
|
+ * 描述:新增管理端民宿账号
|
|
|
* @return
|
|
|
*/
|
|
|
public String insertAdmin() {
|
|
|
@@ -134,12 +144,11 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
|
|
|
return null;
|
|
|
}
|
|
|
admin.setId(Math.toIntExact(UUIDUtil.generateID()));
|
|
|
+ admin.setManagerId(admin.getId());
|
|
|
//保存详细图附件
|
|
|
- if(admin.getFileList()!=null && admin.getFileList().size()>0){
|
|
|
- if(admin.getId()!= null){
|
|
|
- fileService.delLinkFile(admin.getId());
|
|
|
- }
|
|
|
- for(File file : admin.getFileList()){
|
|
|
+ List<File> fileList = JSONArray.parseArray(admin.getFileListJson(), File.class);
|
|
|
+ if(fileList!=null && fileList.size()>0){
|
|
|
+ for(File file : fileList){
|
|
|
file.setLinkId(admin.getId());
|
|
|
fileService.insertFile(file);
|
|
|
}
|
|
|
@@ -170,7 +179,7 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 描述:修改管理端管理员账号
|
|
|
+ * 描述:修改管理端民宿账号
|
|
|
* @return
|
|
|
*/
|
|
|
public String updateAdmin() {
|
|
|
@@ -197,7 +206,7 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
|
|
|
ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
return null;
|
|
|
}
|
|
|
- if (admin.getAdminName()==null || admin.getHotelName()==null || admin.getHotelTownship()==null
|
|
|
+ if (admin.getAdminName()==null || admin.getCorpnName()==null || admin.getHotelTownship()==null
|
|
|
|| admin.getLevel()==null || admin.getCardName()==null || admin.getCorpnPhone()==null){
|
|
|
resultJson.put("message", "各参数不能为空");
|
|
|
resultJson.put("code", 500);
|
|
|
@@ -220,6 +229,152 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
|
|
|
ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
return null;
|
|
|
}
|
|
|
+ //修改详细图附件
|
|
|
+ List<File> fileList = JSONArray.parseArray(admin.getFileListJson(), File.class);
|
|
|
+ if(fileList!=null && fileList.size()>0){
|
|
|
+ if(admin.getId()!= null){
|
|
|
+ fileService.delLinkFile(admin.getId());
|
|
|
+ }
|
|
|
+ for(File file : fileList){
|
|
|
+ file.setLinkId(admin.getId());
|
|
|
+ fileService.insertFile(file);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ resultJson.put("message", "请上传详细图");
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ int m = adminManagerService.updateAdmin(admin);
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 描述:新增民宿端普通账号
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String insertAdminManager() {
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
+ Gson gson = new Gson();
|
|
|
+ com.alibaba.fastjson.JSONObject json = GetHttpParam.getRequestParameters(request);
|
|
|
+ if (json == null) {
|
|
|
+ resultJson.put("message", "请传入参数");
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ AdminManager admin = null;
|
|
|
+ try {
|
|
|
+ admin = gson.fromJson(json.toString(), new TypeToken<AdminManager>() {}.getType());
|
|
|
+ if (admin == null) {
|
|
|
+ resultJson.put("message", "数据为空");
|
|
|
+ resultJson.put("code", 500);
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (admin.getAdminName()==null || admin.getCorpnName()==null || admin.getCorpnPhone()==null
|
|
|
+ || admin.getLevel()==null || admin.getPassword()==null){
|
|
|
+ resultJson.put("message", "各参数不能为空");
|
|
|
+ resultJson.put("code", 500);
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (!PwdDefind.vertify(admin.getPassword())){
|
|
|
+ resultJson.put("message", "密码至少包含:大小写英文字母、数字、特殊符号,密码长度大于8位,小于20位");
|
|
|
+ resultJson.put("code", 500);
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ StringBuilder getOneSqlx = new StringBuilder("");
|
|
|
+ getOneSqlx.append(" and admin_name = '").append(admin.getAdminName()).append("'");
|
|
|
+ AdminManager listc = adminManagerService.getOen(getOneSqlx.toString());
|
|
|
+ if (listc != null) {
|
|
|
+ resultJson.put("message", "该用户已存在");
|
|
|
+ resultJson.put("code", 500);
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ int m = adminManagerService.insertAdmin(admin);
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 描述:修改民宿端普通账号
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String updateAdminManager() {
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
+ Gson gson = new Gson();
|
|
|
+ com.alibaba.fastjson.JSONObject json = GetHttpParam.getRequestParameters(request);
|
|
|
+ if (json == null) {
|
|
|
+ resultJson.put("message", "请传入参数");
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ AdminManager admin = null;
|
|
|
+ try {
|
|
|
+ admin = gson.fromJson(json.toString(), new TypeToken<AdminManager>() {}.getType());
|
|
|
+ if (admin == null) {
|
|
|
+ resultJson.put("message", "数据为空");
|
|
|
+ resultJson.put("code", 500);
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (admin.getAdminName()==null || admin.getCardName()==null || admin.getCorpnPhone()==null
|
|
|
+ || admin.getLevel()==null || admin.getPassword()==null){
|
|
|
+ resultJson.put("message", "各参数不能为空");
|
|
|
+ resultJson.put("code", 500);
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (!PwdDefind.vertify(admin.getPassword())){
|
|
|
+ resultJson.put("message", "密码至少包含:大小写英文字母、数字、特殊符号,密码长度大于8位,小于20位");
|
|
|
+ resultJson.put("code", 500);
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ StringBuilder getOneSqlx = new StringBuilder("");
|
|
|
+ getOneSqlx.append(" and admin_name = '").append(admin.getAdminName()).append("'");
|
|
|
+ getOneSqlx.append(" and id != '").append(admin.getId()).append("'");
|
|
|
+ AdminManager listc = adminManagerService.getOen(getOneSqlx.toString());
|
|
|
+ if (listc != null) {
|
|
|
+ resultJson.put("message", "该用户已存在");
|
|
|
+ resultJson.put("code", 500);
|
|
|
+ ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
int m = adminManagerService.updateAdmin(admin);
|
|
|
if (m > 0) {
|
|
|
resultJson.put("message", "修改成功");
|
|
|
@@ -313,7 +468,7 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
|
|
|
}
|
|
|
AdminManager admin = adminManagerService.getById(id);
|
|
|
if (admin != null && !"".equals(admin)) {
|
|
|
- admin.setStatus(0);
|
|
|
+ admin.setStatus(2);
|
|
|
int m = adminManagerService.updateAdmin(admin);
|
|
|
if(m > 0){
|
|
|
resultJson.put("message", "冻结成功");
|
|
|
@@ -407,6 +562,8 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
|
|
|
return null;
|
|
|
}
|
|
|
AdminManager admin = adminManagerService.getById(id);
|
|
|
+ List<File> fileList = fileService.queryList("and link_id ='"+id+"'");
|
|
|
+ admin.setFileList(fileList);
|
|
|
if (admin != null) {
|
|
|
resultJson.put("message", "查询成功");
|
|
|
resultJson.put("code", 200);
|