|
|
@@ -1,5 +1,6 @@
|
|
|
package com.happy.action;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
import com.happy.Model.AdminManager;
|
|
|
@@ -90,7 +91,7 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 描述:新增民宿端账号
|
|
|
+ * 描述:新增管理端民宿账号
|
|
|
* @return
|
|
|
*/
|
|
|
public String insertAdmin() {
|
|
|
@@ -135,11 +136,9 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
|
|
|
}
|
|
|
admin.setId(Math.toIntExact(UUIDUtil.generateID()));
|
|
|
//保存详细图附件
|
|
|
- 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 +169,7 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 描述:修改管理端管理员账号
|
|
|
+ * 描述:修改管理端民宿账号
|
|
|
* @return
|
|
|
*/
|
|
|
public String updateAdmin() {
|
|
|
@@ -220,6 +219,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.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("'");
|
|
|
+ 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 +458,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", "冻结成功");
|