mirror of
https://github.com/Hello-hao/Tbed.git
synced 2024-04-21 12:32:10 +00:00
2021-03-15更新
This commit is contained in:
@@ -3,6 +3,7 @@ package cn.hellohao.controller;
|
||||
import cn.hellohao.pojo.*;
|
||||
import cn.hellohao.pojo.vo.PageResultBean;
|
||||
import cn.hellohao.service.*;
|
||||
import cn.hellohao.service.impl.AlbumServiceI;
|
||||
import cn.hellohao.service.impl.ImgServiceImpl;
|
||||
import cn.hellohao.service.impl.UserServiceImpl;
|
||||
import cn.hellohao.utils.*;
|
||||
@@ -45,10 +46,16 @@ public class AdminController {
|
||||
private UploadConfigService uploadConfigService;
|
||||
@Autowired
|
||||
private CodeService codeService;
|
||||
|
||||
@Autowired
|
||||
private ImgAndAlbumService imgAndAlbumService;
|
||||
@Autowired
|
||||
private AlbumService albumService;
|
||||
@Autowired
|
||||
AlbumServiceI albumServiceI;
|
||||
|
||||
@RequestMapping(value = "/goadmin")
|
||||
public String goadmin1(HttpSession session, Model model, HttpServletRequest request) {
|
||||
Config config = configService.getSourceype();
|
||||
User user = (User) session.getAttribute("user");
|
||||
UploadConfig uploadConfig = uploadConfigService.getUpdateConfig();
|
||||
Integer usermemory = imgService.getusermemory(user.getId());
|
||||
@@ -65,7 +72,7 @@ public class AdminController {
|
||||
model.addAttribute("levels", user.getLevel());
|
||||
model.addAttribute("username", user.getUsername());
|
||||
model.addAttribute("api", uploadConfig.getApi());
|
||||
|
||||
model.addAttribute("config", config);
|
||||
model.addAttribute("memory",u.getMemory());//单位M
|
||||
if(usermemory==null){
|
||||
model.addAttribute("usermemory", 0);//单位M
|
||||
@@ -102,7 +109,6 @@ public class AdminController {
|
||||
model.addAttribute("sysetmname",sysetmname);
|
||||
model.addAttribute("isarch", isarch);
|
||||
model.addAttribute("jdk", jdk);
|
||||
|
||||
//空间大小
|
||||
UploadConfig uploadConfig = uploadConfigService.getUpdateConfig();
|
||||
Integer usermemory = imgService.getusermemory(u.getId());
|
||||
@@ -125,7 +131,6 @@ public class AdminController {
|
||||
model.addAttribute("usermemory", 0);//单位M
|
||||
}else{
|
||||
float d = (float) (Math.round((usermemory/1024.0F) * 100.0) / 100.0);
|
||||
//Print.Normal();
|
||||
model.addAttribute("usermemory", d);//单位M
|
||||
}
|
||||
}
|
||||
@@ -147,8 +152,9 @@ public class AdminController {
|
||||
if(uploadConfig.getIsupdate()!=1){
|
||||
jsonObject.put("VisitorUpload", 0);//是否禁用了游客上传
|
||||
}else{
|
||||
Integer temp = imgService.getusermemory(0);
|
||||
jsonObject.put("VisitorUpload", uploadConfig.getIsupdate());//是否禁用了游客上传
|
||||
jsonObject.put("UsedSize", (imgService.getusermemory(0)/1024));//访客已用大小
|
||||
jsonObject.put("UsedSize", (temp == null ? 0 : temp/1024));//访客已用大小
|
||||
jsonObject.put("VisitorMemory", uploadConfig.getVisitormemory());//访客共大小
|
||||
}
|
||||
return jsonObject.toString();
|
||||
@@ -177,9 +183,13 @@ public class AdminController {
|
||||
if (u.getLevel() > 1) {
|
||||
if (selecttype == 1) {
|
||||
images = imgService.selectimg(img);
|
||||
} else {
|
||||
} else if(selecttype == 2) {
|
||||
img.setUserid(u.getId());
|
||||
images = imgService.selectimg(img);
|
||||
}else{
|
||||
img.setUserid(u.getId());
|
||||
img.setSelecttype(3);
|
||||
images = imgService.selectimg(img);
|
||||
}
|
||||
} else {
|
||||
img.setUserid(u.getId());
|
||||
@@ -189,8 +199,6 @@ public class AdminController {
|
||||
return new PageResultBean<>(rolePageInfo.getTotal(), rolePageInfo.getList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/selectusertable")
|
||||
@ResponseBody
|
||||
public Map<String, Object> selectByFy12(HttpSession session, @RequestParam(required = false, defaultValue = "1") int page,
|
||||
@@ -216,19 +224,12 @@ public class AdminController {
|
||||
|
||||
@PostMapping("/deleimg")
|
||||
@ResponseBody
|
||||
public String deleimg(HttpSession session, Integer id, Integer sourcekey) {
|
||||
public String deleimg(HttpSession session, Integer id, Integer sourcekey,String imgname) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
User u = (User) session.getAttribute("user");
|
||||
Images images = imgService.selectByPrimaryKey(id);
|
||||
Keys key = keysService.selectKeys(sourcekey);
|
||||
Integer Sourcekey = GetCurrentSource.GetSource(u.getId());
|
||||
Boolean b =false;
|
||||
if(Sourcekey==5){
|
||||
b =true;
|
||||
}else{
|
||||
b = StringUtils.doNull(Sourcekey,key);//判断对象是否有空值
|
||||
}
|
||||
if(b){
|
||||
ImgServiceImpl de = new ImgServiceImpl();
|
||||
if (key.getStorageType() == 1) {
|
||||
de.delect(key, images.getImgname());
|
||||
@@ -244,57 +245,53 @@ public class AdminController {
|
||||
de.delectCOS(key, images.getImgname());
|
||||
}else if (key.getStorageType() == 7) {
|
||||
de.delectFTP(key, images.getImgname());
|
||||
}else if (key.getStorageType() == 8) {
|
||||
de.delectUFile(key, images.getImgname());
|
||||
}else {
|
||||
System.err.println("未获取到对象存储参数,删除失败。");
|
||||
}
|
||||
Integer ret = imgService.deleimg(id);
|
||||
if(ret>0){ imgAndAlbumService.deleteImgAndAlbum(imgname);}
|
||||
Integer count = 0;
|
||||
if (ret > 0) {
|
||||
jsonObject.put("usercount", imgService.countimg(u.getId()));
|
||||
jsonObject.put("count", imgService.counts(null));
|
||||
count = 1;
|
||||
imgAndAlbumService.deleteImgAndAlbum(imgname);//关联表删除关于这张照片的所有记录
|
||||
} else {
|
||||
count = 0;
|
||||
}
|
||||
jsonObject.put("val", count);
|
||||
}else{
|
||||
jsonObject.put("val", 0);
|
||||
}
|
||||
return jsonObject.toString();
|
||||
}
|
||||
|
||||
@PostMapping("/deleallimg")
|
||||
@ResponseBody
|
||||
public String deleallimg(HttpSession session, @RequestParam("ids[]") Integer[] ids) {
|
||||
public String deleallimg(HttpSession session, @RequestParam("ids[]") Integer[] ids,@RequestParam("sources[]") Integer[] sources,
|
||||
@RequestParam("imgnames[]") String[] imgnames) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
Integer v = 0;
|
||||
ImgServiceImpl de = new ImgServiceImpl();
|
||||
User u = (User) session.getAttribute("user");
|
||||
Integer Sourcekey = GetCurrentSource.GetSource(u.getId());
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
Images images = imgService.selectByPrimaryKey(ids[i]);
|
||||
Keys key = keysService.selectKeys(images.getSource());
|
||||
Boolean b =false;
|
||||
if(Sourcekey==5){
|
||||
b =true;
|
||||
}else{
|
||||
b = StringUtils.doNull(Sourcekey,key);//判断对象是否有空值
|
||||
}
|
||||
if(b){
|
||||
Keys key = keysService.selectKeys(sources[i]);
|
||||
if (key.getStorageType() == 1) {
|
||||
de.delect(key, images.getImgname());
|
||||
de.delect(key, imgnames[i]);
|
||||
} else if (key.getStorageType() == 2) {
|
||||
de.delectOSS(key, images.getImgname());
|
||||
de.delectOSS(key, imgnames[i]);
|
||||
} else if (key.getStorageType() == 3) {
|
||||
de.delectUSS(key, images.getImgname());
|
||||
de.delectUSS(key, imgnames[i]);
|
||||
} else if (key.getStorageType() == 4) {
|
||||
de.delectKODO(key, images.getImgname());
|
||||
de.delectKODO(key, imgnames[i]);
|
||||
} else if (key.getStorageType() == 5) {
|
||||
LocUpdateImg.deleteLOCImg(images.getImgname());
|
||||
LocUpdateImg.deleteLOCImg(imgnames[i]);
|
||||
}else if (key.getStorageType() == 6) {
|
||||
de.delectCOS(key, images.getImgname());
|
||||
de.delectCOS(key, imgnames[i]);
|
||||
}else if (key.getStorageType() == 7) {
|
||||
de.delectFTP(key, images.getImgname());
|
||||
de.delectFTP(key, imgnames[i]);
|
||||
}else if (key.getStorageType() == 8) {
|
||||
de.delectUFile(key, imgnames[i]);
|
||||
}else {
|
||||
System.err.println("未获取到对象存储参数,删除失败。");
|
||||
}
|
||||
@@ -303,10 +300,8 @@ public class AdminController {
|
||||
v = 0;
|
||||
} else {
|
||||
v = 1;
|
||||
imgAndAlbumService.deleteImgAndAlbum(imgnames[i]);//关联表删除关于这张照片的所有记录
|
||||
}
|
||||
}else {
|
||||
v = 0;
|
||||
}
|
||||
}
|
||||
jsonObject.put("val", v);
|
||||
jsonObject.put("usercount", imgService.countimg(u.getId()));
|
||||
@@ -344,7 +339,6 @@ public class AdminController {
|
||||
session.removeAttribute("user");
|
||||
session.invalidate();
|
||||
}
|
||||
// -1 用户名重复
|
||||
return jsonArray.toString();
|
||||
}
|
||||
//进入api
|
||||
@@ -359,7 +353,6 @@ public class AdminController {
|
||||
return "admin/api";
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/kuorong")
|
||||
@ResponseBody
|
||||
public String kuorong(HttpSession session, String codestring) {
|
||||
@@ -397,4 +390,61 @@ public class AdminController {
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/albumlist")
|
||||
public String albumlist(HttpSession session, Model model) {
|
||||
Config config = configService.getSourceype();
|
||||
User u = (User) session.getAttribute("user");
|
||||
model.addAttribute("config", config);
|
||||
model.addAttribute("level", u.getLevel());
|
||||
model.addAttribute("email", u.getEmail());
|
||||
model.addAttribute("loginid", 100);
|
||||
|
||||
return "admin/albumlist";
|
||||
}
|
||||
|
||||
@PostMapping("/getAlbumURLList")
|
||||
@ResponseBody
|
||||
public Map<String, Object> getAlbumURLList (HttpSession session,@RequestParam(required = false, defaultValue = "1") int page,
|
||||
@RequestParam(required = false) int limit,Album album){
|
||||
User u = (User) session.getAttribute("user");
|
||||
PageHelper.startPage(page, limit);
|
||||
List<Album> list = null;
|
||||
if (u.getLevel() == 2) {
|
||||
album.setUserid(null);
|
||||
list = albumServiceI.selectAlbumURLList(album);
|
||||
PageInfo<Album> rolePageInfo = new PageInfo<>(list);
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("code", 0);
|
||||
map.put("msg", "");
|
||||
map.put("count", rolePageInfo.getTotal());
|
||||
map.put("data", rolePageInfo.getList());
|
||||
return map;
|
||||
} else {
|
||||
album.setUserid(u.getId());
|
||||
list = albumServiceI.selectAlbumURLList(album);
|
||||
PageInfo<Album> rolePageInfo = new PageInfo<>(list);
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("code", 0);
|
||||
map.put("msg", "");
|
||||
map.put("count", rolePageInfo.getTotal());
|
||||
map.put("data", rolePageInfo.getList());
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/delAlbum")
|
||||
@ResponseBody
|
||||
public Integer delAlbum(String albumkey){
|
||||
Integer ret = albumServiceI.delete(albumkey);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@RequestMapping("/delAlbumAll")
|
||||
@ResponseBody
|
||||
public Integer delAlbumAll( @RequestParam("albumkeyArr[]") String[] albumkeyArr ){
|
||||
Integer ret = albumServiceI.deleteAll(albumkeyArr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user