1.通用mapper集成 2.单元测试
This commit is contained in:
		| @@ -8,12 +8,12 @@ import tk.mybatis.spring.annotation.MapperScan; | ||||
|  | ||||
| /** | ||||
|  * 启动程序 | ||||
|  *  | ||||
|  * | ||||
|  * @author | ||||
|  */ | ||||
|  | ||||
| @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) | ||||
| @MapperScan(basePackages = "com.ruoyi.bookmark.mapper") | ||||
| @MapperScan(basePackages = { "com.ruoyi.**.mapper" }) | ||||
| public class RuoYiApplication | ||||
| { | ||||
|     public static void main(String[] args) | ||||
|   | ||||
| @@ -40,7 +40,7 @@ public class SqBookmarkController extends BaseController | ||||
|      * 测试通用mapper | ||||
|      */ | ||||
|     @GetMapping("/selectByID") | ||||
|     public TableDataInfo selectByID(Long userID) { | ||||
|     public TableDataInfo selectByID( Long userID) { | ||||
|         List<SqBookmark> list = sqBookmarkService.selectByID(userID); | ||||
|         return getDataTable(list); | ||||
|     } | ||||
| @@ -51,6 +51,7 @@ public class SqBookmarkController extends BaseController | ||||
|      * @return | ||||
|      */ | ||||
|     @GetMapping("/selectBymenuIdUserID") | ||||
|     @PreAuthorize("@ss.hasPermi('bookmark:bookmark:list')") | ||||
|     public TableDataInfo selectBymenuIdUserID(Long menuID, Long userID) { | ||||
|         startPage(); | ||||
|         List<SqBookmark> list = sqBookmarkService.selectBymenuIdUserID(menuID,userID); | ||||
|   | ||||
| @@ -0,0 +1,33 @@ | ||||
| package com.ruoyi.web.test.controller; | ||||
|  | ||||
|  | ||||
| import org.junit.After; | ||||
| import org.junit.Before; | ||||
| import org.junit.runner.RunWith; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.springframework.boot.test.context.SpringBootTest; | ||||
| import org.springframework.test.context.junit4.SpringRunner; | ||||
| import org.springframework.test.context.web.WebAppConfiguration; | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * @Auther: Wang | ||||
|  * @Date: 2020/08/08 19:10 | ||||
|  * 功能描述: | ||||
|  */ | ||||
| @RunWith(SpringRunner.class) | ||||
| @SpringBootTest | ||||
| @WebAppConfiguration | ||||
| public class BaseSpringBootTest { | ||||
|     protected  static final Logger logger = LoggerFactory.getLogger(BaseSpringBootTest.class); | ||||
|     @Before | ||||
|     public void init() { | ||||
|         logger.info("开始测试..."); | ||||
|     } | ||||
|  | ||||
|     @After | ||||
|     public void after() { | ||||
|        logger.info("测试结束..."); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,45 @@ | ||||
| package com.ruoyi.web.test.controller; | ||||
|  | ||||
|  | ||||
| import com.ruoyi.web.controller.yunbookmark.SqBookmarkController; | ||||
| import org.assertj.core.api.Assertions; | ||||
| import org.junit.Before; | ||||
| import org.junit.Test; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.boot.test.web.client.TestRestTemplate; | ||||
| import org.springframework.test.web.servlet.MockMvc; | ||||
| import org.springframework.test.web.servlet.MvcResult; | ||||
| import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; | ||||
| import org.springframework.test.web.servlet.result.MockMvcResultHandlers; | ||||
| import org.springframework.test.web.servlet.result.MockMvcResultMatchers; | ||||
| import org.springframework.test.web.servlet.setup.MockMvcBuilders; | ||||
|  | ||||
| /** | ||||
|  * @Auther: Wang | ||||
|  * @Date: 2020/08/08 18:51 | ||||
|  * 功能描述: SqBookmark 测试类 | ||||
|  */ | ||||
| public class SqBookmarkTest extends BaseSpringBootTest{ | ||||
|  | ||||
|  | ||||
|     @Autowired | ||||
|     private SqBookmarkController sqBookmarkController; | ||||
|  | ||||
|     private MockMvc mockMvc; | ||||
|  | ||||
|     @Before | ||||
|     public void setup() { | ||||
|         mockMvc = MockMvcBuilders.standaloneSetup(sqBookmarkController).build(); | ||||
|         logger.info("setup()........."); | ||||
|     } | ||||
|     @Test | ||||
|     public void demo() throws Exception { | ||||
|         MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/bookmark/bookmark/2")) | ||||
|                 .andExpect(MockMvcResultMatchers.status().isOk()) | ||||
|                 .andDo(MockMvcResultHandlers.print()) | ||||
|                 .andReturn(); | ||||
|  | ||||
|         logger.info(mvcResult.getResponse().getContentAsString()); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -42,7 +42,7 @@ spring: | ||||
|   messages: | ||||
|     # 国际化资源文件路径 | ||||
|     basename: i18n/messages | ||||
|   profiles:  | ||||
|   profiles: | ||||
|     active: druid | ||||
|   # 文件上传 | ||||
|   servlet: | ||||
| @@ -63,7 +63,7 @@ spring: | ||||
|     # 端口,默认为6379 | ||||
|     port: 6379 | ||||
|     # 密码 | ||||
|     password:  | ||||
|     password: | ||||
|     # 连接超时时间 | ||||
|     timeout: 10s | ||||
|     lettuce: | ||||
| @@ -85,7 +85,7 @@ token: | ||||
|     secret: abcdefghijklmnopqrstuvwxyz | ||||
|     # 令牌有效期(默认30分钟) | ||||
|     expireTime: 300 | ||||
|    | ||||
|  | ||||
| # MyBatis配置 | ||||
| mybatis: | ||||
|     # 搜索指定包别名 | ||||
| @@ -98,16 +98,17 @@ mybatis: | ||||
| #mappers 多个接口时逗号隔开 | ||||
|  | ||||
| mapper: | ||||
|   mappers: com.ruoyi.common.mybatisMapper.MyMapper | ||||
|   not-empty: false | ||||
|   identity: MYSQL | ||||
|   mappers: | ||||
|     - com.ruoyi.common.mybatisMapper.MyMapper | ||||
|   not-empty: true | ||||
|   identity: mysql | ||||
|  | ||||
| # PageHelper分页插件 | ||||
| pagehelper:  | ||||
| pagehelper: | ||||
|   helperDialect: mysql | ||||
|   reasonable: true | ||||
|   supportMethodsArguments: true | ||||
|   params: count=countSql  | ||||
|   params: count=countSql | ||||
|  | ||||
| # Swagger配置 | ||||
| swagger: | ||||
| @@ -117,7 +118,7 @@ swagger: | ||||
|   pathMapping: /dev-api | ||||
|  | ||||
| # 防止XSS攻击 | ||||
| xss:  | ||||
| xss: | ||||
|   # 过滤开关 | ||||
|   enabled: true | ||||
|   # 排除链接(多个用逗号分隔) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user