Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yichengstreet-be
Project
Project
Details
Activity
Releases
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
yichengstreet
yichengstreet-be
Commits
1b8fbc30
Commit
1b8fbc30
authored
Mar 05, 2025
by
luben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
db3e4c59
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
2153 additions
and
0 deletions
+2153
-0
LabelsController.java
...java/com/ruoyi/web/controller/other/LabelsController.java
+114
-0
Labels.java
...m/src/main/java/com/ruoyi/system/domain/other/Labels.java
+226
-0
LabelsExample.java
...ain/java/com/ruoyi/system/domain/other/LabelsExample.java
+1044
-0
LabelsVO.java
.../main/java/com/ruoyi/system/domain/other/vo/LabelsVO.java
+54
-0
LabelsMapper.java
...main/java/com/ruoyi/system/mapper/other/LabelsMapper.java
+32
-0
LabelsFacadeService.java
...a/com/ruoyi/system/service/other/LabelsFacadeService.java
+261
-0
LabelsService.java
...in/java/com/ruoyi/system/service/other/LabelsService.java
+21
-0
LabelsServiceImpl.java
...om/ruoyi/system/service/other/impl/LabelsServiceImpl.java
+82
-0
LabelsMapper.xml
...i-system/src/main/resources/mapper/other/LabelsMapper.xml
+319
-0
No files found.
ruoyi-admin/src/main/java/com/ruoyi/web/controller/other/LabelsController.java
0 → 100644
View file @
1b8fbc30
package
com
.
ruoyi
.
web
.
controller
.
other
;
import
com.alibaba.fastjson2.JSON
;
import
com.github.pagehelper.PageHelper
;
import
com.ruoyi.common.annotation.Anonymous
;
import
com.ruoyi.common.core.controller.BaseController
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.core.page.TableDataInfo
;
import
com.ruoyi.system.domain.other.Labels
;
import
com.ruoyi.system.domain.other.LabelsExample
;
import
com.ruoyi.system.domain.other.vo.LabelsVO
;
import
com.ruoyi.system.service.other.LabelsFacadeService
;
import
com.ruoyi.system.service.other.LabelsService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
/**
* @Auther: hxc
* @Date: 2019/6/18 0028 14:09
* @Description: 数据字典
*/
@Api
(
tags
=
"基本配置 - 数据字典"
)
@RestController
@RequestMapping
(
"/api/labels"
)
public
class
LabelsController
extends
BaseController
{
@Autowired
private
LabelsFacadeService
commonService
;
@Autowired
private
LabelsService
bsCommonService
;
@ApiOperation
(
"列表"
)
@RequestMapping
(
value
=
"/list"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
TableDataInfo
getCommons
(
@RequestBody
LabelsVO
bsCommonVO
)
{
PageHelper
.
startPage
(
bsCommonVO
.
getPageNum
(),
bsCommonVO
.
getPageSize
());
LabelsExample
example
=
new
LabelsExample
();
LabelsExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(
StringUtils
.
isNotEmpty
(
bsCommonVO
.
getParentId
()))
{
criteria
.
andParentIdEqualTo
(
bsCommonVO
.
getParentId
());
}
example
.
setOrderByClause
(
" sort + 0 asc "
);
List
<
Labels
>
list
=
bsCommonService
.
selectByExample
(
example
);
return
getDataTable
(
list
);
}
@ApiOperation
(
"删除"
)
@RequestMapping
(
value
=
""
,
method
=
RequestMethod
.
DELETE
)
@ResponseBody
public
String
delete
(
@RequestBody
Labels
body
)
{
try
{
return
commonService
.
commit
(
body
,
"delete"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
JSON
.
toJSONString
(
AjaxResult
.
error
(
500
,
"服务器内部错误"
));
}
}
@ApiOperation
(
"创建"
)
@RequestMapping
(
value
=
""
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
String
insert
(
@RequestBody
Labels
body
)
{
try
{
return
commonService
.
commit
(
body
,
"insert"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
JSON
.
toJSONString
(
AjaxResult
.
error
(
500
,
"服务器内部错误"
));
}
}
@ApiOperation
(
"更新"
)
@RequestMapping
(
value
=
""
,
method
=
RequestMethod
.
PATCH
)
@ResponseBody
public
String
update
(
@RequestBody
Labels
body
)
{
try
{
return
commonService
.
commit
(
body
,
"update"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
JSON
.
toJSONString
(
AjaxResult
.
error
(
500
,
"服务器内部错误"
));
}
}
@ApiOperation
(
"树结构"
)
@RequestMapping
(
value
=
"/getTreeNode"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
AjaxResult
getTreeNode
(
@RequestBody
LabelsVO
bsCommonVO
)
{
try
{
return
commonService
.
getTreeNode
(
bsCommonVO
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
AjaxResult
.
error
(
500
,
"服务器内部错误"
);
}
}
@Anonymous
@ApiOperation
(
"获取网格列表"
)
@RequestMapping
(
value
=
"/getWgdxList"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
String
getWgdxList
(
@RequestParam
(
name
=
"code"
)
String
code
)
{
try
{
List
<
Labels
>
wgdxList
=
bsCommonService
.
getWgdxList
(
code
);
return
JSON
.
toJSONString
(
AjaxResult
.
success
(
wgdxList
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
JSON
.
toJSONString
(
AjaxResult
.
error
(
500
,
"服务器内部错误"
));
}
}
}
ruoyi-system/src/main/java/com/ruoyi/system/domain/other/Labels.java
0 → 100644
View file @
1b8fbc30
package
com
.
ruoyi
.
system
.
domain
.
other
;
import
java.io.Serializable
;
public
class
Labels
implements
Serializable
{
/**
* ID
*
* @mbg.generated
*/
private
String
id
;
private
String
code
;
/**
* 字段名
*
* @mbg.generated
*/
private
String
name
;
/**
* 描述
* 若是选人,这里是names
* @mbg.generated
*/
private
String
description
;
/**
* 父节点
*
* @mbg.generated
*/
private
String
parentId
;
/**
* 是否有效 0:无效 1:有效
*
* @mbg.generated
*/
private
String
isValid
;
/**
* 排序
*
* @mbg.generated
*/
private
String
sort
;
//若是选人,这里是ids
private
String
ylzd1
;
private
String
ylzd2
;
private
String
ylzd3
;
private
String
ylzd4
;
private
String
ylzd5
;
private
static
final
long
serialVersionUID
=
1L
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
String
getParentId
()
{
return
parentId
;
}
public
void
setParentId
(
String
parentId
)
{
this
.
parentId
=
parentId
;
}
public
String
getIsValid
()
{
return
isValid
;
}
public
void
setIsValid
(
String
isValid
)
{
this
.
isValid
=
isValid
;
}
public
String
getSort
()
{
return
sort
;
}
public
void
setSort
(
String
sort
)
{
this
.
sort
=
sort
;
}
public
String
getYlzd1
()
{
return
ylzd1
;
}
public
void
setYlzd1
(
String
ylzd1
)
{
this
.
ylzd1
=
ylzd1
;
}
public
String
getYlzd2
()
{
return
ylzd2
;
}
public
void
setYlzd2
(
String
ylzd2
)
{
this
.
ylzd2
=
ylzd2
;
}
public
String
getYlzd3
()
{
return
ylzd3
;
}
public
void
setYlzd3
(
String
ylzd3
)
{
this
.
ylzd3
=
ylzd3
;
}
public
String
getYlzd4
()
{
return
ylzd4
;
}
public
void
setYlzd4
(
String
ylzd4
)
{
this
.
ylzd4
=
ylzd4
;
}
public
String
getYlzd5
()
{
return
ylzd5
;
}
public
void
setYlzd5
(
String
ylzd5
)
{
this
.
ylzd5
=
ylzd5
;
}
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
getClass
().
getSimpleName
());
sb
.
append
(
" ["
);
sb
.
append
(
"Hash = "
).
append
(
hashCode
());
sb
.
append
(
", id="
).
append
(
id
);
sb
.
append
(
", code="
).
append
(
code
);
sb
.
append
(
", name="
).
append
(
name
);
sb
.
append
(
", description="
).
append
(
description
);
sb
.
append
(
", parentId="
).
append
(
parentId
);
sb
.
append
(
", isValid="
).
append
(
isValid
);
sb
.
append
(
", sort="
).
append
(
sort
);
sb
.
append
(
", ylzd1="
).
append
(
ylzd1
);
sb
.
append
(
", ylzd2="
).
append
(
ylzd2
);
sb
.
append
(
", ylzd3="
).
append
(
ylzd3
);
sb
.
append
(
", ylzd4="
).
append
(
ylzd4
);
sb
.
append
(
", ylzd5="
).
append
(
ylzd5
);
sb
.
append
(
"]"
);
return
sb
.
toString
();
}
@Override
public
boolean
equals
(
Object
that
)
{
if
(
this
==
that
)
{
return
true
;
}
if
(
that
==
null
)
{
return
false
;
}
if
(
getClass
()
!=
that
.
getClass
())
{
return
false
;
}
BsCommon
other
=
(
BsCommon
)
that
;
return
(
this
.
getId
()
==
null
?
other
.
getId
()
==
null
:
this
.
getId
().
equals
(
other
.
getId
()))
&&
(
this
.
getCode
()
==
null
?
other
.
getCode
()
==
null
:
this
.
getCode
().
equals
(
other
.
getCode
()))
&&
(
this
.
getName
()
==
null
?
other
.
getName
()
==
null
:
this
.
getName
().
equals
(
other
.
getName
()))
&&
(
this
.
getDescription
()
==
null
?
other
.
getDescription
()
==
null
:
this
.
getDescription
().
equals
(
other
.
getDescription
()))
&&
(
this
.
getParentId
()
==
null
?
other
.
getParentId
()
==
null
:
this
.
getParentId
().
equals
(
other
.
getParentId
()))
&&
(
this
.
getIsValid
()
==
null
?
other
.
getIsValid
()
==
null
:
this
.
getIsValid
().
equals
(
other
.
getIsValid
()))
&&
(
this
.
getSort
()
==
null
?
other
.
getSort
()
==
null
:
this
.
getSort
().
equals
(
other
.
getSort
()))
&&
(
this
.
getYlzd1
()
==
null
?
other
.
getYlzd1
()
==
null
:
this
.
getYlzd1
().
equals
(
other
.
getYlzd1
()))
&&
(
this
.
getYlzd2
()
==
null
?
other
.
getYlzd2
()
==
null
:
this
.
getYlzd2
().
equals
(
other
.
getYlzd2
()))
&&
(
this
.
getYlzd3
()
==
null
?
other
.
getYlzd3
()
==
null
:
this
.
getYlzd3
().
equals
(
other
.
getYlzd3
()))
&&
(
this
.
getYlzd4
()
==
null
?
other
.
getYlzd4
()
==
null
:
this
.
getYlzd4
().
equals
(
other
.
getYlzd4
()))
&&
(
this
.
getYlzd5
()
==
null
?
other
.
getYlzd5
()
==
null
:
this
.
getYlzd5
().
equals
(
other
.
getYlzd5
()));
}
@Override
public
int
hashCode
()
{
final
int
prime
=
31
;
int
result
=
1
;
result
=
prime
*
result
+
((
getId
()
==
null
)
?
0
:
getId
().
hashCode
());
result
=
prime
*
result
+
((
getCode
()
==
null
)
?
0
:
getCode
().
hashCode
());
result
=
prime
*
result
+
((
getName
()
==
null
)
?
0
:
getName
().
hashCode
());
result
=
prime
*
result
+
((
getDescription
()
==
null
)
?
0
:
getDescription
().
hashCode
());
result
=
prime
*
result
+
((
getParentId
()
==
null
)
?
0
:
getParentId
().
hashCode
());
result
=
prime
*
result
+
((
getIsValid
()
==
null
)
?
0
:
getIsValid
().
hashCode
());
result
=
prime
*
result
+
((
getSort
()
==
null
)
?
0
:
getSort
().
hashCode
());
result
=
prime
*
result
+
((
getYlzd1
()
==
null
)
?
0
:
getYlzd1
().
hashCode
());
result
=
prime
*
result
+
((
getYlzd2
()
==
null
)
?
0
:
getYlzd2
().
hashCode
());
result
=
prime
*
result
+
((
getYlzd3
()
==
null
)
?
0
:
getYlzd3
().
hashCode
());
result
=
prime
*
result
+
((
getYlzd4
()
==
null
)
?
0
:
getYlzd4
().
hashCode
());
result
=
prime
*
result
+
((
getYlzd5
()
==
null
)
?
0
:
getYlzd5
().
hashCode
());
return
result
;
}
}
ruoyi-system/src/main/java/com/ruoyi/system/domain/other/LabelsExample.java
0 → 100644
View file @
1b8fbc30
This diff is collapsed.
Click to expand it.
ruoyi-system/src/main/java/com/ruoyi/system/domain/other/vo/LabelsVO.java
0 → 100644
View file @
1b8fbc30
package
com
.
ruoyi
.
system
.
domain
.
other
.
vo
;
/**
* @Auther: hxc
* @Date: 2019/6/18 0018 15:46
* @Description:
*/
public
class
LabelsVO
{
private
String
Id
;
private
String
parentId
;
private
String
code
;
private
Integer
pageNum
;
private
Integer
pageSize
;
public
String
getId
()
{
return
Id
;
}
public
void
setId
(
String
id
)
{
Id
=
id
;
}
public
String
getParentId
()
{
return
parentId
;
}
public
void
setParentId
(
String
parentId
)
{
this
.
parentId
=
parentId
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
Integer
getPageNum
()
{
return
pageNum
;
}
public
void
setPageNum
(
Integer
pageNum
)
{
this
.
pageNum
=
pageNum
;
}
public
Integer
getPageSize
()
{
return
pageSize
;
}
public
void
setPageSize
(
Integer
pageSize
)
{
this
.
pageSize
=
pageSize
;
}
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/other/LabelsMapper.java
0 → 100644
View file @
1b8fbc30
package
com
.
ruoyi
.
system
.
mapper
.
other
;
import
com.ruoyi.system.domain.other.Labels
;
import
com.ruoyi.system.domain.other.LabelsExample
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
public
interface
LabelsMapper
{
long
countByExample
(
LabelsExample
example
);
int
deleteByExample
(
LabelsExample
example
);
int
deleteByPrimaryKey
(
String
id
);
int
insert
(
Labels
record
);
int
insertSelective
(
Labels
record
);
Labels
selectByPrimaryKey
(
String
id
);
List
<
Labels
>
selectByExample
(
LabelsExample
example
);
int
updateByExampleSelective
(
@Param
(
"record"
)
Labels
record
,
@Param
(
"example"
)
LabelsExample
example
);
int
updateByPrimaryKeySelective
(
Labels
record
);
int
updateByExample
(
@Param
(
"record"
)
Labels
record
,
@Param
(
"example"
)
LabelsExample
example
);
List
<
Labels
>
getWgdxList
(
String
code
);
}
\ No newline at end of file
ruoyi-system/src/main/java/com/ruoyi/system/service/other/LabelsFacadeService.java
0 → 100644
View file @
1b8fbc30
package
com
.
ruoyi
.
system
.
service
.
other
;
import
com.alibaba.fastjson2.JSON
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.system.domain.other.Labels
;
import
com.ruoyi.system.domain.other.LabelsExample
;
import
com.ruoyi.system.domain.other.vo.LabelsVO
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
java.lang.reflect.Method
;
import
java.util.*
;
/**
* @Auther: hxc
* @Date: 2019/6/18 0018 09:23
* @Description: 数据字典
*/
@Component
public
class
LabelsFacadeService
{
@Autowired
private
LabelsService
bsCommonService
;
public
String
commit
(
Labels
body
,
String
method
)
{
try
{
AjaxResult
result
=
new
AjaxResult
();
Method
methodCheck
=
null
;
try
{
methodCheck
=
this
.
getClass
().
getMethod
(
method
+
"Pre"
,
body
.
getClass
(),
result
.
getClass
());
}
catch
(
Exception
e
)
{
methodCheck
=
null
;
}
if
(
null
!=
methodCheck
)
{
Object
ret
=
methodCheck
.
invoke
(
this
,
body
,
result
);
if
((
ret
instanceof
Boolean
)
&&
!(
boolean
)
ret
)
{
return
JSON
.
toJSONString
(
result
);
}
}
Method
methodCommit
=
null
;
try
{
methodCommit
=
this
.
getClass
().
getMethod
(
method
,
body
.
getClass
(),
result
.
getClass
());
}
catch
(
Exception
e
)
{
methodCommit
=
null
;
}
if
(
null
==
methodCommit
)
{
return
JSON
.
toJSONString
(
AjaxResult
.
error
(
600
,
"方法未找到:"
+
method
));
}
methodCommit
.
invoke
(
this
,
body
,
result
);
return
JSON
.
toJSONString
(
result
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
JSON
.
toJSONString
(
AjaxResult
.
error
(
500
,
"服务器内部错误"
));
}
}
public
boolean
insertPre
(
Labels
body
,
AjaxResult
result
)
{
if
(
null
==
body
)
{
result
.
buildError
(
500
,
"body为空"
);
return
false
;
}
LabelsExample
example
=
new
LabelsExample
();
example
.
createCriteria
().
andCodeEqualTo
(
body
.
getCode
());
int
count
=
bsCommonService
.
countByExample
(
example
);
if
(
count
>
0
)
{
result
.
buildError
(
500
,
"编码存在,请重新填写!"
);
return
false
;
}
return
true
;
}
public
void
insert
(
Labels
body
,
AjaxResult
result
)
{
String
id
=
UUID
.
randomUUID
().
toString
();
Labels
bsCommon
=
new
Labels
();
bsCommon
.
setId
(
id
);
bsCommon
.
setCode
(
body
.
getCode
());
bsCommon
.
setDescription
(
body
.
getDescription
());
bsCommon
.
setName
(
body
.
getName
());
bsCommon
.
setParentId
(
body
.
getParentId
());
bsCommon
.
setIsValid
(
body
.
getIsValid
());
bsCommon
.
setSort
(
body
.
getSort
());
bsCommon
.
setYlzd1
(
body
.
getYlzd1
());
bsCommon
.
setYlzd2
(
body
.
getYlzd2
());
bsCommon
.
setYlzd3
(
body
.
getYlzd3
());
bsCommon
.
setYlzd4
(
body
.
getYlzd4
());
bsCommon
.
setYlzd5
(
body
.
getYlzd5
());
int
ret
=
bsCommonService
.
insertSelective
(
bsCommon
);
if
(
ret
>
0
)
{
result
.
buildSuccess
(
"success"
,
id
);
}
else
{
result
.
buildError
(
600
,
"新增失败"
);
}
return
;
}
public
boolean
updatePre
(
Labels
body
,
AjaxResult
result
)
{
if
(
null
==
body
)
{
result
.
buildError
(
500
,
"body为空"
);
return
false
;
}
return
true
;
}
public
void
update
(
Labels
body
,
AjaxResult
result
)
{
String
id
=
body
.
getId
();
Labels
bean
=
get
(
id
,
null
);
if
(
null
==
bean
)
{
result
.
buildError
(
500
,
"body为空"
);
return
;
}
if
(!
bean
.
getCode
().
equals
(
body
.
getCode
()))
{
LabelsExample
example
=
new
LabelsExample
();
example
.
createCriteria
().
andCodeEqualTo
(
body
.
getCode
());
int
count
=
bsCommonService
.
countByExample
(
example
);
if
(
count
>
0
)
{
result
.
buildError
(
500
,
"编码存在,请重新填写!"
);
return
;
}
}
int
ret
=
bsCommonService
.
updateByPrimaryKeySelective
(
body
);
if
(
ret
>
0
)
{
result
.
buildSuccess
(
"success"
,
id
);
}
else
{
result
.
buildError
(
600
,
"更新失败"
);
}
return
;
}
public
Labels
get
(
String
id
,
Labels
bsCommon
)
{
if
(
null
==
bsCommon
)
{
if
(
StringUtils
.
isNotEmpty
(
id
))
{
bsCommon
=
bsCommonService
.
selectByPrimaryKey
(
id
);
}
if
(
null
==
bsCommon
)
{
return
null
;
}
}
return
bsCommon
;
}
public
boolean
deletePre
(
Labels
body
,
AjaxResult
result
)
{
if
(
null
==
body
)
{
result
.
buildError
(
500
,
"body为空"
);
return
false
;
}
if
(!
itemIsUUID
(
body
.
getId
()))
{
result
.
buildError
(
500
,
"参数非法"
);
return
false
;
}
return
true
;
}
public
void
delete
(
Labels
body
,
AjaxResult
result
)
{
Labels
bean
=
get
(
body
.
getId
(),
null
);
if
(
null
==
bean
)
{
result
.
buildError
(
500
,
"找不到该数据"
);
return
;
}
// 如果该网格下有子网格,则无法删除
LabelsExample
gridRegionExample
=
new
LabelsExample
();
gridRegionExample
.
createCriteria
().
andIsValidEqualTo
(
"1"
).
andParentIdEqualTo
(
body
.
getId
());
int
count
=
bsCommonService
.
countByExample
(
gridRegionExample
);
if
(
count
>
0
)
{
result
.
buildError
(
600
,
"有子数据无法删除"
);
return
;
}
// 防止数据残留
int
ret
=
bsCommonService
.
deleteByStringPrimaryKey
(
body
.
getId
());
if
(
ret
>
0
)
{
result
.
buildSuccess
(
"success"
,
null
);
}
else
{
result
.
buildError
(
600
,
"删除失败"
);
}
return
;
}
public
AjaxResult
getTreeNode
(
LabelsVO
bsCommonVO
)
{
LabelsExample
bsCommonExample
=
new
LabelsExample
();
LabelsExample
.
Criteria
criteria
=
bsCommonExample
.
createCriteria
();
criteria
.
andIsValidEqualTo
(
"1"
);
if
(
bsCommonVO
!=
null
){
if
(
StringUtils
.
isNotBlank
(
bsCommonVO
.
getCode
())){
criteria
.
andCodeLike
(
"%"
+
bsCommonVO
.
getCode
()+
"%"
);
}
}
bsCommonExample
.
setOrderByClause
(
" sort + 0 "
);
List
<
Labels
>
bsCommons
=
bsCommonService
.
selectByExample
(
bsCommonExample
);
List
<
Map
<
String
,
Object
>>
jsTreeModels
=
convertFrBomsCommon
(
bsCommons
);
return
AjaxResult
.
success
(
"success"
,
jsTreeModels
);
}
private
List
<
Map
<
String
,
Object
>>
convertFrBomsCommon
(
List
<
Labels
>
bsCommons
)
{
List
<
Map
<
String
,
Object
>>
models
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
bsCommons
))
{
for
(
Labels
bsCommon
:
bsCommons
)
{
if
(
StringUtils
.
isEmpty
(
bsCommon
.
getParentId
()))
{
Map
<
String
,
Object
>
model
=
new
HashMap
<>();
model
.
put
(
"id"
,
bsCommon
.
getId
());
model
.
put
(
"code"
,
bsCommon
.
getCode
());
model
.
put
(
"name"
,
bsCommon
.
getName
());
model
.
put
(
"description"
,
bsCommon
.
getDescription
());
model
.
put
(
"parentId"
,
bsCommon
.
getParentId
());
model
.
put
(
"isValid"
,
bsCommon
.
getIsValid
());
model
.
put
(
"sort"
,
bsCommon
.
getSort
());
List
<
Map
<
String
,
Object
>>
childrenDocTypes
=
convertFromWgCodeByParent
(
bsCommons
,
bsCommon
.
getId
());
model
.
put
(
"child"
,
childrenDocTypes
);
models
.
add
(
model
);
}
}
}
return
models
;
}
private
List
<
Map
<
String
,
Object
>>
convertFromWgCodeByParent
(
List
<
Labels
>
bsCommons
,
String
parentId
)
{
List
<
Map
<
String
,
Object
>>
models
=
new
ArrayList
<>();
for
(
Labels
bsCommon
:
bsCommons
)
{
if
(
StringUtils
.
isNotEmpty
(
bsCommon
.
getParentId
())
&&
bsCommon
.
getParentId
().
equals
(
parentId
))
{
Map
<
String
,
Object
>
model
=
new
HashMap
<>();
model
.
put
(
"id"
,
bsCommon
.
getId
());
model
.
put
(
"code"
,
bsCommon
.
getCode
());
model
.
put
(
"name"
,
bsCommon
.
getName
());
model
.
put
(
"description"
,
bsCommon
.
getDescription
());
model
.
put
(
"parentId"
,
bsCommon
.
getParentId
());
model
.
put
(
"isValid"
,
bsCommon
.
getIsValid
());
model
.
put
(
"sort"
,
bsCommon
.
getSort
());
List
<
Map
<
String
,
Object
>>
childrenDocTypes
=
convertFromWgCodeByParent
(
bsCommons
,
bsCommon
.
getId
());
model
.
put
(
"child"
,
childrenDocTypes
);
models
.
add
(
model
);
}
}
return
models
;
}
private
boolean
itemIsUUID
(
String
item
)
{
if
(
StringUtils
.
isEmpty
(
item
))
{
return
false
;
}
return
item
.
matches
(
"(\\w{8}(-\\w{4}){3}-\\w{12}?)"
);
}
}
ruoyi-system/src/main/java/com/ruoyi/system/service/other/LabelsService.java
0 → 100644
View file @
1b8fbc30
package
com
.
ruoyi
.
system
.
service
.
other
;
import
com.ruoyi.system.domain.other.Labels
;
import
com.ruoyi.system.domain.other.LabelsExample
;
import
com.ruoyi.system.service.BaseService
;
import
java.util.List
;
import
java.util.Map
;
public
interface
LabelsService
extends
BaseService
<
Labels
,
LabelsExample
>
{
List
<
Labels
>
getWgdxList
(
String
code
);
String
getName
(
String
code
);
String
getCode
(
String
name
);
List
<
Labels
>
getBsCommonMap
();
Map
<
String
,
String
>
getMapByCodes
(
List
<
String
>
codes
);
}
\ No newline at end of file
ruoyi-system/src/main/java/com/ruoyi/system/service/other/impl/LabelsServiceImpl.java
0 → 100644
View file @
1b8fbc30
package
com
.
ruoyi
.
system
.
service
.
other
.
impl
;
import
com.ruoyi.system.domain.other.Labels
;
import
com.ruoyi.system.domain.other.LabelsExample
;
import
com.ruoyi.system.listener.MyBaseService
;
import
com.ruoyi.system.mapper.other.LabelsMapper
;
import
com.ruoyi.system.service.BaseServiceImpl
;
import
com.ruoyi.system.service.other.LabelsService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* @author Cesar
* @date ${cTime}
* @desc BsCommonService实现
*/
@Service
@MyBaseService
public
class
LabelsServiceImpl
extends
BaseServiceImpl
<
LabelsMapper
,
Labels
,
LabelsExample
>
implements
LabelsService
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
LabelsServiceImpl
.
class
);
@Autowired
private
LabelsMapper
bsCommonMapper
;
@Override
public
List
<
Labels
>
getWgdxList
(
String
code
)
{
return
bsCommonMapper
.
getWgdxList
(
code
);
}
@Override
public
String
getName
(
String
code
)
{
LabelsExample
ex
=
new
LabelsExample
();
LabelsExample
.
Criteria
ca
=
ex
.
createCriteria
();
ca
.
andCodeEqualTo
(
code
);
ca
.
andIsValidEqualTo
(
"1"
);
Labels
bsCommon
=
selectFirstByExample
(
ex
);
if
(
bsCommon
!=
null
)
{
return
bsCommon
.
getName
();
}
else
{
return
null
;
}
}
@Override
public
String
getCode
(
String
name
)
{
LabelsExample
ex
=
new
LabelsExample
();
LabelsExample
.
Criteria
ca
=
ex
.
createCriteria
();
ca
.
andNameEqualTo
(
name
);
ca
.
andIsValidEqualTo
(
"1"
);
Labels
bsCommon
=
selectFirstByExample
(
ex
);
if
(
bsCommon
!=
null
)
{
return
bsCommon
.
getCode
();
}
else
{
return
null
;
}
}
@Override
public
List
<
Labels
>
getBsCommonMap
()
{
LabelsExample
ex
=
new
LabelsExample
();
LabelsExample
.
Criteria
ca
=
ex
.
createCriteria
();
ca
.
andIsValidEqualTo
(
"1"
);
return
this
.
selectByExample
(
ex
);
}
@Override
public
Map
<
String
,
String
>
getMapByCodes
(
List
<
String
>
codes
)
{
LabelsExample
ex
=
new
LabelsExample
();
LabelsExample
.
Criteria
ca
=
ex
.
createCriteria
();
ca
.
andIsValidEqualTo
(
"1"
);
ca
.
andCodeIn
(
codes
);
List
<
Labels
>
commonList
=
bsCommonMapper
.
selectByExample
(
ex
);
return
commonList
.
stream
().
collect
(
Collectors
.
toMap
(
Labels:
:
getCode
,
Labels:
:
getName
));
}
}
ruoyi-system/src/main/resources/mapper/other/LabelsMapper.xml
0 → 100644
View file @
1b8fbc30
This diff is collapsed.
Click to expand it.
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