Commit 60a5a33b authored by ms-dev's avatar ms-dev

合并分支

parent 8fbe0fb7
......@@ -47,15 +47,15 @@ import com.mingsoft.util.StringUtil;
/**
* 网站基本信息控制层
*
* @author 史爱华
* @version
* 版本号:100-000-000<br/>
* @version 版本号:100-000-000<br/>
* 创建日期:2014-07-14<br/>
* 历史修订:<br/>
*/
@Controller
@RequestMapping("/manager/app/")
public class AppAction extends BaseAction{
public class AppAction extends BaseAction {
/**
* appBiz业务层的注入
......@@ -69,222 +69,140 @@ public class AppAction extends BaseAction{
@Autowired
private IManagerBiz managerBiz;
/**
* 对系统管理进行的查询站点列表信息
* @param request 请求对象
* @param mode ModelMap实体对象
* @param response 响应对象
* @return 站点列表显示页面
*/
@RequestMapping("/list")
public String queryList(HttpServletRequest request,ModelMap mode,HttpServletResponse response){
ManagerEntity managerSession = (ManagerEntity) getSession(request, SessionConst.MANAGER_ESSION);
int pageNo=1;
//查询总记录数
int recordCount = appBiz.queryCount();
//排序依据字段
String orderBy="app_id";
if(request.getParameter("pageNo")!=null){
pageNo=Integer.parseInt(request.getParameter("pageNo").toString());
}
PageUtil page=new PageUtil(pageNo,100,recordCount,getUrl(request)+"/manager/app/list.do");
//保存cookie值
this.setCookie(request, response, CookieConst.PAGENO_COOKIE, String.valueOf(pageNo));
//分页查询
List<BaseEntity>apps = appBiz.queryByPage(page, orderBy,false);
mode.addAttribute("listApp",apps);
mode.addAttribute("page",page);
mode.addAttribute("managerSession", managerSession);
return "/manager/app/app_list";
}
/**
* 根据id删除站点信息
* @param basicId 要删除的站点Id
* @param request 请求对象
* @return 返回当前页数
*/
@RequestMapping("/{basicId}/delete")
@ResponseBody
public int delete(@PathVariable int basicId, HttpServletRequest request){
AppEntity app = (AppEntity) appBiz.getEntity(basicId);
/*
* 删除对应的站点管理员
*/
if(app!=null){
int managerId = app.getAppManagerId();
managerBiz.deleteEntity(managerId);
appBiz.deleteBasic(basicId);
}
int pageNo = 2;
//保存页面cookie值
int cookie = Integer.valueOf(this.getCookie(request, CookieConst.PAGENO_COOKIE));
if(cookie>=1){
pageNo=cookie;
}
return pageNo;
}
/**
* 跳转到站点保存页面
* @param request 请求对象
* @param mode ModelMap实体对象
* @return 站点保存页面
*/
@RequestMapping("/add")
public String add(HttpServletRequest request,ModelMap mode){
//超级管理员识别
mode.addAttribute("SystemManager",true);
AppEntity app = new AppEntity();
//传入一个空的app
mode.addAttribute("app",app);
return "/manager/app/app";
}
/**
* 跳转到修改页面
* @param mode ModelMap实体对象
* @param appId 站点id
* @param request 请求对象
*
* @param mode
* ModelMap实体对象
* @param appId
* 站点id
* @param request
* 请求对象
* @return 站点修改页面
*/
@RequestMapping(value="/{appId}/edit")
public String edit(ModelMap mode,@PathVariable int appId, HttpServletRequest request) {
@RequestMapping(value = "/{appId}/edit")
public String edit(ModelMap mode, @PathVariable int appId, HttpServletRequest request) {
AppEntity app = null;
if (appId<0) {
if (appId < 0) {
app = this.getApp(request);
} else {
app = (AppEntity) appBiz.getEntity(appId);
}
//判断否是超级管理员,是的话不显示站点风格
if(this.isSystemManager(request)){
mode.addAttribute("SystemManager",true);
}else{
mode.addAttribute("SystemManager",false);
// 判断否是超级管理员,是的话不显示站点风格
if (this.isSystemManager(request)) {
mode.addAttribute("SystemManager", true);
} else {
mode.addAttribute("SystemManager", false);
}
mode.addAttribute("app",app);
mode.addAttribute("app", app);
return "/manager/app/app";
}
/**
* 更新站点信息
* @param mode ModelMap实体对象
* @param app 站点对象
* @param request 请求对象
* @param response 相应对象
*
* @param mode
* ModelMap实体对象
* @param app
* 站点对象
* @param request
* 请求对象
* @param response
* 相应对象
*/
@RequestMapping("/update")
public void update(ModelMap mode,@ModelAttribute AppEntity app, HttpServletRequest request, HttpServletResponse response){
public void update(ModelMap mode, @ModelAttribute AppEntity app, HttpServletRequest request,
HttpServletResponse response) {
mode.clear();
// 获取Session值
ManagerEntity managerSession = (ManagerEntity) getManagerBySession(request);
if(managerSession==null){
return ;
if (managerSession == null) {
return;
}
mode.addAttribute("managerSession",managerSession);
mode.addAttribute("managerSession", managerSession);
//判断否是超级管理员,不是则不修改应用续费时间和清单
if(!this.isSystemManager(request)){
// 判断否是超级管理员,不是则不修改应用续费时间和清单
if (!this.isSystemManager(request)) {
app.setAppPayDate(null);
app.setAppPay(null);
// 设置当前的站点id
app.setAppId(this.getAppId(request));
}
int managerRoleID = managerSession.getManagerRoleID();
//判断站点数据的合法性
// 判断站点数据的合法性
// 获取cookie
String cookie =this.getCookie(request, CookieConst.PAGENO_COOKIE);
String cookie = this.getCookie(request, CookieConst.PAGENO_COOKIE);
int pageNo = 1;
//判断cookies是否为空
if(!StringUtil.isBlank(cookie) && Integer.valueOf(cookie)>0){
pageNo=Integer.valueOf(cookie);
// 判断cookies是否为空
if (!StringUtil.isBlank(cookie) && Integer.valueOf(cookie) > 0) {
pageNo = Integer.valueOf(cookie);
}
mode.addAttribute("pageNo", pageNo);
if(!checkForm(app,response)){
if (!checkForm(app, response)) {
return;
}
if(!StringUtil.isBlank(app.getAppLogo())) {
app.setAppLogo( app.getAppLogo().replace("|", ""));
if (!StringUtil.isBlank(app.getAppLogo())) {
app.setAppLogo(app.getAppLogo().replace("|", ""));
}
// 过滤地址后面的/\符号
String url = app.getAppUrl();
String[] _url = url.split("\n");
String _url[] = url.split("\r\n");
StringBuffer sb = new StringBuffer();
for (String temp:_url) {
if (temp.lastIndexOf("/")>-1 || temp.lastIndexOf("\\")>-1) {
temp = temp.substring(temp.length()-1);
sb.append(temp).append("\n");
String lastChar = temp.trim().substring(temp.length()-1);
if (lastChar.equals("/") || lastChar.equals("\\")) {
sb.append(temp.substring(0, temp.trim().length()-1)).append("\r\n");
}
}
app.setAppUrl(sb.toString());
//更新站点信息
// 更新站点信息
appBiz.updateEntity(app);
this.outJson(response, ModelCode.APP, true, String.valueOf(pageNo), String.valueOf(managerRoleID));
}
/**
* 保存站点信息
* @param app 站点实体对象
* @param request 请求对象
* @param response 相应对象
*/
@RequestMapping("/save")
public void save(@ModelAttribute AppEntity app, HttpServletRequest request, HttpServletResponse response){
//验证站点数据的合法性
if(!checkForm(app,response)){
return;
}
//问题:由于上传的图片路径后面可能带有|符合。所以要进行将“|”替换空
//空值判断
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对象
*
* @param app
* 要验证的站点信息
* @param response
* response对象
*/
public boolean checkForm(AppEntity app, HttpServletResponse 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"));
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"));
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"));
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"));
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"));
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"));
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;
......@@ -292,19 +210,21 @@ public class AppAction extends BaseAction{
/**
* 判断是否有重复的域名
* @param request 请求对象
*
* @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){
public boolean checkUrl(HttpServletRequest request) {
if (request.getParameter("appUrl") != null) {
if (appBiz.countByUrl(request.getParameter("appUrl")) > 0) {
return true;
}else{
} else {
return false;
}
}else{
} else {
return false;
}
......
......@@ -12,8 +12,8 @@
<@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>"/>
<@ms.textarea name="appUrl" label="域 名" width="400" rows="4" value="${app.appUrl?default('')}"
placeholder="使用回车换行可以输入多个域名地址,必须要加http://"
help="多个域名回车换行显示,必须以http[s]://打头,<br/>例如:http://www.a.com <br/> http://a.com"
placeholder="使用回车换行可以输入多个域名地址,必须要加http:// 域名不要以/\\符号结尾"
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个字符以内!"} />
<@ms.select name="appStyle" width="300" id="appStyle" label="模板风格" />
<@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