From 501330a1f64082c545f0af545822637d6d7aeedd Mon Sep 17 00:00:00 2001 From: tamguo Date: Mon, 10 Dec 2018 18:09:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=9A=E5=91=98=E4=B8=AD=E5=BF=83=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tamguo/common/utils/SystemConstant.java | 21 +++- .../test/java/com/tamguo/PaperCrawler.java | 8 +- .../com/tamguo/web/AccountController.java | 16 +++ .../java/com/tamguo/web/EmailController.java | 34 ++++++ .../resources/static/css/member/account.css | 106 ++++++++++++++++++ .../static/js/password/securityCheck.js | 4 +- .../src/main/resources/templates/account.html | 97 ++++++++++++++++ .../main/resources/templates/book/edit.html | 4 +- .../templates/password/resetPassword.html | 18 +-- .../templates/password/resetPwSuccess.html | 16 +-- tamguo-modules-core/pom.xml | 5 + .../member/service/impl/MemberService.java | 5 +- .../modules/sys/service/IEmailService.java | 9 ++ .../sys/service/impl/EmailService.java | 37 ++++++ .../resources/mappers/sys/SysUserMapper.xml | 2 +- 15 files changed, 350 insertions(+), 32 deletions(-) create mode 100644 tamguo-mms/src/main/java/com/tamguo/web/AccountController.java create mode 100644 tamguo-mms/src/main/java/com/tamguo/web/EmailController.java create mode 100644 tamguo-mms/src/main/resources/static/css/member/account.css create mode 100644 tamguo-mms/src/main/resources/templates/account.html create mode 100644 tamguo-modules-core/src/main/java/com/tamguo/modules/sys/service/IEmailService.java create mode 100644 tamguo-modules-core/src/main/java/com/tamguo/modules/sys/service/impl/EmailService.java diff --git a/tamguo-common/src/main/java/com/tamguo/common/utils/SystemConstant.java b/tamguo-common/src/main/java/com/tamguo/common/utils/SystemConstant.java index cc9647e..5b28983 100644 --- a/tamguo-common/src/main/java/com/tamguo/common/utils/SystemConstant.java +++ b/tamguo-common/src/main/java/com/tamguo/common/utils/SystemConstant.java @@ -65,9 +65,6 @@ public class SystemConstant { /** 短信找回密码前缀*/ public static final String ALIYUN_MOBILE_SMS_PREFIX = "MOBILE_SMS_PREKEY_"; - /** 邮箱找回密码前缀*/ - public static final String ALIYUN_MAIL_FIND_PASSWORD_PREFIX = "EMAIL_FIND_PASSWORD_"; - /** 默认会员头像*/ public static final String DEFAULT_MEMBER_AVATAR = "/images/avatar.png"; @@ -85,4 +82,22 @@ public class SystemConstant { /** 所有地区*/ public static final String AREA_ALL_TREE = "AREAALL:"; + + /** ALIYUN*/ + public static final String ALIYUN_SMTP_HOST_NAME = "smtp.aliyun.com"; + + /** ALIYUN*/ + public static final int ALIYUN_SMTP_HOST_PORT = 465; + + /** ALIYUN*/ + public static final String ALIYUN_MAIL_ACCOUNT = "candy.tam@aliyun.com"; + + /** ALIYUN*/ + public static final String ALIYUN_MAIL_PASSWORD = "tanguo520pig"; + + /** 邮件主题*/ + public static final String ALIYUN_MAIL_SUBJECT_FINDPASSWORD = "探果网找回密码"; + + /** 邮箱找回密码前缀*/ + public static final String ALIYUN_MAIL_FIND_PASSWORD_PREFIX = "EMAIL_FIND_PASSWORD_"; } diff --git a/tamguo-crawler/src/test/java/com/tamguo/PaperCrawler.java b/tamguo-crawler/src/test/java/com/tamguo/PaperCrawler.java index a8381ed..09ee6a0 100644 --- a/tamguo-crawler/src/test/java/com/tamguo/PaperCrawler.java +++ b/tamguo-crawler/src/test/java/com/tamguo/PaperCrawler.java @@ -34,13 +34,13 @@ public class PaperCrawler { // 140000 山西 | 350000 福建 | 340000 安徽 | 220000 吉林 | 150000 内蒙古 | 640000 宁夏 | 650000 新疆 | 广西 450000 | 210000 辽宁 // 230000 黑龙江 | 610000 陕西 | 360000 江西 | 440000 广东 | 430000 湖南 | 460000 海南 | 530000 云南 | 510000 四川 | 630000 青海 // 620000 甘肃 | 130000 河北 | 540000 西藏 | 贵州 520000 - private final String AREA_ID = "450000"; + private final String AREA_ID = "230000"; // 年份 - private final String YEAR = "2017"; + private final String YEAR = "2016"; // 真题试卷 类型(1:真题试卷,2:模拟试卷,3:押题预测,4:名校精品) - private final String PAPER_TYPE = "2"; + private final String PAPER_TYPE = "4"; // 开始采集的URL - private final String START_URL = "https://tiku.baidu.com/tikupc/paperlist/1bfd700abb68a98271fefa04-20-4-2017-1111-1-download"; + private final String START_URL = "https://tiku.baidu.com/tikupc/paperlist/1bfd700abb68a98271fefa04-20-7-2016-1247-1-download"; private RunData runData; diff --git a/tamguo-mms/src/main/java/com/tamguo/web/AccountController.java b/tamguo-mms/src/main/java/com/tamguo/web/AccountController.java new file mode 100644 index 0000000..548af56 --- /dev/null +++ b/tamguo-mms/src/main/java/com/tamguo/web/AccountController.java @@ -0,0 +1,16 @@ +package com.tamguo.web; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.servlet.ModelAndView; + +@Controller +public class AccountController { + + @RequestMapping(value = {"account.html"}, method = RequestMethod.GET) + public ModelAndView list(ModelAndView model) { + model.setViewName("account"); + return model; + } +} diff --git a/tamguo-mms/src/main/java/com/tamguo/web/EmailController.java b/tamguo-mms/src/main/java/com/tamguo/web/EmailController.java new file mode 100644 index 0000000..fcbe63c --- /dev/null +++ b/tamguo-mms/src/main/java/com/tamguo/web/EmailController.java @@ -0,0 +1,34 @@ +package com.tamguo.web; + +import org.apache.commons.mail.EmailException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.tamguo.common.utils.Result; +import com.tamguo.common.utils.SystemConstant; +import com.tamguo.modules.sys.service.IEmailService; + +@Controller +public class EmailController { + + @Autowired + private IEmailService iEmailService; + + @RequestMapping(value = {"sendFindPasswordEmail"}, method = RequestMethod.GET) + @ResponseBody + public Result sendFindPasswordEmail(String email){ + try { + Integer result = iEmailService.sendFindPasswordEmail(email , SystemConstant.ALIYUN_MAIL_SUBJECT_FINDPASSWORD); + if(result == 0){ + return Result.result(200, null, "服务器异常"); + } + } catch (EmailException e) { + e.printStackTrace(); + } + return Result.result(500, null, "服务器异常"); + } + +} diff --git a/tamguo-mms/src/main/resources/static/css/member/account.css b/tamguo-mms/src/main/resources/static/css/member/account.css new file mode 100644 index 0000000..8d5b228 --- /dev/null +++ b/tamguo-mms/src/main/resources/static/css/member/account.css @@ -0,0 +1,106 @@ +@charset "utf-8"; +body { font-family: "Microsoft Yahei"; color: #333;background:#f5f5f6} +em, i { font-style: normal; } +.start{color: red} +.hide-text{ overflow: hidden;white-space: nowrap;text-overflow: ellipsis;} +.well{height: 10px;background: #f5f5f6;width: 340px;position: relative;left: -10px;} +.cnav { height: 98px; width: 100%; background: url(../../images/project-cnavbj.jpg) no-repeat; background-size: cover; } +.cnav_b { position: relative; } +.cnav_left { float: left; width: 162px; height: 54px; margin: 22px 0 0 46px; font-size: 18px; color: #fff; line-height: 54px; background: url(../../images/test-paper/top-kaos.png) no-repeat; padding-left: 55px; } +.cnav_right { float: left; width:728px; height: 5px; background: url(../../images/project-cnav.png) repeat-x; margin: 47px 0 0 0; } +.cnav_right ul { position: absolute; top: 30px; left: 230px; } +.cnav_right ul li { width: 120px; height: 50px; float: left; font-size: 14px; color: #fff; text-align: center; line-height: 12px; margin-left: 32px; } +.cnav_right ul li span { font-size: 12px; font-weight: bold; width: 27px; height: 27px; color: #29bdb9; display: block; margin: 5px auto 5px auto; text-align: center; line-height: 27px; background: url(../../images/project-candidate.png) no-repeat -26px 0; } +.cnavX { background: url(../../images/project-candidate.png) no-repeat -61px -39px; width: 17px; height: 17px; position: absolute; top: 12px; left: 1082px; cursor: pointer; } +.cnav_right ul li .Cnav_t { background: url(../../images/project-candidate.png) no-repeat -54px 0; width: 37px; height: 37px; line-height: 37px; margin: 0 auto; } +.contentBox{margin-top: 20px;font-size: 14px;overflow: hidden;} +.acphoto { + display: inline-block; + position: relative; + /*padding: 0 2em;*/ + border: none; + border-radius: 80px; + height: 80px; + width: 80px; + background: #eee; + color: #fff; + font-size: 14px; + line-height: 28px; + text-decoration: none; + cursor: pointer; + float: left; +} +.up_photo{ + display: inline-block; + position: relative; + padding: 0 2em; + /*border: none;*/ + border: 1px solid #29bdb9; + border-radius: 0px; + background: #29bdb9; + color: #fff; + font-size: 14px; + line-height: 28px; + text-decoration: none; + cursor: pointer; + margin-top: 15px; +} +.mybtn{ + float: left; + margin-left: 10px; + padding-top: 10px; +} +.contentBox{margin-top: 20px;font-size: 14px;overflow: hidden;} +.contentBox .navLeft{float: left;display: inline-block;width: 16.4%;background:rgb(41,186,185);} +.contentBox .navLeft dl{} +.contentBox .navLeft dl dt{height: 40px;line-height: 40px;background:rgb(37,172,169);padding-left: 10px;font-size: 14px;color:white;cursor: pointer; } +.icon-w{float: right;position: relative;top: 50%;transform: translateY(-50%);margin-right: 10px;} +.icon-f{margin-right: 10px;} +.contentBox .navLeft dl dd{text-align: center;;color: white;height: 40px;line-height: 40px;cursor: pointer; } +.contentBox .navLeft dl dd a{color: white} +.contentBox .newsRight{float: left;display: inline-block;width:83%;background:white;min-height: 279px;} +.user_list{padding: 0px;} +.info-cnt{padding-top:0px;background: #f5f5f6; } +.photoBox{display: none;} +.navLeft dl dd i {width: 17px;height: 14px;display: inline-block;background: url(../../images/icon-erro.png) no-repeat;margin: 0px 4px;position: relative;top: 1px;margin-left: 0px; +} +.icon-h { + font-size: 14px; + position: relative; + margin-right: 10px; +} +.acm-container{/*position: relative;top: -20px;*/padding-bottom: 200px;} +.info-cnt { + padding-top:0px; + padding-bottom:0px; + +} +.footer{margin-top: 0px!important;} +.headlogotable{float: right;} +.info-rBox{padding-bottom: 40px!important;} +.navLeft .list a dd:hover{background:#52cdc8} +.contentBox .navLeft dl dt:hover{background:#52cdc8 } +.head .logo { + padding-top: 0px; + float: left; + display: -webkit-box; + line-height: 59px; +} + .head .logo a{ + max-width: 120px; + height: 55px; + line-height: 55px; + text-align: center; + display: block; + } + .head .logo img{ + float: none; + max-width: 100%; + max-height: 100% + } + .head .logo p { + float: none; + line-height: 59px; + padding-left: 12px; +} +.weixinPng:hover img:nth-child(2){display: block} \ No newline at end of file diff --git a/tamguo-mms/src/main/resources/static/js/password/securityCheck.js b/tamguo-mms/src/main/resources/static/js/password/securityCheck.js index dc9bd9c..8f4bffe 100644 --- a/tamguo-mms/src/main/resources/static/js/password/securityCheck.js +++ b/tamguo-mms/src/main/resources/static/js/password/securityCheck.js @@ -31,7 +31,7 @@ $(function(){ // 发送短信 $.ajax({ type : "get", - url : mainHttp + "sms/sendFindPasswordSms.html", + url : mainHttp + "sendFindPasswordSms", async : false, data:{mobile:$("input[name='mobile']").val()}, dataType : "json", @@ -43,7 +43,7 @@ $(function(){ // 发送邮件 $.ajax({ type : "get", - url : mainHttp + "email/sendFindPasswordEmail.html", + url : mainHttp + "sendFindPasswordEmail", async : false, data:{email:$("input[name='email']").val()}, dataType : "json", diff --git a/tamguo-mms/src/main/resources/templates/account.html b/tamguo-mms/src/main/resources/templates/account.html new file mode 100644 index 0000000..0d432e8 --- /dev/null +++ b/tamguo-mms/src/main/resources/templates/account.html @@ -0,0 +1,97 @@ + + + + + 个人信息 - 探果网 + + + + + + + + + + + +
+
+ + +
+
+ tamguo + 退出 +
+
+
+
+ + + +
+ +
+ +
+ + + + + + + + \ No newline at end of file diff --git a/tamguo-mms/src/main/resources/templates/book/edit.html b/tamguo-mms/src/main/resources/templates/book/edit.html index bd479d4..82b0f93 100644 --- a/tamguo-mms/src/main/resources/templates/book/edit.html +++ b/tamguo-mms/src/main/resources/templates/book/edit.html @@ -162,7 +162,7 @@
- +
@@ -362,7 +362,7 @@
- +
diff --git a/tamguo-mms/src/main/resources/templates/password/resetPassword.html b/tamguo-mms/src/main/resources/templates/password/resetPassword.html index c60d917..96cd7a9 100644 --- a/tamguo-mms/src/main/resources/templates/password/resetPassword.html +++ b/tamguo-mms/src/main/resources/templates/password/resetPassword.html @@ -5,23 +5,23 @@ 找回密码_探果网 - - - + + +
@@ -41,7 +41,7 @@

您正在找回的帐号是:喜欢吃鱼的果果

-
+
@@ -85,6 +85,6 @@
- - + + \ No newline at end of file diff --git a/tamguo-mms/src/main/resources/templates/password/resetPwSuccess.html b/tamguo-mms/src/main/resources/templates/password/resetPwSuccess.html index 1875239..480166a 100644 --- a/tamguo-mms/src/main/resources/templates/password/resetPwSuccess.html +++ b/tamguo-mms/src/main/resources/templates/password/resetPwSuccess.html @@ -5,23 +5,23 @@ 修改密码_探果网 - - - + + +
@@ -42,9 +42,9 @@
- + 恭喜,探果帐号喜欢吃鱼的果果重置密码成功 - 直接登录 + 直接登录
以下为您最近2次的操作记录,请仔细检查手机及邮箱,如非本人所有,可通过帐号申诉更换。 diff --git a/tamguo-modules-core/pom.xml b/tamguo-modules-core/pom.xml index d423e39..d42f307 100644 --- a/tamguo-modules-core/pom.xml +++ b/tamguo-modules-core/pom.xml @@ -62,6 +62,11 @@ shiro-ehcache 1.2.5 + + org.apache.commons + commons-email + 1.5 + diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/member/service/impl/MemberService.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/member/service/impl/MemberService.java index 99ceaef..438a5c8 100644 --- a/tamguo-modules-core/src/main/java/com/tamguo/modules/member/service/impl/MemberService.java +++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/member/service/impl/MemberService.java @@ -210,12 +210,11 @@ public class MemberService extends ServiceImpl imple return memberMapper.selectById(uid); } + @SuppressWarnings("unchecked") @Transactional(readOnly=true) @Override public MemberEntity findByUsername(String username) { - MemberEntity condition = new MemberEntity(); - condition.setUsername(username); - return memberMapper.selectOne(condition); + return this.selectOne(Condition.create().eq("username", username).or().eq("mobile", username).or().eq("email", username)); } @Transactional(readOnly=false) diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/service/IEmailService.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/service/IEmailService.java new file mode 100644 index 0000000..297ea7e --- /dev/null +++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/service/IEmailService.java @@ -0,0 +1,9 @@ +package com.tamguo.modules.sys.service; + +import org.apache.commons.mail.EmailException; + +public interface IEmailService { + + public Integer sendFindPasswordEmail(String email , String subject) throws EmailException; + +} diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/service/impl/EmailService.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/service/impl/EmailService.java new file mode 100644 index 0000000..1b2d232 --- /dev/null +++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/service/impl/EmailService.java @@ -0,0 +1,37 @@ +package com.tamguo.modules.sys.service.impl; + +import org.apache.commons.mail.EmailException; +import org.apache.commons.mail.HtmlEmail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.tamguo.common.utils.SystemConstant; +import com.tamguo.config.redis.CacheService; +import com.tamguo.modules.sys.service.IEmailService; + +@Service +public class EmailService implements IEmailService{ + + @Autowired + private CacheService cacheService; + + @Override + public Integer sendFindPasswordEmail(String email , String subject) throws EmailException { + HtmlEmail mail = new HtmlEmail(); + mail.setHostName(SystemConstant.ALIYUN_SMTP_HOST_NAME); + mail.setSmtpPort(SystemConstant.ALIYUN_SMTP_HOST_PORT); + mail.setAuthentication(SystemConstant.ALIYUN_MAIL_ACCOUNT, SystemConstant.ALIYUN_MAIL_PASSWORD); + mail.setSSLOnConnect(true); + mail.setFrom(SystemConstant.ALIYUN_MAIL_ACCOUNT, "探果网"); + mail.addTo(email); + mail.setSubject(subject); + mail.setCharset("UTF-8"); + Integer vcode = (int) ((Math.random()*9+1)*100000); + mail.setHtmlMsg("探果网找回密码验证码:"+vcode); + mail.send(); + + cacheService.setObject(SystemConstant.ALIYUN_MAIL_FIND_PASSWORD_PREFIX + email , vcode.toString() , 3 * 60); + return 0; + } + +} diff --git a/tamguo-modules-core/src/main/resources/mappers/sys/SysUserMapper.xml b/tamguo-modules-core/src/main/resources/mappers/sys/SysUserMapper.xml index 005df51..2f56ab4 100644 --- a/tamguo-modules-core/src/main/resources/mappers/sys/SysUserMapper.xml +++ b/tamguo-modules-core/src/main/resources/mappers/sys/SysUserMapper.xml @@ -27,7 +27,7 @@ and u.login_code = #{loginCode} - and u.user_name = #{userName} + and u.username = #{userName} and u.email = #{email}