重构版功能实现

This commit is contained in:
tiansh
2021-10-28 18:54:05 +08:00
parent 3a03c965e1
commit 551bb6c20a
64 changed files with 881 additions and 6794 deletions
@@ -50,7 +50,6 @@ public class SubjectFilter extends BasicHttpAuthenticationFilter {
return false;
}
}
//验证Token
String token = httpServletRequest.getHeader("Authorization");
JSONObject jsonObject = JWTUtil.checkToken(token);
if(!jsonObject.getBoolean("check")){
@@ -63,20 +62,14 @@ public class SubjectFilter extends BasicHttpAuthenticationFilter {
}else{
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
//判断shiro里是否存有用户信息,如果没有,就再存进去。
if(user==null){
// System.out.println("Token没过期,但是Shiro里的用户信息空了,重新执行登录");
//封装用户的登录数据(shiro认证的时候使用)
UsernamePasswordToken tokenOBJ = new UsernamePasswordToken(jsonObject.getString("email"),jsonObject.getString("password"));
//设置记住我
tokenOBJ.setRememberMe(true);
try {
//执行登录方法,如果没有异常,说明登录成功
subject.login(tokenOBJ);
SecurityUtils.getSubject().getSession().setTimeout(3600000);//一小时
} catch (Exception e) {
System.err.println("拦截器,登录失败,false");
//e.printStackTrace();
// System.err.println("拦截器,登录失败,false");
this.CODE = "403";
return false;
}
@@ -103,9 +96,7 @@ public class SubjectFilter extends BasicHttpAuthenticationFilter {
protected boolean onAccessDenied(ServletRequest request, ServletResponse response, Object mappedValue) {
String info = "未知错误";
try {
if(this.CODE.equals("405")){
info = "当前请求域名认证失败";
}else if(this.CODE.equals("406")){
if(this.CODE.equals("406")){
info = "前端域名配置不正确";
}else if(this.CODE.equals("403")){
info = "当前用户无权访问该请求";
@@ -20,30 +20,14 @@ import java.util.Map;
@Configuration
public class ShiroConfig {
//shiro过滤对象
@Bean//(name = "shiroFilterFactoryBean")
@Bean
public ShiroFilterFactoryBean shiroFilterFactoryBean(@Qualifier("defaultWebSecurityManager") DefaultWebSecurityManager defaultWebSecurityManager){
ShiroFilterFactoryBean bean = new ShiroFilterFactoryBean();
//设置安全管理器
bean.setSecurityManager(defaultWebSecurityManager);
Map<String, Filter> filters = bean.getFilters();
// Map<String,Filter> filter = new HashMap<>();
filters.put("JWT",new SubjectFilter());
bean.setFilters(filters);
//添加shiro内置过滤器
/*
* anon: 无需认证就可以访问
* authc: 必须认证了才可以访问
* user: 必须拥有 记住我 功能才能访问
* perms: 拥有对某个资源的权限才能访问
* roles: 拥有某个角色的权限才能访问
* */
Map<String,String> filterMap = new LinkedHashMap<>();
//放行页面
filterMap.put("/verifyCode","anon");
filterMap.put("/verifyCodeForRegister","anon");
filterMap.put("/verifyCodeForRetrieve","anon");
@@ -52,17 +36,13 @@ public class ShiroConfig {
filterMap.put("/ota/**","anon");
filterMap.put("/admin/root/**","roles[admin]");
filterMap.put("/**","JWT");
//认证失败的返回页面
bean.setLoginUrl("/jurisError");
//未授权页面
bean.setUnauthorizedUrl("/authError");
bean.setFilterChainDefinitionMap(filterMap);
return bean;
}
//安全对象
@Bean
public DefaultWebSecurityManager defaultWebSecurityManager(@Qualifier("userRealm") UserRealm userRealm){
@@ -80,12 +60,5 @@ public class ShiroConfig {
}
//配置禁用session
// @Bean
// public StatelessDefaultSubjectFactory statelessDefaultSubjectFactory(){
// StatelessDefaultSubjectFactory statelessDefaultSubjectFactory = new StatelessDefaultSubjectFactory();
// return statelessDefaultSubjectFactory;
// }
}
@@ -1,14 +0,0 @@
package cn.hellohao.auth.shiro;
/**
* @author Hellohao
* @version 1.0
* @date 2021/6/15 17:30
*/
//public class StatelessDefaultSubjectFactory extends DefaultWebSecurityManager {
// //不创建Session
// public Subject createSubject(SubjectContext context){
// context.setSessionCreationEnabled(false);
// return super.createSubject(context);
// }
//}
@@ -28,38 +28,28 @@ public class UserRealm extends AuthorizingRealm {
//授权
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
// System.out.println("..///执行了授权方法");
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
//拿到当前登录的对象
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
ArrayList<String> roleList = new ArrayList();
if(user.getLevel()==2){
//赋予管理员权限
// info.addRole("admin");
roleList.add("admin");
roleList.add("user");
// info.addStringPermission("user:one");
}else{
// info.addRole("user");
roleList.add("user");
}
info.addRoles(roleList);
return info;
}
//认证(登录)
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken tokenOBJ) throws AuthenticationException {
// System.out.println("执行了认证方法");
UsernamePasswordToken userToken = null;
userToken = (UsernamePasswordToken)tokenOBJ;
User user = new User();
user.setEmail(userToken.getUsername());
User u = userService.getUsers(user);
//用户名认证
if(u==null){
//返回null 就是异常:UnknownAccountException
return null;
}
//密码认证(防止泄露,不需要我们做)
@@ -1,7 +1,7 @@
package cn.hellohao.config;
/**
* @author Tiansh
* @author Hellohao
* @version 1.0
* @date 2020/5/15 9:20
*/
@@ -13,10 +13,6 @@ public class WebImgConfigurer implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
String filePath = File.separator + "HellohaoData" + File.separator;
//和页面有关的静态目录都放在项目的static目录下
//registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
//上传的图片在D盘下的OTA目录下,访问路径如:http://localhost:8081/OTA/d3cf0281-bb7f-40e0-ab77-406db95ccf2c.jpg
//其中OTA表示访问的前缀。"file:D:/OTA/"是文件真实的存储路径
registry.addResourceHandler("/ota/**").addResourceLocations("file:"+filePath);
}
@@ -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.AlbumServiceImpl;
import cn.hellohao.service.impl.UserServiceImpl;
import cn.hellohao.service.impl.*;
import cn.hellohao.utils.*;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -43,7 +42,7 @@ public class AdminController {
@Autowired
private ImgreviewService imgreviewService;
@Autowired
private ConfigService configService;
private ImgTempService imgTempService;
@Autowired
private UploadConfigService uploadConfigService;
@Autowired
@@ -55,6 +54,22 @@ public class AdminController {
@Autowired
AlbumServiceImpl albumServiceI;
@Autowired
private NOSImageupload nosImageupload;
@Autowired
private OSSImageupload ossImageupload;
@Autowired
private COSImageupload cosImageupload;
@Autowired
private KODOImageupload kodoImageupload;
@Autowired
private USSImageupload ussImageupload;
@Autowired
private UFileImageupload uFileImageupload;
@Autowired
private FTPImageupload ftpImageupload;
@PostMapping(value = "/overviewData") //new
@ResponseBody
public Msg overviewData(@RequestParam(value = "data", defaultValue = "") String data) {
@@ -122,7 +137,7 @@ public class AdminController {
}
@PostMapping(value = "/SpaceExpansion")//new kuorong
@PostMapping(value = "/SpaceExpansion")//new
@ResponseBody
public Msg SpaceExpansion(@RequestParam(value = "data", defaultValue = "") String data) {
final Msg msg = new Msg();
@@ -159,67 +174,6 @@ public class AdminController {
}
@RequestMapping(value = "/tosurvey")
public String admin2(HttpSession session, Model model) {
User u = (User) session.getAttribute("user");
String sysetmname = System.getProperty("os.name");
String isarch = System.getProperty("os.arch");
String jdk = System.getProperty("java.version");
model.addAttribute("username", u.getUsername());
model.addAttribute("levels", u.getLevel());
model.addAttribute("sysetmname",sysetmname);
model.addAttribute("isarch", isarch);
model.addAttribute("jdk", jdk);
//空间大小
UploadConfig uploadConfig = uploadConfigService.getUpdateConfig();
Long usermemory = imgService.getusermemory(u.getId());
if(usermemory==null){usermemory=0L;}
User user = userService.getUsers(u);
if(u!=null){
if (u.getLevel() == 1) {
model.addAttribute("level", "普通用户");
} else if (u.getLevel() == 2) {
model.addAttribute("level", "管理员");
} else {
model.addAttribute("level", "未 知");
}
model.addAttribute("levels", u.getLevel());
model.addAttribute("username", u.getUsername());
model.addAttribute("api", uploadConfig.getApi());
model.addAttribute("memory",user.getMemory());//单位M
if(usermemory==null){
model.addAttribute("usermemory", 0);//单位M
}else{
float d = (float) (Math.round((usermemory/1024.0F) * 100.0) / 100.0);
model.addAttribute("usermemory", d);//单位M
}
}
return "admin/survey";
}
@RequestMapping(value = "/getwebconfig")
@ResponseBody
public String getwebconfig(HttpSession session) {
JSONObject jsonObject = new JSONObject();
UploadConfig uploadConfig = uploadConfigService.getUpdateConfig();
User u = (User) session.getAttribute("user");
Imgreview imgreview = imgreviewService.selectByPrimaryKey(1);
jsonObject.put("usercount", imgService.countimg(u.getId()));
jsonObject.put("counts", imgService.counts(null) );
jsonObject.put("getusertotal", userService.getUserTotal());
jsonObject.put("imgreviewcount", imgreview.getCount());
if(uploadConfig.getIsupdate()!=1){
jsonObject.put("VisitorUpload", 0);//是否禁用了游客上传
}else{
Long temp = imgService.getusermemory(0);
jsonObject.put("VisitorUpload", uploadConfig.getIsupdate());//是否禁用了游客上传
jsonObject.put("UsedSize", (temp == null ? 0 : temp/1024));//访客已用大小
jsonObject.put("VisitorMemory", uploadConfig.getVisitormemory());//访客共大小
}
return jsonObject.toString();
}
@PostMapping("/getRecently")//new 获取榜单和最近上传
@ResponseBody
public Msg getRecently(@RequestParam(value = "data", defaultValue = "") String data) {
@@ -303,7 +257,7 @@ public class AdminController {
return msg;
}
@PostMapping("/getStorage")//new 获取当前一共有多少种存储源 这是种类
@PostMapping("/getStorage")//new
@ResponseBody
public Msg getStorage() {
Msg msg = new Msg();
@@ -312,7 +266,7 @@ public class AdminController {
return msg;
}
@PostMapping("/getStorageName")//new 获取当前一共有多少个存储源 这是总个数
@PostMapping("/getStorageName")//new
@ResponseBody
public Msg getStorageName() {
Msg msg = new Msg();
@@ -358,7 +312,6 @@ public class AdminController {
}
Images img = new Images();
PageHelper.startPage(pageNum, pageSize);
// img.setUseridlist(user.getId().toString());
if(violation){
img.setViolation("true");
}
@@ -431,7 +384,6 @@ public class AdminController {
msg.setInfo("用户名不得超过20位字符");
return msg;
}
if(subject.hasRole("admin")){
final User userOld = new User();
userOld.setId(u.getId());
@@ -475,9 +427,87 @@ public class AdminController {
}
@PostMapping("/deleImages") //new
@ResponseBody
public Msg deleImages(@RequestParam(value = "data", defaultValue = "") String data) {
Msg msg = new Msg();
JSONObject jsonObj = JSONObject.parseObject(data);
JSONArray images = jsonObj.getJSONArray("images");
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
if(null == user){
msg.setCode("500");
msg.setInfo("当前用户信息不存在");
return msg;
}
if(images.size()==0){
msg.setCode("404");
msg.setInfo("为获取到图像信息");
return msg;
}
for (int i = 0; i < images.size(); i++) {
Integer imgid = images.getInteger(i);
Images image = imgService.selectByPrimaryKey(imgid);
Integer keyid = image.getSource();
String imgname = image.getImgname();
Keys key = keysService.selectKeys(keyid);
if(!subject.hasRole("admin")){
if(image.getUserid()!=user.getId()){
break;
}
}
//删除图片
boolean isDele = false;
try{
if (key.getStorageType() == 1) {
isDele = nosImageupload.delNOS(key.getId(), imgname);
} else if (key.getStorageType() == 2) {
isDele = ossImageupload.delOSS(key.getId(), imgname);
} else if (key.getStorageType() == 3) {
isDele = ussImageupload.delUSS(key.getId(), imgname);
} else if (key.getStorageType() == 4) {
isDele = kodoImageupload.delKODO(key.getId(), imgname);
} else if (key.getStorageType() == 5) {
isDele = LocUpdateImg.deleteLOCImg(imgname);
}else if (key.getStorageType() == 6) {
isDele = cosImageupload.delCOS(key.getId(), imgname);
}else if (key.getStorageType() == 7) {
isDele = ftpImageupload.delFTP(key.getId(), imgname);
}else if (key.getStorageType() == 8) {
isDele = uFileImageupload.delUFile(key.getId(), imgname);
}else {
System.err.println("未获取到对象存储参数,删除失败。");
}
}catch (Exception e){
e.printStackTrace();
}
//删除库
if(isDele){
try {
//删除图像表之前先删除临时数据表,图像表也会删除
imgTempService.delImgAndExp(image.getImguid());
imgService.deleimg(imgid);
imgAndAlbumService.deleteImgAndAlbum(imgname);
} catch (Exception e) {
e.printStackTrace();
msg.setInfo("图片记录删除失败,请重试");
msg.setCode("500");
return msg;
}
msg.setInfo("删除成功");
}else{
imgTempService.delImgAndExp(image.getImguid());
imgService.deleimg(imgid);
imgAndAlbumService.deleteImgAndAlbum(imgname);
msg.setInfo("图片记录已删除,但是图片源删除失败");
}
}
System.out.println("返回的值:"+msg.toString());
return msg;
}
//工具函数
@@ -3,10 +3,7 @@ package cn.hellohao.controller;
import cn.hellohao.pojo.*;
import cn.hellohao.service.*;
import cn.hellohao.service.impl.*;
import cn.hellohao.utils.GetCurrentSource;
import cn.hellohao.utils.Print;
import cn.hellohao.utils.SetFiles;
import cn.hellohao.utils.StringUtils;
import cn.hellohao.utils.*;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
@@ -53,10 +50,11 @@ public class AdminRootController {
private GroupService groupService;
@Autowired
private ImgService imgService;
@Autowired
private ImgreviewService imgreviewService;
@PostMapping(value = "/getUserList")//new selectusertable
@ResponseBody
@PostMapping(value = "/getUserList")//new
public Map<String, Object> getUserList(@RequestParam(value = "data", defaultValue = "") String data) {
JSONObject jsonObj = JSONObject.parseObject(data);
Integer pageNum = jsonObj.getInteger("pageNum");
@@ -181,8 +179,6 @@ public class AdminRootController {
return msg;
}
//获取当前所有的存储策略信息
@PostMapping("/LoadInfo")//new
@ResponseBody
public Msg LoadInfo(@RequestParam(value = "data", defaultValue = "") String data) {
@@ -190,7 +186,6 @@ public class AdminRootController {
try {
JSONObject jsonData = JSONObject.parseObject(data);
Integer keyId = jsonData.getInteger("keyId");
JSONObject jsonObject = new JSONObject();
jsonObject.put("id",keyId);
Keys key = keysService.selectKeys(keyId);
@@ -210,7 +205,6 @@ public class AdminRootController {
}else if(key.getStorageType()==8){
ret = UFileImageupload.Initialize(key);
}
Long l = imgService.getsourcememory(keyId);
jsonObject.put("isok",ret);
jsonObject.put("storagetype",key.getStorageType());
@@ -265,7 +259,7 @@ public class AdminRootController {
}
@PostMapping("/getSettingConfig") //new upload配置表的相关设置
@PostMapping("/getSettingConfig") //new
@ResponseBody
public Msg getSettingConfig(@RequestParam(value = "data", defaultValue = "") String data) {
final Msg msg = new Msg();
@@ -276,9 +270,6 @@ public class AdminRootController {
UploadConfig uploadConfig = uploadConfigService.getUpdateConfig();
Config config = configService.getSourceype();
SysConfig sysConfig = sysConfigService.getstate();
//把字节换算一下,页面上显示M
// filesizetourists = (filesizetourists*1024*1024) ,filesizeuser=(filesizeuser*1024*1024)
// visitormemory=(visitormemory*1024*1024),usermemory=(usermemory*1024*1024)
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));
@@ -321,11 +312,9 @@ public class AdminRootController {
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);
msg.setInfo("配置保存成功");
}catch (Exception e){
e.printStackTrace();
@@ -336,5 +325,70 @@ public class AdminRootController {
}
@PostMapping(value = "/getOrderConfig")//new
@ResponseBody
public Msg emailconfig() {
final Msg msg = new Msg();
EmailConfig emailConfig = null;
Imgreview imgreview = null;
try {
final JSONObject jsonObject = new JSONObject();
emailConfig = emailConfigService.getemail();
imgreview = imgreviewService.selectByPrimaryKey(1);
jsonObject.put("emailConfig",emailConfig);
jsonObject.put("imgreview",imgreview);
msg.setData(jsonObject);
} catch (Exception e) {
e.printStackTrace();
msg.setCode("110500");
msg.setInfo("获取相关配置信息失败");
}
return msg;
}
@PostMapping("/updateEmailConfig") //new
@ResponseBody
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("")){
msg.setCode("110400");
msg.setInfo("各参数不能为空");
return msg;
}
emailConfigService.updateemail(emailConfig);
msg.setInfo("保存成功");
} catch (Exception e) {
e.printStackTrace();
msg.setCode("110500");
msg.setInfo("保存过程出现错误");
}
return msg;
}
@PostMapping("/mailTest") //new
@ResponseBody
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){
// if(jsonObj.size()==0){
msg.setCode("110400");
msg.setInfo("邮箱配置参数不能为空");
}else{
msg = NewSendEmail.sendTestEmail(emailConfig, tomail);
}
return msg;
}
}
@@ -1,6 +1,7 @@
package cn.hellohao.controller;
import cn.hellohao.pojo.*;
import cn.hellohao.pojo.vo.PageResultBean;
import cn.hellohao.service.*;
import cn.hellohao.service.impl.AlbumServiceImpl;
import com.alibaba.fastjson.JSONArray;
@@ -39,7 +40,7 @@ public class AlbumController {
@Autowired
private UserService userService;
@PostMapping("/admin/getGalleryList") //new 获取画廊地址
@PostMapping("/admin/getGalleryList") //new
@ResponseBody
public Map<String, Object> getGalleryList (@RequestParam(value = "data", defaultValue = "") String data){
Subject subject = SecurityUtils.getSubject();
@@ -177,8 +178,82 @@ public class AlbumController {
}
@PostMapping("/checkPass")//new
@ResponseBody
public Msg checkPass(@RequestParam(value = "data", defaultValue = "") String data) {
Msg msg = new Msg();
JSONObject json = new JSONObject();
JSONObject jsonObject = null;
try {
jsonObject = JSONObject.parseObject(data);
String key = jsonObject.getString("key");
Album album = new Album();
album.setAlbumkey(key);
Album a = albumServiceImpl.selectAlbum(album);
if(a!=null){
json.put("album",a);
json.put("exist",true);
if(a.getPassword()!=null && !a.getPassword().equals("")){
json.put("passType",true);
}else{
json.put("passType",false);
}
msg.setData(json);
}else{
json.put("exist",false);
msg.setData(json);
}
} catch (Exception e) {
e.printStackTrace();
msg.setCode("110500");
msg.setInfo("操作失败");
msg.setData(json);
}
return msg;
}
@PostMapping("/getAlbumList") //new
@ResponseBody
public Msg getAlbumList(@RequestParam(value = "data", defaultValue = "") String data){
Msg msg = new Msg();
JSONObject json = new JSONObject();
JSONObject jsonObject = JSONObject.parseObject(data);
Integer pageNum = jsonObject.getInteger("pageNum");
Integer pageSize = jsonObject.getInteger("pageSize");
String albumkey = jsonObject.getString("albumkey");
String password = jsonObject.getString("password");
if(null!=password){
password = password.replace(" ", "");
}
Album album = new Album();
album.setAlbumkey(albumkey);
Album a = albumServiceImpl.selectAlbum(album);
if(a==null){
msg.setCode("110404");
msg.setInfo("画廊地址不存在");
}else{
PageHelper.startPage(pageNum, pageSize);
if(a.getPassword()==null || (a.getPassword().replace(" ", "")).equals("")){
List<Images> imagesList = imgAndAlbumService.selectImgForAlbumkey(albumkey);
PageInfo<Images> rolePageInfo = new PageInfo<>(imagesList);
PageResultBean<Images> pageResultBean = new PageResultBean<>(rolePageInfo.getTotal(), rolePageInfo.getList());
json.put("imagesList",pageResultBean);
}else{
if(a.getPassword().equals(password)){
List<Images> imagesList = imgAndAlbumService.selectImgForAlbumkey(albumkey);
PageInfo<Images> rolePageInfo = new PageInfo<>(imagesList);
PageResultBean<Images> pageResultBean = new PageResultBean<>(rolePageInfo.getTotal(), rolePageInfo.getList());
json.put("imagesList",pageResultBean);
}else{
msg.setCode("110403");
msg.setInfo("画廊密码错误");
}
}
json.put("titlename",a.getAlbumtitle());
msg.setData(json);
}
return msg;
}
@@ -29,35 +29,17 @@ import java.util.*;
*/
@RestController
public class ClientController {
@Autowired
private NOSImageupload nOSImageupload;
@Autowired
private UserService userService;
@Autowired
private KeysService keysService;
@Autowired
private OSSImageupload ossImageupload;
@Autowired
private ConfigService configService;
@Autowired
private USSImageupload ussImageupload;
@Autowired
private KODOImageupload kodoImageupload;
@Autowired
private UploadConfigService uploadConfigService;
@Autowired
private NoticeService noticeService;
@Autowired
private COSImageupload cosImageupload;
@Autowired
private FTPImageupload ftpImageupload;
@Autowired
private UFileImageupload uFileImageupload;
@Autowired
private ImgService imgService;
@Value("${systemupdate}")
private String systemupdate;
@Autowired
private ClientService clientService;
@PostMapping(value = "/uploadbymail")
@ResponseBody
public Msg uploadbymail(HttpServletRequest request, @RequestParam("file") MultipartFile file, String mail, String pass) {
Msg resultBean = clientService.uploadImg(request, file, mail, pass);
return resultBean;
}
}
@@ -1,13 +1,8 @@
package cn.hellohao.controller;
import cn.hellohao.pojo.Code;
import cn.hellohao.pojo.Config;
import cn.hellohao.pojo.Msg;
import cn.hellohao.pojo.User;
import cn.hellohao.service.CodeService;
import cn.hellohao.service.KeysService;
import cn.hellohao.service.UserService;
import cn.hellohao.service.impl.ImgServiceImpl;
import cn.hutool.crypto.SecureUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -18,8 +13,6 @@ import org.springframework.stereotype.Controller;
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.HttpSession;
import java.util.*;
/**
@@ -1,44 +0,0 @@
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;
/**
* 错误页面拦截
* */
@Controller
class MainsiteErrorController implements ErrorController {
@RequestMapping("/error")
public String handleError(HttpServletRequest request){
//获取statusCode:401,404,500
Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code");
if(statusCode == 401){
return "401";
}else if(statusCode == 404){
return "404";
}else if(statusCode == 403){
return "403";
}else{
return "500";
}
}
//认证失败
@RequestMapping("/jurisError")
@ResponseBody
public Msg jurisError(HttpServletRequest request){
Msg msg = new Msg();
msg.setCode("4031");
msg.setInfo("Authentication request failed");
return msg;
}
}
@@ -67,20 +67,5 @@ public class ExceptionHandling {
// @ExceptionHandler
// public String methodArgumentNotValid(BindException e) {
// List<ObjectError> allErrors = e.getBindingResult().getAllErrors();
// StringBuilder errorMessage = new StringBuilder();
// for (int i = 0; i < allErrors.size(); i++) {
// ObjectError error = allErrors.get(i);
// errorMessage.append(error.getDefaultMessage());
// if (i != allErrors.size() - 1) {
// errorMessage.append(", ");
// }
// }
// // do something
// System.out.println(errorMessage.toString());// 这里面是错误信息
// return errorMessage.toString();
// }
}
@@ -1,26 +1,19 @@
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;
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.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -52,8 +45,6 @@ public class GroupController {
return msg;
}
//获取code列表
@PostMapping(value = "/getGroupList")//new
@ResponseBody
public Map<String, Object> getgrouplist(@RequestParam(value = "data", defaultValue = "") String data) {
@@ -78,7 +69,6 @@ public class GroupController {
return map;
}
@PostMapping(value = "/addGroup")//new
@ResponseBody
public Msg addisgroup(@RequestParam(value = "data", defaultValue = "") String data) {
@@ -95,7 +85,6 @@ public class GroupController {
@PostMapping("/updateGroup")//new
@ResponseBody
public Msg updategroup(@RequestParam(value = "data", defaultValue = "") String data) {
JSONObject jsonObject = JSONObject.parseObject(data);
Group group = new Group();
group.setId(jsonObject.getInteger("id"));
@@ -1,43 +1,61 @@
package cn.hellohao.controller;
import cn.hellohao.pojo.Imgreview;
import cn.hellohao.pojo.Msg;
import cn.hellohao.service.ImgreviewService;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
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;
@Controller
@RequestMapping("/admin")
@RequestMapping("/admin/root")
public class ImageReviewController {
@Autowired
private ImgreviewService imgreviewService;
@RequestMapping(value = "/root/ImageReview")
public String ForwardImageReview(Model model) {
Imgreview imgreview = imgreviewService.selectByPrimaryKey(1);
model.addAttribute("appid", imgreview.getAppId());
model.addAttribute("apikey", imgreview.getApiKey());
model.addAttribute("secretkey", imgreview.getSecretKey());
model.addAttribute("using", imgreview.getUsing());
return "admin/imageIdentify";
}
@RequestMapping(value = "/root/ImgreviewSwitch")
@PostMapping("/updateimgReviewConfig") //new
@ResponseBody
public String ImgreviewSwitch(String appId, String apiKey, String secretKey, Integer using) {
Imgreview imgreview = new Imgreview();
imgreview.setId(1);//目前就一种鉴黄功能所以设死了
imgreview.setUsing(using);
imgreview.setAppId(appId);
imgreview.setApiKey(apiKey);
imgreview.setSecretKey(secretKey);
Integer ret = imgreviewService.updateByPrimaryKeySelective(imgreview);
return ret.toString();
public Msg updateimgReviewConfig(@RequestParam(value = "data", defaultValue = "") String data ) {
final Msg msg = new Msg();
try {
JSONObject jsonObj = JSONObject.parseObject(data);
Imgreview imgreview = JSON.toJavaObject(jsonObj,Imgreview.class);
if(imgreview.getId()==1){
if(null==imgreview.getId() || null==imgreview.getApiKey() || null==imgreview.getUsing() || null==imgreview.getSecretKey()
|| null==imgreview.getAppId() || imgreview.getApiKey().equals("")
|| imgreview.getSecretKey().equals("") || imgreview.getAppId().equals("")){
msg.setCode("110400");
msg.setInfo("各参数不能为空");
return msg;
}
}else{
if(null==imgreview.getId() || null==imgreview.getApiKey() || null==imgreview.getUsing()
|| imgreview.getApiKey().equals("")
){
msg.setCode("110400");
msg.setInfo("各参数不能为空");
return msg;
}
}
if(null == imgreviewService.selectByPrimaryKey(imgreview.getId())){
imgreviewService.insert(imgreview);
}else{
imgreviewService.updateByPrimaryKeySelective(imgreview);
}
msg.setInfo("保存成功");
} catch (Exception e) {
e.printStackTrace();
msg.setCode("110500");
msg.setInfo("保存过程出现错误");
}
return msg;
}
}
@@ -14,62 +14,55 @@ import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.*;
@Controller
public class IndexController {
@Autowired
private ImgService imgService;
@Autowired
private SysConfigService sysConfigService;
@Autowired
IRedisService iRedisService;
@Autowired
private NOSImageupload nOSImageupload;
@Autowired
private UserService userService;
@Autowired
private KeysService keysService;
@Autowired
private ConfigService configService;
@Autowired
private UploadConfigService uploadConfigService;
@Autowired
private USSImageupload ussImageupload;
private UploadServicel uploadServicel;
@Autowired
private KODOImageupload kodoImageupload;
private NOSImageupload nosImageupload;
@Autowired
private OSSImageupload ossImageupload;
@Autowired
private COSImageupload cosImageupload;
@Autowired
private KODOImageupload kodoImageupload;
@Autowired
private USSImageupload ussImageupload;
@Autowired
private UFileImageupload uFileImageupload;
@Autowired
private FTPImageupload ftpImageupload;
@Autowired
private ImgService imgService;
AlbumServiceImpl albumService;
@Autowired
private UploadServicel uploadServicel;
private String[] iparr;
public static String vu;
private KeysService keysService;
@Autowired
private ImgTempService imgTempService;
@Autowired
private ImgAndAlbumService imgAndAlbumService;
@RequestMapping(value = "/webInfo")//upimg new
@RequestMapping(value = "/webInfo")
@ResponseBody
public Msg webInfo(HttpSession httpSession) {
public Msg webInfo() {
final Msg msg = new Msg();
Config config = configService.getSourceype();
UploadConfig updateConfig = uploadConfigService.getUpdateConfig();
@@ -86,8 +79,6 @@ public class IndexController {
jsonObject.put("aboutinfo",config.getAboutinfo());
jsonObject.put("logo",config.getLogo());
jsonObject.put("api",updateConfig.getApi());
// jsonObject.put("watermark",updateConfig.getWatermark());
// jsonObject.put("guidepage",sysConfig.getGuidepage());
jsonObject.put("register",sysConfig.getRegister());
msg.setData(jsonObject);
return msg;
@@ -109,11 +100,6 @@ public class IndexController {
return uploadServicel.uploadForLoc(request,multipartFile,day,null,jsonArray);
}
@RequestMapping(value = "/getUploadInfo")//new
@ResponseBody
public Msg getUploadInfo() {
@@ -148,19 +134,13 @@ public class IndexController {
String token = request.getHeader("Authorization");
if(token != null) {
JSONObject tokenJson = JWTUtil.checkToken(token);
// boolean check = (boolean) result.get("check");
// String password = (String) result.get("password");
if(tokenJson.getBoolean("check")){
//获取当前用户
Subject subject = SecurityUtils.getSubject();
//封装用户的登录数据(shiro认证的时候使用)
UsernamePasswordToken tokenOBJ = new UsernamePasswordToken(tokenJson.getString("email"),tokenJson.getString("password"));
//设置记住我
tokenOBJ.setRememberMe(true);
try {
//执行登录方法,如果没有异常,说明登录成功
subject.login(tokenOBJ);
SecurityUtils.getSubject().getSession().setTimeout(3600000);//一小时
SecurityUtils.getSubject().getSession().setTimeout(3600000);
User u = (User) subject.getPrincipal();
final JSONObject jsonObject = new JSONObject();
jsonObject.put("RoleLevel",u.getLevel()==2?"admin":"user");
@@ -168,7 +148,6 @@ public class IndexController {
msg.setCode("200");
msg.setData(jsonObject);
} catch (Exception e) {
//此异常说明用户名不存在
msg.setCode("40041");
msg.setInfo("登录失效,请重新登录");
System.err.println("登录失效,请重新登录");
@@ -246,8 +225,92 @@ public class IndexController {
}
}
//删除图像
@PostMapping("/deleImagesByUid") //new
@ResponseBody
public Msg deleImagesByUid(@RequestParam(value = "data", defaultValue = "") String data) {
Msg msg = new Msg();
JSONObject jsonObj = JSONObject.parseObject(data);
String imguid = jsonObj.getString("imguid");
Images image = imgService.selectImgUrlByImgUID(imguid);
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
if(null!=user){
if(user.getId()!=image.getUserid()){
msg.setInfo("删除失败,该图片不允许你执行操作");
msg.setCode("100403");
return msg;
}
}
Integer keyid = image.getSource();
String imgname = image.getImgname();
Keys key = keysService.selectKeys(keyid);
//删除图片
boolean isDele = false;
if (key.getStorageType() == 1) {
isDele = nosImageupload.delNOS(key.getId(), imgname);
} else if (key.getStorageType() == 2) {
isDele = ossImageupload.delOSS(key.getId(), imgname);
} else if (key.getStorageType() == 3) {
isDele = ussImageupload.delUSS(key.getId(), imgname);
} else if (key.getStorageType() == 4) {
isDele = kodoImageupload.delKODO(key.getId(), imgname);
} else if (key.getStorageType() == 5) {
isDele = LocUpdateImg.deleteLOCImg(imgname);
}else if (key.getStorageType() == 6) {
isDele = cosImageupload.delCOS(key.getId(), imgname);
}else if (key.getStorageType() == 7) {
isDele = ftpImageupload.delFTP(key.getId(), imgname);
}else if (key.getStorageType() == 8) {
isDele = uFileImageupload.delUFile(key.getId(), imgname);
}else {
System.err.println("未获取到对象存储参数,删除失败。");
}
//删除库
if(isDele){
try {
imgAndAlbumService.deleteImgAndAlbum(imgname);
imgTempService.delImgAndExp(image.getImguid());
imgService.deleimg(image.getId());
} catch (Exception e) {
e.printStackTrace();
msg.setInfo("图片记录时发生错误");
msg.setCode("500");
return msg;
}
msg.setInfo("删除成功");
}else{
imgAndAlbumService.deleteImgAndAlbum(imgname);
imgTempService.delImgAndExp(image.getImguid());
imgService.deleimg(image.getId());
msg.setInfo("图片记录已删除,但是图片源删除失败");
msg.setCode("500");
}
System.out.println("返回的值:"+msg.toString());
return msg;
}
//没有权限
@RequestMapping("/authError")
@ResponseBody
public Msg authError(HttpServletRequest request){
Msg msg = new Msg();
msg.setCode("4031");
msg.setInfo("You don't have authority");
return msg;
}
//认证失败
@RequestMapping("/jurisError")
@ResponseBody
public Msg jurisError(HttpServletRequest request){
Msg msg = new Msg();
msg.setCode("4031");
msg.setInfo("Authentication request failed");
return msg;
}
}
@@ -13,6 +13,7 @@ import cn.hellohao.config.SysName;
import cn.hellohao.pojo.*;
import cn.hellohao.service.*;
import cn.hellohao.utils.*;
import cn.hutool.core.util.HexUtil;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.UnknownAccountException;
@@ -54,16 +55,13 @@ public class UserController {
String userIP = GetIPS.getIpAddr(request);
String verifyCodeForRegister = jsonObj.getString("verifyCode");
Object redis_verifyCodeForRegister = iRedisService.getValue(userIP+"_hellohao_verifyCodeForRegister");
if(!SetText.checkEmail(email)){
//邮箱格式不正确
msg.setCode("110403");
msg.setInfo("邮箱格式不正确");
return msg;
}
String regex = "^\\w+$";
if(username.length()>20 || !username.matches (regex)){
//用户名格式不正确
msg.setCode("110403");
msg.setInfo("用户名不得超过20位字符");
return msg;
@@ -135,7 +133,6 @@ public class UserController {
return msg;
}
//shiro登录认证
@PostMapping("/login")//new
@ResponseBody
public Msg login(HttpServletRequest request,@RequestParam(value = "data", defaultValue = "") String data) {
@@ -156,15 +153,10 @@ public class UserController {
return msg;
}
if((redis_VerifyCode.toString().toLowerCase()).compareTo((verifyCode.toLowerCase()))==0){
// if(true){
//获取当前用户
Subject subject = SecurityUtils.getSubject();
//封装用户的登录数据(shiro认证的时候使用)
UsernamePasswordToken tokenOBJ = new UsernamePasswordToken(email,password);
//设置记住我
tokenOBJ.setRememberMe(true);
try {
//执行登录方法,如果没有异常,说明登录成功
subject.login(tokenOBJ);
SecurityUtils.getSubject().getSession().setTimeout(3600000);//一小时
JSONObject jsonObject = new JSONObject();
@@ -179,7 +171,6 @@ public class UserController {
msg.setCode("110403");
return msg;
}
// String token = TokenUtil.sign(user);
String token = JWTUtil.createToken(user);
Subject su = SecurityUtils.getSubject();
System.out.println("当前用户角色:admin:"+su.hasRole("admin"));
@@ -216,8 +207,33 @@ public class UserController {
return msg;
}
//邮箱激活
@RequestMapping(value = "/activation", method = RequestMethod.GET)
public String activation(Model model, HttpServletRequest request, HttpSession session, String activation, String username) {
Config config = configService.getSourceype();
Integer ret = 0;
User u2 = new User();
u2.setUid(activation);
User user = userService.getUsers(u2);
model.addAttribute("webhost",SubjectFilter.WEBHOST);
if (user != null && user.getIsok() == 0) {
userService.uiduser(activation);
model.addAttribute("title","激活成功");
model.addAttribute("name","Hi~"+username);
model.addAttribute("note","您的账号已成功激活看");
return "msg";
} else {
model.addAttribute("title","操作无效");
model.addAttribute("name","该页面为无效页面");
model.addAttribute("note","请返回首页");
return "msg";
}
}
//退出
@PostMapping(value = "/logout")
@PostMapping(value = "/logout")//new
@ResponseBody
public Msg exit(Model model, HttpServletRequest request, HttpServletResponse response, HttpSession session) {
Msg msg = new Msg();
@@ -228,7 +244,8 @@ public class UserController {
return msg;
}
@PostMapping("/retrievePass")
//retrievepass
@PostMapping("/retrievePass") //new
@ResponseBody
public Msg retrievePass(HttpServletRequest request, @RequestParam(value = "data", defaultValue = "") String data) {
Msg msg = new Msg();
@@ -238,6 +255,7 @@ public class UserController {
String retrieveCode = jsonObj.getString("retrieveCode");
String userIP = GetIPS.getIpAddr(request);
Object redis_verifyCodeForEmailRetrieve = iRedisService.getValue(userIP+"_hellohao_verifyCodeForEmailRetrieve");
EmailConfig emailConfig = emailConfigService.getemail();
if(null==redis_verifyCodeForEmailRetrieve){
msg.setCode("4035");
@@ -290,47 +308,43 @@ public class UserController {
}
//邮箱激活
@RequestMapping(value = "/activation", method = RequestMethod.GET)
public String activation(Model model, HttpServletRequest request, HttpSession session, String activation, String username) {
Config config = configService.getSourceype();
@RequestMapping(value = "/retrieve", method = RequestMethod.GET) //new
public String retrieve(Model model, String activation,String cip) {
Integer ret = 0;
User u2 = new User();
u2.setUid(activation);
User user = userService.getUsers(u2);
try {
User u2 = new User();
u2.setUid(activation);
User user = userService.getUsers(u2);
user.setIsok(1);
String new_pass = HexUtil.decodeHexStr(cip);//解密密码
user.setPassword(Base64Encryption.encryptBASE64(new_pass.getBytes()));
String uid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
user.setUid(uid);
if (user != null) {
Integer r = userService.changeUser(user);
model.addAttribute("title","成功");
model.addAttribute("name","新密码:"+new_pass);//
model.addAttribute("note","密码已被系统重置,请即使登录修改你的新密码");
} else {
model.addAttribute("title","抱歉");
model.addAttribute("name","为获取到用户信息");
model.addAttribute("note","操作失败");
}
}catch (Exception e){
e.printStackTrace();
model.addAttribute("title","抱歉");
model.addAttribute("name","系统操作过程中发生错误");
model.addAttribute("note","操作失败");
}
model.addAttribute("webhost", SubjectFilter.WEBHOST);
if (user != null && user.getIsok() == 0) {
userService.uiduser(activation);
model.addAttribute("title","激活成功");
model.addAttribute("name","Hi~"+username);
model.addAttribute("note","您的账号已成功激活看");
return "msg";
} else {
model.addAttribute("title","操作无效");
model.addAttribute("name","该页面为无效页面");
model.addAttribute("note","请返回首页");
return "msg";
}
return "msg";
}
}
@PostMapping(value = "/verification")
@ResponseBody
public Integer verification(HttpSession session,Integer tmp,Integer type) {
Random random = new Random();
if(type==1){
number1 = random.nextInt(100);
istmp1 = tmp;
Print.Normal(tmp-number1);
}
if(type==2){
number2 = random.nextInt(100);
istmp2 = tmp;
Print.Normal(tmp-number2);
}
return 1;
}
private Integer number1;
private Integer istmp1;
private Integer number2;
private Integer istmp2;
}
+2 -1
View File
@@ -32,7 +32,7 @@ public interface ImgMapper {
Long getsourcememory(@Param("source") Integer source);
Integer md5Count(@Param("md5key") String md5key);
Integer md5Count(Images images);
Images selectImgUrlByMD5(@Param("md5key") String md5key);
@@ -46,5 +46,6 @@ public interface ImgMapper {
List<Images> countByM(Images images);
Images selectImgUrlByImgUID(@Param("imguid") String imguid);
}
+2 -11
View File
@@ -22,7 +22,6 @@ public class Images {
private String notes;
private String useridlist;
private String imguid;
private String shortlink;
private String format;
private String about;
private Integer great;
@@ -41,7 +40,7 @@ public class Images {
super();
}
public Images(String imgurl, String sizes, String abnormal, String updatetime, String username, String md5key, String imguid,String shortlink) {
public Images(String imgurl, String sizes, String abnormal, String updatetime, String username, String md5key, String imguid) {
this.imgurl = imgurl;
this.sizes = sizes;
this.abnormal = abnormal;
@@ -54,7 +53,7 @@ public class Images {
public Images(Integer id, String imgname, String imgurl, Integer userid, String sizes, String abnormal, Integer source,
Integer imgtype, String updatetime, String username, Integer storageType, String starttime, String stoptime,
String explains, String md5key, String notes, String useridlist, String imguid, String albumtitle,
String password, Integer selecttype,Long countNum,Integer monthNum,String yyyy,String shortlink,
String password, Integer selecttype,Long countNum,Integer monthNum,String yyyy,
String format,String about,Integer great,String[] classifuidlist,String classificationuid,String violation) {
this.id = id;
this.imgname = imgname;
@@ -74,7 +73,6 @@ public class Images {
this.notes = notes;
this.useridlist = useridlist;
this.imguid = imguid;
this.shortlink = shortlink;
this.albumtitle = albumtitle;
this.password = password;
this.selecttype = selecttype;
@@ -234,13 +232,6 @@ public class Images {
this.imguid = imguid;
}
public String getShortlink() {
return shortlink;
}
public void setShortlink(String shortlink) {
this.shortlink = shortlink;
}
public String getAlbumtitle() {
return albumtitle;
+13 -1
View File
@@ -8,13 +8,15 @@ package cn.hellohao.pojo;
public class SysConfig {
private Integer id;
private Integer register;
private String checkduplicate;
public SysConfig() {
}
public SysConfig(Integer id, Integer register) {
public SysConfig(Integer id, Integer register, String checkduplicate) {
this.id = id;
this.register = register;
this.checkduplicate = checkduplicate;
}
public Integer getId() {
@@ -32,4 +34,14 @@ public class SysConfig {
public void setRegister(Integer register) {
this.register = register;
}
public String getCheckduplicate() {
return checkduplicate;
}
public void setCheckduplicate(String checkduplicate) {
this.checkduplicate = checkduplicate;
}
}
@@ -33,7 +33,7 @@ public interface ImgService {
Long getsourcememory(Integer source);
Integer md5Count(String md5key);
Integer md5Count(Images images);
Images selectImgUrlByMD5(String md5key);
@@ -47,4 +47,6 @@ public interface ImgService {
List<Images> countByM(Images images);
Images selectImgUrlByImgUID( String imguid);
}
@@ -42,7 +42,6 @@ public class COSImageupload {
String userkey =username + "/" + ShortUID + "." + entry.getKey();
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, userkey, file);
PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
returnImage.setUid(ShortUID);
returnImage.setImgname(userkey);
returnImage.setImgurl(key.getRequestAddress() + "/" + userkey);
returnImage.setImgSize(entry.getValue().length());
@@ -0,0 +1,331 @@
package cn.hellohao.service.impl;
import cn.hellohao.dao.*;
import cn.hellohao.pojo.*;
import cn.hellohao.pojo.vo.PageResultBean;
import cn.hellohao.service.ImgAndAlbumService;
import cn.hellohao.service.SysConfigService;
import cn.hellohao.utils.*;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baidu.aip.contentcensor.AipContentCensor;
import com.baidu.aip.contentcensor.EImgType;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import net.coobird.thumbnailator.filters.Watermark;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.FileInputStream;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @author Hellohao
* @version 1.0
* @date 2021/10/28 16:38
*/
@Service
public class ClientService {
@Autowired
private ImgAndAlbumService imgAndAlbumService;
@Autowired
private NOSImageupload nOSImageupload;
@Autowired
private OSSImageupload ossImageupload;
@Autowired
private USSImageupload ussImageupload;
@Autowired
private KODOImageupload kodoImageupload;
@Autowired
private COSImageupload cosImageupload;
@Autowired
private SysConfigService sysConfigService;
@Autowired
private FTPImageupload ftpImageupload;
@Autowired
private UFileImageupload uFileImageupload;
@Autowired
private UserMapper userMapper;
@Autowired
private KeysMapper keysMapper;
@Autowired
private ConfigMapper configMapper;
@Autowired
private UploadConfigMapper uploadConfigMapper;
@Autowired
private NoticeMapper noticeMapper;
@Autowired
private ImgMapper imgMapper;
@Autowired
ImgreviewMapper imgreviewMapper;
public Msg uploadImg(HttpServletRequest request, MultipartFile multipartFile, String email, String pass ){
Msg msg = new Msg();
try {
Integer sourceKeyId = 0;
FileInputStream fis = null;
String md5key = null;
Integer setday = 0;
JSONObject jsonObject = new JSONObject();
Config config = configMapper.getSourceype();
String userip = GetIPS.getIpAddr(request);
UploadConfig uploadConfig = uploadConfigMapper.getUpdateConfig();
if (uploadConfig.getApi() != 1) {
msg.setCode("4003");
msg.setInfo("管理员关闭了API接口");
return msg;
}
File file = SetFiles.changeFile_new(multipartFile);
User u2 = new User();
if (!file.exists() || email == null || pass == null) {
msg.setCode("4005");
msg.setInfo("必要参数不能为空");
return msg;
}
u2.setEmail(email);
u2.setPassword(Base64Encryption.encryptBASE64(pass.getBytes()));
User u = userMapper.getUsers(u2);
//判断用户的账号密码是否存在(正确)
if (null == u || u.getIsok() != 1) {
msg.setCode("4006");
msg.setInfo("用户信息不正确,账号异常");
return msg;
}
String imguid = UUID.randomUUID().toString().replace("-", "");
//判断上传前的一些用户限制信息
Msg msg1 = updateImgCheck(u, uploadConfig);
if (!msg1.getCode().equals("300")) {
return msg1;
}
sourceKeyId = group.getKeyid();
Keys key = keysMapper.selectKeys(sourceKeyId);
Long tmp = (memory == -1 ? -2 : UsedTotleMemory);
if (tmp >= memory) {
msg.setCode("4007");
msg.setInfo(u == null ? "游客空间已用尽" : "您的可用空间不足");
return msg;
}
if (file.length() > TotleMemory) {
System.err.println("文件大小:" + file.length());
System.err.println("最大限制:" + TotleMemory);
msg.setCode("4008");
msg.setInfo("图像超出系统限制大小");
return msg;
}
try {
fis = new FileInputStream(file);
md5key = DigestUtils.md5Hex(fis);
} catch (Exception e) {
e.printStackTrace();
System.out.println("未获取到图片的MD5,成成UUID");
}
Msg fileMiME = TypeDict.FileMiME(file, uploadConfig.getSuffix());
if (!fileMiME.getCode().equals("200")) {
//非图像文本
msg.setCode("4009");
msg.setInfo(fileMiME.getInfo());
return msg;
}
if (md5key == null || md5key.equals("")) {
md5key = UUID.randomUUID().toString().replace("-", "");
}
String prefix = file.getName().substring(file.getName().lastIndexOf(".") + 1);
if (uploadConfig.getBlacklist() != null) {
String[] iparr = uploadConfig.getBlacklist().split(";");
for (String s : iparr) {
if (s.equals(userip)) {
msg.setCode("4010");
msg.setInfo("你暂时不能上传");
return msg;
}
}
}
//判断图片是否存在
if(Integer.valueOf(sysConfigService.getstate().getCheckduplicate())==1) {
Images imaOBJ = new Images();
imaOBJ.setMd5key(md5key);
imaOBJ.setUserid(u.getId());
if (imgMapper.md5Count(imaOBJ) > 0) {
Images images = imgMapper.selectImgUrlByMD5(md5key);
jsonObject.put("url", images.getImgurl());
jsonObject.put("name", file.getName());
jsonObject.put("size", images.getSizes());
msg.setData(jsonObject);
return msg;
}
}
Map<String, File> map = new HashMap<>();
String fileName = file.getName();
if (file.exists()) {
map.put(prefix, file);
}
long stime = System.currentTimeMillis();
Map<ReturnImage, Integer> m = null;
ReturnImage returnImage = GetSource.storageSource(key.getStorageType(), map, updatePath, key.getId());
Images img = new Images();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (returnImage.getCode().equals("200")) {
String imgurl = returnImage.getImgurl();
Long imgsize = returnImage.getImgSize();
String imgname = returnImage.getImgname();
img.setImgurl(imgurl);
img.setUpdatetime(df.format(new Date()));
img.setSource(key.getId());
img.setUserid(u == null ? 0 : u.getId());
img.setSizes(imgsize.toString());
if (uploadConfig.getUrltype() == 2) {
img.setImgname(imgname);
} else {
img.setImgname(SetText.getSubString(imgname, key.getRequestAddress() + "/", ""));
}
img.setImgtype(setday > 0 ? 1 : 0);
img.setAbnormal(userip);
img.setMd5key(md5key);
img.setImguid(imguid);
img.setFormat(fileMiME.getData().toString());
userMapper.insertimg(img);
long etime = System.currentTimeMillis();
Print.Normal("上传图片所用总时长:" + String.valueOf(etime - stime) + "ms");
jsonObject.put("url", img.getImgurl());
jsonObject.put("name", imgname);
jsonObject.put("size", img.getSizes());
//启动鉴黄线程
new Thread(() -> {
LegalImageCheck(img);
}).start();
} else {
msg.setCode("5001");
msg.setInfo("上传服务内部错误");
return msg;
}
file.delete();
msg.setData(jsonObject);
// 新代码结束=========
return msg;
}catch (Exception e){
e.printStackTrace();
msg.setCode("5001");
msg.setInfo("Error for server:500");
return msg;
}
}
public static Group group; //上传用户或游客的所属分组
public static Long memory;//上传用户或者游客的分配容量 memory
public static Long TotleMemory;//用户或者游客下可使用的总容量 //maxsize
public static Long UsedTotleMemory;//用户或者游客已经用掉的总容量 //usermemory
public static String updatePath="tourist";
//判断用户 或 游客 当前上传图片的一系列校验
private Msg updateImgCheck(User user, UploadConfig uploadConfig){
final Msg msg = new Msg();
java.text.DateFormat dateFormat = null;
try {
dateFormat = new SimpleDateFormat("yyyy/MM/dd");
if (user == null) {
//用户没有登陆,值判断游客能不能上传即可
if(uploadConfig.getIsupdate()!=1){
msg.setCode("1000");
msg.setInfo("系统已禁用游客上传");
return msg;
}
group = GetCurrentSource.GetSource(null);
memory = Long.valueOf(uploadConfig.getVisitormemory());//单位 B 游客设置总量
TotleMemory = Long.valueOf(uploadConfig.getFilesizetourists());//单位 B 游客单文件大小
UsedTotleMemory = imgMapper.getusermemory(0)==null?0L : imgMapper.getusermemory(0);//单位 B
} else {
//判断用户能不能上传
if(uploadConfig.getUserclose()!=1){
msg.setCode("1001");
msg.setInfo("系统已禁用上传功能");
return msg;
}
updatePath = user.getUsername();
group= GetCurrentSource.GetSource(user.getId());
memory = Long.valueOf(user.getMemory())*1024*1024;//单位 B
TotleMemory = Long.valueOf(uploadConfig.getFilesizeuser());//单位 B
UsedTotleMemory = imgMapper.getusermemory(user.getId())==null?0L:imgMapper.getusermemory(user.getId());//单位 B
}
//判断上传的图片目录结构类型
if (uploadConfig.getUrltype() == 2) {
updatePath = dateFormat.format(new Date());
}
msg.setCode("300");
} catch (Exception e) {
e.printStackTrace();
msg.setCode("500");
}
return msg;
}
//图片鉴黄
private synchronized void LegalImageCheck(Images images){
System.out.println("非法图像鉴别进程启动");
Imgreview imgreview = null;
try {
imgreview = imgreviewMapper.selectByusing(1);
} catch (Exception e) {
Print.warning("获取鉴别程序的时候发生错误");
e.printStackTrace();
}
LegalImageCheckForBaiDu(imgreview,images);
}
private void LegalImageCheckForBaiDu(Imgreview imgreview,Images images){
if(imgreview.getUsing()==1){
try {
AipContentCensor client = new AipContentCensor(imgreview.getAppId(), imgreview.getApiKey(), imgreview.getSecretKey());
client.setConnectionTimeoutInMillis(5000);
client.setSocketTimeoutInMillis(30000);
org.json.JSONObject res = client.antiPorn(images.getImgurl());
res = client.imageCensorUserDefined(images.getImgurl(), EImgType.URL, null);
com.alibaba.fastjson.JSONArray jsonArray = JSON.parseArray("[" + res.toString() + "]");
for (Object o : jsonArray) {
JSONObject jsonObject = (JSONObject) o;
com.alibaba.fastjson.JSONArray data = jsonObject.getJSONArray("data");
Integer conclusionType = jsonObject.getInteger("conclusionType");
if(conclusionType!=null){
if (conclusionType == 2) {
for (Object datum : data) {
JSONObject imgdata = (JSONObject) datum;
if (imgdata.getInteger("type") == 1) {
Images img = new Images();
img.setImgname(images.getImgname());
img.setViolation("1[1]");//数字是鉴别平台的主键ID,括号是非法的类型,参考上面的注释
imgMapper.setImg(img);
Imgreview imgv = new Imgreview();
imgv.setId(1);
Integer count = imgreview.getCount();
System.out.println("违法图片总数:" + count);
imgv.setCount(count + 1);
imgreviewMapper.updateByPrimaryKeySelective(imgv);
System.err.println("存在非法图片,进行处理操作");
}
}
}
}
}
}catch (Exception e){
System.out.println("图像鉴黄线程执行过程中出现异常");
e.printStackTrace();
}
}
}
}
@@ -39,7 +39,6 @@ public class FTPImageupload {
if (flag) {
boolean isUpload = ftps.upload(file, "/" + userkey, "");
if(isUpload){
returnImage.setUid(ShortUID);
returnImage.setImgname(userkey);
returnImage.setImgurl(key.getRequestAddress() + "/"+ userkey);
returnImage.setImgSize(entry.getValue().length());
@@ -10,7 +10,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author Tiansh
* @author Hellohao
* @version 1.0
* @date 2019/12/19 15:40
*/
@@ -211,8 +211,8 @@ public class ImgServiceImpl implements ImgService {
}
@Override
public Integer md5Count(String md5key) {
return imgMapper.md5Count(md5key);
public Integer md5Count(Images images) {
return imgMapper.md5Count(images);
}
@Override
@@ -244,4 +244,9 @@ public class ImgServiceImpl implements ImgService {
return imgMapper.countByM(images);
}
@Override
public Images selectImgUrlByImgUID(String imguid) {
return imgMapper.selectImgUrlByImgUID(imguid);
}
}
@@ -58,7 +58,6 @@ public class KODOImageupload {
try {
Response response = uploadManager.put(file,username + "/" + ShortUID + "." + entry.getKey(),upToken);
DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
returnImage.setUid(ShortUID);
returnImage.setImgname(username + "/" + ShortUID + "." + entry.getKey());
returnImage.setImgurl(key.getRequestAddress() + "/" + username + "/" + ShortUID + "." + entry.getKey());
returnImage.setImgSize(entry.getValue().length());
@@ -35,7 +35,6 @@ public class NOSImageupload {
String ShortUID = SetText.getShortUuid();
file = entry.getValue();
nosClient.putObject(key.getBucketname(), username + "/" + ShortUID+ "." + entry.getKey(), file);
returnImage.setUid(ShortUID);
returnImage.setImgname(username + "/" + ShortUID+ "." + entry.getKey());
returnImage.setImgurl(key.getRequestAddress() + "/" + username + "/" + ShortUID + "." + entry.getKey());
returnImage.setImgSize(entry.getValue().length());
@@ -30,7 +30,6 @@ public class OSSImageupload {
file = entry.getValue();
System.out.println("待上传的图片:"+username + "/" + ShortUID + "." + entry.getKey());
ossClient.putObject(key.getBucketname(), username + "/" + ShortUID + "." + entry.getKey(),file);
returnImage.setUid(ShortUID);
returnImage.setImgname(username + "/" + ShortUID + "." + entry.getKey());//entry.getValue().getOriginalFilename()
returnImage.setImgurl(key.getRequestAddress() + "/" + username + "/" + ShortUID + "." + entry.getKey());
returnImage.setImgSize(file.length());
@@ -29,7 +29,6 @@ public class UFileImageupload {
uFile.setContentMD5(UpYun.md5(file));
boolean result = uFile.writeFile(username + "/" + ShortUID + "." + entry.getKey(), file, true);
if(result){
returnImage.setUid(ShortUID);
returnImage.setImgname(username + "/" + ShortUID + "." + entry.getKey());
returnImage.setImgurl(key.getRequestAddress() + "/" +username + "/" + ShortUID + "." + entry.getKey());
returnImage.setImgSize(entry.getValue().length());
@@ -32,7 +32,6 @@ public class USSImageupload {
upyun.setContentMD5(UpYun.md5(file));
boolean result = upyun.writeFile(username + "/" + ShortUID + "." + entry.getKey(), file, true);
if(result){
returnImage.setUid(ShortUID);
returnImage.setImgname(username + "/" + ShortUID + "." + entry.getKey());
returnImage.setImgurl(key.getRequestAddress() + "/" +username + "/" + ShortUID + "." + entry.getKey());
returnImage.setImgSize(entry.getValue().length());
@@ -120,6 +120,24 @@ public class UploadServicel {
if(md5key==null || md5key.equals("")){
md5key = UUID.randomUUID().toString().replace("-", "");
}
//判断图片是否存在
if(Integer.valueOf(sysConfigService.getstate().getCheckduplicate())==1){
Images imaOBJ = new Images();
imaOBJ.setMd5key(md5key);
imaOBJ.setUserid(u==null?0:u.getId());
if(imgMapper.md5Count(imaOBJ)>0){
Images images = imgMapper.selectImgUrlByMD5(md5key);
jsonObject.put("url", images.getImgurl());
jsonObject.put("name",file.getName());
jsonObject.put("imguid",images.getImguid());
// jsonObject.put("shortLink",images.getShortlink());
msg.setData(jsonObject);
return msg;
}
}
String prefix = file.getName().substring(file.getName().lastIndexOf(".")+1);
//判断黑名单
if (uploadConfig.getBlacklist() != null) {
@@ -170,17 +188,14 @@ public class UploadServicel {
img.setMd5key(md5key);
img.setImguid(imguid);
img.setFormat(fileMiME.getData().toString());
img.setShortlink(returnImage.getUid());
userMapper.insertimg(img);
long etime = System.currentTimeMillis();
Print.Normal("上传图片所用总时长:" + String.valueOf(etime - stime) + "ms");
jsonObject.put("url", img.getImgurl());
jsonObject.put("name", imgname);
jsonObject.put("imguid",img.getImguid());
jsonObject.put("shortLink", img.getShortlink());
//启动鉴黄线程
// jsonObject.put("shortLink", img.getShortlink());
new Thread(()->{LegalImageCheck(img);}).start();
}else{
msg.setCode("5001");
msg.setInfo("上传服务内部错误");
@@ -266,13 +281,18 @@ public class UploadServicel {
TotleMemory = Long.valueOf(uploadConfig.getFilesizetourists());//单位 B 游客单文件大小
UsedTotleMemory = imgMapper.getusermemory(0)==null?0L : imgMapper.getusermemory(0);//单位 B
} else {
//判断用户能不能上传
if(uploadConfig.getUserclose()!=1){
msg.setCode("1001");
msg.setInfo("系统已禁用上传功能");
return msg;
}
updatePath = user.getUsername();
group= GetCurrentSource.GetSource(user.getId());
memory = Long.valueOf(user.getMemory())*1024*1024;//单位 B
TotleMemory = Long.valueOf(uploadConfig.getFilesizeuser());//单位 B
UsedTotleMemory = imgMapper.getusermemory(user.getId())==null?0L:imgMapper.getusermemory(user.getId());//单位 B
}
//判断上传的图片目录结构类型
if (uploadConfig.getUrltype() == 2) {
updatePath = dateFormat.format(new Date());
}
@@ -293,7 +313,6 @@ public class UploadServicel {
Print.warning("获取鉴别程序的时候发生错误");
e.printStackTrace();
}
//判断哪个鉴别平台
if(null != imgreview){
LegalImageCheckForBaiDu(imgreview,images);
}
@@ -302,7 +321,6 @@ public class UploadServicel {
private void LegalImageCheckForBaiDu(Imgreview imgreview,Images images){
System.out.println("非法图像鉴别进程启动-BaiDu");
// Imgreview imgreview = imgreviewService.selectByPrimaryKey(1);
if(imgreview.getUsing()==1){
try {
AipContentCensor client = new AipContentCensor(imgreview.getAppId(), imgreview.getApiKey(), imgreview.getSecretKey());
@@ -312,24 +330,19 @@ public class UploadServicel {
res = client.imageCensorUserDefined(images.getImgurl(), EImgType.URL, null);
System.err.println("返回的鉴黄json:"+res.toString());
com.alibaba.fastjson.JSONArray jsonArray = JSON.parseArray("[" + res.toString() + "]");
for (Object o : jsonArray) {
com.alibaba.fastjson.JSONObject jsonObject = (com.alibaba.fastjson.JSONObject) o;
com.alibaba.fastjson.JSONArray data = jsonObject.getJSONArray("data");
Integer conclusionType = jsonObject.getInteger("conclusionType");
if(conclusionType!=null){
if (conclusionType == 2) {
//1:合规,2:不合规,3:疑似,4:审核失败
for (Object datum : data) {
com.alibaba.fastjson.JSONObject imgdata = (com.alibaba.fastjson.JSONObject) datum;
if (imgdata.getInteger("type") == 1) {
//type参数 0:百度官方违禁图库、1:色情识别、2:暴恐识别、3:恶心图识别、4:广告检测、5:政治敏感识别、6:图像质量检测、7:用户图像黑名单、8:用户图像白名单、10:用户头像审核、11:百度官方违禁词库、12:图文审核、13:自定义文本黑名单、14:自定义文本白名单、15:EasyDL自定义模型、16:敏感旗帜标志识别、21:不良场景识别、24:直播场景审核
//存在非法图片,进行处理操作
Images img = new Images();
img.setImgname(images.getImgname());
img.setViolation("1[1]");//数字是鉴别平台的主键ID,括号是非法的类型,参考上面的注释
img.setViolation("1[1]");
imgMapper.setImg(img);
//计入总数
Imgreview imgv = new Imgreview();
imgv.setId(1);
Integer count = imgreview.getCount();
@@ -50,7 +50,6 @@ public class LocUpdateImg {
}
bos.flush();
bos.close();
returnImage.setUid(ShortUID);
returnImage.setImgname(username + "/" +ShortUID + "." + entry.getKey());//entry.getValue().getOriginalFilename()
returnImage.setImgurl(key.getRequestAddress() +"/ota/"+username + "/" + ShortUID + "." + entry.getKey());
returnImage.setImgSize(entry.getValue().length());
@@ -9,7 +9,6 @@ import com.mitchellbosecke.pebble.PebbleEngine;
import com.mitchellbosecke.pebble.template.PebbleTemplate;
import io.github.biezhi.ome.OhMyEmail;
import org.springframework.core.io.ClassPathResource;
import java.io.StringWriter;
import java.io.Writer;
import java.util.HashMap;
@@ -19,16 +18,6 @@ import java.util.UUID;
public class NewSendEmail {
public static void initialEmail(EmailConfig emailConfig) {
// Properties p = new Properties();
// p.setProperty("mail.smtp.auth", "true");
// p.setProperty("mail.smtp.host", emailConfig.getEmailurl());
// p.setProperty("mail.smtp.port", emailConfig.getPort());
// p.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
}
public static Integer sendEmail(EmailConfig emailConfig, String username, String uid, String toEmail, Config config) {
Properties props = new Properties();
@@ -114,7 +103,6 @@ public class NewSendEmail {
// 配置一次即可,可以配置为静态方法
// OhMyEmail.config(OhMyEmail.SMTP_QQ(false), "xxxx@qq.com", "your@password");
OhMyEmail.config(props, emailConfig.getEmails(), emailConfig.getEmailkey());
String webname=config.getWebname();
String domain = config.getDomain();
String new_pass = UUID.randomUUID().toString().replace("-", "").toLowerCase().substring(0,10);
@@ -144,28 +132,5 @@ public class NewSendEmail {
}
public static void main(String[] args)throws Exception {
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.ssl.enable", "true");
props.put("mail.debug", "false");
props.put("mail.transport.protocol", "smtp");
props.put("mail.debug", "false");
props.put("mail.smtp.timeout", "20000");
props.put("mail.smtp.port", "25");//465 25
props.put("mail.smtp.host", "smtpdm.aliyun.com");
// 配置一次即可,可以配置为静态方法
// OhMyEmail.config(OhMyEmail.SMTP_QQ(false), "xxxx@qq.com", "your@password");
OhMyEmail.config(props, "hellohao@wwery.com", "TianShiHao1995");
OhMyEmail.subject("账号激活邮件测试")
.from("hahhaha")
.to("923453645@qq.com")
.html("<a href='http://www.hellohao.cn'>hellohao</a>")
.send();
}
}