Commit 83c95d79 authored by killfen's avatar killfen

域名地址问题修复

parent 2498f983
...@@ -19,283 +19,214 @@ The MIT License (MIT) * Copyright (c) 2015 铭飞科技 ...@@ -19,283 +19,214 @@ The MIT License (MIT) * Copyright (c) 2015 铭飞科技
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
package com.mingsoft.basic.action; package com.mingsoft.basic.action;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.mingsoft.basic.action.BaseAction; import com.mingsoft.basic.action.BaseAction;
import com.mingsoft.base.entity.BaseEntity; import com.mingsoft.base.entity.BaseEntity;
import com.mingsoft.basic.biz.IAppBiz; import com.mingsoft.basic.biz.IAppBiz;
import com.mingsoft.basic.biz.IManagerBiz; import com.mingsoft.basic.biz.IManagerBiz;
import com.mingsoft.base.constant.CookieConst; import com.mingsoft.base.constant.CookieConst;
import com.mingsoft.base.constant.ModelCode; import com.mingsoft.base.constant.ModelCode;
import com.mingsoft.base.constant.SessionConst; import com.mingsoft.base.constant.SessionConst;
import com.mingsoft.basic.entity.AppEntity; import com.mingsoft.basic.entity.AppEntity;
import com.mingsoft.basic.entity.ManagerEntity; import com.mingsoft.basic.entity.ManagerEntity;
import com.mingsoft.parser.IParserRegexConstant; import com.mingsoft.parser.IParserRegexConstant;
import com.mingsoft.util.PageUtil; import com.mingsoft.util.PageUtil;
import com.mingsoft.util.StringUtil; import com.mingsoft.util.StringUtil;
/** /**
* 网站基本信息控制层 * 网站基本信息控制层
* @author 史爱华 *
* @version * @author 史爱华
* 版本号:100-000-000<br/> * @version 版本号:100-000-000<br/>
* 创建日期:2014-07-14<br/> * 创建日期:2014-07-14<br/>
* 历史修订:<br/> * 历史修订:<br/>
*/ */
@Controller @Controller
@RequestMapping("/manager/app/") @RequestMapping("/manager/app/")
public class AppAction extends BaseAction{ public class AppAction extends BaseAction {
/** /**
* appBiz业务层的注入 * appBiz业务层的注入
*/ */
@Autowired @Autowired
private IAppBiz appBiz; private IAppBiz appBiz;
/** /**
* managerBiz业务层的注入 * managerBiz业务层的注入
*/ */
@Autowired @Autowired
private IManagerBiz managerBiz; private IManagerBiz managerBiz;
/** /**
* 对系统管理进行的查询站点列表信息 * 跳转到修改页面
* @param request 请求对象 *
* @param mode ModelMap实体对象 * @param mode
* @param response 响应对象 * ModelMap实体对象
* @return 站点列表显示页面 * @param appId
*/ * 站点id
@RequestMapping("/list") * @param request
public String queryList(HttpServletRequest request,ModelMap mode,HttpServletResponse response){ * 请求对象
ManagerEntity managerSession = (ManagerEntity) getSession(request, SessionConst.MANAGER_ESSION); * @return 站点修改页面
int pageNo=1; */
//查询总记录数 @RequestMapping(value = "/{appId}/edit")
int recordCount = appBiz.queryCount(); public String edit(ModelMap mode, @PathVariable int appId, HttpServletRequest request) {
//排序依据字段 AppEntity app = null;
String orderBy="app_id"; if (appId < 0) {
if(request.getParameter("pageNo")!=null){ app = this.getApp(request);
pageNo=Integer.parseInt(request.getParameter("pageNo").toString()); } else {
} app = (AppEntity) appBiz.getEntity(appId);
PageUtil page=new PageUtil(pageNo,100,recordCount,getUrl(request)+"/manager/app/list.do"); }
//保存cookie值
this.setCookie(request, response, CookieConst.PAGENO_COOKIE, String.valueOf(pageNo)); // 判断否是超级管理员,是的话不显示站点风格
//分页查询 if (this.isSystemManager(request)) {
List<BaseEntity>apps = appBiz.queryByPage(page, orderBy,false); mode.addAttribute("SystemManager", true);
mode.addAttribute("listApp",apps); } else {
mode.addAttribute("page",page); mode.addAttribute("SystemManager", false);
mode.addAttribute("managerSession", managerSession); }
return "/manager/app/app_list";
} mode.addAttribute("app", app);
return "/manager/app/app";
/** }
* 根据id删除站点信息
* @param basicId 要删除的站点Id /**
* @param request 请求对象 * 更新站点信息
* @return 返回当前页数 *
*/ * @param mode
@RequestMapping("/{basicId}/delete") * ModelMap实体对象
@ResponseBody * @param app
public int delete(@PathVariable int basicId, HttpServletRequest request){ * 站点对象
AppEntity app = (AppEntity) appBiz.getEntity(basicId); * @param request
/* * 请求对象
* 删除对应的站点管理员 * @param response
*/ * 相应对象
if(app!=null){ */
int managerId = app.getAppManagerId(); @RequestMapping("/update")
managerBiz.deleteEntity(managerId); public void update(ModelMap mode, @ModelAttribute AppEntity app, HttpServletRequest request,
appBiz.deleteBasic(basicId); HttpServletResponse response) {
} mode.clear();
int pageNo = 2; // 获取Session值
//保存页面cookie值 ManagerEntity managerSession = (ManagerEntity) getManagerBySession(request);
int cookie = Integer.valueOf(this.getCookie(request, CookieConst.PAGENO_COOKIE)); if (managerSession == null) {
if(cookie>=1){ return;
pageNo=cookie; }
} mode.addAttribute("managerSession", managerSession);
return pageNo;
} // 判断否是超级管理员,不是则不修改应用续费时间和清单
if (!this.isSystemManager(request)) {
/** app.setAppPayDate(null);
* 跳转到站点保存页面 app.setAppPay(null);
* @param request 请求对象 // 设置当前的站点id
* @param mode ModelMap实体对象 app.setAppId(this.getAppId(request));
* @return 站点保存页面 }
*/ int managerRoleID = managerSession.getManagerRoleID();
@RequestMapping("/add") // 判断站点数据的合法性
public String add(HttpServletRequest request,ModelMap mode){ // 获取cookie
//超级管理员识别 String cookie = this.getCookie(request, CookieConst.PAGENO_COOKIE);
mode.addAttribute("SystemManager",true); int pageNo = 1;
AppEntity app = new AppEntity(); // 判断cookies是否为空
//传入一个空的app if (!StringUtil.isBlank(cookie) && Integer.valueOf(cookie) > 0) {
mode.addAttribute("app",app); pageNo = Integer.valueOf(cookie);
return "/manager/app/app"; }
} mode.addAttribute("pageNo", pageNo);
if (!checkForm(app, response)) {
/** return;
* 跳转到修改页面 }
* @param mode ModelMap实体对象 if (!StringUtil.isBlank(app.getAppLogo())) {
* @param appId 站点id app.setAppLogo(app.getAppLogo().replace("|", ""));
* @param request 请求对象 }
* @return 站点修改页面 // 过滤地址后面的/\符号
*/ String url = app.getAppUrl();
@RequestMapping(value="/{appId}/edit") String _url[] = url.split("\r\n");
public String edit(ModelMap mode,@PathVariable int appId, HttpServletRequest request) { StringBuffer sb = new StringBuffer();
AppEntity app = null; for (String temp:_url) {
if (appId<0) { String lastChar = temp.trim().substring(temp.length()-1);
app = this.getApp(request); if (lastChar.equals("/") || lastChar.equals("\\")) {
} else { sb.append(temp.substring(0, temp.trim().length()-1)).append("\r\n");
app = (AppEntity) appBiz.getEntity(appId); }
} }
app.setAppUrl(sb.toString());
//判断否是超级管理员,是的话不显示站点风格 // 更新站点信息
if(this.isSystemManager(request)){ appBiz.updateEntity(app);
mode.addAttribute("SystemManager",true); this.outJson(response, ModelCode.APP, true, String.valueOf(pageNo), String.valueOf(managerRoleID));
}else{ }
mode.addAttribute("SystemManager",false);
} /**
* 判断站点域名的合法性
mode.addAttribute("app",app); *
return "/manager/app/app"; * @param app
} * 要验证的站点信息
* @param response
/** * response对象
* 更新站点信息 */
* @param mode ModelMap实体对象 public boolean checkForm(AppEntity app, HttpServletResponse response) {
* @param app 站点对象
* @param request 请求对象 /*
* @param response 相应对象 * 判断数据的合法性
*/ */
@RequestMapping("/update") if (!StringUtil.checkLength(app.getAppKeyword(), 0, 1000)) {
public void update(ModelMap mode,@ModelAttribute AppEntity app, HttpServletRequest request, HttpServletResponse response){ this.outJson(response, ModelCode.APP, false,
mode.clear(); getResString("err.length", this.getResString("appKeyword"), "0", "1000"));
// 获取Session值 return false;
ManagerEntity managerSession = (ManagerEntity) getManagerBySession(request); }
if(managerSession==null){ if (!StringUtil.checkLength(app.getAppCopyright(), 0, 1000)) {
return ; this.outJson(response, ModelCode.APP, false,
} getResString("err.length", this.getResString("appCopyright"), "0", "1000"));
mode.addAttribute("managerSession",managerSession); return false;
}
//判断否是超级管理员,不是则不修改应用续费时间和清单 if (!StringUtil.checkLength(app.getAppDescription(), 0, 1000)) {
if(!this.isSystemManager(request)){ this.outJson(response, ModelCode.APP, false,
app.setAppPayDate(null); getResString("err.length", this.getResString("appDescrip"), "0", "1000"));
app.setAppPay(null); return false;
// 设置当前的站点id }
app.setAppId(this.getAppId(request)); if (!StringUtil.checkLength(app.getAppName(), 1, 50)) {
} this.outJson(response, ModelCode.APP, false,
int managerRoleID = managerSession.getManagerRoleID(); getResString("err.length", this.getResString("appTitle"), "1", "50"));
//判断站点数据的合法性 return false;
// 获取cookie }
String cookie =this.getCookie(request, CookieConst.PAGENO_COOKIE); if (!StringUtil.isBlank(app.getAppStyle()) && !StringUtil.checkLength(app.getAppStyle(), 1, 30)) {
int pageNo = 1; this.outJson(response, ModelCode.APP, false,
//判断cookies是否为空 getResString("err.length", this.getResString("appStyle"), "1", "30"));
if(!StringUtil.isBlank(cookie) && Integer.valueOf(cookie)>0){ return false;
pageNo=Integer.valueOf(cookie); }
} if (!StringUtil.checkLength(app.getAppHostUrl(), 10, 150)) {
mode.addAttribute("pageNo", pageNo); this.outJson(response, ModelCode.APP, false,
if(!checkForm(app,response)){ getResString("err.length", this.getResString("appUrl"), "10", "150"));
return; return false;
} }
if(!StringUtil.isBlank(app.getAppLogo())) { return true;
app.setAppLogo( app.getAppLogo().replace("|", "")); }
}
//更新站点信息 /**
appBiz.updateEntity(app); * 判断是否有重复的域名
this.outJson(response, ModelCode.APP, true, String.valueOf(pageNo), String.valueOf(managerRoleID)); *
} * @param request
* 请求对象
/** * @return true:重复,false:不重复
* 保存站点信息 */
* @param app 站点实体对象 @RequestMapping("/checkUrl")
* @param request 请求对象 @ResponseBody
* @param response 相应对象 public boolean checkUrl(HttpServletRequest request) {
*/ if (request.getParameter("appUrl") != null) {
@RequestMapping("/save") if (appBiz.countByUrl(request.getParameter("appUrl")) > 0) {
public void save(@ModelAttribute AppEntity app, HttpServletRequest request, HttpServletResponse response){ return true;
//验证站点数据的合法性 } else {
if(!checkForm(app,response)){ return false;
return; }
} } else {
//问题:由于上传的图片路径后面可能带有|符合。所以要进行将“|”替换空 return false;
//空值判断 }
if(!StringUtil.isBlank(app.getAppLogo())) {
app.setAppLogo( app.getAppLogo().replace("|", "")); }
}
//问题:去掉域名后面的"/"
String appUrl = app.getAppHostUrl();
app.setAppUrl(appUrl);
appBiz.saveEntity(app);
if(isSystemManager(request)) {
String file = this.getRealPath(request,IParserRegexConstant.REGEX_SAVE_TEMPLATE+File.separator+ app.getAppId());
File fileName = new File(file);
fileName.mkdir();
}
this.outJson(response, ModelCode.APP, true,null);
}
/**
* 判断站点域名的合法性
* @param app 要验证的站点信息
* @param response response对象
*/
public boolean checkForm(AppEntity app, HttpServletResponse response){
/*
* 判断数据的合法性
*/
if(!StringUtil.checkLength(app.getAppKeyword(), 0,1000)){
this.outJson(response, ModelCode.APP, false,getResString("err.length",this.getResString("appKeyword"),"0","1000"));
return false;
}
if(!StringUtil.checkLength(app.getAppCopyright(), 0,1000)){
this.outJson(response, ModelCode.APP, false,getResString("err.length",this.getResString("appCopyright"),"0","1000"));
return false;
}
if(!StringUtil.checkLength(app.getAppDescription(), 0,1000)){
this.outJson(response, ModelCode.APP, false,getResString("err.length",this.getResString("appDescrip"),"0","1000"));
return false;
}
if(!StringUtil.checkLength(app.getAppName(),1,50)){
this.outJson(response, ModelCode.APP, false,getResString("err.length",this.getResString("appTitle"),"1","50"));
return false;
}
if(!StringUtil.isBlank(app.getAppStyle()) && !StringUtil.checkLength(app.getAppStyle(),1,30)){
this.outJson(response, ModelCode.APP, false,getResString("err.length",this.getResString("appStyle"),"1","30"));
return false;
}
if(!StringUtil.checkLength(app.getAppHostUrl(),10,150)){
this.outJson(response, ModelCode.APP, false,getResString("err.length",this.getResString("appUrl"),"10","150"));
return false;
}
return true;
}
/**
* 判断是否有重复的域名
* @param request 请求对象
* @return true:重复,false:不重复
*/
@RequestMapping("/checkUrl")
@ResponseBody
public boolean checkUrl(HttpServletRequest request){
if(request.getParameter("appUrl")!=null){
if(appBiz.countByUrl(request.getParameter("appUrl"))>0){
return true;
}else{
return false;
}
}else{
return false;
}
}
} }
\ No newline at end of file
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
<@ms.checkbox name="appMobileStyle" width="200" list=[{"id":"m","value":"启用"}] listKey="id" listValue="value" valueList=["${app.appMobileStyle!('')}"] label="启用移动端" <@ms.checkbox name="appMobileStyle" width="200" list=[{"id":"m","value":"启用"}] listKey="id" listValue="value" valueList=["${app.appMobileStyle!('')}"] label="启用移动端"
help="启用后手机用户访问网站会显示手机版网页,前提是网站必需提供移动端皮肤,相关教程:<a href='http://ms.ming-soft.com/mbbs/13086/detail.do' target='_blank'>铭飞移动端开发教程</a>"/> help="启用后手机用户访问网站会显示手机版网页,前提是网站必需提供移动端皮肤,相关教程:<a href='http://ms.ming-soft.com/mbbs/13086/detail.do' target='_blank'>铭飞移动端开发教程</a>"/>
<@ms.textarea name="appUrl" label="域 名" width="400" rows="4" value="${app.appUrl?default('')}" <@ms.textarea name="appUrl" label="域 名" width="400" rows="4" value="${app.appUrl?default('')}"
placeholder="使用回车换行可以输入多个域名地址,必须要加http://" placeholder="使用回车换行可以输入多个域名地址,必须要加http:// 域名不要以/\\符号结尾"
help="多个域名回车换行显示,必须以http[s]://打头,<br/>例如:http://www.a.com <br/> http://a.com" help="多个域名回车换行显示,必须以http[s]://打头,域名不要以/\\符号结尾<br/>例如:<br/>http://www.a.com <br/> http://a.com "
validation={"maxlength":"150","required":"true","data-bv-notempty-message":"必填项目", "data-bv-stringlength-message":"长度在150个字符以内!"} /> validation={"maxlength":"150","required":"true","data-bv-notempty-message":"必填项目", "data-bv-stringlength-message":"长度在150个字符以内!"} />
<@ms.select name="appStyle" width="300" id="appStyle" label="模板风格" /> <@ms.select name="appStyle" width="300" id="appStyle" label="模板风格" />
<@ms.textarea name="appKeyword" label="关键字" width="700" value="${app.appKeyword?default('')}" rows="4" placeholder="请输入关键字"/> <@ms.textarea name="appKeyword" label="关键字" width="700" value="${app.appKeyword?default('')}" rows="4" placeholder="请输入关键字"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment