| @@ -17,6 +17,10 @@ | |||||
| <artifactId>mallinkService</artifactId> | <artifactId>mallinkService</artifactId> | ||||
| <version>1.0</version> | <version>1.0</version> | ||||
| </dependency> | </dependency> | ||||
| <dependency> | |||||
| <groupId>junit</groupId> | |||||
| <artifactId>junit</artifactId> | |||||
| </dependency> | |||||
| </dependencies> | </dependencies> | ||||
| <build> | <build> | ||||
| <plugins> | <plugins> | ||||
| @@ -341,7 +341,7 @@ public class WxUserGrantController extends BaseController { | |||||
| userVo.setLevelName("无"); | userVo.setLevelName("无"); | ||||
| List<WxLevelConfig> levelList = wxLevelConfigService.getByTenantId(user.getTenantId()); | List<WxLevelConfig> levelList = wxLevelConfigService.getByTenantId(user.getTenantId()); | ||||
| for(WxLevelConfig levelConfig: levelList) { | for(WxLevelConfig levelConfig: levelList) { | ||||
| if (userVo.getScore() > levelConfig.getPoints()) { | |||||
| if (userVo.getScore() >= levelConfig.getPoints()) { | |||||
| userVo.setLevelName(levelConfig.getLevel()); | userVo.setLevelName(levelConfig.getLevel()); | ||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,47 @@ | |||||
| package com.iformall.test; | |||||
| import com.iformall.CApplication; | |||||
| import com.iformall.domain.po.WxLevelConfig; | |||||
| import com.iformall.service.WxLevelConfigService; | |||||
| import org.junit.Before; | |||||
| import org.junit.Test; | |||||
| import org.junit.runner.RunWith; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.boot.test.context.SpringBootTest; | |||||
| import org.springframework.test.context.junit4.SpringRunner; | |||||
| import org.springframework.test.context.web.WebAppConfiguration; | |||||
| import org.springframework.test.web.servlet.MockMvc; | |||||
| import org.springframework.test.web.servlet.setup.MockMvcBuilders; | |||||
| import org.springframework.web.context.WebApplicationContext; | |||||
| import java.util.List; | |||||
| @RunWith(SpringRunner.class) | |||||
| @SpringBootTest(classes = CApplication.class)//这里的Application是springboot的启动类名 | |||||
| @WebAppConfiguration | |||||
| public class appTest { | |||||
| @Autowired | |||||
| private WebApplicationContext wac; | |||||
| private MockMvc mockMvc; | |||||
| @Autowired | |||||
| WxLevelConfigService wxLevelConfigService; | |||||
| @Before | |||||
| public void setupMockMvc() throws Exception { | |||||
| mockMvc = MockMvcBuilders.webAppContextSetup(wac).build(); | |||||
| } | |||||
| @Test | |||||
| public void testSend() throws Exception { | |||||
| Integer score = 2055; | |||||
| List<WxLevelConfig> levelList = wxLevelConfigService.getByTenantId("456"); | |||||
| for (WxLevelConfig levelConfig : levelList) { | |||||
| if (score >= levelConfig.getPoints()) { | |||||
| System.out.println(levelConfig.getLevel()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -30,7 +30,7 @@ public class WxLevelConfigServiceImpl implements WxLevelConfigService { | |||||
| public List<WxLevelConfig> getByTenantId(String tenantId) { | public List<WxLevelConfig> getByTenantId(String tenantId) { | ||||
| WxLevelConfig wxLevelConfig = new WxLevelConfig(); | WxLevelConfig wxLevelConfig = new WxLevelConfig(); | ||||
| wxLevelConfig.setTenantId(tenantId); | wxLevelConfig.setTenantId(tenantId); | ||||
| wxLevelConfig.setSortColumns(WxLevelConfig.Field.Level_ASC); | |||||
| wxLevelConfig.setSortColumns(WxLevelConfig.Field.Points_ASC); | |||||
| return wxLevelConfigMapper.findList(wxLevelConfig); | return wxLevelConfigMapper.findList(wxLevelConfig); | ||||
| } | } | ||||