Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
RuoYi-Vue-master
Project
Project
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
融通安全管理系统
RuoYi-Vue-master
Commits
5aa1d56b
Commit
5aa1d56b
authored
Jun 27, 2023
by
陈晓晋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
升级若依mybatis到mybatis-plus以及网站管理测试用例20230627
parent
80e253d0
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
678 additions
and
36 deletions
+678
-36
pom.xml
pom.xml
+20
-0
ruoyi-admin/src/main/resources/application.yml
ruoyi-admin/src/main/resources/application.yml
+15
-7
ruoyi-common/pom.xml
ruoyi-common/pom.xml
+19
-6
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntityClean.java
...in/java/com/ruoyi/common/core/domain/BaseEntityClean.java
+46
-0
ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java
...c/main/java/com/ruoyi/framework/config/MyBatisConfig.java
+17
-17
ruoyi-framework/src/main/java/com/ruoyi/framework/config/MybatisPlusConfig.java
...in/java/com/ruoyi/framework/config/MybatisPlusConfig.java
+69
-0
ruoyi-generator/src/main/resources/vm/java/domain.java.vm
ruoyi-generator/src/main/resources/vm/java/domain.java.vm
+1
-1
ruoyi-generator/src/main/resources/vm/java/mapper.java.vm
ruoyi-generator/src/main/resources/vm/java/mapper.java.vm
+2
-1
ruoyi-generator/src/main/resources/vm/java/service.java.vm
ruoyi-generator/src/main/resources/vm/java/service.java.vm
+2
-2
ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm
...-generator/src/main/resources/vm/java/serviceImpl.java.vm
+2
-2
ruoyi-system/src/main/java/com/ruoyi/system/controller/WebsitesController.java
.../java/com/ruoyi/system/controller/WebsitesController.java
+104
-0
ruoyi-system/src/main/java/com/ruoyi/system/domain/Websites.java
...ystem/src/main/java/com/ruoyi/system/domain/Websites.java
+94
-0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/WebsitesMapper.java
...src/main/java/com/ruoyi/system/mapper/WebsitesMapper.java
+62
-0
ruoyi-system/src/main/java/com/ruoyi/system/service/IWebsitesService.java
.../main/java/com/ruoyi/system/service/IWebsitesService.java
+61
-0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WebsitesServiceImpl.java
...va/com/ruoyi/system/service/impl/WebsitesServiceImpl.java
+93
-0
ruoyi-system/src/main/resources/mapper/system/WebsitesMapper.xml
...ystem/src/main/resources/mapper/system/WebsitesMapper.xml
+71
-0
No files found.
pom.xml
View file @
5aa1d56b
...
...
@@ -30,6 +30,7 @@
<poi.version>
4.1.2
</poi.version>
<velocity.version>
2.3
</velocity.version>
<jwt.version>
0.9.1
</jwt.version>
<mybatis-plus.version>
3.5.2
</mybatis-plus.version>
</properties>
<!-- 依赖声明 -->
...
...
@@ -177,6 +178,25 @@
<version>
${ruoyi.version}
</version>
</dependency>
<!--mybatis-plus-->
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<version>
${mybatis-plus.version}
</version>
</dependency>
<!-- pagehelper 分页插件 -->
<dependency>
<groupId>
com.github.pagehelper
</groupId>
<artifactId>
pagehelper-spring-boot-starter
</artifactId>
<version>
${pagehelper.boot.version}
</version>
<exclusions>
<exclusion>
<groupId>
org.mybatis
</groupId>
<artifactId>
mybatis
</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
...
...
ruoyi-admin/src/main/resources/application.yml
View file @
5aa1d56b
...
...
@@ -101,13 +101,21 @@ token:
expireTime
:
30
# MyBatis配置
mybatis
:
# 搜索指定包别名
typeAliasesPackage
:
com.ruoyi.**.domain
# 配置mapper的扫描,找到所有的mapper.xml映射文件
mapperLocations
:
classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件
configLocation
:
classpath:mybatis/mybatis-config.xml
#mybatis:
# ## # 搜索指定包别名
# ## typeAliasesPackage: com.ruoyi.**.domain
# ## # 配置mapper的扫描,找到所有的mapper.xml映射文件
# ## mapperLocations: classpath*:mapper/**/*Mapper.xml
# ## # 加载全局的配置文件
# ## configLocation: classpath:mybatis/mybatis-config.xml
# MyBatis Plus配置
mybatis-plus
:
# 搜索指定包别名
typeAliasesPackage
:
com.ruoyi.**.domain
# 配置mapper的扫描,找到所有的mapper.xml映射文件
mapperLocations
:
classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件
# configLocation: classpath:mybatis/mybatis-config.xml
# PageHelper分页插件
pagehelper
:
...
...
ruoyi-common/pom.xml
View file @
5aa1d56b
...
...
@@ -58,13 +58,13 @@
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
</dependency>
<!-- 动态数据源 -->
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
dynamic-datasource-spring-boot-starter
</artifactId>
<version>
3.5.2
</version>
</dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
dynamic-datasource-spring-boot-starter
</artifactId>
<version>
3.5.2
</version>
</dependency>
<!-- 阿里JSON解析器 -->
<dependency>
...
...
@@ -126,6 +126,19 @@
<artifactId>
javax.servlet-api
</artifactId>
</dependency>
<!--mybatis-plus-->
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<version>
1.18.4
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntityClean.java
0 → 100644
View file @
5aa1d56b
package
com
.
ruoyi
.
common
.
core
.
domain
;
import
com.baomidou.mybatisplus.annotation.FieldFill
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* Entity基类
*
* @author ruoyi
*/
@Data
public
class
BaseEntityClean
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/** 创建者 */
private
String
createBy
;
/** 创建时间 */
@TableField
(
value
=
"create_time"
,
fill
=
FieldFill
.
INSERT
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
createTime
;
/** 更新者 */
private
String
updateBy
;
/** 更新时间 */
@TableField
(
value
=
"update_time"
,
fill
=
FieldFill
.
INSERT_UPDATE
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
updateTime
;
/** 备注 */
private
String
remark
;
}
ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java
View file @
5aa1d56b
...
...
@@ -26,7 +26,7 @@ import com.ruoyi.common.utils.StringUtils;
/**
* Mybatis支持*匹配扫描包
*
*
* @author ruoyi
*/
@Configuration
...
...
@@ -113,20 +113,20 @@ public class MyBatisConfig
return
resources
.
toArray
(
new
Resource
[
resources
.
size
()]);
}
@Bean
public
SqlSessionFactory
sqlSessionFactory
(
DataSource
dataSource
)
throws
Exception
{
String
typeAliasesPackage
=
env
.
getProperty
(
"mybatis.typeAliasesPackage"
);
String
mapperLocations
=
env
.
getProperty
(
"mybatis.mapperLocations"
);
String
configLocation
=
env
.
getProperty
(
"mybatis.configLocation"
);
typeAliasesPackage
=
setTypeAliasesPackage
(
typeAliasesPackage
);
VFS
.
addImplClass
(
SpringBootVFS
.
class
);
final
SqlSessionFactoryBean
sessionFactory
=
new
SqlSessionFactoryBean
();
sessionFactory
.
setDataSource
(
dataSource
);
sessionFactory
.
setTypeAliasesPackage
(
typeAliasesPackage
);
sessionFactory
.
setMapperLocations
(
resolveMapperLocations
(
StringUtils
.
split
(
mapperLocations
,
","
)));
sessionFactory
.
setConfigLocation
(
new
DefaultResourceLoader
().
getResource
(
configLocation
));
return
sessionFactory
.
getObject
();
}
//
@Bean
//
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception
//
{
//
String typeAliasesPackage = env.getProperty("mybatis.typeAliasesPackage");
//
String mapperLocations = env.getProperty("mybatis.mapperLocations");
//
String configLocation = env.getProperty("mybatis.configLocation");
//
typeAliasesPackage = setTypeAliasesPackage(typeAliasesPackage);
//
VFS.addImplClass(SpringBootVFS.class);
//
//
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
//
sessionFactory.setDataSource(dataSource);
//
sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
//
sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ",")));
//
sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation));
//
return sessionFactory.getObject();
//
}
}
\ No newline at end of file
ruoyi-framework/src/main/java/com/ruoyi/framework/config/MybatisPlusConfig.java
0 → 100644
View file @
5aa1d56b
package
com
.
ruoyi
.
framework
.
config
;
/**
* @description:
* @author: pyz
* @create: 2021-12-28 15:04
**/
import
com.baomidou.mybatisplus.annotation.DbType
;
import
com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor
;
import
com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor
;
import
com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor
;
import
com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
/**
* Mybatis Plus 配置
*
* @author ruoyi
*/
@EnableTransactionManagement
(
proxyTargetClass
=
true
)
@Configuration
public
class
MybatisPlusConfig
{
@Bean
public
MybatisPlusInterceptor
mybatisPlusInterceptor
()
{
MybatisPlusInterceptor
interceptor
=
new
MybatisPlusInterceptor
();
// 分页插件
interceptor
.
addInnerInterceptor
(
paginationInnerInterceptor
());
// 乐观锁插件
interceptor
.
addInnerInterceptor
(
optimisticLockerInnerInterceptor
());
// 阻断插件
interceptor
.
addInnerInterceptor
(
blockAttackInnerInterceptor
());
return
interceptor
;
}
/**
* 分页插件,自动识别数据库类型 https://baomidou.com/guide/interceptor-pagination.html
*/
public
PaginationInnerInterceptor
paginationInnerInterceptor
()
{
PaginationInnerInterceptor
paginationInnerInterceptor
=
new
PaginationInnerInterceptor
();
// 设置数据库类型为mysql
paginationInnerInterceptor
.
setDbType
(
DbType
.
MYSQL
);
// 设置最大单页限制数量,默认 500 条,-1 不受限制
paginationInnerInterceptor
.
setMaxLimit
(-
1L
);
return
paginationInnerInterceptor
;
}
/**
* 乐观锁插件 https://baomidou.com/guide/interceptor-optimistic-locker.html
*/
public
OptimisticLockerInnerInterceptor
optimisticLockerInnerInterceptor
()
{
return
new
OptimisticLockerInnerInterceptor
();
}
/**
* 如果是对全表的删除或更新操作,就会终止该操作 https://baomidou.com/guide/interceptor-block-attack.html
*/
public
BlockAttackInnerInterceptor
blockAttackInnerInterceptor
()
{
return
new
BlockAttackInnerInterceptor
();
}
}
ruoyi-generator/src/main/resources/vm/java/domain.java.vm
View file @
5aa1d56b
...
...
@@ -19,7 +19,7 @@ import com.ruoyi.common.core.domain.TreeEntity;
*
@
date
${
datetime
}
*/
#
if
($
table
.
crud
||
$
table
.
sub
)
#
set
($
Entity
=
"BaseEntity"
)
#
set
($
Entity
=
"BaseEntity
Clean
"
)
#
elseif
($
table
.
tree
)
#
set
($
Entity
=
"TreeEntity"
)
#
end
...
...
ruoyi-generator/src/main/resources/vm/java/mapper.java.vm
View file @
5aa1d56b
...
...
@@ -2,6 +2,7 @@ package ${packageName}.mapper;
import
java
.
util
.
List
;
import
${
packageName
}.
domain
.${
ClassName
};
import
com
.
baomidou
.
mybatisplus
.
core
.
mapper
.
BaseMapper
;
#
if
($
table
.
sub
)
import
${
packageName
}.
domain
.${
subClassName
};
#
end
...
...
@@ -12,7 +13,7 @@ import ${packageName}.domain.${subClassName};
*
@
author
${
author
}
*
@
date
${
datetime
}
*/
public
interface
${
ClassName
}
Mapper
public
interface
${
ClassName
}
Mapper
extends
BaseMapper
<${
ClassName
}>
{
/**
*
查询
${
functionName
}
...
...
ruoyi-generator/src/main/resources/vm/java/service.java.vm
View file @
5aa1d56b
...
...
@@ -2,14 +2,14 @@ package ${packageName}.service;
import
java
.
util
.
List
;
import
${
packageName
}.
domain
.${
ClassName
};
import
com
.
baomidou
.
mybatisplus
.
extension
.
service
.
IService
;
/**
*
${
functionName
}
Service
接口
*
*
@
author
${
author
}
*
@
date
${
datetime
}
*/
public
interface
I
${
ClassName
}
Service
public
interface
I
${
ClassName
}
Service
extends
IService
<${
ClassName
}>
{
/**
*
查询
${
functionName
}
...
...
ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm
View file @
5aa1d56b
...
...
@@ -18,7 +18,7 @@ import ${packageName}.domain.${subClassName};
import
${
packageName
}.
mapper
.${
ClassName
}
Mapper
;
import
${
packageName
}.
domain
.${
ClassName
};
import
${
packageName
}.
service
.
I
${
ClassName
}
Service
;
import
com
.
baomidou
.
mybatisplus
.
extension
.
service
.
impl
.
ServiceImpl
;
/**
*
${
functionName
}
Service
业务层处理
*
...
...
@@ -26,7 +26,7 @@ import ${packageName}.service.I${ClassName}Service;
*
@
date
${
datetime
}
*/
@
Service
public
class
${
ClassName
}
ServiceImpl
implements
I
${
ClassName
}
Service
public
class
${
ClassName
}
ServiceImpl
extends
ServiceImpl
<${
ClassName
}
Mapper
,
${
ClassName
}>
implements
I
${
ClassName
}
Service
{
@
Autowired
private
${
ClassName
}
Mapper
${
className
}
Mapper
;
...
...
ruoyi-system/src/main/java/com/ruoyi/system/controller/WebsitesController.java
0 → 100644
View file @
5aa1d56b
package
com
.
ruoyi
.
system
.
controller
;
import
java.util.List
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ruoyi.common.annotation.Log
;
import
com.ruoyi.common.core.controller.BaseController
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.enums.BusinessType
;
import
com.ruoyi.system.domain.Websites
;
import
com.ruoyi.system.service.IWebsitesService
;
import
com.ruoyi.common.utils.poi.ExcelUtil
;
import
com.ruoyi.common.core.page.TableDataInfo
;
/**
* 网站管理Controller
*
* @author ruoyi
* @date 2023-06-27
*/
@RestController
@RequestMapping
(
"/system/websites"
)
public
class
WebsitesController
extends
BaseController
{
@Autowired
private
IWebsitesService
websitesService
;
/**
* 查询网站管理列表
*/
@PreAuthorize
(
"@ss.hasPermi('system:websites:list')"
)
@GetMapping
(
"/list"
)
public
TableDataInfo
list
(
Websites
websites
)
{
startPage
();
List
<
Websites
>
list
=
websitesService
.
selectWebsitesList
(
websites
);
return
getDataTable
(
list
);
}
/**
* 导出网站管理列表
*/
@PreAuthorize
(
"@ss.hasPermi('system:websites:export')"
)
@Log
(
title
=
"网站管理"
,
businessType
=
BusinessType
.
EXPORT
)
@PostMapping
(
"/export"
)
public
void
export
(
HttpServletResponse
response
,
Websites
websites
)
{
List
<
Websites
>
list
=
websitesService
.
selectWebsitesList
(
websites
);
ExcelUtil
<
Websites
>
util
=
new
ExcelUtil
<
Websites
>(
Websites
.
class
);
util
.
exportExcel
(
response
,
list
,
"网站管理数据"
);
}
/**
* 获取网站管理详细信息
*/
@PreAuthorize
(
"@ss.hasPermi('system:websites:query')"
)
@GetMapping
(
value
=
"/{id}"
)
public
AjaxResult
getInfo
(
@PathVariable
(
"id"
)
Long
id
)
{
return
success
(
websitesService
.
selectWebsitesById
(
id
));
}
/**
* 新增网站管理
*/
@PreAuthorize
(
"@ss.hasPermi('system:websites:add')"
)
@Log
(
title
=
"网站管理"
,
businessType
=
BusinessType
.
INSERT
)
@PostMapping
public
AjaxResult
add
(
@RequestBody
Websites
websites
)
{
return
toAjax
(
websitesService
.
insertWebsites
(
websites
));
}
/**
* 修改网站管理
*/
@PreAuthorize
(
"@ss.hasPermi('system:websites:edit')"
)
@Log
(
title
=
"网站管理"
,
businessType
=
BusinessType
.
UPDATE
)
@PutMapping
public
AjaxResult
edit
(
@RequestBody
Websites
websites
)
{
return
toAjax
(
websitesService
.
updateWebsites
(
websites
));
}
/**
* 删除网站管理
*/
@PreAuthorize
(
"@ss.hasPermi('system:websites:remove')"
)
@Log
(
title
=
"网站管理"
,
businessType
=
BusinessType
.
DELETE
)
@DeleteMapping
(
"/{ids}"
)
public
AjaxResult
remove
(
@PathVariable
Long
[]
ids
)
{
return
toAjax
(
websitesService
.
deleteWebsitesByIds
(
ids
));
}
}
ruoyi-system/src/main/java/com/ruoyi/system/domain/Websites.java
0 → 100644
View file @
5aa1d56b
package
com
.
ruoyi
.
system
.
domain
;
import
com.ruoyi.common.core.domain.BaseEntityClean
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
com.ruoyi.common.annotation.Excel
;
import
com.ruoyi.common.core.domain.BaseEntity
;
/**
* 网站管理对象 websites
*
* @author ruoyi
* @date 2023-06-27
*/
public
class
Websites
extends
BaseEntityClean
{
private
static
final
long
serialVersionUID
=
1L
;
/** 主键 */
private
Long
id
;
/** 站点名称 */
@Excel
(
name
=
"站点名称"
)
private
String
name
;
/** 网址 */
@Excel
(
name
=
"网址"
)
private
String
url
;
/** Alexa 排名 */
@Excel
(
name
=
"Alexa 排名"
)
private
Long
alexa
;
/** 国家 */
@Excel
(
name
=
"国家"
)
private
String
country
;
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
Long
getId
()
{
return
id
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getName
()
{
return
name
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
public
String
getUrl
()
{
return
url
;
}
public
void
setAlexa
(
Long
alexa
)
{
this
.
alexa
=
alexa
;
}
public
Long
getAlexa
()
{
return
alexa
;
}
public
void
setCountry
(
String
country
)
{
this
.
country
=
country
;
}
public
String
getCountry
()
{
return
country
;
}
@Override
public
String
toString
()
{
return
new
ToStringBuilder
(
this
,
ToStringStyle
.
MULTI_LINE_STYLE
)
.
append
(
"id"
,
getId
())
.
append
(
"name"
,
getName
())
.
append
(
"url"
,
getUrl
())
.
append
(
"alexa"
,
getAlexa
())
.
append
(
"country"
,
getCountry
())
.
toString
();
}
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/WebsitesMapper.java
0 → 100644
View file @
5aa1d56b
package
com
.
ruoyi
.
system
.
mapper
;
import
java.util.List
;
import
com.ruoyi.system.domain.Websites
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
/**
* 网站管理Mapper接口
*
* @author ruoyi
* @date 2023-06-27
*/
public
interface
WebsitesMapper
extends
BaseMapper
<
Websites
>
{
/**
* 查询网站管理
*
* @param id 网站管理主键
* @return 网站管理
*/
public
Websites
selectWebsitesById
(
Long
id
);
/**
* 查询网站管理列表
*
* @param websites 网站管理
* @return 网站管理集合
*/
public
List
<
Websites
>
selectWebsitesList
(
Websites
websites
);
/**
* 新增网站管理
*
* @param websites 网站管理
* @return 结果
*/
public
int
insertWebsites
(
Websites
websites
);
/**
* 修改网站管理
*
* @param websites 网站管理
* @return 结果
*/
public
int
updateWebsites
(
Websites
websites
);
/**
* 删除网站管理
*
* @param id 网站管理主键
* @return 结果
*/
public
int
deleteWebsitesById
(
Long
id
);
/**
* 批量删除网站管理
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public
int
deleteWebsitesByIds
(
Long
[]
ids
);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/IWebsitesService.java
0 → 100644
View file @
5aa1d56b
package
com
.
ruoyi
.
system
.
service
;
import
java.util.List
;
import
com.ruoyi.system.domain.Websites
;
import
com.baomidou.mybatisplus.extension.service.IService
;
/**
* 网站管理Service接口
*
* @author ruoyi
* @date 2023-06-27
*/
public
interface
IWebsitesService
extends
IService
<
Websites
>
{
/**
* 查询网站管理
*
* @param id 网站管理主键
* @return 网站管理
*/
public
Websites
selectWebsitesById
(
Long
id
);
/**
* 查询网站管理列表
*
* @param websites 网站管理
* @return 网站管理集合
*/
public
List
<
Websites
>
selectWebsitesList
(
Websites
websites
);
/**
* 新增网站管理
*
* @param websites 网站管理
* @return 结果
*/
public
int
insertWebsites
(
Websites
websites
);
/**
* 修改网站管理
*
* @param websites 网站管理
* @return 结果
*/
public
int
updateWebsites
(
Websites
websites
);
/**
* 批量删除网站管理
*
* @param ids 需要删除的网站管理主键集合
* @return 结果
*/
public
int
deleteWebsitesByIds
(
Long
[]
ids
);
/**
* 删除网站管理信息
*
* @param id 网站管理主键
* @return 结果
*/
public
int
deleteWebsitesById
(
Long
id
);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WebsitesServiceImpl.java
0 → 100644
View file @
5aa1d56b
package
com
.
ruoyi
.
system
.
service
.
impl
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.system.mapper.WebsitesMapper
;
import
com.ruoyi.system.domain.Websites
;
import
com.ruoyi.system.service.IWebsitesService
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
/**
* 网站管理Service业务层处理
*
* @author ruoyi
* @date 2023-06-27
*/
@Service
public
class
WebsitesServiceImpl
extends
ServiceImpl
<
WebsitesMapper
,
Websites
>
implements
IWebsitesService
{
@Autowired
private
WebsitesMapper
websitesMapper
;
/**
* 查询网站管理
*
* @param id 网站管理主键
* @return 网站管理
*/
@Override
public
Websites
selectWebsitesById
(
Long
id
)
{
return
websitesMapper
.
selectWebsitesById
(
id
);
}
/**
* 查询网站管理列表
*
* @param websites 网站管理
* @return 网站管理
*/
@Override
public
List
<
Websites
>
selectWebsitesList
(
Websites
websites
)
{
return
websitesMapper
.
selectWebsitesList
(
websites
);
}
/**
* 新增网站管理
*
* @param websites 网站管理
* @return 结果
*/
@Override
public
int
insertWebsites
(
Websites
websites
)
{
return
websitesMapper
.
insertWebsites
(
websites
);
}
/**
* 修改网站管理
*
* @param websites 网站管理
* @return 结果
*/
@Override
public
int
updateWebsites
(
Websites
websites
)
{
return
websitesMapper
.
updateWebsites
(
websites
);
}
/**
* 批量删除网站管理
*
* @param ids 需要删除的网站管理主键
* @return 结果
*/
@Override
public
int
deleteWebsitesByIds
(
Long
[]
ids
)
{
return
websitesMapper
.
deleteWebsitesByIds
(
ids
);
}
/**
* 删除网站管理信息
*
* @param id 网站管理主键
* @return 结果
*/
@Override
public
int
deleteWebsitesById
(
Long
id
)
{
return
websitesMapper
.
deleteWebsitesById
(
id
);
}
}
ruoyi-system/src/main/resources/mapper/system/WebsitesMapper.xml
0 → 100644
View file @
5aa1d56b
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.ruoyi.system.mapper.WebsitesMapper"
>
<resultMap
type=
"Websites"
id=
"WebsitesResult"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"name"
column=
"name"
/>
<result
property=
"url"
column=
"url"
/>
<result
property=
"alexa"
column=
"alexa"
/>
<result
property=
"country"
column=
"country"
/>
</resultMap>
<sql
id=
"selectWebsitesVo"
>
select id, name, url, alexa, country from websites
</sql>
<select
id=
"selectWebsitesList"
parameterType=
"Websites"
resultMap=
"WebsitesResult"
>
<include
refid=
"selectWebsitesVo"
/>
<where>
<if
test=
"name != null and name != ''"
>
and name like concat('%', #{name}, '%')
</if>
<if
test=
"url != null and url != ''"
>
and url = #{url}
</if>
<if
test=
"alexa != null "
>
and alexa = #{alexa}
</if>
<if
test=
"country != null and country != ''"
>
and country = #{country}
</if>
</where>
</select>
<select
id=
"selectWebsitesById"
parameterType=
"Long"
resultMap=
"WebsitesResult"
>
<include
refid=
"selectWebsitesVo"
/>
where id = #{id}
</select>
<insert
id=
"insertWebsites"
parameterType=
"Websites"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into websites
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"name != null and name != ''"
>
name,
</if>
<if
test=
"url != null and url != ''"
>
url,
</if>
<if
test=
"alexa != null"
>
alexa,
</if>
<if
test=
"country != null and country != ''"
>
country,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"name != null and name != ''"
>
#{name},
</if>
<if
test=
"url != null and url != ''"
>
#{url},
</if>
<if
test=
"alexa != null"
>
#{alexa},
</if>
<if
test=
"country != null and country != ''"
>
#{country},
</if>
</trim>
</insert>
<update
id=
"updateWebsites"
parameterType=
"Websites"
>
update websites
<trim
prefix=
"SET"
suffixOverrides=
","
>
<if
test=
"name != null and name != ''"
>
name = #{name},
</if>
<if
test=
"url != null and url != ''"
>
url = #{url},
</if>
<if
test=
"alexa != null"
>
alexa = #{alexa},
</if>
<if
test=
"country != null and country != ''"
>
country = #{country},
</if>
</trim>
where id = #{id}
</update>
<delete
id=
"deleteWebsitesById"
parameterType=
"Long"
>
delete from websites where id = #{id}
</delete>
<delete
id=
"deleteWebsitesByIds"
parameterType=
"String"
>
delete from websites where id in
<foreach
item=
"id"
collection=
"array"
open=
"("
separator=
","
close=
")"
>
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
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