mirror of
https://github.com/Hello-hao/Tbed.git
synced 2024-04-21 12:32:10 +00:00
重构版功能实现
This commit is contained in:
@@ -126,7 +126,7 @@
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.54</version>
|
||||
<version>1.2.76</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
|
||||
@@ -4,8 +4,7 @@ import cn.hellohao.config.SysName;
|
||||
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.AlbumServiceImpl;
|
||||
import cn.hellohao.service.impl.UserServiceImpl;
|
||||
import cn.hellohao.utils.*;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
@@ -18,7 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -38,7 +37,7 @@ public class AdminController {
|
||||
@Autowired
|
||||
private KeysService keysService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
private UserServiceImpl userService;
|
||||
@Autowired
|
||||
private UserServiceImpl userServiceImpl;
|
||||
@Autowired
|
||||
@@ -54,7 +53,7 @@ public class AdminController {
|
||||
@Autowired
|
||||
private AlbumService albumService;
|
||||
@Autowired
|
||||
AlbumServiceI albumServiceI;
|
||||
AlbumServiceImpl albumServiceI;
|
||||
|
||||
@PostMapping(value = "/overviewData") //new
|
||||
@ResponseBody
|
||||
@@ -72,7 +71,6 @@ public class AdminController {
|
||||
jsonObject.put("myToken","这个去掉");
|
||||
jsonObject.put("myImgTotal", imgService.countimg(user.getId())); //我的图片数
|
||||
jsonObject.put("myAlbumTitle", albumService.selectAlbumCount(user.getId()));//我的画廊数量
|
||||
jsonObject.put("myView360Title", "0");//我的全景视图
|
||||
//计算自己的百分比 已用量/分配量
|
||||
long memory = Long.valueOf(user.getMemory());//分配量
|
||||
Long usermemory = imgService.getusermemory(user.getId())==null?0L:imgService.getusermemory(user.getId());
|
||||
@@ -125,6 +123,44 @@ public class AdminController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/SpaceExpansion")//new kuorong
|
||||
@ResponseBody
|
||||
public Msg SpaceExpansion(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
final Msg msg = new Msg();
|
||||
final JSONObject jsonObject = JSONObject.parseObject(data);
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
User user = (User) subject.getPrincipal();
|
||||
user = userService.getUsers(user);
|
||||
if(user.getIsok()==0){
|
||||
msg.setCode("100403");
|
||||
msg.setInfo("你暂时无法使用此功能");
|
||||
return msg;
|
||||
}
|
||||
if(null==user){
|
||||
msg.setCode("100405");
|
||||
msg.setInfo("用户信息不存在");
|
||||
return msg;
|
||||
}else{
|
||||
long sizes = 0;
|
||||
Code code = codeService.selectCodekey(jsonObject.getString("code"));
|
||||
if(null==code){
|
||||
msg.setCode("100404");
|
||||
msg.setInfo("扩容码不存在,请重新填写");
|
||||
return msg;
|
||||
}
|
||||
Long userMemory = Long.valueOf(user.getMemory());
|
||||
sizes = Long.valueOf(code.getValue())+ userMemory;
|
||||
User newMemoryUser = new User();
|
||||
newMemoryUser.setMemory(Long.toString(sizes));
|
||||
newMemoryUser.setId(user.getId());
|
||||
userService.usersetmemory(newMemoryUser,jsonObject.getString("code"));
|
||||
msg.setInfo("你已成功扩容"+SetFiles.readableFileSize(sizes));
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/tosurvey")
|
||||
public String admin2(HttpSession session, Model model) {
|
||||
User u = (User) session.getAttribute("user");
|
||||
|
||||
@@ -9,18 +9,24 @@ import cn.hellohao.utils.StringUtils;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/admin/root")
|
||||
@@ -47,93 +53,127 @@ public class AdminRootController {
|
||||
@Value("${systemupdate}")
|
||||
private String systemupdate;
|
||||
|
||||
@RequestMapping(value = "/touser")
|
||||
public String touser() {
|
||||
return "admin/user";
|
||||
|
||||
|
||||
|
||||
@PostMapping(value = "/getUserList")//new selectusertable
|
||||
@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;
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = "tostorage")
|
||||
public String tostorage(HttpSession session, Model model, HttpServletRequest request) {
|
||||
User u = (User) session.getAttribute("user");
|
||||
Group group = GetCurrentSource.GetSource(u.getId());
|
||||
Keys key= keysService.selectKeys(group.getKeyid());
|
||||
//Boolean b = StringUtils.doNull(Sourcekey,key);
|
||||
Integer StorageType = 0;
|
||||
if(key.getStorageType()!=5){
|
||||
model.addAttribute("AccessKey", key.getAccessKey());
|
||||
model.addAttribute("AccessSecret", key.getAccessSecret());
|
||||
model.addAttribute("Endpoint", key.getEndpoint());
|
||||
model.addAttribute("Bucketname", key.getBucketname());
|
||||
model.addAttribute("RequestAddress", key.getRequestAddress());
|
||||
model.addAttribute("StorageType", key.getStorageType());
|
||||
if(key.getStorageType()==4){
|
||||
model.addAttribute("Endpoint2", key.getEndpoint());
|
||||
}else{
|
||||
model.addAttribute("Endpoint2", 0);
|
||||
|
||||
|
||||
@PostMapping(value = "/updateUserInfo")//new
|
||||
@ResponseBody
|
||||
public Msg updateUserInfo(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
final Msg msg = new Msg();
|
||||
try{
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
User u = (User) subject.getPrincipal();
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
Integer id = jsonObj.getInteger("id");
|
||||
String email = jsonObj.getString("email");
|
||||
Integer memory = jsonObj.getInteger("memory");
|
||||
Integer groupid = jsonObj.getInteger("groupid");
|
||||
Integer isok = jsonObj.getInteger("isok");
|
||||
final User user = new User();
|
||||
final User user2 = new User();
|
||||
user2.setId(id);
|
||||
User userInfo = userService.getUsers(user2);
|
||||
user.setId(id);
|
||||
user.setEmail(email);
|
||||
user.setMemory(Integer.toString(memory*1024*1024));
|
||||
user.setGroupid(groupid);
|
||||
if(userInfo.getLevel()==1){
|
||||
user.setIsok(isok==1?1:-1);
|
||||
}
|
||||
}else{
|
||||
model.addAttribute("StorageType", 5);
|
||||
model.addAttribute("Endpoint2", 0);
|
||||
userService.changeUser(user);
|
||||
msg.setInfo("修改成功");
|
||||
}catch (Exception e){
|
||||
msg.setCode("500");
|
||||
msg.setInfo("修改失败");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "admin/storageconfig";
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/getkey")
|
||||
|
||||
@PostMapping("/disableUser")//new
|
||||
@ResponseBody
|
||||
public String getkey(Integer storageType) {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
Keys key = keysService.selectKeys(storageType);
|
||||
jsonArray.add(key);
|
||||
return jsonArray.toString();
|
||||
public Msg disableUser(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
try {
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
JSONArray userIdList = jsonObj.getJSONArray("arr");
|
||||
for (int i = 0; i < userIdList.size(); i++) {
|
||||
User u = new User();
|
||||
u.setId(userIdList.getInteger(i));
|
||||
User u2 = userService.getUsers(u);
|
||||
if(u2.getLevel()==1){
|
||||
User user = new User();
|
||||
user.setId(userIdList.getInteger(i));
|
||||
user.setIsok(-1);
|
||||
userService.changeUser(user);
|
||||
}
|
||||
|
||||
}
|
||||
msg.setInfo("所选用户已被禁用");
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
msg.setInfo("系统错误");
|
||||
msg.setCode("500");
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/getkeyourceype")
|
||||
@PostMapping("/deleUser")//new
|
||||
@ResponseBody
|
||||
public Integer getkeyourceype(HttpSession session) {
|
||||
User u = (User) session.getAttribute("user");
|
||||
Group group = GetCurrentSource.GetSource(u.getId());
|
||||
Keys key = keysService.selectKeys(group.getKeyid());
|
||||
Integer ret = 0;
|
||||
|
||||
|
||||
return ret;
|
||||
public Msg deleuser(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
try {
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
JSONArray userIdList = jsonObj.getJSONArray("arr");
|
||||
boolean b = false;
|
||||
for (int i = 0; i < userIdList.size(); i++) {
|
||||
User u = new User();
|
||||
u.setId(userIdList.getInteger(i));
|
||||
User user = userService.getUsers(u);
|
||||
if(user.getLevel()==1){
|
||||
userService.deleuser(userIdList.getInteger(i));
|
||||
}else{
|
||||
b = true;
|
||||
}
|
||||
}
|
||||
if(b && userIdList.size()==1){
|
||||
msg.setInfo("管理员账户不可删除");
|
||||
}else {
|
||||
msg.setInfo("用户已删除成功");
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
msg.setInfo("系统错误");
|
||||
msg.setCode("500");
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/updatekey")
|
||||
@ResponseBody
|
||||
public String updatekey(Keys key) {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
Config config = new Config();
|
||||
config.setSourcekey(key.getStorageType());
|
||||
Integer val = configService.setSourceype(config);
|
||||
Integer ret = -2;
|
||||
if(key.getStorageType()==1){
|
||||
ret =nOSImageupload.Initialize(key);
|
||||
}else if (key.getStorageType()==2){
|
||||
ret = OSSImageupload.Initialize(key);
|
||||
}else if(key.getStorageType()==3 ){
|
||||
ret = USSImageupload.Initialize(key);
|
||||
}else if(key.getStorageType()==4){
|
||||
ret = KODOImageupload.Initialize(key);
|
||||
}else if(key.getStorageType()==6){
|
||||
ret = COSImageupload.Initialize(key);
|
||||
}else if(key.getStorageType()==7){
|
||||
ret = FTPImageupload.Initialize(key);
|
||||
}else if(key.getStorageType()==8){
|
||||
ret = UFileImageupload.Initialize(key);
|
||||
}
|
||||
else{
|
||||
Print.Normal("为获取到存储参数,或者使用存储源是本地的。");
|
||||
}
|
||||
if(ret>0){
|
||||
ret = keysService.updateKey(key);
|
||||
}
|
||||
//-1 对象存储有参数为空,初始化失败
|
||||
//0,保存失败
|
||||
//1 正确
|
||||
jsonArray.add(ret);
|
||||
return jsonArray.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/deleuser")
|
||||
@ResponseBody
|
||||
|
||||
@@ -2,14 +2,12 @@ package cn.hellohao.controller;
|
||||
|
||||
import cn.hellohao.pojo.*;
|
||||
import cn.hellohao.service.*;
|
||||
import cn.hellohao.service.impl.AlbumServiceI;
|
||||
import cn.hellohao.service.impl.ImgAndAlbumServiceImpl;
|
||||
import cn.hellohao.utils.GetCurrentSource;
|
||||
import cn.hellohao.utils.Print;
|
||||
import cn.hellohao.service.impl.AlbumServiceImpl;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -29,7 +27,7 @@ import java.util.*;
|
||||
@Controller
|
||||
public class AlbumController {
|
||||
@Autowired
|
||||
AlbumServiceI albumServiceI;
|
||||
AlbumServiceImpl albumServiceImpl;
|
||||
@Autowired
|
||||
private ConfigService configService;
|
||||
@Autowired
|
||||
@@ -60,7 +58,7 @@ public class AlbumController {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Album> albums = null;
|
||||
try {
|
||||
albums = albumServiceI.selectAlbumURLList(album);
|
||||
albums = albumServiceImpl.selectAlbumURLList(album);
|
||||
PageInfo<Album> rolePageInfo = new PageInfo<>(albums);
|
||||
map.put("code", 200);
|
||||
map.put("info", "");
|
||||
@@ -86,13 +84,13 @@ public class AlbumController {
|
||||
JSONArray albumkeyList = jsonObject.getJSONArray("albumkeyList");
|
||||
for (int i = 0; i < albumkeyList.size(); i++) {
|
||||
if(subject.hasRole("admin")){
|
||||
albumServiceI.deleteAlbum(albumkeyList.getString(i));
|
||||
albumServiceImpl.deleteAlbum(albumkeyList.getString(i));
|
||||
}else{
|
||||
Album album = new Album();
|
||||
album.setAlbumkey(albumkeyList.getString(i));
|
||||
final Album alb = albumServiceI.selectAlbum(album);
|
||||
final Album alb = albumServiceImpl.selectAlbum(album);
|
||||
if(alb.getUserid()==user.getId()){
|
||||
albumServiceI.deleteAlbum(albumkeyList.getString(i));
|
||||
albumServiceImpl.deleteAlbum(albumkeyList.getString(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,21 +104,45 @@ public class AlbumController {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/SaveForAlbum")
|
||||
@PostMapping("/getAlbumImgList") //new
|
||||
@ResponseBody
|
||||
public Msg SaveForAlbum(HttpSession session,@RequestParam("imgarr[]") String[] imgarr, @RequestParam("aboutarr[]") String[] aboutarr,
|
||||
String albumtitle, String password){
|
||||
public Msg getAlbumImgList(@RequestParam("data") String data) {
|
||||
Msg msg = new Msg();
|
||||
User u = (User) session.getAttribute("user");
|
||||
String uuid = "TOALBUM"+ UUID.randomUUID().toString().replace("-", "").toLowerCase().substring(0,5)+"N";
|
||||
Integer ret =0;
|
||||
Integer temp = 0;
|
||||
Integer temp2 = 0;
|
||||
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
|
||||
for (int i = 0; i < imgarr.length; i++) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||
JSONArray jsonArray = jsonObject.getJSONArray("imguidlist");
|
||||
JSONArray json = albumServiceImpl.getAlbumList(jsonArray);
|
||||
msg.setData(json);
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/SaveForAlbum")//new
|
||||
@ResponseBody
|
||||
public Msg SaveForAlbum(@RequestParam(value = "data", defaultValue = "") String data){
|
||||
data = StringEscapeUtils.unescapeHtml4(data);
|
||||
Msg msg = new Msg();
|
||||
try {
|
||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||
String albumtitle = jsonObject.getString("albumtitle");
|
||||
String password = jsonObject.getString("password");
|
||||
JSONArray jsonArray = JSONArray.parseArray(jsonObject.getString("albumlist"));
|
||||
if(null!=password){
|
||||
password = password.replace(" ", "");
|
||||
if(password.replace(" ", "").equals("") || password.length()<3){
|
||||
msg.setCode("110403");
|
||||
msg.setInfo("密码长度不得小于三位有效字符");
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
if(albumtitle==null || jsonArray.size()==0){
|
||||
msg.setCode("110404");
|
||||
msg.setInfo("标题和图片参数不能为空");
|
||||
return msg;
|
||||
}
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
User u = (User) subject.getPrincipal();
|
||||
String uuid = "TOALBUM"+ UUID.randomUUID().toString().replace("-", "").toLowerCase().substring(0,5)+"N";
|
||||
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Album album = new Album();
|
||||
ImgAndAlbum imgAndAlbum = new ImgAndAlbum();
|
||||
album.setAlbumtitle(albumtitle);
|
||||
album.setCreatedate(df.format(new Date()));
|
||||
album.setPassword(password);
|
||||
@@ -130,48 +152,42 @@ public class AlbumController {
|
||||
}else{
|
||||
album.setUserid(u.getId());
|
||||
}
|
||||
String imgurl = "";
|
||||
Integer sourcekey = 0;
|
||||
UploadConfig updateConfig = uploadConfigService.getUpdateConfig();
|
||||
if(updateConfig.getUrltype()==2){
|
||||
imgurl = imgarr[i];
|
||||
}else{
|
||||
if (u == null) {
|
||||
//sourcekey = GetCurrentSource.GetSource(null);
|
||||
imgurl="tourist/"+imgarr[i];
|
||||
} else {
|
||||
//sourcekey = GetCurrentSource.GetSource(u.getId());
|
||||
imgurl=u.getUsername()+"/"+imgarr[i];
|
||||
}
|
||||
albumServiceImpl.addAlbum(album);
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject img = jsonArray.getJSONObject(i);
|
||||
ImgAndAlbum imgAndAlbum = new ImgAndAlbum();
|
||||
imgAndAlbum.setImgname(img.getString("imgurl"));
|
||||
imgAndAlbum.setAlbumkey(uuid);
|
||||
imgAndAlbum.setNotes(img.getString("notes"));
|
||||
albumServiceImpl.addAlbumForImgAndAlbumMapper(imgAndAlbum);
|
||||
}
|
||||
|
||||
imgAndAlbum.setImgname(imgarr[i]);
|
||||
imgAndAlbum.setAlbumkey(uuid);
|
||||
imgAndAlbum.setNotes(aboutarr[i]);
|
||||
if(temp==0){
|
||||
temp2 = albumServiceI.addAlbum(album);
|
||||
temp = 1;
|
||||
}
|
||||
if(temp2>0){
|
||||
ret = albumServiceI.addAlbumForImgAndAlbumMapper(imgAndAlbum);
|
||||
}
|
||||
}
|
||||
if(ret>0){
|
||||
final JSONObject json = new JSONObject();
|
||||
json.put("url",uuid);
|
||||
json.put("title",albumtitle);
|
||||
json.put("password",password);
|
||||
msg.setCode("200");
|
||||
msg.setInfo("成功创建画廊链接:");
|
||||
msg.setData(configService.getSourceype().getDomain()+"/"+uuid);
|
||||
}else{
|
||||
msg.setInfo("成功创建画廊链接");
|
||||
msg.setData(json);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
msg.setCode("500");
|
||||
msg.setInfo("创建画廊链接失败:");
|
||||
msg.setInfo("创建画廊链接失败");
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping("/TOALBUM{key}N")
|
||||
public String selectByFy(@PathVariable("key") String key, Model model) {
|
||||
Album album = new Album();
|
||||
album.setAlbumkey("TOALBUM"+key+"N");
|
||||
Album a = albumServiceI.selectAlbum(album);
|
||||
Album a = albumServiceImpl.selectAlbum(album);
|
||||
Config config = configService.getSourceype();
|
||||
model.addAttribute("webname",config.getWebname());
|
||||
model.addAttribute("domain",config.getDomain());
|
||||
@@ -196,7 +212,7 @@ public class AlbumController {
|
||||
Msg msg = new Msg();
|
||||
Album album = new Album();
|
||||
album.setAlbumkey(albumkey);
|
||||
Album a = albumServiceI.selectAlbum(album);
|
||||
Album a = albumServiceImpl.selectAlbum(album);
|
||||
if(a==null){
|
||||
msg.setCode("404");
|
||||
msg.setInfo("画廊地址不存在");
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package cn.hellohao.controller;
|
||||
|
||||
import cn.hellohao.pojo.Msg;
|
||||
import org.springframework.boot.web.servlet.error.ErrorController;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@@ -28,6 +30,15 @@ class MainsiteErrorController implements ErrorController {
|
||||
}
|
||||
|
||||
}
|
||||
//认证失败
|
||||
@RequestMapping("/jurisError")
|
||||
@ResponseBody
|
||||
public Msg jurisError(HttpServletRequest request){
|
||||
Msg msg = new Msg();
|
||||
msg.setCode("4031");
|
||||
msg.setInfo("Authentication request failed");
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -2,12 +2,14 @@ package cn.hellohao.controller;
|
||||
|
||||
import cn.hellohao.pojo.Group;
|
||||
import cn.hellohao.pojo.Keys;
|
||||
import cn.hellohao.pojo.Msg;
|
||||
import cn.hellohao.pojo.User;
|
||||
import cn.hellohao.service.GroupService;
|
||||
import cn.hellohao.service.KeysService;
|
||||
import cn.hellohao.service.UserService;
|
||||
import cn.hellohao.utils.StringUtils;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -39,83 +41,73 @@ public class GroupController {
|
||||
private UserService userService;
|
||||
|
||||
|
||||
@RequestMapping(value = "/group")
|
||||
public String togroup() {
|
||||
return "admin/group";
|
||||
}
|
||||
@RequestMapping(value = "/addgroup")
|
||||
public String addgroup() {
|
||||
return "admin/addgroup";
|
||||
}
|
||||
//获取code列表
|
||||
@RequestMapping(value = "/getgrouplist")
|
||||
|
||||
@PostMapping("/getGrouplistForUsers") //new
|
||||
@ResponseBody
|
||||
public Map<String, Object> getgrouplist(HttpSession session, @RequestParam(required = false, defaultValue = "1") int page,
|
||||
@RequestParam(required = false) int limit) {
|
||||
User u = (User) session.getAttribute("user");
|
||||
PageHelper.startPage(page, limit);
|
||||
public Msg getGrouplistForUsers() {
|
||||
Msg msg = new Msg();
|
||||
//只获取用户组type为0的,只有是0的才是未分配用户组的,才能给指定用户设置
|
||||
List<Group> groupList = groupService.grouplist(0);
|
||||
msg.setData(groupList);
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
//获取code列表
|
||||
@PostMapping(value = "/getGroupList")//new
|
||||
@ResponseBody
|
||||
public Map<String, Object> getgrouplist(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
Integer pageNum = jsonObj.getInteger("pageNum");
|
||||
Integer pageSize = jsonObj.getInteger("pageSize");
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<Group> group = null;
|
||||
if (u.getLevel() > 1) {
|
||||
group = groupService.grouplist();
|
||||
try {
|
||||
group = groupService.grouplist(null);
|
||||
PageInfo<Group> rolePageInfo = new PageInfo<>(group);
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("code", 0);
|
||||
map.put("msg", "");
|
||||
map.put("code", 200);
|
||||
map.put("info", "");
|
||||
map.put("count", rolePageInfo.getTotal());
|
||||
map.put("data", rolePageInfo.getList());
|
||||
return map;
|
||||
} else {
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
map.put("code", 500);
|
||||
map.put("info", "获取数据异常");
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/addisgroup")
|
||||
|
||||
@PostMapping(value = "/addGroup")//new
|
||||
@ResponseBody
|
||||
public Integer addisgroup(Group group) {
|
||||
Integer ret = 0;
|
||||
ret = groupService.addgroup(group);
|
||||
return ret;
|
||||
public Msg addisgroup(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||
Group group = new Group();
|
||||
group.setGroupname(jsonObject.getString("groupname"));
|
||||
group.setKeyid(jsonObject.getInteger("keyid"));
|
||||
group.setUsertype(jsonObject.getInteger("usertype"));
|
||||
group.setCompress(jsonObject.getBoolean("compress")?1:0);
|
||||
Msg msg = groupService.addgroup(group);
|
||||
return msg;
|
||||
}
|
||||
@RequestMapping(value = "/delegroup")
|
||||
|
||||
|
||||
@PostMapping(value = "/deleGroup")//new
|
||||
@ResponseBody
|
||||
public Integer delegroup(Integer id) {
|
||||
Integer ret = -1;
|
||||
public Msg delegroup(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||
Integer id = jsonObject.getInteger("id");
|
||||
Msg msg = null;
|
||||
if(id!=1){
|
||||
ret = groupService.delegroup(id);
|
||||
msg = groupService.delegroup(id);
|
||||
return msg;
|
||||
}else{
|
||||
final Msg msg2 = new Msg();
|
||||
msg2.setCode("500");
|
||||
msg2.setInfo("默认群组不可删除");
|
||||
return msg2;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@PostMapping("/getgrouplist")
|
||||
@ResponseBody
|
||||
public String getgrouplist() {
|
||||
List<Group> li = groupService.grouplist();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for (Group group : li) {
|
||||
jsonArray.add(group);
|
||||
}
|
||||
return jsonArray.toString();
|
||||
}
|
||||
|
||||
@PostMapping("/updateuser")
|
||||
@ResponseBody
|
||||
public Integer updateuser(User user) {
|
||||
Integer ret = userService.change(user);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@PostMapping("/updategroup")
|
||||
@ResponseBody
|
||||
public Integer updategroup(Group group) {
|
||||
Integer ret = groupService.setgroup(group);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@RequestMapping("/modifygroup")
|
||||
public String modifygroup(Model model, Integer id) {
|
||||
Group group = groupService.idgrouplist(id);
|
||||
model.addAttribute("group",group);
|
||||
return "admin/setgroup";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -172,6 +172,7 @@ public class IndexController {
|
||||
User u = (User) subject.getPrincipal();
|
||||
final JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("RoleLevel",u.getLevel()==2?"admin":"user");
|
||||
jsonObject.put("userName",u.getUsername());
|
||||
msg.setCode("200");
|
||||
msg.setData(jsonObject);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -186,6 +186,7 @@ public class UserController {
|
||||
msg.setInfo("登录成功");
|
||||
jsonObject.put("token",token);
|
||||
jsonObject.put("RoleLevel",user.getLevel()==2?"admin":"user");
|
||||
jsonObject.put("userName",user.getUsername());
|
||||
msg.setData(jsonObject);
|
||||
return msg;
|
||||
} catch (UnknownAccountException e) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.List;
|
||||
*/
|
||||
@Mapper
|
||||
public interface GroupMapper {
|
||||
List<Group> grouplist();
|
||||
List<Group> grouplist(Integer usertype);
|
||||
Group idgrouplist(@Param("id") Integer id);
|
||||
Integer addgroup(Group group);
|
||||
Integer GetCountFroUserType(@Param("usertype") Integer usertype);
|
||||
|
||||
@@ -25,12 +25,13 @@ public interface UserMapper {
|
||||
//修改资料
|
||||
Integer change(User user);
|
||||
|
||||
Integer changeUser(User user);
|
||||
//检查用户名是否重复
|
||||
Integer checkUsername(@Param("username") String username);
|
||||
|
||||
Integer getUserTotal();
|
||||
|
||||
List<User> getuserlist(User user);
|
||||
List<User> getuserlist(String username);
|
||||
|
||||
//刪除用戶
|
||||
Integer deleuser(@Param("id") Integer id);
|
||||
|
||||
@@ -3,20 +3,29 @@ package cn.hellohao.pojo;
|
||||
/**
|
||||
* @author Hellohao
|
||||
* @version 1.0
|
||||
* @date 2019/8/19 15:59
|
||||
* @date 2021/10/26 18:59
|
||||
*/
|
||||
public class Group {
|
||||
private Integer id;
|
||||
private String groupname;
|
||||
private Integer keyid;
|
||||
private Integer usertype;
|
||||
private Integer compress;
|
||||
private Integer storageType;
|
||||
private String keyname;
|
||||
|
||||
|
||||
public Group() {
|
||||
}
|
||||
|
||||
public Group(Integer id, String groupname, Integer keyid) {
|
||||
public Group(Integer id, String groupname, Integer keyid, Integer usertype, Integer compress, Integer storageType, String keyname) {
|
||||
this.id = id;
|
||||
this.groupname = groupname;
|
||||
this.keyid = keyid;
|
||||
this.usertype = usertype;
|
||||
this.compress = compress;
|
||||
this.storageType = storageType;
|
||||
this.keyname = keyname;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
@@ -42,4 +51,36 @@ public class Group {
|
||||
public void setKeyid(Integer keyid) {
|
||||
this.keyid = keyid;
|
||||
}
|
||||
|
||||
public Integer getUsertype() {
|
||||
return usertype;
|
||||
}
|
||||
|
||||
public void setUsertype(Integer usertype) {
|
||||
this.usertype = usertype;
|
||||
}
|
||||
|
||||
public Integer getCompress() {
|
||||
return compress;
|
||||
}
|
||||
|
||||
public void setCompress(Integer compress) {
|
||||
this.compress = compress;
|
||||
}
|
||||
|
||||
public Integer getStorageType() {
|
||||
return storageType;
|
||||
}
|
||||
|
||||
public void setStorageType(Integer storageType) {
|
||||
this.storageType = storageType;
|
||||
}
|
||||
|
||||
public String getKeyname() {
|
||||
return keyname;
|
||||
}
|
||||
|
||||
public void setKeyname(String keyname) {
|
||||
this.keyname = keyname;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,22 +2,22 @@ package cn.hellohao.pojo;
|
||||
|
||||
public class UploadConfig {
|
||||
private String suffix;
|
||||
private Integer filesizetourists;
|
||||
private Integer filesizeuser;
|
||||
private String filesizetourists;
|
||||
private String filesizeuser;
|
||||
private Integer imgcounttourists;
|
||||
private Integer imgcountuser;
|
||||
private Integer urltype;
|
||||
private Integer isupdate;
|
||||
private Integer api;
|
||||
private Integer visitormemory;
|
||||
private Integer usermemory;
|
||||
private String visitormemory;
|
||||
private String usermemory;
|
||||
private String blacklist;
|
||||
|
||||
|
||||
public UploadConfig() {
|
||||
}
|
||||
|
||||
public UploadConfig(String suffix, Integer filesizetourists, Integer filesizeuser, Integer imgcounttourists, Integer imgcountuser, Integer urltype, Integer isupdate, Integer api, Integer visitormemory, Integer usermemory, String blacklist) {
|
||||
public UploadConfig(String suffix, String filesizetourists, String filesizeuser, Integer imgcounttourists, Integer imgcountuser, Integer urltype, Integer isupdate, Integer api, String visitormemory, String usermemory, String blacklist) {
|
||||
this.suffix = suffix;
|
||||
this.filesizetourists = filesizetourists;
|
||||
this.filesizeuser = filesizeuser;
|
||||
@@ -39,19 +39,19 @@ public class UploadConfig {
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
public Integer getFilesizetourists() {
|
||||
public String getFilesizetourists() {
|
||||
return filesizetourists;
|
||||
}
|
||||
|
||||
public void setFilesizetourists(Integer filesizetourists) {
|
||||
public void setFilesizetourists(String filesizetourists) {
|
||||
this.filesizetourists = filesizetourists;
|
||||
}
|
||||
|
||||
public Integer getFilesizeuser() {
|
||||
public String getFilesizeuser() {
|
||||
return filesizeuser;
|
||||
}
|
||||
|
||||
public void setFilesizeuser(Integer filesizeuser) {
|
||||
public void setFilesizeuser(String filesizeuser) {
|
||||
this.filesizeuser = filesizeuser;
|
||||
}
|
||||
|
||||
@@ -95,19 +95,19 @@ public class UploadConfig {
|
||||
this.api = api;
|
||||
}
|
||||
|
||||
public Integer getVisitormemory() {
|
||||
public String getVisitormemory() {
|
||||
return visitormemory;
|
||||
}
|
||||
|
||||
public void setVisitormemory(Integer visitormemory) {
|
||||
public void setVisitormemory(String visitormemory) {
|
||||
this.visitormemory = visitormemory;
|
||||
}
|
||||
|
||||
public Integer getUsermemory() {
|
||||
public String getUsermemory() {
|
||||
return usermemory;
|
||||
}
|
||||
|
||||
public void setUsermemory(Integer usermemory) {
|
||||
public void setUsermemory(String usermemory) {
|
||||
this.usermemory = usermemory;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public class User {
|
||||
private Integer level;
|
||||
private String uid;
|
||||
private Integer isok;
|
||||
private Integer memory;
|
||||
private String memory;
|
||||
private Integer groupid;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class User {
|
||||
super();
|
||||
}
|
||||
|
||||
public User(Integer id, String username, String password, String email, String birthder, Integer level, String uid, Integer isok, Integer memory, Integer groupid) {
|
||||
public User(Integer id, String username, String password, String email, String birthder, Integer level, String uid, Integer isok, String memory, Integer groupid) {
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
@@ -101,11 +101,11 @@ public class User {
|
||||
this.isok = isok;
|
||||
}
|
||||
|
||||
public Integer getMemory() {
|
||||
public String getMemory() {
|
||||
return memory;
|
||||
}
|
||||
|
||||
public void setMemory(Integer memory) {
|
||||
public void setMemory(String memory) {
|
||||
this.memory = memory;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.hellohao.service;
|
||||
|
||||
import cn.hellohao.pojo.Album;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -14,6 +15,8 @@ import java.util.List;
|
||||
@Service
|
||||
public interface AlbumService {
|
||||
|
||||
JSONArray getAlbumList(JSONArray array);
|
||||
|
||||
Album selectAlbum(Album album);
|
||||
|
||||
Integer addAlbum(Album album);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.hellohao.service;
|
||||
|
||||
import cn.hellohao.pojo.Group;
|
||||
import cn.hellohao.pojo.Msg;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -12,11 +13,11 @@ import java.util.List;
|
||||
*/
|
||||
@Service
|
||||
public interface GroupService {
|
||||
List<Group> grouplist();
|
||||
List<Group> grouplist(Integer usertype);
|
||||
Group idgrouplist(Integer id);
|
||||
Integer addgroup(Group group);
|
||||
Msg addgroup(Group group);
|
||||
Integer GetCountFroUserType(Integer usertype);
|
||||
Integer delegroup(Integer id);
|
||||
Msg delegroup(Integer id);
|
||||
Integer setgroup(Group group);
|
||||
Group getGroupFroUserType(Integer usertype);
|
||||
}
|
||||
|
||||
@@ -24,12 +24,14 @@ public interface UserService {
|
||||
//修改资料
|
||||
Integer change(User user);
|
||||
|
||||
Integer changeUser(User user);
|
||||
|
||||
//检查用户名是否重复
|
||||
Integer checkUsername(String username);
|
||||
|
||||
Integer getUserTotal();
|
||||
|
||||
List<User> getuserlist(User user);
|
||||
List<User> getuserlist(String username);
|
||||
|
||||
Integer deleuser(Integer id);
|
||||
|
||||
|
||||
+18
-1
@@ -3,11 +3,14 @@ package cn.hellohao.service.impl;
|
||||
import cn.hellohao.dao.AlbumMapper;
|
||||
import cn.hellohao.dao.ConfigMapper;
|
||||
import cn.hellohao.dao.ImgAndAlbumMapper;
|
||||
import cn.hellohao.dao.ImgMapper;
|
||||
import cn.hellohao.exception.CodeException;
|
||||
import cn.hellohao.pojo.Album;
|
||||
import cn.hellohao.pojo.Images;
|
||||
import cn.hellohao.pojo.ImgAndAlbum;
|
||||
import cn.hellohao.pojo.Msg;
|
||||
import cn.hellohao.service.AlbumService;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -22,13 +25,27 @@ import java.util.UUID;
|
||||
* @date 2019-12-18 22:30
|
||||
*/
|
||||
@Service
|
||||
public class AlbumServiceI implements AlbumService {
|
||||
public class AlbumServiceImpl implements AlbumService {
|
||||
@Autowired
|
||||
AlbumMapper albumMapper;
|
||||
@Autowired
|
||||
ImgAndAlbumMapper andAlbumMapper;
|
||||
@Autowired
|
||||
ConfigMapper configMapper;
|
||||
@Autowired
|
||||
ImgMapper imgMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public JSONArray getAlbumList(JSONArray array) {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
Images images = new Images();
|
||||
images.setImguid(array.getString(i));
|
||||
jsonArray.add(imgMapper.selectimg(images).get(0));
|
||||
}
|
||||
return jsonArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Album selectAlbum(Album album) {
|
||||
@@ -4,6 +4,7 @@ import cn.hellohao.dao.GroupMapper;
|
||||
import cn.hellohao.dao.UserMapper;
|
||||
import cn.hellohao.exception.CodeException;
|
||||
import cn.hellohao.pojo.Group;
|
||||
import cn.hellohao.pojo.Msg;
|
||||
import cn.hellohao.pojo.User;
|
||||
import cn.hellohao.service.GroupService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -25,8 +26,8 @@ public class GroupServiceImpl implements GroupService {
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Override
|
||||
public List<Group> grouplist() {
|
||||
return groupMapper.grouplist();
|
||||
public List<Group> grouplist(Integer usertype) {
|
||||
return groupMapper.grouplist(usertype);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -35,8 +36,22 @@ public class GroupServiceImpl implements GroupService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer addgroup(Group group) {
|
||||
return groupMapper.addgroup(group);
|
||||
public Msg addgroup(Group group) {
|
||||
final Msg msg = new Msg();
|
||||
if(group.getUsertype()!=0){
|
||||
Integer count = groupMapper.GetCountFroUserType(group.getUsertype());
|
||||
if(count==0){
|
||||
groupMapper.addgroup(group);
|
||||
msg.setInfo("添加成功");
|
||||
}else{
|
||||
msg.setCode("110401");
|
||||
msg.setInfo("分配的该用户组已存在。请勿重复分配。");
|
||||
}
|
||||
}else{
|
||||
groupMapper.addgroup(group);
|
||||
msg.setInfo("添加成功");
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,7 +61,8 @@ public class GroupServiceImpl implements GroupService {
|
||||
|
||||
@Override
|
||||
@Transactional//默认遇到throw new RuntimeException(“…”);会回滚
|
||||
public Integer delegroup(Integer id) {
|
||||
public Msg delegroup(Integer id) {
|
||||
Msg msg = new Msg();
|
||||
Integer ret = 0;
|
||||
ret = groupMapper.delegroup(id);
|
||||
if(ret>0){
|
||||
@@ -57,11 +73,13 @@ public class GroupServiceImpl implements GroupService {
|
||||
u.setUid(user.getUid());
|
||||
userMapper.change(u);
|
||||
}
|
||||
|
||||
msg.setInfo("删除成功");
|
||||
}else{
|
||||
msg.setCode("500");
|
||||
msg.setInfo("删除成功");
|
||||
throw new CodeException("用户之没有设置成功。");
|
||||
}
|
||||
return ret;
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -49,6 +49,12 @@ public class UserServiceImpl implements UserService {
|
||||
return userMapper.change(user);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Integer changeUser(User user) {
|
||||
return userMapper.changeUser(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer checkUsername(String username) {
|
||||
// TODO Auto-generated method stub
|
||||
@@ -77,8 +83,8 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> getuserlist(User user) {
|
||||
return userMapper.getuserlist(user);
|
||||
public List<User> getuserlist(String username) {
|
||||
return userMapper.getuserlist(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,15 +117,29 @@ public class UserServiceImpl implements UserService {
|
||||
return userMapper.getuserlistforgroupid(groupid);
|
||||
}
|
||||
|
||||
// @Transactional//默认遇到throw new RuntimeException(“…”);会回滚
|
||||
// public Integer usersetmemory(User user,String codestring) {
|
||||
// Integer ret = userMapper.setmemory(user);
|
||||
// if(ret<=0){
|
||||
// Print.warning("用户空间没有设置成功。回滚");
|
||||
// throw new CodeException("用户之没有设置成功。");
|
||||
// }else{
|
||||
// ret = codeMapper.deleteCode(codestring);
|
||||
// }
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
@Transactional//默认遇到throw new RuntimeException(“…”);会回滚
|
||||
public Integer usersetmemory(User user,String codestring) {
|
||||
Integer ret = userMapper.setmemory(user);
|
||||
public Integer usersetmemory(User user, String codestring) {
|
||||
Integer ret = userMapper.changeUser(user);
|
||||
if(ret<=0){
|
||||
Print.warning("用户空间没有设置成功。回滚");
|
||||
throw new CodeException("用户之没有设置成功。");
|
||||
throw new CodeException("用户没有设置成功。");
|
||||
}else{
|
||||
ret = codeMapper.deleteCode(codestring);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,13 +3,27 @@
|
||||
<mapper namespace="cn.hellohao.dao.GroupMapper">
|
||||
|
||||
|
||||
<select id="grouplist" resultType="cn.hellohao.pojo.Group">
|
||||
<!-- <select id="grouplist" resultType="cn.hellohao.pojo.Group">-->
|
||||
<!-- SELECT-->
|
||||
<!-- *-->
|
||||
<!-- FROM-->
|
||||
<!-- `group`-->
|
||||
<!-- </select>-->
|
||||
|
||||
|
||||
<select id="grouplist" resultType="cn.hellohao.pojo.Group" parameterType="integer">
|
||||
SELECT
|
||||
*
|
||||
g.id,g.groupname,g.keyid,g.usertype,g.compress,k.storageType,k.keyname
|
||||
FROM
|
||||
`group`
|
||||
`group` as g LEFT JOIN `keys` as k on g.keyid = k.id
|
||||
where 1=1
|
||||
<if test="usertype!=null">
|
||||
and g.usertype=#{usertype}
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
<select id="idgrouplist" parameterType="integer" resultType="cn.hellohao.pojo.Group">
|
||||
SELECT
|
||||
*
|
||||
|
||||
@@ -133,6 +133,34 @@
|
||||
where uid=#{uid}
|
||||
</update>
|
||||
|
||||
<update id="changeUser" parameterType="cn.hellohao.pojo.User">
|
||||
UPDATE `user`
|
||||
<set>
|
||||
<if test="email != null">
|
||||
`email` = #{email},
|
||||
</if>
|
||||
<if test="username != null">
|
||||
`username` = #{username},
|
||||
</if>
|
||||
<if test="password != null">
|
||||
`password` = #{password},
|
||||
</if>
|
||||
<if test="memory != null">
|
||||
`memory` = #{memory},
|
||||
</if>
|
||||
<if test="groupid != null">
|
||||
`groupid` = #{groupid},
|
||||
</if>
|
||||
<if test="isok != null">
|
||||
`isok` = #{isok},
|
||||
</if>
|
||||
<if test="uid != null">
|
||||
`uid` = #{uid},
|
||||
</if>
|
||||
</set>
|
||||
where id=#{id}
|
||||
</update>
|
||||
|
||||
<select id="checkUsername" parameterType="string" resultType="integer">
|
||||
SELECT count(username) FROM `user` where username=#{username}
|
||||
</select>
|
||||
@@ -141,8 +169,9 @@
|
||||
<select id="getUserTotal" resultType="integer">
|
||||
SELECT count(*) FROM `user`
|
||||
</select>
|
||||
|
||||
<!-- 获取用户的详细信息 -->
|
||||
<select id="getuserlist" resultType="cn.hellohao.pojo.User">
|
||||
<select id="getuserlist" resultType="cn.hellohao.pojo.User" parameterType="string">
|
||||
SELECT
|
||||
id,
|
||||
username,
|
||||
@@ -155,6 +184,7 @@
|
||||
ceil((memory/1024/1024)) as memory,
|
||||
groupid,
|
||||
(select groupname from `group` where id = groupid) as groupname,
|
||||
token
|
||||
FROM
|
||||
user
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user