@author Hellohao @version 1.0 @date 2019-07-17 14:22
| 35 | * @date 2019-07-17 14:22 |
| 36 | */ |
| 37 | @Controller |
| 38 | @RequestMapping("/admin") |
| 39 | public class AdminController { |
| 40 | |
| 41 | @Autowired private ImgService imgService; |
| 42 | @Autowired private KeysService keysService; |
| 43 | @Autowired private UserServiceImpl userService; |
| 44 | @Autowired private ImgreviewService imgreviewService; |
| 45 | @Autowired private UploadConfigService uploadConfigService; |
| 46 | @Autowired private CodeService codeService; |
| 47 | @Autowired private AlbumService albumService; |
| 48 | @Autowired AlbumServiceImpl albumServiceI; |
| 49 | @Autowired private deleImages deleimages; |
| 50 | @Autowired private IRedisService iRedisService; |
| 51 | |
| 52 | @PostMapping(value = "/overviewData") |
| 53 | @ResponseBody |
| 54 | public Msg overviewData(@RequestParam(value = "data", defaultValue = "") String data) { |
| 55 | Msg msg = new Msg(); |
| 56 | Subject subject = SecurityUtils.getSubject(); |
| 57 | User user = (User) subject.getPrincipal(); |
| 58 | user = userService.getUsers(user); |
| 59 | JSONObject jsonObject = new JSONObject(); |
| 60 | UploadConfig uploadConfig = uploadConfigService.getUpdateConfig(); |
| 61 | Imgreview imgreview = imgreviewService.selectByPrimaryKey(1); |
| 62 | Imgreview isImgreviewOK = imgreviewService.selectByusing(1); |
| 63 | String ok = "false"; |
| 64 | jsonObject.put("myToken", user.getToken()); |
| 65 | jsonObject.put("myImgTotal", imgService.countimg(user.getId())); |
| 66 | jsonObject.put("myAlbumTitle", albumService.selectAlbumCount(user.getId())); |
| 67 | long memory = Long.valueOf(user.getMemory()); |
| 68 | Long usermemory = |
| 69 | imgService.getusermemory(user.getId()) == null |
| 70 | ? 0L |
| 71 | : imgService.getusermemory(user.getId()); |
| 72 | if (memory == 0) { |
| 73 | jsonObject.put("myMemory", "无容量"); |
| 74 | } else { |
| 75 | Double aDouble = |
| 76 | Double.valueOf(String.format("%.2f", (((double) usermemory / (double) memory) * 100))); |
| 77 | if (aDouble >= 999) { |
| 78 | jsonObject.put("myMemory", 999); |
| 79 | } else { |
| 80 | jsonObject.put("myMemory", aDouble); |
| 81 | } |
| 82 | } |
| 83 | jsonObject.put("myMemorySum", SetFiles.readableFileSize(memory)); |
| 84 | if (user.getLevel() > 1) { |
| 85 | ok = "true"; |
| 86 | jsonObject.put("imgTotal", imgService.counts(null)); |
| 87 | jsonObject.put("userTotal", userService.getUserTotal()); |
| 88 | jsonObject.put("ViolationImgTotal", imgreview.getCount()); |
| 89 | jsonObject.put("ViolationSwitch", isImgreviewOK == null ? 0 : isImgreviewOK.getId()); |
| 90 | jsonObject.put("VisitorUpload", uploadConfig.getIsupdate()); |
| 91 | jsonObject.put( |
| 92 | "VisitorMemory", |
| 93 | SetFiles.readableFileSize(Long.valueOf(uploadConfig.getVisitormemory()))); // 访客共大小 |
| 94 | if (uploadConfig.getIsupdate() != 1) { |
nothing calls this directly
no outgoing calls
no test coverage detected