OverallController.java 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package com.fdkankan.manage.controller;
  2. import cn.dev33.satoken.stp.StpUtil;
  3. import com.alibaba.fastjson.JSONArray;
  4. import com.alibaba.fastjson.JSONObject;
  5. import com.fdkankan.manage.common.PageInfo;
  6. import com.fdkankan.manage.common.ResultData;
  7. import com.fdkankan.manage.httpClient.client.OverallClient;
  8. import com.fdkankan.manage.httpClient.vo.OverallParam;
  9. import com.fdkankan.manage.httpClient.vo.OverallVo;
  10. import org.apache.commons.lang3.StringUtils;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.web.bind.annotation.PostMapping;
  13. import org.springframework.web.bind.annotation.RequestBody;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RestController;
  16. import javax.annotation.Resource;
  17. import java.util.ArrayList;
  18. import java.util.List;
  19. /**
  20. * 全景看看作品
  21. */
  22. @RestController
  23. @RequestMapping("/service/manage/overall")
  24. public class OverallController {
  25. private static String appId ="BDA385EC848C1A425F746869011C8D23";
  26. private static String key ="appId";
  27. @Autowired
  28. OverallClient overallClient;
  29. @PostMapping("/list")
  30. public ResultData list(@RequestBody OverallParam param){
  31. OverallVo vo = overallClient.list(param,appId,key);
  32. if(vo.getCode() != 0 ){
  33. return ResultData.error(vo.getCode(),vo.getMsg());
  34. }
  35. Object data = vo.getData();
  36. JSONObject dataObj = JSONObject.parseObject(JSONObject.toJSONString(data));
  37. JSONArray array = dataObj.getJSONArray("list");
  38. for (Object o : array) {
  39. JSONObject obj = (JSONObject) o;
  40. obj.put("thumb",obj.getString("share"));
  41. obj.put("sceneCodes",obj.getString("id"));
  42. String name = obj.getString("name");
  43. if(StringUtils.isBlank(name)){
  44. name = "无标题";
  45. }
  46. obj.put("name",name);
  47. }
  48. List<Object> list = new ArrayList<>(array);
  49. long total = dataObj.getLongValue("total");
  50. return ResultData.ok(new PageInfo<>(param.getPageNum(), param.getPageSize(), total, list));
  51. }
  52. @PostMapping("/delete")
  53. public ResultData delete(@RequestBody OverallParam param){
  54. OverallVo vo = overallClient.delete(param.getId(),appId,key);
  55. if(vo.getCode() != 0 ){
  56. return ResultData.error(vo.getCode(),vo.getMsg());
  57. }
  58. return ResultData.ok(vo.getData());
  59. }
  60. }