|
@@ -22,6 +22,7 @@ import io.swagger.annotations.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.BeansException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -184,31 +185,36 @@ public class BrandController extends AbstractController{
|
|
|
return R.error("场景码错误!");
|
|
|
}
|
|
|
|
|
|
- // 判断直播间名称是否重复
|
|
|
- Map<String,Object> paramsMap = new HashMap<>();
|
|
|
- paramsMap.put("name",params.getName());
|
|
|
- List<BrandEntity> entities = brandService.queryList(paramsMap);
|
|
|
- if(!ObjectUtils.isEmpty(entities)){
|
|
|
- return R.error("直播间名称重复!");
|
|
|
- }
|
|
|
- BrandEntity brand = brandService.queryByScene(params.getSceneNum());
|
|
|
- if(!ObjectUtils.isEmpty(brand)){
|
|
|
- return R.error("该场景已经绑定直播间!");
|
|
|
- }
|
|
|
- brand = new BrandEntity();
|
|
|
- BeanUtils.copyProperties(params,brand);
|
|
|
- brand.setCreateUserId(getUserId());
|
|
|
- if (ObjectUtils.isEmpty(brand.getType())) {
|
|
|
- brand.setType(0);
|
|
|
- }
|
|
|
- // 生成直播间地址
|
|
|
- String liveRoomUrl = scene.getSceneUrl().replaceAll("smobile.html", "shop.html");
|
|
|
- brand.setLiveRoomUrl(liveRoomUrl);
|
|
|
+ try {
|
|
|
+ // 判断直播间名称是否重复
|
|
|
+ Map<String,Object> paramsMap = new HashMap<>();
|
|
|
+ paramsMap.put("name",params.getName());
|
|
|
+ List<BrandEntity> entities = brandService.queryList(paramsMap);
|
|
|
+ if(!ObjectUtils.isEmpty(entities)){
|
|
|
+ return R.error("直播间名称重复!");
|
|
|
+ }
|
|
|
+ BrandEntity brand = brandService.queryByScene(params.getSceneNum());
|
|
|
+ if(!ObjectUtils.isEmpty(brand)){
|
|
|
+ return R.error("该场景已经绑定直播间!");
|
|
|
+ }
|
|
|
+ brand = new BrandEntity();
|
|
|
+ BeanUtils.copyProperties(params,brand);
|
|
|
+ brand.setCreateUserId(getUserId());
|
|
|
+ if (ObjectUtils.isEmpty(brand.getType())) {
|
|
|
+ brand.setType(0);
|
|
|
+ }
|
|
|
+ // 生成直播间地址
|
|
|
+ String liveRoomUrl = scene.getSceneUrl().replaceAll("smobile.html", "shop.html");
|
|
|
+ brand.setLiveRoomUrl(liveRoomUrl);
|
|
|
|
|
|
- brandService.save(brand);
|
|
|
- //生成微信分享二维码
|
|
|
- brandService.generalWxShareQrCode(brand , true);
|
|
|
- brandService.sendDataToApi(brand);
|
|
|
+ brandService.save(brand);
|
|
|
+ //生成微信分享二维码
|
|
|
+ brandService.generalWxShareQrCode(brand , true);
|
|
|
+ brandService.sendDataToApi(brand);
|
|
|
+ } catch (BeansException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return R.error(ObjectUtils.isEmpty(e.getMessage())?"该场景已经绑定直播间!":e.getMessage());
|
|
|
+ }
|
|
|
return R.ok("新增商铺成功");
|
|
|
}
|
|
|
|