Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
cms_sys
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
西魏
cms_sys
Commits
00a8a7c7
Commit
00a8a7c7
authored
Mar 05, 2019
by
sunxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自定义模型字段搜索
parent
1089fccd
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
95 additions
and
17 deletions
+95
-17
4.6.5-to-4.7.0-mysql.sql
doc/4.6.5-to-4.7.0-mysql.sql
+0
-0
db-mcms-mysql-4.7.0.sql
doc/db-mcms-mysql-4.7.0.sql
+0
-0
ArticleAction.java
src/main/java/net/mingsoft/cms/action/ArticleAction.java
+4
-4
ArticleAction.java
src/main/java/net/mingsoft/cms/action/web/ArticleAction.java
+0
-1
SearchAction.java
src/main/java/net/mingsoft/cms/action/web/SearchAction.java
+91
-12
No files found.
doc/4.6.5-to-4.7.0-mysql.sql
View file @
00a8a7c7
This diff is collapsed.
Click to expand it.
doc/db-mcms-mysql-4.7.0.sql
View file @
00a8a7c7
This diff is collapsed.
Click to expand it.
src/main/java/net/mingsoft/cms/action/ArticleAction.java
View file @
00a8a7c7
...
@@ -287,7 +287,7 @@ public class ArticleAction extends BaseAction {
...
@@ -287,7 +287,7 @@ public class ArticleAction extends BaseAction {
// 判断栏目是否存在新增字段
// 判断栏目是否存在新增字段
if
(
column
.
getColumnContentModelId
()
!=
0
)
{
if
(
column
.
getColumnContentModelId
()
!=
0
)
{
// 保存所有的字段信息
// 保存所有的字段信息
List
<
Base
Entity
>
listField
=
fieldBiz
.
queryListByCmid
(
column
.
getColumnContentModelId
());
List
<
ContentModelField
Entity
>
listField
=
fieldBiz
.
queryListByCmid
(
column
.
getColumnContentModelId
());
// 获取内容模型实体
// 获取内容模型实体
ContentModelEntity
contentModel
=
(
ContentModelEntity
)
contentBiz
ContentModelEntity
contentModel
=
(
ContentModelEntity
)
contentBiz
.
getEntity
(
column
.
getColumnContentModelId
());
.
getEntity
(
column
.
getColumnContentModelId
());
...
@@ -414,7 +414,7 @@ public class ArticleAction extends BaseAction {
...
@@ -414,7 +414,7 @@ public class ArticleAction extends BaseAction {
// 判断栏目是否存在新增字段
// 判断栏目是否存在新增字段
if
(
column
.
getColumnContentModelId
()
!=
0
)
{
if
(
column
.
getColumnContentModelId
()
!=
0
)
{
// 保存所有的字段信息
// 保存所有的字段信息
List
<
Base
Entity
>
listField
=
fieldBiz
.
queryListByCmid
(
column
.
getColumnContentModelId
());
List
<
ContentModelField
Entity
>
listField
=
fieldBiz
.
queryListByCmid
(
column
.
getColumnContentModelId
());
ContentModelEntity
newContentModel
=
(
ContentModelEntity
)
contentBiz
ContentModelEntity
newContentModel
=
(
ContentModelEntity
)
contentBiz
.
getEntity
(
column
.
getColumnContentModelId
());
.
getEntity
(
column
.
getColumnContentModelId
());
if
(
newContentModel
!=
null
)
{
if
(
newContentModel
!=
null
)
{
...
@@ -442,7 +442,7 @@ public class ArticleAction extends BaseAction {
...
@@ -442,7 +442,7 @@ public class ArticleAction extends BaseAction {
// 判断该文章是否存在新增字段
// 判断该文章是否存在新增字段
if
(
column
.
getColumnContentModelId
()
!=
0
)
{
if
(
column
.
getColumnContentModelId
()
!=
0
)
{
// 保存所有的字段信息
// 保存所有的字段信息
List
<
Base
Entity
>
listField
=
fieldBiz
.
queryListByCmid
(
column
.
getColumnContentModelId
());
List
<
ContentModelField
Entity
>
listField
=
fieldBiz
.
queryListByCmid
(
column
.
getColumnContentModelId
());
// // update中的where条件
// // update中的where条件
Map
<
String
,
Integer
>
where
=
new
HashMap
<
String
,
Integer
>();
Map
<
String
,
Integer
>
where
=
new
HashMap
<
String
,
Integer
>();
// 压入默认的basicId字段
// 压入默认的basicId字段
...
@@ -576,7 +576,7 @@ public class ArticleAction extends BaseAction {
...
@@ -576,7 +576,7 @@ public class ArticleAction extends BaseAction {
* 文章id
* 文章id
* @return 字段信息
* @return 字段信息
*/
*/
private
Map
checkField
(
List
<
Base
Entity
>
listField
,
HttpServletRequest
request
,
int
articleId
)
{
private
Map
checkField
(
List
<
ContentModelField
Entity
>
listField
,
HttpServletRequest
request
,
int
articleId
)
{
Map
<
String
,
Object
>
mapParams
=
new
HashMap
();
Map
<
String
,
Object
>
mapParams
=
new
HashMap
();
// 压入默认的basicId字段
// 压入默认的basicId字段
mapParams
.
put
(
"basicId"
,
articleId
);
mapParams
.
put
(
"basicId"
,
articleId
);
...
...
src/main/java/net/mingsoft/cms/action/web/ArticleAction.java
View file @
00a8a7c7
...
@@ -227,7 +227,6 @@ public class ArticleAction extends BaseAction {
...
@@ -227,7 +227,6 @@ public class ArticleAction extends BaseAction {
}
}
}
}
}
}
this
.
outJson
(
response
,
JSONArray
.
toJSONString
(
new
ListBean
(
list
,
BasicUtil
.
endPage
(
list
)),
new
DateValueFilter
(
"yyyy-MM-dd HH:mm:ss"
)));
this
.
outJson
(
response
,
JSONArray
.
toJSONString
(
new
ListBean
(
list
,
BasicUtil
.
endPage
(
list
)),
new
DateValueFilter
(
"yyyy-MM-dd HH:mm:ss"
)));
}
}
...
...
src/main/java/net/mingsoft/cms/action/web/SearchAction.java
View file @
00a8a7c7
...
@@ -41,12 +41,17 @@ import org.springframework.web.bind.annotation.RequestMethod;
...
@@ -41,12 +41,17 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
net.mingsoft.basic.action.BaseAction
;
import
net.mingsoft.basic.action.BaseAction
;
import
net.mingsoft.basic.biz.ICategoryBiz
;
import
net.mingsoft.basic.biz.IColumnBiz
;
import
net.mingsoft.basic.biz.IColumnBiz
;
import
net.mingsoft.basic.biz.IModelBiz
;
import
net.mingsoft.basic.entity.BaseEntity
;
import
net.mingsoft.basic.entity.ColumnEntity
;
import
net.mingsoft.basic.entity.ColumnEntity
;
import
net.mingsoft.cms.biz.IArticleBiz
;
import
net.mingsoft.cms.biz.IArticleBiz
;
import
net.mingsoft.cms.util.CmsParserUtil
;
import
net.mingsoft.cms.util.CmsParserUtil
;
import
net.mingsoft.mdiy.biz.IContentModelBiz
;
import
net.mingsoft.mdiy.biz.IContentModelFieldBiz
;
import
net.mingsoft.mdiy.biz.IContentModelFieldBiz
;
import
net.mingsoft.mdiy.biz.ISearchBiz
;
import
net.mingsoft.mdiy.biz.ISearchBiz
;
import
net.mingsoft.mdiy.entity.ContentModelEntity
;
import
net.mingsoft.mdiy.entity.ContentModelFieldEntity
;
import
net.mingsoft.mdiy.entity.ContentModelFieldEntity
;
import
net.mingsoft.mdiy.entity.SearchEntity
;
import
net.mingsoft.mdiy.entity.SearchEntity
;
import
cn.hutool.core.map.MapUtil
;
import
cn.hutool.core.map.MapUtil
;
...
@@ -97,6 +102,33 @@ public class SearchAction extends BaseAction {
...
@@ -97,6 +102,33 @@ public class SearchAction extends BaseAction {
*/
*/
@Autowired
@Autowired
private
IColumnBiz
columnBiz
;
private
IColumnBiz
columnBiz
;
/**
* 内容模型业务层
*/
@Autowired
private
IContentModelBiz
contentModelBiz
;
/**
* 内容字段业务层
*/
@Autowired
private
IContentModelFieldBiz
fieldBiz
;
/**
* 注入分类业务层
*/
@Autowired
private
ICategoryBiz
categoryBiz
;
/**
* 模块管理biz
*/
@Autowired
private
IModelBiz
modelBiz
;
/**
/**
* 实现前端页面的文章搜索
* 实现前端页面的文章搜索
*
*
...
@@ -117,7 +149,6 @@ public class SearchAction extends BaseAction {
...
@@ -117,7 +149,6 @@ public class SearchAction extends BaseAction {
if
(
ObjectUtil
.
isNull
(
search
))
{
if
(
ObjectUtil
.
isNull
(
search
))
{
this
.
outJson
(
response
,
false
);
this
.
outJson
(
response
,
false
);
}
}
Map
<
String
,
Object
>
map
=
BasicUtil
.
assemblyRequestMap
();
Map
<
String
,
Object
>
map
=
BasicUtil
.
assemblyRequestMap
();
// 读取请求字段
// 读取请求字段
Map
<
String
,
String
[]>
field
=
request
.
getParameterMap
();
Map
<
String
,
String
[]>
field
=
request
.
getParameterMap
();
...
@@ -126,6 +157,32 @@ public class SearchAction extends BaseAction {
...
@@ -126,6 +157,32 @@ public class SearchAction extends BaseAction {
Map
<
String
,
Object
>
articleFieldName
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
articleFieldName
=
new
HashMap
<
String
,
Object
>();
// 自定义字段集合
// 自定义字段集合
Map
<
String
,
String
>
diyFieldName
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
diyFieldName
=
new
HashMap
<
String
,
String
>();
ColumnEntity
column
=
null
;
// 当前栏目
ContentModelEntity
contentModel
=
null
;
// 栏目对应模型
List
<
ContentModelFieldEntity
>
fieldList
=
new
ArrayList
<
ContentModelFieldEntity
>();
// 栏目对应字段
List
<
DiyMap
>
fieldValueList
=
new
ArrayList
<
DiyMap
>();
// 栏目对应字段的值
int
typeId
=
BasicUtil
.
getInt
(
"categoryId"
,
0
);
//记录自定义模型字段名
List
filedStr
=
new
ArrayList
<>();
//根据栏目确定模版
if
(
typeId
>
0
){
column
=
(
ColumnEntity
)
columnBiz
.
getEntity
(
Integer
.
parseInt
(
typeId
+
""
));
// 获取表单类型的id
if
(
column
!=
null
)
{
contentModel
=
(
ContentModelEntity
)
contentModelBiz
.
getEntity
(
column
.
getColumnContentModelId
());
if
(
contentModel
!=
null
)
{
fieldList
=
fieldBiz
.
queryListByCmid
(
contentModel
.
getCmId
());
for
(
ContentModelFieldEntity
cmField
:
fieldList
)
{
filedStr
.
add
(
cmField
.
getFieldFieldName
());
}
map
.
put
(
ParserUtil
.
TABLE_NAME
,
contentModel
.
getCmTableName
());
}
}
map
.
put
(
ParserUtil
.
COLUMN
,
column
);
//设置栏目编号
map
.
put
(
ParserUtil
.
TYPE_ID
,
typeId
);
}
// 遍历取字段集合
// 遍历取字段集合
if
(
field
!=
null
)
{
if
(
field
!=
null
)
{
for
(
Entry
<
String
,
String
[]>
entry
:
field
.
entrySet
())
{
for
(
Entry
<
String
,
String
[]>
entry
:
field
.
entrySet
())
{
...
@@ -147,22 +204,28 @@ public class SearchAction extends BaseAction {
...
@@ -147,22 +204,28 @@ public class SearchAction extends BaseAction {
}
else
{
}
else
{
if
(!
StringUtil
.
isBlank
(
value
))
{
if
(!
StringUtil
.
isBlank
(
value
))
{
diyFieldName
.
put
(
entry
.
getKey
(),
value
);
diyFieldName
.
put
(
entry
.
getKey
(),
value
);
//判断请求中的是否是自定义模型中的字段
if
(
filedStr
.
contains
(
entry
.
getKey
())){
//设置自定义模型字段和值
DiyMap
diyMap
=
new
DiyMap
();
diyMap
.
setKey
(
entry
.
getKey
());
diyMap
.
setValue
(
value
);
fieldValueList
.
add
(
diyMap
);
}
}
}
}
}
}
}
}
}
}
Map
whereMap
=
this
.
searchMap
(
articleFieldName
,
diyFieldName
,
null
);
// 获取符合条件的文章总数
int
count
=
articleBiz
.
getSearchCount
(
null
,
whereMap
,
BasicUtil
.
getAppId
(),
null
);
int
typeId
=
BasicUtil
.
getInt
(
"categoryId"
,
0
);
//根据栏目确定模版
if
(
typeId
>
0
){
ColumnEntity
column
=
(
ColumnEntity
)
columnBiz
.
getEntity
(
Integer
.
parseInt
(
map
.
get
(
"typeid"
)+
""
));
map
.
put
(
ParserUtil
.
COLUMN
,
column
);
//设置栏目编号
map
.
put
(
ParserUtil
.
TYPE_ID
,
typeId
);
}
}
//添加自定义模型的字段和值
if
(
fieldValueList
.
size
()>
0
){
map
.
put
(
"diyModel"
,
fieldValueList
);
}
Map
whereMap
=
this
.
searchMap
(
articleFieldName
,
diyFieldName
,
fieldList
);
// 获取符合条件的文章总数
@SuppressWarnings
(
"deprecation"
)
int
count
=
articleBiz
.
getSearchCount
(
contentModel
,
whereMap
,
BasicUtil
.
getAppId
(),
null
);
int
size
=
BasicUtil
.
getInt
(
ParserUtil
.
SIZE
,
10
);
int
size
=
BasicUtil
.
getInt
(
ParserUtil
.
SIZE
,
10
);
int
total
=
PageUtil
.
totalPage
(
count
,
size
);
int
total
=
PageUtil
.
totalPage
(
count
,
size
);
//获取总数
//获取总数
...
@@ -184,6 +247,7 @@ public class SearchAction extends BaseAction {
...
@@ -184,6 +247,7 @@ public class SearchAction extends BaseAction {
pre
=
pageNo
-
1
==
0
?
1
:
pageNo
-
1
;
pre
=
pageNo
-
1
==
0
?
1
:
pageNo
-
1
;
}
}
String
str
=
ParserUtil
.
PAGE_NO
+
","
;
String
str
=
ParserUtil
.
PAGE_NO
+
","
;
//设置分页的统一链接
String
url
=
BasicUtil
.
getUrl
()
+
request
.
getServletPath
()
+
"?"
+
BasicUtil
.
assemblyRequestUrlParams
(
str
.
split
(
","
));
String
url
=
BasicUtil
.
getUrl
()
+
request
.
getServletPath
()
+
"?"
+
BasicUtil
.
assemblyRequestUrlParams
(
str
.
split
(
","
));
String
pageNoStr
=
"&"
+
ParserUtil
.
PAGE_NO
+
"="
;
String
pageNoStr
=
"&"
+
ParserUtil
.
PAGE_NO
+
"="
;
//下一页
//下一页
...
@@ -325,5 +389,20 @@ public class SearchAction extends BaseAction {
...
@@ -325,5 +389,20 @@ public class SearchAction extends BaseAction {
}
}
return
null
;
return
null
;
}
}
public
class
DiyMap
{
String
key
;
Object
value
;
public
String
getKey
()
{
return
key
;
}
public
void
setKey
(
String
key
)
{
this
.
key
=
key
;
}
public
Object
getValue
()
{
return
value
;
}
public
void
setValue
(
Object
value
)
{
this
.
value
=
value
;
}
}
}
}
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