From 7906948ab7fbd301cffacf18a4cb5bf619c21085 Mon Sep 17 00:00:00 2001 From: hello-hao <923453645@qq.com> Date: Wed, 21 Jun 2023 19:04:59 +0800 Subject: [PATCH] =?UTF-8?q?update:=E4=BC=98=E5=8C=96=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E4=BA=86=E5=A4=9A=E4=B8=AA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/hellohao/auth/shiro/UserRealm.java | 7 +- .../hellohao/controller/AdminController.java | 12 +- .../hellohao/controller/UserController.java | 18 +- src/main/java/cn/hellohao/pojo/Images.java | 644 +++++++++--------- src/main/java/cn/hellohao/utils/SetText.java | 2 +- src/main/resources/application.properties | 8 +- src/main/resources/mapper/ImgMapper.xml | 32 +- src/main/resources/mapper/UserMapper.xml | 3 + 8 files changed, 394 insertions(+), 332 deletions(-) diff --git a/src/main/java/cn/hellohao/auth/shiro/UserRealm.java b/src/main/java/cn/hellohao/auth/shiro/UserRealm.java index 5bfb3e4..1b1e7b0 100644 --- a/src/main/java/cn/hellohao/auth/shiro/UserRealm.java +++ b/src/main/java/cn/hellohao/auth/shiro/UserRealm.java @@ -2,6 +2,7 @@ package cn.hellohao.auth.shiro; import cn.hellohao.pojo.User; import cn.hellohao.service.UserService; +import cn.hellohao.utils.SetText; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authc.*; import org.apache.shiro.authz.AuthorizationInfo; @@ -46,7 +47,11 @@ public class UserRealm extends AuthorizingRealm { UsernamePasswordToken userToken = null; userToken = (UsernamePasswordToken)tokenOBJ; User user = new User(); - user.setEmail(userToken.getUsername()); + if(SetText.checkEmail(userToken.getUsername())){ + user.setEmail(userToken.getUsername()); + }else{ + user.setUsername(userToken.getUsername()); + } User u = userService.getUsers(user); if(u==null){ return null; diff --git a/src/main/java/cn/hellohao/controller/AdminController.java b/src/main/java/cn/hellohao/controller/AdminController.java index c948866..63317f3 100644 --- a/src/main/java/cn/hellohao/controller/AdminController.java +++ b/src/main/java/cn/hellohao/controller/AdminController.java @@ -313,6 +313,7 @@ public class AdminController { String starttime = jsonObj.getString("starttime"); String stoptime = jsonObj.getString("stoptime"); String selectUserType = jsonObj.getString("selectUserType"); // me/all + String order = jsonObj.getString("order"); String username = jsonObj.getString("username"); String searchname = jsonObj.getString("searchname"); Integer selecttype = jsonObj.getInteger("selecttype"); @@ -359,6 +360,7 @@ public class AdminController { if(!StringUtils.isBlank(searchname)){ img.setSearchname(searchname); } + img.setOrder(StringUtils.isBlank(order)?"desc":order); List images = imgService.selectimg(img); PageInfo rolePageInfo = new PageInfo<>(images); PageResultBean pageResultBean = @@ -407,9 +409,15 @@ public class AdminController { return msg; } String regex = "^\\w+$"; - if (username.length() > 20 || !username.matches(regex)) { + if (username.length() > 30) { msg.setCode("110403"); - msg.setInfo("用户名不得超过20位字符"); + msg.setInfo("用户名不得超过30位字符"); + return msg; + } + if(!username.matches (regex)){ + //用户名格式不正确 + msg.setCode("110403"); + msg.setInfo("用户名不得含有特殊字符"); return msg; } if (subject.hasRole("admin")) { diff --git a/src/main/java/cn/hellohao/controller/UserController.java b/src/main/java/cn/hellohao/controller/UserController.java index 3e22dc7..27d1331 100644 --- a/src/main/java/cn/hellohao/controller/UserController.java +++ b/src/main/java/cn/hellohao/controller/UserController.java @@ -62,10 +62,16 @@ public class UserController { return msg; } String regex = "^\\w+$"; - if(username.length()>20 || !username.matches (regex)){ + if(username.length()>30){ //用户名格式不正确 msg.setCode("110403"); - msg.setInfo("用户名不得超过20位字符"); + msg.setInfo("用户名不得超过30位字符"); + return msg; + } + if(!username.matches (regex)){ + //用户名格式不正确 + msg.setCode("110403"); + msg.setInfo("用户名不得含有特殊字符"); return msg; } if(null==redis_verifyCodeForRegister){ @@ -198,15 +204,15 @@ public class UserController { } catch (UnknownAccountException e) { //此异常说明用户名不存在 msg.setCode("4000"); - msg.setInfo("登录邮箱不存在"); - System.err.println("邮箱不存在"); - e.printStackTrace(); + msg.setInfo("登录账号不存在"); + System.err.println("邮箱/用户名不存在"); +// e.printStackTrace(); return msg; }catch (IncorrectCredentialsException e) { msg.setCode("4000"); msg.setInfo("登录密码错误"); System.err.println("密码不存在"); - e.printStackTrace(); +// e.printStackTrace(); return msg; }catch (Exception e) { msg.setCode("5000"); diff --git a/src/main/java/cn/hellohao/pojo/Images.java b/src/main/java/cn/hellohao/pojo/Images.java index 451ef6e..9d80805 100644 --- a/src/main/java/cn/hellohao/pojo/Images.java +++ b/src/main/java/cn/hellohao/pojo/Images.java @@ -1,5 +1,8 @@ package cn.hellohao.pojo; +import lombok.Data; + +@Data public class Images { // 默认的时间字符串格式 @@ -38,326 +41,327 @@ public class Images { private String idname; private Integer isRepeat;//如果没有开启查重的时候他是0,开启为1 private String searchname; - - public Images() { - super(); - } - - 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; - this.updatetime = updatetime; - this.username = username; - this.md5key = md5key; - this.imguid = imguid; - } - - public Images(Long 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 format,String about,Integer great,String[] classifuidlist,String classificationuid,String violation, - String idname,Integer isRepeat,String searchname) { - this.id = id; - this.imgname = imgname; - this.imgurl = imgurl; - this.userid = userid; - this.sizes = sizes; - this.abnormal = abnormal; - this.source = source; - this.imgtype = imgtype; - this.updatetime = updatetime; - this.username = username; - this.storageType = storageType; - this.starttime = starttime; - this.stoptime = stoptime; - this.explains = explains; - this.md5key = md5key; - this.notes = notes; - this.useridlist = useridlist; - this.imguid = imguid; - this.albumtitle = albumtitle; - this.password = password; - this.selecttype = selecttype; - this.countNum = countNum; - this.monthNum = monthNum; - this.yyyy = yyyy; - this.format = format; - this.about = about; - this.great = great; - this.classifuidlist = classifuidlist; - this.classificationuid = classificationuid; - this.violation = violation; - this.idname = idname; - this.isRepeat = isRepeat; - this.searchname = searchname; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getImgname() { - return imgname; - } - - public void setImgname(String imgname) { - this.imgname = imgname; - } - - public String getImgurl() { - return imgurl; - } - - public void setImgurl(String imgurl) { - this.imgurl = imgurl; - } - - public Integer getUserid() { - return userid; - } - - public void setUserid(Integer userid) { - this.userid = userid; - } - - public String getSizes() { - return sizes; - } - - public void setSizes(String sizes) { - this.sizes = sizes; - } - - public String getAbnormal() { - return abnormal; - } - - public void setAbnormal(String abnormal) { - this.abnormal = abnormal; - } - - public Integer getSource() { - return source; - } - - public void setSource(Integer source) { - this.source = source; - } - - public Integer getImgtype() { - return imgtype; - } - - public void setImgtype(Integer imgtype) { - this.imgtype = imgtype; - } - - public String getUpdatetime() { - return updatetime; - } - - public void setUpdatetime(String updatetime) { - this.updatetime = updatetime; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public Integer getStorageType() { - return storageType; - } - - public void setStorageType(Integer storageType) { - this.storageType = storageType; - } - - public String getStarttime() { - return starttime; - } - - public void setStarttime(String starttime) { - this.starttime = starttime; - } - - public String getStoptime() { - return stoptime; - } - - public void setStoptime(String stoptime) { - this.stoptime = stoptime; - } - - public String getExplains() { - return explains; - } - - public void setExplains(String explains) { - this.explains = explains; - } - - public String getMd5key() { - return md5key; - } - - public void setMd5key(String md5key) { - this.md5key = md5key; - } - - public String getNotes() { - return notes; - } - - public void setNotes(String notes) { - this.notes = notes; - } - - public String getUseridlist() { - return useridlist; - } - - public void setUseridlist(String useridlist) { - this.useridlist = useridlist; - } - - public String getImguid() { - return imguid; - } - - public void setImguid(String imguid) { - this.imguid = imguid; - } - - - public String getAlbumtitle() { - return albumtitle; - } - - public void setAlbumtitle(String albumtitle) { - this.albumtitle = albumtitle; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public Integer getSelecttype() { - return selecttype; - } - - public void setSelecttype(Integer selecttype) { - this.selecttype = selecttype; - } - - public Long getCountNum() { - return countNum; - } - - public void setCountNum(Long countNum) { - this.countNum = countNum; - } - - public Integer getMonthNum() { - return monthNum; - } - - public void setMonthNum(Integer monthNum) { - this.monthNum = monthNum; - } - - public String getYyyy() { - return yyyy; - } - - public void setYyyy(String yyyy) { - this.yyyy = yyyy; - } - - public String getFormat() { - return format; - } - - public void setFormat(String format) { - this.format = format; - } - - public String getAbout() { - return about; - } - - public void setAbout(String about) { - this.about = about; - } - - public Integer getGreat() { - return great; - } - - public void setGreat(Integer great) { - this.great = great; - } - - public String[] getClassifuidlist() { - return classifuidlist; - } - - public void setClassifuidlist(String[] classifuidlist ) { - this.classifuidlist = classifuidlist; - } - - public String getClassificationuid() { - return classificationuid; - } - - public void setClassificationuid(String classificationuid) { - this.classificationuid = classificationuid; - } - - public String getViolation() { - return violation; - } - - public void setViolation(String violation) { - this.violation = violation; - } - - public String getIdname() { - return idname; - } - - public void setIdname(String idname) { - this.idname = idname; - } - - public Integer getIsRepeat() { - return isRepeat; - } - - public void setIsRepeat(Integer isRepeat) { - this.isRepeat = isRepeat; - } - - public String getSearchname() { - return searchname; - } - - public void setSearchname(String searchname) { - this.searchname = searchname; - } + private String order; +// +// public Images() { +// super(); +// } +// +// 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; +// this.updatetime = updatetime; +// this.username = username; +// this.md5key = md5key; +// this.imguid = imguid; +// } +// +// public Images(Long 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 format,String about,Integer great,String[] classifuidlist,String classificationuid,String violation, +// String idname,Integer isRepeat,String searchname) { +// this.id = id; +// this.imgname = imgname; +// this.imgurl = imgurl; +// this.userid = userid; +// this.sizes = sizes; +// this.abnormal = abnormal; +// this.source = source; +// this.imgtype = imgtype; +// this.updatetime = updatetime; +// this.username = username; +// this.storageType = storageType; +// this.starttime = starttime; +// this.stoptime = stoptime; +// this.explains = explains; +// this.md5key = md5key; +// this.notes = notes; +// this.useridlist = useridlist; +// this.imguid = imguid; +// this.albumtitle = albumtitle; +// this.password = password; +// this.selecttype = selecttype; +// this.countNum = countNum; +// this.monthNum = monthNum; +// this.yyyy = yyyy; +// this.format = format; +// this.about = about; +// this.great = great; +// this.classifuidlist = classifuidlist; +// this.classificationuid = classificationuid; +// this.violation = violation; +// this.idname = idname; +// this.isRepeat = isRepeat; +// this.searchname = searchname; +// } +// +// public Long getId() { +// return id; +// } +// +// public void setId(Long id) { +// this.id = id; +// } +// +// public String getImgname() { +// return imgname; +// } +// +// public void setImgname(String imgname) { +// this.imgname = imgname; +// } +// +// public String getImgurl() { +// return imgurl; +// } +// +// public void setImgurl(String imgurl) { +// this.imgurl = imgurl; +// } +// +// public Integer getUserid() { +// return userid; +// } +// +// public void setUserid(Integer userid) { +// this.userid = userid; +// } +// +// public String getSizes() { +// return sizes; +// } +// +// public void setSizes(String sizes) { +// this.sizes = sizes; +// } +// +// public String getAbnormal() { +// return abnormal; +// } +// +// public void setAbnormal(String abnormal) { +// this.abnormal = abnormal; +// } +// +// public Integer getSource() { +// return source; +// } +// +// public void setSource(Integer source) { +// this.source = source; +// } +// +// public Integer getImgtype() { +// return imgtype; +// } +// +// public void setImgtype(Integer imgtype) { +// this.imgtype = imgtype; +// } +// +// public String getUpdatetime() { +// return updatetime; +// } +// +// public void setUpdatetime(String updatetime) { +// this.updatetime = updatetime; +// } +// +// public String getUsername() { +// return username; +// } +// +// public void setUsername(String username) { +// this.username = username; +// } +// +// public Integer getStorageType() { +// return storageType; +// } +// +// public void setStorageType(Integer storageType) { +// this.storageType = storageType; +// } +// +// public String getStarttime() { +// return starttime; +// } +// +// public void setStarttime(String starttime) { +// this.starttime = starttime; +// } +// +// public String getStoptime() { +// return stoptime; +// } +// +// public void setStoptime(String stoptime) { +// this.stoptime = stoptime; +// } +// +// public String getExplains() { +// return explains; +// } +// +// public void setExplains(String explains) { +// this.explains = explains; +// } +// +// public String getMd5key() { +// return md5key; +// } +// +// public void setMd5key(String md5key) { +// this.md5key = md5key; +// } +// +// public String getNotes() { +// return notes; +// } +// +// public void setNotes(String notes) { +// this.notes = notes; +// } +// +// public String getUseridlist() { +// return useridlist; +// } +// +// public void setUseridlist(String useridlist) { +// this.useridlist = useridlist; +// } +// +// public String getImguid() { +// return imguid; +// } +// +// public void setImguid(String imguid) { +// this.imguid = imguid; +// } +// +// +// public String getAlbumtitle() { +// return albumtitle; +// } +// +// public void setAlbumtitle(String albumtitle) { +// this.albumtitle = albumtitle; +// } +// +// public String getPassword() { +// return password; +// } +// +// public void setPassword(String password) { +// this.password = password; +// } +// +// public Integer getSelecttype() { +// return selecttype; +// } +// +// public void setSelecttype(Integer selecttype) { +// this.selecttype = selecttype; +// } +// +// public Long getCountNum() { +// return countNum; +// } +// +// public void setCountNum(Long countNum) { +// this.countNum = countNum; +// } +// +// public Integer getMonthNum() { +// return monthNum; +// } +// +// public void setMonthNum(Integer monthNum) { +// this.monthNum = monthNum; +// } +// +// public String getYyyy() { +// return yyyy; +// } +// +// public void setYyyy(String yyyy) { +// this.yyyy = yyyy; +// } +// +// public String getFormat() { +// return format; +// } +// +// public void setFormat(String format) { +// this.format = format; +// } +// +// public String getAbout() { +// return about; +// } +// +// public void setAbout(String about) { +// this.about = about; +// } +// +// public Integer getGreat() { +// return great; +// } +// +// public void setGreat(Integer great) { +// this.great = great; +// } +// +// public String[] getClassifuidlist() { +// return classifuidlist; +// } +// +// public void setClassifuidlist(String[] classifuidlist ) { +// this.classifuidlist = classifuidlist; +// } +// +// public String getClassificationuid() { +// return classificationuid; +// } +// +// public void setClassificationuid(String classificationuid) { +// this.classificationuid = classificationuid; +// } +// +// public String getViolation() { +// return violation; +// } +// +// public void setViolation(String violation) { +// this.violation = violation; +// } +// +// public String getIdname() { +// return idname; +// } +// +// public void setIdname(String idname) { +// this.idname = idname; +// } +// +// public Integer getIsRepeat() { +// return isRepeat; +// } +// +// public void setIsRepeat(Integer isRepeat) { +// this.isRepeat = isRepeat; +// } +// +// public String getSearchname() { +// return searchname; +// } +// +// public void setSearchname(String searchname) { +// this.searchname = searchname; +// } } diff --git a/src/main/java/cn/hellohao/utils/SetText.java b/src/main/java/cn/hellohao/utils/SetText.java index 1a89d3f..4a78334 100644 --- a/src/main/java/cn/hellohao/utils/SetText.java +++ b/src/main/java/cn/hellohao/utils/SetText.java @@ -57,6 +57,7 @@ public class SetText { boolean flag = false; try { String check = "^\\w+@[a-zA-Z0-9]{2,10}(?:\\.[a-z]{2,4}){1,3}$"; +// String regex = "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"; //这个也可以用 Pattern regex = Pattern.compile(check); Matcher matcher = regex.matcher(email); flag = matcher.matches(); @@ -66,6 +67,5 @@ public class SetText { return flag; } - } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 5051862..a2d6677 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -49,4 +49,10 @@ spring.datasource.druid.stat-view-servlet.login-password=52BNmXPJL0rQQ3CU spring.datasource.druid.stat-view-servlet.allow=127.0.0.1 spring.datasource.druid.web-stat-filter.exclusions=false #log4j.logger.cn.hellohao.dao=DEBUG -log4j2.formatMsgNoLookups=True \ No newline at end of file +log4j2.formatMsgNoLookups=True +logging.level.cn.hellohao=DEBUG +logging.file.name=/HellohaoData/tbedlog/tbed_core.log +logging.pattern.console=%blue(%d{yyyy-MM-dd HH:mm:ss,SSS}) [%cyan(%t)] [%yellow(%c)]-[%highlight(%p)] %msg%n +logging.pattern.file=%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n +logging.logback.rollingpolicy.clean-history-on-start=true +logging.logback.rollingpolicy.max-history=7 diff --git a/src/main/resources/mapper/ImgMapper.xml b/src/main/resources/mapper/ImgMapper.xml index 58a5424..4d1bcdb 100644 --- a/src/main/resources/mapper/ImgMapper.xml +++ b/src/main/resources/mapper/ImgMapper.xml @@ -76,7 +76,37 @@ and idname LIKE '%${idname}%' - order by a.id desc + order by + + + a.updatetime desc + + + a.updatetime asc + + + CONVERT(a.sizes,SIGNED) asc + + + CONVERT(a.sizes,SIGNED) desc + + + a.updatetime desc + + + + + + + + + + + + + + + diff --git a/src/main/resources/mapper/UserMapper.xml b/src/main/resources/mapper/UserMapper.xml index 7a290fc..46e5781 100644 --- a/src/main/resources/mapper/UserMapper.xml +++ b/src/main/resources/mapper/UserMapper.xml @@ -74,6 +74,9 @@ and email = #{email} + + and username = #{username} + and uid = #{uid}