通用mapper集成 90%
This commit is contained in:
parent
7ea7a3bccd
commit
0f4d4f68ca
@ -1,18 +1,19 @@
|
|||||||
package com.ruoyi;
|
package com.ruoyi;
|
||||||
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import tk.mybatis.spring.annotation.MapperScan;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动程序
|
* 启动程序
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
|
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
|
||||||
|
@MapperScan(basePackages = "com.ruoyi.bookmark.mapper")
|
||||||
public class RuoYiApplication
|
public class RuoYiApplication
|
||||||
{
|
{
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
|
@ -36,6 +36,15 @@ public class SqBookmarkController extends BaseController
|
|||||||
private ISqBookmarkService sqBookmarkService;
|
private ISqBookmarkService sqBookmarkService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试通用mapper
|
||||||
|
*/
|
||||||
|
@GetMapping("/selectByID")
|
||||||
|
public TableDataInfo selectByID(Long userID) {
|
||||||
|
List<SqBookmark> list = sqBookmarkService.selectByID(userID);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户栏目下的书签
|
* 查询用户栏目下的书签
|
||||||
|
@ -94,6 +94,13 @@ mybatis:
|
|||||||
mapperLocations: classpath*:mapper/**/*Mapper.xml
|
mapperLocations: classpath*:mapper/**/*Mapper.xml
|
||||||
# 加载全局的配置文件
|
# 加载全局的配置文件
|
||||||
configLocation: classpath:mybatis/mybatis-config.xml
|
configLocation: classpath:mybatis/mybatis-config.xml
|
||||||
|
#通用mapper的所在接口名称 不只是包名
|
||||||
|
#mappers 多个接口时逗号隔开
|
||||||
|
|
||||||
|
mapper:
|
||||||
|
mappers: com.ruoyi.common.mybatisMapper.MyMapper
|
||||||
|
not-empty: false
|
||||||
|
identity: MYSQL
|
||||||
|
|
||||||
# PageHelper分页插件
|
# PageHelper分页插件
|
||||||
pagehelper:
|
pagehelper:
|
||||||
|
@ -118,6 +118,12 @@
|
|||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!--通用Mapper插件-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>tk.mybatis</groupId>
|
||||||
|
<artifactId>mapper-spring-boot-starter</artifactId>
|
||||||
|
<version>2.1.5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.ruoyi.common.mybatisMapper;
|
||||||
|
|
||||||
|
|
||||||
|
import tk.mybatis.mapper.common.Mapper;
|
||||||
|
import tk.mybatis.mapper.common.MySqlMapper;
|
||||||
|
|
||||||
|
public interface MyMapper<T> extends Mapper<T>, MySqlMapper<T> {
|
||||||
|
//TODO
|
||||||
|
//FIXME 特别注意,该接口不能被扫描到,否则会出错
|
||||||
|
}
|
@ -5,61 +5,79 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||||||
import com.ruoyi.common.annotation.Excel;
|
import com.ruoyi.common.annotation.Excel;
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 书签管理对象 sq_bookmark
|
* 书签管理对象 sq_bookmark
|
||||||
*
|
*
|
||||||
* @author wanghao
|
* @author wanghao 不存在的字段注解 @Transient
|
||||||
* @date 2020-08-02
|
* @date 2020-08-02
|
||||||
*/
|
*/
|
||||||
|
@Table(name="sq_bookmark")
|
||||||
public class SqBookmark extends BaseEntity
|
public class SqBookmark extends BaseEntity
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(generator = "JDBC")//返回自增长主键
|
||||||
/** $column.columnComment */
|
/** $column.columnComment */
|
||||||
private Long bookmarkId;
|
private Long bookmarkId;
|
||||||
|
|
||||||
/** 所属用户ID */
|
/** 所属用户ID */
|
||||||
|
@Column(name = "userid")
|
||||||
@Excel(name = "所属用户ID")
|
@Excel(name = "所属用户ID")
|
||||||
private Long userid;
|
private Long userid;
|
||||||
|
|
||||||
/** 书签标题 */
|
/** 书签标题 */
|
||||||
@Excel(name = "书签标题")
|
@Excel(name = "书签标题")
|
||||||
|
@Column(name = "title")
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
/** 书签地址 */
|
/** 书签地址 */
|
||||||
@Excel(name = "书签地址")
|
@Excel(name = "书签地址")
|
||||||
|
@Column(name = "url")
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
/** $column.columnComment */
|
/** $column.columnComment */
|
||||||
@Excel(name = "书签地址")
|
@Excel(name = "书签地址")
|
||||||
|
@Column(name = "urls")
|
||||||
private String urls;
|
private String urls;
|
||||||
|
|
||||||
/** 书签描述 */
|
/** 书签描述 */
|
||||||
@Excel(name = "书签描述")
|
@Excel(name = "书签描述")
|
||||||
|
@Column(name = "description")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
/** $column.columnComment */
|
/** $column.columnComment */
|
||||||
@Excel(name = "书签描述")
|
@Excel(name = "书签描述")
|
||||||
|
@Column(name = "image")
|
||||||
private String image;
|
private String image;
|
||||||
|
|
||||||
/** 标签 */
|
/** 标签 */
|
||||||
@Excel(name = "标签")
|
@Excel(name = "标签")
|
||||||
|
@Column(name = "Label")
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
/** 分类ID */
|
/** 分类ID */
|
||||||
@Excel(name = "分类ID")
|
@Excel(name = "分类ID")
|
||||||
|
@Column(name = "menu_id")
|
||||||
private Long menuId;
|
private Long menuId;
|
||||||
|
|
||||||
/** 点赞数 */
|
/** 点赞数 */
|
||||||
@Excel(name = "点赞数")
|
@Excel(name = "点赞数")
|
||||||
|
@Column(name = "zcount")
|
||||||
private Long zcount;
|
private Long zcount;
|
||||||
|
|
||||||
/** 0 未删除 1表示删除 */
|
/** 0 未删除 1表示删除 */
|
||||||
@Excel(name = "0 未删除 1表示删除")
|
@Excel(name = "0 未删除 1表示删除")
|
||||||
|
@Column(name = "IDelete")
|
||||||
private Integer idelete;
|
private Integer idelete;
|
||||||
|
|
||||||
/** 0公开显示 1隐藏显示 2好友显示 3稍后再看 */
|
/** 0公开显示 1隐藏显示 2好友显示 3稍后再看 */
|
||||||
@Excel(name = "0公开显示 1隐藏显示 2好友显示 3稍后再看")
|
@Excel(name = "0公开显示 1隐藏显示 2好友显示 3稍后再看")
|
||||||
|
@Column(name = "Start")
|
||||||
private Integer start;
|
private Integer start;
|
||||||
|
|
||||||
public void setBookmarkId(Long bookmarkId)
|
public void setBookmarkId(Long bookmarkId)
|
||||||
|
@ -2,6 +2,7 @@ package com.ruoyi.bookmark.mapper;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.ruoyi.bookmark.domain.SqBookmark;
|
import com.ruoyi.bookmark.domain.SqBookmark;
|
||||||
|
import com.ruoyi.common.mybatisMapper.MyMapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -10,7 +11,7 @@ import org.apache.ibatis.annotations.Param;
|
|||||||
* @author wanghao
|
* @author wanghao
|
||||||
* @date 2020-08-02
|
* @date 2020-08-02
|
||||||
*/
|
*/
|
||||||
public interface SqBookmarkMapper
|
public interface SqBookmarkMapper extends MyMapper<SqBookmark>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 查询栏目下书签管理
|
* 查询栏目下书签管理
|
||||||
|
@ -11,6 +11,10 @@ import com.ruoyi.bookmark.domain.SqBookmark;
|
|||||||
*/
|
*/
|
||||||
public interface ISqBookmarkService
|
public interface ISqBookmarkService
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* 测试 通用mapper
|
||||||
|
*/
|
||||||
|
public List<SqBookmark> selectByID(Long userID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户栏目下书签管理
|
* 查询用户栏目下书签管理
|
||||||
|
@ -20,6 +20,12 @@ public class SqBookmarkServiceImpl implements ISqBookmarkService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SqBookmarkMapper sqBookmarkMapper;
|
private SqBookmarkMapper sqBookmarkMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SqBookmark> selectByID(Long userID) {
|
||||||
|
|
||||||
|
return sqBookmarkMapper.selectByExample(userID);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询书签管理
|
* 查询书签管理
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user