Quellcode durchsuchen

Merge branch 'dev' of 113.31.163.91:quanshu/mp-server into dev

chunping vor 3 Jahren
Ursprung
Commit
80b049bf03

+ 3 - 11
mp-admin/src/main/java/com/qs/mp/web/controller/api/channel/ChannelController.java

@@ -107,11 +107,7 @@ public class ChannelController extends BaseApiController {
 		Long channelId = SecurityUtils.getLoginUser().getChannelId();
 		Channel channel = mapperFacade.map(channelParam, Channel.class);
 		channel.setParentId(channelId);
-		try {
-			channelService.saveChannel(channel, "channel");
-		} catch (Exception e) {
-			return AjaxResult.error("子渠道'" + channel.getName() + "'新增失败");
-		}
+		channelService.saveChannel(channel, "channel");
 		return AjaxResult.success("子渠道'" + channel.getName() + "'新增成功");
 	}
 
@@ -128,11 +124,7 @@ public class ChannelController extends BaseApiController {
 			return error(ErrorCodeEnum.ERROR_CODE_1001);
 		}
 		Channel channel = mapperFacade.map(channelParam, Channel.class);
-		try {
-			channelService.updateChannel(channel, "channel");
-		} catch (Exception e) {
-			return AjaxResult.error("子渠道'" + channel.getName() + "'编辑失败");
-		}
+		channelService.updateChannel(channel, "channel");
 		return AjaxResult.success("子渠道'" + channel.getName() + "'编辑成功");
 	}
 	
@@ -184,7 +176,7 @@ public class ChannelController extends BaseApiController {
 		}
 		days = days > 0?days:1;
 		List<Channel> list = channelService.list(
-		        new LambdaQueryWrapper<Channel>().eq(Channel::getParentId, channelId)
+		        new LambdaQueryWrapper<Channel>().eq(Channel::getParentId, channelId).gt(Channel::getLevel, 0)
 		            .orderByDesc(Channel::getChannelId));
 		
 		List<ChannelOperDataVO> dataList = new ArrayList<ChannelOperDataVO>();

+ 2 - 2
mp-admin/src/test/java/com/qs/mp/api/ChannelControllerTest.java

@@ -39,7 +39,7 @@ public class ChannelControllerTest extends BaseControllerTest {
 	 */
 	@Test
 	public void testGetChannelDetail() {
-		String channelId = "1";
+		String channelId = "4";
 		String params = "{\"channelId\":\"" + channelId + "\"}";
 		String url = "http://localhost:8080/api/v1/mp/channel/subchannel/detail?";
 		System.out.println(request(url, params));
@@ -51,7 +51,7 @@ public class ChannelControllerTest extends BaseControllerTest {
 	 */
 	@Test
 	public void testSubChannelAdd() {
-		String mobile = "15112682435";
+		String mobile = "15112682431";
 		String name = "西湖渠道";
 		Long provinceId = 330000000000L;
 		String province = "浙江省";

+ 1 - 1
mp-admin/src/test/java/com/qs/mp/common/BaseControllerTest.java

@@ -31,7 +31,7 @@ public class BaseControllerTest {
     headers.put("content-type", "application/json; charset=UTF-8");
     headers.put("x-zz-timestamp", timestamp);
     // 本地登录状态
-    String token = "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjZmZDZjYmU1LTIzYjItNDY3ZS1hYWRlLWExMjAwOWUwZDAyZSJ9.7AQ5wEBV9qr0YMXy9L0e1UvwEriU4u4WZeufCfvrXsj3nuEkHnxjEpy_6LOcDBAB88e_SZY3P2vLhL4seWkcHA";
+    String token = "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjNiODY5YWVjLWQ2NTYtNDc2OC05NmIyLWRmMDljMDk1ZWE4YyJ9.5ejb8VGTmqc8MyPHxnjyQLg2EMSFty3C-A0D9ZgVnghn_uxPNvtXvS3ApzKVhwsC8JL5RcoEvKZ2eR3rFEzqRA";
 
     if (!StringUtils.isBlank(token)) {
       headers.put("Authorization", "Bearer "+token);

+ 2 - 2
mp-service/src/main/java/com/qs/mp/channel/service/IChannelService.java

@@ -25,7 +25,7 @@ public interface IChannelService extends IService<Channel> {
 	 * @param channelType channel:子渠道  site: 经销商
 	 * @return
 	 */
-    public void saveChannel(Channel channel, String channelType) throws Exception;
+    public void saveChannel(Channel channel, String channelType);
      
     /**
 	 * 编辑子渠道、经销商信息
@@ -34,7 +34,7 @@ public interface IChannelService extends IService<Channel> {
 	 * @param channelType channel:子渠道  site: 经销商
 	 * @return
 	 */
-    public void updateChannel(Channel channel, String channelType) throws Exception;
+    public void updateChannel(Channel channel, String channelType);
     
     
 	/**

+ 9 - 3
mp-service/src/main/java/com/qs/mp/channel/service/impl/ChannelServiceImpl.java

@@ -52,7 +52,7 @@ public class ChannelServiceImpl extends ServiceImpl<ChannelMapper, Channel> impl
 
 	@Override
 	@Transactional
-	public void saveChannel(Channel channel, String channelType) throws Exception {
+	public void saveChannel(Channel channel, String channelType){
 		
 		String title = channelType.equals("channel")?"渠道":"经销商";
 		// 1、校验名称是否重复、手机号是否存在(渠道表)
@@ -85,6 +85,7 @@ public class ChannelServiceImpl extends ServiceImpl<ChannelMapper, Channel> impl
 			channel.setLevel(0);
 		}
 		// 3.插入数据
+		channel.setChannelNo(channel.getChannelId()+"");
 		boolean res = channelService.save(channel);
 		if(res && null != channel.getChannelId()) {
 			channel.setChannelNo(parentChannel.getChannelNo()+"."+channel.getChannelId());
@@ -100,15 +101,20 @@ public class ChannelServiceImpl extends ServiceImpl<ChannelMapper, Channel> impl
 		        throw new ServiceException("新增'" + title + channel.getName() + "'失败,请联系管理员");
 		    }
 		    channel.setUserId(sysUser.getUserId());
-		    channelService.updateById(channel);
+		    boolean ures = channelService.updateById(channel);
+		    if(!ures) {
+		    	throw new ServiceException("新增'" + title + channel.getName() + "'失败,请联系管理员");
+		    }
 		    // 4.发送账号创建成功短信
+		}else {
+			throw new ServiceException("新增'" + title + channel.getName() + "'失败,请联系管理员");
 		}
 	}
 	
 
 	@Override
 	@Transactional
-	public void updateChannel(Channel channel, String channelType) throws Exception {
+	public void updateChannel(Channel channel, String channelType) {
 		String title = channelType.equals("channel")?"渠道":"经销商";
 		// 1、校验修改子渠道是否为当前用户的子渠道
 		Channel oldChannel = channelService.getById(channel.getChannelId());