Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MCMS
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
MCMS
Commits
60a5a33b
Commit
60a5a33b
authored
Mar 25, 2016
by
ms-dev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合并分支
parent
8fbe0fb7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
206 additions
and
286 deletions
+206
-286
src/main/java/com/mingsoft/basic/action/AppAction.java
src/main/java/com/mingsoft/basic/action/AppAction.java
+204
-284
src/main/webapp/manager/app/app.ftl
src/main/webapp/manager/app/app.ftl
+2
-2
No files found.
src/main/java/com/mingsoft/basic/action/AppAction.java
View file @
60a5a33b
...
...
@@ -19,294 +19,214 @@ The MIT License (MIT) * Copyright (c) 2015 铭飞科技
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package
com
.
mingsoft
.
basic
.
action
;
import
java.io.File
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.ModelMap
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.mingsoft.basic.action.BaseAction
;
import
com.mingsoft.base.entity.BaseEntity
;
import
com.mingsoft.basic.biz.IAppBiz
;
import
com.mingsoft.basic.biz.IManagerBiz
;
import
com.mingsoft.base.constant.CookieConst
;
import
com.mingsoft.base.constant.ModelCode
;
import
com.mingsoft.base.constant.SessionConst
;
import
com.mingsoft.basic.entity.AppEntity
;
import
com.mingsoft.basic.entity.ManagerEntity
;
import
com.mingsoft.parser.IParserRegexConstant
;
import
com.mingsoft.util.PageUtil
;
import
com.mingsoft.util.StringUtil
;
/**
* 网站基本信息控制层
* @author 史爱华
* @version
* 版本号:100-000-000<br/>
* 创建日期:2014-07-14<br/>
* 历史修订:<br/>
*/
@Controller
@RequestMapping
(
"/manager/app/"
)
public
class
AppAction
extends
BaseAction
{
/**
* appBiz业务层的注入
*/
@Autowired
private
IAppBiz
appBiz
;
/**
* managerBiz业务层的注入
*/
@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 请求对象
* @return 站点修改页面
*/
@RequestMapping
(
value
=
"/{appId}/edit"
)
public
String
edit
(
ModelMap
mode
,
@PathVariable
int
appId
,
HttpServletRequest
request
)
{
AppEntity
app
=
null
;
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
);
}
mode
.
addAttribute
(
"app"
,
app
);
return
"/manager/app/app"
;
}
/**
* 更新站点信息
* @param mode ModelMap实体对象
* @param app 站点对象
* @param request 请求对象
* @param response 相应对象
*/
@RequestMapping
(
"/update"
)
public
void
update
(
ModelMap
mode
,
@ModelAttribute
AppEntity
app
,
HttpServletRequest
request
,
HttpServletResponse
response
){
mode
.
clear
();
// 获取Session值
ManagerEntity
managerSession
=
(
ManagerEntity
)
getManagerBySession
(
request
);
if
(
managerSession
==
null
){
return
;
}
mode
.
addAttribute
(
"managerSession"
,
managerSession
);
//判断否是超级管理员,不是则不修改应用续费时间和清单
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
);
int
pageNo
=
1
;
//判断cookies是否为空
if
(!
StringUtil
.
isBlank
(
cookie
)
&&
Integer
.
valueOf
(
cookie
)>
0
){
pageNo
=
Integer
.
valueOf
(
cookie
);
}
mode
.
addAttribute
(
"pageNo"
,
pageNo
);
if
(!
checkForm
(
app
,
response
)){
return
;
}
if
(!
StringUtil
.
isBlank
(
app
.
getAppLogo
()))
{
app
.
setAppLogo
(
app
.
getAppLogo
().
replace
(
"|"
,
""
));
package
com
.
mingsoft
.
basic
.
action
;
import
java.io.File
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.ModelMap
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.mingsoft.basic.action.BaseAction
;
import
com.mingsoft.base.entity.BaseEntity
;
import
com.mingsoft.basic.biz.IAppBiz
;
import
com.mingsoft.basic.biz.IManagerBiz
;
import
com.mingsoft.base.constant.CookieConst
;
import
com.mingsoft.base.constant.ModelCode
;
import
com.mingsoft.base.constant.SessionConst
;
import
com.mingsoft.basic.entity.AppEntity
;
import
com.mingsoft.basic.entity.ManagerEntity
;
import
com.mingsoft.parser.IParserRegexConstant
;
import
com.mingsoft.util.PageUtil
;
import
com.mingsoft.util.StringUtil
;
/**
* 网站基本信息控制层
*
* @author 史爱华
* @version 版本号:100-000-000<br/>
* 创建日期:2014-07-14<br/>
* 历史修订:<br/>
*/
@Controller
@RequestMapping
(
"/manager/app/"
)
public
class
AppAction
extends
BaseAction
{
/**
* appBiz业务层的注入
*/
@Autowired
private
IAppBiz
appBiz
;
/**
* managerBiz业务层的注入
*/
@Autowired
private
IManagerBiz
managerBiz
;
/**
* 跳转到修改页面
*
* @param mode
* ModelMap实体对象
* @param appId
* 站点id
* @param request
* 请求对象
* @return 站点修改页面
*/
@RequestMapping
(
value
=
"/{appId}/edit"
)
public
String
edit
(
ModelMap
mode
,
@PathVariable
int
appId
,
HttpServletRequest
request
)
{
AppEntity
app
=
null
;
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
);
}
mode
.
addAttribute
(
"app"
,
app
);
return
"/manager/app/app"
;
}
/**
* 更新站点信息
*
* @param mode
* ModelMap实体对象
* @param app
* 站点对象
* @param request
* 请求对象
* @param response
* 相应对象
*/
@RequestMapping
(
"/update"
)
public
void
update
(
ModelMap
mode
,
@ModelAttribute
AppEntity
app
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
mode
.
clear
();
// 获取Session值
ManagerEntity
managerSession
=
(
ManagerEntity
)
getManagerBySession
(
request
);
if
(
managerSession
==
null
)
{
return
;
}
mode
.
addAttribute
(
"managerSession"
,
managerSession
);
// 判断否是超级管理员,不是则不修改应用续费时间和清单
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
);
int
pageNo
=
1
;
// 判断cookies是否为空
if
(!
StringUtil
.
isBlank
(
cookie
)
&&
Integer
.
valueOf
(
cookie
)
>
0
)
{
pageNo
=
Integer
.
valueOf
(
cookie
);
}
mode
.
addAttribute
(
"pageNo"
,
pageNo
);
if
(!
checkForm
(
app
,
response
))
{
return
;
}
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 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
;
}
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对象
*/
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
src/main/webapp/manager/app/app.ftl
View file @
60a5a33b
...
...
@@ -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="请输入关键字"/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment