mirror of
https://github.com/Hello-hao/Tbed.git
synced 2024-04-21 12:32:10 +00:00
:art:完善部分新功能
This commit is contained in:
@@ -19,9 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/admin/root")
|
||||
@@ -42,30 +40,35 @@ public class AdminRootController {
|
||||
private ImgService imgService;
|
||||
@Autowired
|
||||
private ImgreviewService imgreviewService;
|
||||
@Autowired
|
||||
private AppClientService appClientService;
|
||||
|
||||
|
||||
@PostMapping(value = "/getUserList")//new
|
||||
@PostMapping(value = "/getUserList")
|
||||
@ResponseBody
|
||||
public Map<String, Object> getUserList(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
Integer pageNum = jsonObj.getInteger("pageNum");
|
||||
Integer pageSize = jsonObj.getInteger("pageSize");
|
||||
String queryText = jsonObj.getString("queryText");
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<User> users = userService.getuserlist(queryText);
|
||||
PageInfo<User> rolePageInfo = new PageInfo<>(users);
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("count", rolePageInfo.getTotal());
|
||||
map.put("users", rolePageInfo.getList());
|
||||
return map;
|
||||
public Msg getUserList(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
try{
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
Integer pageNum = jsonObj.getInteger("pageNum");
|
||||
Integer pageSize = jsonObj.getInteger("pageSize");
|
||||
String queryText = jsonObj.getString("queryText");
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<User> users = userService.getuserlist(queryText);
|
||||
PageInfo<User> rolePageInfo = new PageInfo<>(users);
|
||||
msg.setData(rolePageInfo);
|
||||
}catch (Exception e){
|
||||
msg.setCode("500");
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/updateUserInfo")//new
|
||||
@PostMapping(value = "/updateUserInfo")
|
||||
@ResponseBody
|
||||
public Msg updateUserInfo(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
final Msg msg = new Msg();
|
||||
try{
|
||||
try {
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
User u = (User) subject.getPrincipal();
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
@@ -74,7 +77,7 @@ public class AdminRootController {
|
||||
Long memory = jsonObj.getLong("memory");
|
||||
Integer groupid = jsonObj.getInteger("groupid");
|
||||
Integer isok = jsonObj.getInteger("isok");
|
||||
if(memory<0 || memory>1048576L){
|
||||
if (memory < 0 || memory > 1048576L) {
|
||||
msg.setCode("500");
|
||||
msg.setInfo("容量不得超过1048576");
|
||||
return msg;
|
||||
@@ -85,14 +88,14 @@ public class AdminRootController {
|
||||
User userInfo = userService.getUsers(user2);
|
||||
user.setId(id);
|
||||
user.setEmail(email);
|
||||
user.setMemory(Long.toString(memory*1024*1024));
|
||||
user.setMemory(Long.toString(memory * 1024 * 1024));
|
||||
user.setGroupid(groupid);
|
||||
if(userInfo.getLevel()==1){
|
||||
user.setIsok(isok==1?1:-1);
|
||||
if (userInfo.getLevel() == 1) {
|
||||
user.setIsok(isok == 1 ? 1 : -1);
|
||||
}
|
||||
userService.changeUser(user);
|
||||
msg.setInfo("修改成功");
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
msg.setCode("500");
|
||||
msg.setInfo("修改失败");
|
||||
e.printStackTrace();
|
||||
@@ -101,7 +104,7 @@ public class AdminRootController {
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/disableUser")//new
|
||||
@PostMapping("/disableUser")
|
||||
@ResponseBody
|
||||
public Msg disableUser(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
@@ -112,7 +115,7 @@ public class AdminRootController {
|
||||
User u = new User();
|
||||
u.setId(userIdList.getInteger(i));
|
||||
User u2 = userService.getUsers(u);
|
||||
if(u2.getLevel()==1){
|
||||
if (u2.getLevel() == 1) {
|
||||
User user = new User();
|
||||
user.setId(userIdList.getInteger(i));
|
||||
user.setIsok(-1);
|
||||
@@ -121,7 +124,7 @@ public class AdminRootController {
|
||||
|
||||
}
|
||||
msg.setInfo("所选用户已被禁用");
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
msg.setInfo("系统错误");
|
||||
msg.setCode("500");
|
||||
@@ -129,7 +132,7 @@ public class AdminRootController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/deleUser")//new
|
||||
@PostMapping("/deleUser")
|
||||
@ResponseBody
|
||||
public Msg deleuser(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
@@ -141,18 +144,18 @@ public class AdminRootController {
|
||||
User u = new User();
|
||||
u.setId(userIdList.getInteger(i));
|
||||
User user = userService.getUsers(u);
|
||||
if(user.getLevel()==1){
|
||||
if (user.getLevel() == 1) {
|
||||
userService.deleuser(userIdList.getInteger(i));
|
||||
}else{
|
||||
} else {
|
||||
b = true;
|
||||
}
|
||||
}
|
||||
if(b && userIdList.size()==1){
|
||||
if (b && userIdList.size() == 1) {
|
||||
msg.setInfo("管理员账户不可删除");
|
||||
}else {
|
||||
} else {
|
||||
msg.setInfo("用户已删除成功");
|
||||
}
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
msg.setInfo("系统错误");
|
||||
msg.setCode("500");
|
||||
@@ -160,7 +163,7 @@ public class AdminRootController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/getKeysList") //new
|
||||
@PostMapping("/getKeysList")
|
||||
@ResponseBody
|
||||
public Msg getKeysList() {
|
||||
Msg msg = new Msg();
|
||||
@@ -169,7 +172,7 @@ public class AdminRootController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/LoadInfo")//new
|
||||
@PostMapping("/LoadInfo")
|
||||
@ResponseBody
|
||||
public Msg LoadInfo(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
@@ -177,34 +180,34 @@ public class AdminRootController {
|
||||
JSONObject jsonData = JSONObject.parseObject(data);
|
||||
Integer keyId = jsonData.getInteger("keyId");
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("id",keyId);
|
||||
jsonObject.put("id", keyId);
|
||||
Keys key = keysService.selectKeys(keyId);
|
||||
Integer ret = 0;
|
||||
if(key.getStorageType()==1){
|
||||
if (key.getStorageType() == 1) {
|
||||
ret = NOSImageupload.Initialize(key);
|
||||
}else if (key.getStorageType()==2){
|
||||
} else if (key.getStorageType() == 2) {
|
||||
ret = OSSImageupload.Initialize(key);
|
||||
}else if(key.getStorageType()==3){
|
||||
} else if (key.getStorageType() == 3) {
|
||||
ret = USSImageupload.Initialize(key);
|
||||
}else if(key.getStorageType()==4){
|
||||
} else if (key.getStorageType() == 4) {
|
||||
ret = KODOImageupload.Initialize(key);
|
||||
}else if(key.getStorageType()==6){
|
||||
} else if (key.getStorageType() == 6) {
|
||||
ret = COSImageupload.Initialize(key);
|
||||
}else if(key.getStorageType()==7){
|
||||
} else if (key.getStorageType() == 7) {
|
||||
ret = FTPImageupload.Initialize(key);
|
||||
}else if(key.getStorageType()==8){
|
||||
} else if (key.getStorageType() == 8) {
|
||||
ret = UFileImageupload.Initialize(key);
|
||||
}
|
||||
Long l = imgService.getsourcememory(keyId);
|
||||
jsonObject.put("isok",ret);
|
||||
jsonObject.put("storagetype",key.getStorageType());
|
||||
if(l==null){
|
||||
jsonObject.put("usedCapacity",0);
|
||||
}else{
|
||||
jsonObject.put("isok", ret);
|
||||
jsonObject.put("storagetype", key.getStorageType());
|
||||
if (l == null) {
|
||||
jsonObject.put("usedCapacity", 0);
|
||||
} else {
|
||||
jsonObject.put("usedCapacity", SetFiles.readableFileSize(l));
|
||||
}
|
||||
msg.setData(jsonObject);
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
msg.setCode("500");
|
||||
}
|
||||
@@ -212,7 +215,7 @@ public class AdminRootController {
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/updateStorage") //new
|
||||
@PostMapping("/updateStorage")
|
||||
@ResponseBody
|
||||
public Msg updateStorage(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
@@ -237,7 +240,7 @@ public class AdminRootController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/getStorageById")//new
|
||||
@PostMapping("/getStorageById")
|
||||
@ResponseBody
|
||||
public Msg getselectkey(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
@@ -248,7 +251,7 @@ public class AdminRootController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/getSettingConfig") //new
|
||||
@PostMapping("/getSettingConfig")
|
||||
@ResponseBody
|
||||
public Msg getSettingConfig(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
final Msg msg = new Msg();
|
||||
@@ -259,13 +262,15 @@ public class AdminRootController {
|
||||
UploadConfig uploadConfig = uploadConfigService.getUpdateConfig();
|
||||
Config config = configService.getSourceype();
|
||||
SysConfig sysConfig = sysConfigService.getstate();
|
||||
uploadConfig.setUsermemory(Long.toString(Long.valueOf(uploadConfig.getUsermemory())/1024/1024));
|
||||
uploadConfig.setVisitormemory(Long.toString(Long.valueOf(uploadConfig.getVisitormemory())/1024/1024));
|
||||
uploadConfig.setFilesizetourists(Long.toString(Long.valueOf(uploadConfig.getFilesizetourists())/1024/1024));
|
||||
uploadConfig.setFilesizeuser(Long.toString(Long.valueOf(uploadConfig.getFilesizeuser())/1024/1024));
|
||||
jsonObject.put("uploadConfig",uploadConfig);
|
||||
jsonObject.put("config",config);
|
||||
jsonObject.put("sysConfig",sysConfig);
|
||||
AppClient appClientData = appClientService.getAppClientData("app");
|
||||
uploadConfig.setUsermemory(Long.toString(Long.valueOf(uploadConfig.getUsermemory()) / 1024 / 1024));
|
||||
uploadConfig.setVisitormemory(Long.toString(Long.valueOf(uploadConfig.getVisitormemory()) / 1024 / 1024));
|
||||
uploadConfig.setFilesizetourists(Long.toString(Long.valueOf(uploadConfig.getFilesizetourists()) / 1024 / 1024));
|
||||
uploadConfig.setFilesizeuser(Long.toString(Long.valueOf(uploadConfig.getFilesizeuser()) / 1024 / 1024));
|
||||
jsonObject.put("uploadConfig", uploadConfig);
|
||||
jsonObject.put("config", config);
|
||||
jsonObject.put("sysConfig", sysConfig);
|
||||
jsonObject.put("appClient", appClientData);
|
||||
msg.setData(jsonObject);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -276,36 +281,44 @@ public class AdminRootController {
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/updateConfig")//new
|
||||
@PostMapping("/updateConfig")
|
||||
@ResponseBody
|
||||
public Msg updateConfig(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
try {
|
||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||
UploadConfig uploadConfig = JSON.toJavaObject((JSON) jsonObject.get("uploadConfig"),UploadConfig.class);
|
||||
String vm = uploadConfig.getVisitormemory();
|
||||
if((Long.valueOf(vm)<-1) || Long.valueOf(vm) > 104857600 || Long.valueOf(uploadConfig.getFilesizetourists())<0 || Long.valueOf(uploadConfig.getFilesizetourists()) > 5120
|
||||
|| Long.valueOf(uploadConfig.getUsermemory())<0 || Long.valueOf(uploadConfig.getUsermemory())>1048576
|
||||
|| Long.valueOf(uploadConfig.getFilesizeuser())<0 || Long.valueOf(uploadConfig.getFilesizeuser())>5120 ){
|
||||
UploadConfig uploadConfig = JSON.toJavaObject((JSON) jsonObject.get("uploadConfig"), UploadConfig.class);
|
||||
String vm = uploadConfig.getVisitormemory();
|
||||
if ((Long.valueOf(vm) < -1) || Long.valueOf(vm) > 104857600 || Long.valueOf(uploadConfig.getFilesizetourists()) < 0 || Long.valueOf(uploadConfig.getFilesizetourists()) > 5120
|
||||
|| Long.valueOf(uploadConfig.getUsermemory()) < 0 || Long.valueOf(uploadConfig.getUsermemory()) > 1048576
|
||||
|| Long.valueOf(uploadConfig.getFilesizeuser()) < 0 || Long.valueOf(uploadConfig.getFilesizeuser()) > 5120) {
|
||||
msg.setInfo("你输入的值不正确");
|
||||
msg.setCode("500");
|
||||
return msg;
|
||||
return msg;
|
||||
}
|
||||
Config config = JSON.toJavaObject((JSON) jsonObject.get("config"),Config.class);
|
||||
SysConfig sysConfig = JSON.toJavaObject((JSON) jsonObject.get("sysConfig"),SysConfig.class);
|
||||
if(Integer.valueOf(vm)==-1){
|
||||
Config config = JSON.toJavaObject((JSON) jsonObject.get("config"), Config.class);
|
||||
SysConfig sysConfig = JSON.toJavaObject((JSON) jsonObject.get("sysConfig"), SysConfig.class);
|
||||
AppClient appClient = JSON.toJavaObject((JSON) jsonObject.get("appClient"), AppClient.class);
|
||||
if (Integer.valueOf(vm) == -1) {
|
||||
uploadConfig.setVisitormemory("-1");
|
||||
}else{
|
||||
uploadConfig.setVisitormemory(Long.toString(Long.valueOf(uploadConfig.getVisitormemory())*1024*1024));
|
||||
} else {
|
||||
uploadConfig.setVisitormemory(Long.toString(Long.valueOf(uploadConfig.getVisitormemory()) * 1024 * 1024));
|
||||
}
|
||||
uploadConfig.setFilesizetourists(Long.toString(Long.valueOf(uploadConfig.getFilesizetourists())*1024*1024));
|
||||
uploadConfig.setUsermemory(Long.toString(Long.valueOf(uploadConfig.getUsermemory())*1024*1024));
|
||||
uploadConfig.setFilesizeuser(Long.toString(Long.valueOf(uploadConfig.getFilesizeuser())*1024*1024));
|
||||
uploadConfig.setFilesizetourists(Long.toString(Long.valueOf(uploadConfig.getFilesizetourists()) * 1024 * 1024));
|
||||
uploadConfig.setUsermemory(Long.toString(Long.valueOf(uploadConfig.getUsermemory()) * 1024 * 1024));
|
||||
uploadConfig.setFilesizeuser(Long.toString(Long.valueOf(uploadConfig.getFilesizeuser()) * 1024 * 1024));
|
||||
uploadConfigService.setUpdateConfig(uploadConfig);
|
||||
configService.setSourceype(config);
|
||||
sysConfigService.setstate(sysConfig);
|
||||
if (!appClient.getIsuse().equals("on")) {
|
||||
appClient.setIsuse("off");
|
||||
}
|
||||
if (!appClient.getAppupdate().equals("on")) {
|
||||
appClient.setAppupdate("off");
|
||||
}
|
||||
appClientService.editAppClientData(appClient);
|
||||
msg.setInfo("配置保存成功");
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
msg.setInfo("操作出现异常");
|
||||
msg.setCode("500");
|
||||
@@ -314,7 +327,7 @@ public class AdminRootController {
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/getOrderConfig")//new
|
||||
@PostMapping(value = "/getOrderConfig")
|
||||
@ResponseBody
|
||||
public Msg emailconfig() {
|
||||
final Msg msg = new Msg();
|
||||
@@ -324,8 +337,8 @@ public class AdminRootController {
|
||||
final JSONObject jsonObject = new JSONObject();
|
||||
emailConfig = emailConfigService.getemail();
|
||||
imgreview = imgreviewService.selectByPrimaryKey(1);
|
||||
jsonObject.put("emailConfig",emailConfig);
|
||||
jsonObject.put("imgreview",imgreview);
|
||||
jsonObject.put("emailConfig", emailConfig);
|
||||
jsonObject.put("imgreview", imgreview);
|
||||
msg.setData(jsonObject);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -336,17 +349,17 @@ public class AdminRootController {
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/updateEmailConfig") //new
|
||||
@PostMapping("/updateEmailConfig")
|
||||
@ResponseBody
|
||||
public Msg updateemail(@RequestParam(value = "data", defaultValue = "") String data ) {
|
||||
public Msg updateemail(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
final Msg msg = new Msg();
|
||||
try {
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
EmailConfig emailConfig = JSON.toJavaObject(jsonObj,EmailConfig.class);
|
||||
if(null==emailConfig.getId() || null==emailConfig.getEmailname() || null==emailConfig.getEmailurl() || null==emailConfig.getEmails()
|
||||
|| null==emailConfig.getEmailkey() || null==emailConfig.getPort() || null==emailConfig.getUsing()
|
||||
|| emailConfig.getEmailname().equals("") || emailConfig.getEmailurl().equals("") || emailConfig.getEmails().equals("")
|
||||
|| emailConfig.getEmailkey().equals("") || emailConfig.getPort().equals("")){
|
||||
EmailConfig emailConfig = JSON.toJavaObject(jsonObj, EmailConfig.class);
|
||||
if (null == emailConfig.getId() || null == emailConfig.getEmailname() || null == emailConfig.getEmailurl() || null == emailConfig.getEmails()
|
||||
|| null == emailConfig.getEmailkey() || null == emailConfig.getPort() || null == emailConfig.getUsing()
|
||||
|| emailConfig.getEmailname().equals("") || emailConfig.getEmailurl().equals("") || emailConfig.getEmails().equals("")
|
||||
|| emailConfig.getEmailkey().equals("") || emailConfig.getPort().equals("")) {
|
||||
msg.setCode("110400");
|
||||
msg.setInfo("各参数不能为空");
|
||||
return msg;
|
||||
@@ -361,18 +374,18 @@ public class AdminRootController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/mailTest") //new
|
||||
@PostMapping("/mailTest")
|
||||
@ResponseBody
|
||||
public Msg mailTest(@RequestParam(value = "data", defaultValue = "") String data ) {
|
||||
public Msg mailTest(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
String tomail = jsonObj.getString("tomail");
|
||||
EmailConfig emailConfig = JSON.toJavaObject(jsonObj,EmailConfig.class);
|
||||
if(null==emailConfig.getEmails() || null==emailConfig.getEmailkey() || null==emailConfig.getEmailurl()
|
||||
|| null==emailConfig.getPort() || null==emailConfig.getEmailname() || null==tomail){
|
||||
EmailConfig emailConfig = JSON.toJavaObject(jsonObj, EmailConfig.class);
|
||||
if (null == emailConfig.getEmails() || null == emailConfig.getEmailkey() || null == emailConfig.getEmailurl()
|
||||
|| null == emailConfig.getPort() || null == emailConfig.getEmailname() || null == tomail) {
|
||||
msg.setCode("110400");
|
||||
msg.setInfo("邮箱配置参数不能为空");
|
||||
}else{
|
||||
} else {
|
||||
msg = NewSendEmail.sendTestEmail(emailConfig, tomail);
|
||||
}
|
||||
return msg;
|
||||
|
||||
Reference in New Issue
Block a user