|
@@ -0,0 +1,92 @@
|
|
|
+package com.xiaoan.web.backend;
|
|
|
+
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import com.xiaoan.common.constant.MsgCode;
|
|
|
+import com.xiaoan.common.model.PageDto;
|
|
|
+import com.xiaoan.common.util.ResultJson;
|
|
|
+import com.xiaoan.domain.backend.SceneProEntity;
|
|
|
+import com.xiaoan.domain.dto.request.SceneProRequest;
|
|
|
+import com.xiaoan.domain.dto.response.SceneResponse;
|
|
|
+import com.xiaoan.service.backend.SceneService;
|
|
|
+import com.xiaoan.service.backend.UserService;
|
|
|
+import com.xiaoan.web.aop.WebControllerLog;
|
|
|
+import com.xiaoan.web.shiro.JWTUtil;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by Hb_zzZ on 2020/3/2.
|
|
|
+ */
|
|
|
+
|
|
|
+@Api(tags = "PersonalCenterController", description = "后台个人中心")
|
|
|
+@RestController
|
|
|
+@RequestMapping("api/manage/center")
|
|
|
+@Transactional
|
|
|
+public class PersonalCenterController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SceneService sceneService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
+ @WebControllerLog(description = "个人中心-我的场景/搜索")
|
|
|
+ @ApiOperation("获取场景列表/搜索")
|
|
|
+ @PostMapping("scene/list")
|
|
|
+ public ResultJson findSceneList(@RequestBody SceneProRequest param){
|
|
|
+ List<Long> ids = null;
|
|
|
+ if(StringUtils.isNotEmpty(param.getSearchKey())){
|
|
|
+ ids = userService.findUserIdByRealName(param.getSearchKey());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SceneResponse> list = null;
|
|
|
+ List userRole = JWTUtil.getUserRole(getToken());
|
|
|
+ if (userRole.contains("admin")) {
|
|
|
+ list = sceneService.findAllBySearchKey(param, ids);
|
|
|
+ } else {
|
|
|
+ Long userId = JWTUtil.getUserId(getToken());
|
|
|
+ list = sceneService.findAllBySearchKey(param, ids, userId);
|
|
|
+ }
|
|
|
+
|
|
|
+ PageInfo<SceneResponse> pageInfo = new PageInfo<SceneResponse>(list);
|
|
|
+ return new ResultJson(MsgCode.SUCCESS_CODE, pageInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @WebControllerLog(description = "个人中心-我的场景/删除")
|
|
|
+ @ApiOperation("删除场景")
|
|
|
+ @PostMapping("scene/delete/{id}")
|
|
|
+ public ResultJson delete(@PathVariable Long id){
|
|
|
+ sceneService.deleteById(id);
|
|
|
+ return new ResultJson(MsgCode.SUCCESS_CODE, MsgCode.SUCCESS_MSG);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑场景是把web_site字段的url的showProMobile替换成editProMobile
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @WebControllerLog(description = "个人中心-我的场景/编辑")
|
|
|
+ @ApiOperation("编辑场景")
|
|
|
+ @PostMapping("scene/edit/{id}")
|
|
|
+ public ResultJson edit(@PathVariable Long id){
|
|
|
+ SceneProEntity proEntity = sceneService.findById(id);
|
|
|
+ String webSite = proEntity.getWebSite();
|
|
|
+ webSite = webSite.replace("showProMobile", "editProMobile");
|
|
|
+ return new ResultJson(MsgCode.SUCCESS_CODE, webSite);
|
|
|
+ }
|
|
|
+
|
|
|
+ @WebControllerLog(description = "个人中心-我的相机/搜索")
|
|
|
+ @ApiOperation("获取相机列表/搜索")
|
|
|
+ @PostMapping("camera/list")
|
|
|
+ public ResultJson cameraList(@RequestBody PageDto param){
|
|
|
+
|
|
|
+ return new ResultJson(MsgCode.SUCCESS_CODE, "");
|
|
|
+ }
|
|
|
+}
|