|
@@ -7,32 +7,29 @@ import com.platform.entity.BrandEntity;
|
|
|
import com.platform.entity.Result;
|
|
|
import com.platform.entity.SceneEntity;
|
|
|
import com.platform.entity.SysUserEntity;
|
|
|
-import com.platform.enums.ResultCodeEnum;
|
|
|
import com.platform.exception.CommonBaseException;
|
|
|
import com.platform.service.BrandService;
|
|
|
import com.platform.service.SceneService;
|
|
|
import com.platform.service.SysDeptService;
|
|
|
import com.platform.service.SysUserService;
|
|
|
import com.platform.service.impl.ZhiHouseService;
|
|
|
-import com.platform.utils.*;
|
|
|
-import com.platform.vo.BrandBindUserVo;
|
|
|
+import com.platform.utils.Constant;
|
|
|
+import com.platform.utils.DepartmentUtils;
|
|
|
import com.platform.vos.CurrentUserLoginVo;
|
|
|
import com.platform.vos.RequestScene;
|
|
|
import io.swagger.annotations.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.http.HttpEntity;
|
|
|
-import org.springframework.http.HttpHeaders;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
-import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -65,67 +62,6 @@ public class SceneController extends AbstractController{
|
|
|
@Autowired
|
|
|
private ZhiHouseService zhiHouseService;
|
|
|
|
|
|
- /**
|
|
|
- * 更新显示状态
|
|
|
- */
|
|
|
- @CanUserUpdateRecord
|
|
|
- @RequestMapping("/update")
|
|
|
- @RequiresPermissions("brand:list")
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public Result updateShowStatus(@RequestBody SceneEntity sceneParam) {
|
|
|
- if(ObjectUtils.isEmpty(sceneParam.getId()) && ObjectUtils.isEmpty(sceneParam.getSceneNum())){
|
|
|
- log.error("参数有误");
|
|
|
- return Result.failure("参数有误");
|
|
|
- }
|
|
|
- if(!ObjectUtils.isEmpty(sceneParam.getId())){
|
|
|
- sceneService.update(sceneParam,true);
|
|
|
- }else{
|
|
|
- // 获取情景信息
|
|
|
- RequestScene requestScene = new RequestScene();
|
|
|
- requestScene.setToken(sceneParam.getToken());
|
|
|
- requestScene.setNums("'"+sceneParam.getSceneNum()+"'");
|
|
|
- requestScene.setUserId(-1L);
|
|
|
- JSONObject mySceneJsonData = zhiHouseService.getSceneFromZhiHouse(requestScene);
|
|
|
- if(ObjectUtils.isEmpty(mySceneJsonData) || !mySceneJsonData.containsKey("list")){
|
|
|
- log.error("场景码错误!");
|
|
|
- return Result.failure("场景码错误!");
|
|
|
- }
|
|
|
-
|
|
|
- List<Object> mySceneList = mySceneJsonData.getJSONArray("list");
|
|
|
- if (ObjectUtils.isEmpty(mySceneList)) {
|
|
|
- log.error("场景码错误!");
|
|
|
- return Result.failure("场景码错误!");
|
|
|
- }
|
|
|
- JSONObject sceneRes = JSONObject.parseObject(JSONObject.toJSONString(mySceneList.get(0)));
|
|
|
- SceneEntity sceneEntity = new SceneEntity();
|
|
|
- sceneEntity.setIsShow(sceneParam.getIsShow());
|
|
|
- if(ObjectUtils.isEmpty(sceneEntity.getIsShow())){
|
|
|
- sceneEntity.setIsShow(0);
|
|
|
- }
|
|
|
- String webSite = sceneRes.getString("webSite");
|
|
|
- sceneEntity.setSceneUrl(webSite);
|
|
|
- sceneEntity.setAppListPicUrl(sceneParam.getAppListPicUrl());
|
|
|
- String phone = sceneRes.getString("phone");
|
|
|
- SysUserEntity userEntity = sysUserService.queryByUserMobile(phone);
|
|
|
- if (ObjectUtils.isEmpty(userEntity)) {
|
|
|
- log.error("找不到用户:{}",phone);
|
|
|
- return Result.failure("找不到用户:" + phone);
|
|
|
- }
|
|
|
- sceneEntity.setCreateUserId(userEntity.getUserId());
|
|
|
- sceneEntity.setName(sceneRes.getString("sceneName"));
|
|
|
- if(!ObjectUtils.isEmpty(sceneParam.getName())){
|
|
|
- sceneEntity.setName(sceneParam.getName());
|
|
|
- }
|
|
|
- sceneEntity.setSceneNum(sceneParam.getSceneNum());
|
|
|
- int result = sceneService.save(sceneEntity,false);
|
|
|
- if(result==0){
|
|
|
- log.error("场景已经被绑定!");
|
|
|
- return Result.failure("场景已经被绑定!");
|
|
|
- }
|
|
|
- }
|
|
|
- return Result.success();
|
|
|
- }
|
|
|
-
|
|
|
public List<Long> getAllSubDeptIds(Long deptId) {
|
|
|
if (null == deptId) {
|
|
|
log.info("部门ID为空");
|
|
@@ -325,10 +261,8 @@ public class SceneController extends AbstractController{
|
|
|
/**
|
|
|
* 删除
|
|
|
*/
|
|
|
- @CanUserUpdateRecord
|
|
|
@PostMapping("/generateDefaultLiveRoom")
|
|
|
- @RequiresPermissions("brand:delete")
|
|
|
- public Result generateDefaultLiveRoom(@RequestBody SceneEntity requestScene) {
|
|
|
+ public Result generateDefaultLiveRoom(@RequestBody RequestScene requestScene) {
|
|
|
try {
|
|
|
String sceneNum = requestScene.getSceneNum();
|
|
|
if (ObjectUtils.isEmpty(sceneNum)) {
|
|
@@ -340,13 +274,10 @@ public class SceneController extends AbstractController{
|
|
|
return Result.failure("直播间已存在!");
|
|
|
}
|
|
|
|
|
|
- SceneEntity entity = sceneService.queryByScene(sceneNum);
|
|
|
- if (ObjectUtils.isEmpty(entity)) {
|
|
|
- updateShowStatus(requestScene);
|
|
|
- }
|
|
|
- BrandEntity brandEntity = null;
|
|
|
+ Object result = zhiHouseService.generateDefaultLiveRoom(sceneNum);
|
|
|
|
|
|
- brandEntity = brandService.generateDefaultLiveRoom(sceneNum);
|
|
|
+ SceneEntity sceneEntity = JSONObject.parseObject(JSONObject.toJSONString(result),SceneEntity.class);
|
|
|
+ BrandEntity brandEntity = brandService.generateDefaultLiveRoom(sceneEntity);
|
|
|
if(ObjectUtils.isEmpty(brandEntity)){
|
|
|
return Result.failure("场景获取失败!");
|
|
|
}
|