diff --git a/tamguo-common/pom.xml b/tamguo-common/pom.xml
index 49cf8f5..0b34b17 100644
--- a/tamguo-common/pom.xml
+++ b/tamguo-common/pom.xml
@@ -10,6 +10,23 @@
slf4j-api
1.7.25
+
+
+ com.bladejava
+ blade-patchca
+ 1.0.5
+
+
+
+ com.aliyun
+ aliyun-java-sdk-dysmsapi
+ 1.0.0
+
+
+ com.aliyun
+ aliyun-java-sdk-core
+ 3.2.8
+
diff --git a/tamguo-oms/src/main/java/com/tamguo/config/image/CaptchaUtils.java b/tamguo-common/src/main/java/com/tamguo/common/image/CaptchaUtils.java
similarity index 96%
rename from tamguo-oms/src/main/java/com/tamguo/config/image/CaptchaUtils.java
rename to tamguo-common/src/main/java/com/tamguo/common/image/CaptchaUtils.java
index b5b44b7..f9246ad 100644
--- a/tamguo-oms/src/main/java/com/tamguo/config/image/CaptchaUtils.java
+++ b/tamguo-common/src/main/java/com/tamguo/common/image/CaptchaUtils.java
@@ -1,7 +1,7 @@
/**
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
*/
-package com.tamguo.config.image;
+package com.tamguo.common.image;
import java.awt.Color;
import java.awt.Graphics;
diff --git a/tamguo-common/src/main/java/com/tamguo/common/utils/Status.java b/tamguo-common/src/main/java/com/tamguo/common/utils/Status.java
new file mode 100644
index 0000000..1bd741d
--- /dev/null
+++ b/tamguo-common/src/main/java/com/tamguo/common/utils/Status.java
@@ -0,0 +1,5 @@
+package com.tamguo.common.utils;
+
+public enum Status {
+ SUCCESS , ERROR
+}
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 54a713c..378ff0a 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
@@ -58,4 +58,25 @@ public class SystemConstant {
/** 名校缓存KEY*/
public static final String ELITE_PAPER = "ElitePaper:";
+
+ /** 安全验证前缀*/
+ public static final String SECURITY_CHECK_PREFIX = "securityCheck:";
+
+ /** 短信找回密码前缀*/
+ 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";
+
+ /** 登录错误次数*/
+ public static final String LOGIN_FAILURE_COUNT = "loginFailureCount:";
+
+ /** ALIYUN */
+ public static final String ALIYUN_ACCESS_KEY_ID = "LTAINGkheMeWtxUR";
+
+ /** ALIYUN*/
+ public static final String ALIYUN_ACCESS_KEY_SECRET = "ONUKuCz85kU4In07y4dvpM28mfWOGa";
}
diff --git a/tamguo-common/src/main/java/com/tamguo/common/utils/UploaderMessage.java b/tamguo-common/src/main/java/com/tamguo/common/utils/UploaderMessage.java
new file mode 100644
index 0000000..84fa24a
--- /dev/null
+++ b/tamguo-common/src/main/java/com/tamguo/common/utils/UploaderMessage.java
@@ -0,0 +1,67 @@
+package com.tamguo.common.utils;
+
+import java.util.ArrayList;
+
+
+public class UploaderMessage {
+ private Status status;
+ private String statusMsg = "";
+ private ArrayList errorKys;
+ private String error = "";
+ private String filePath = "";
+ private String fileDomain = "";
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(Status status) {
+ this.status = status;
+ }
+
+ public String getStatusMsg() {
+ return statusMsg;
+ }
+
+ public void setStatusMsg(String statusMsg) {
+ this.statusMsg = statusMsg;
+ }
+
+ public ArrayList getErrorKys() {
+ return errorKys;
+ }
+
+ public void setErrorKys(ArrayList errorKys) {
+ this.errorKys = errorKys;
+ }
+
+ public String getError() {
+ return error;
+ }
+
+ public void setError(String error) {
+ this.error = error;
+ }
+
+ public String getFilePath() {
+ return filePath;
+ }
+
+ public void setFilePath(String filePath) {
+ this.filePath = filePath;
+ }
+
+ public String getFileDomain() {
+ return fileDomain;
+ }
+
+ public void setFileDomain(String fileDomain) {
+ this.fileDomain = fileDomain;
+ }
+
+
+}
+
+
+
+
diff --git a/tamguo-modules-core/pom.xml b/tamguo-modules-core/pom.xml
index 81ed7f3..d423e39 100644
--- a/tamguo-modules-core/pom.xml
+++ b/tamguo-modules-core/pom.xml
@@ -51,6 +51,17 @@
log4j
1.2.17
+
+
+ org.apache.shiro
+ shiro-spring
+ 1.2.5
+
+
+ org.apache.shiro
+ shiro-ehcache
+ 1.2.5
+
diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/member/dao/MemberMapper.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/member/dao/MemberMapper.java
new file mode 100644
index 0000000..26716b5
--- /dev/null
+++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/member/dao/MemberMapper.java
@@ -0,0 +1,8 @@
+package com.tamguo.modules.member.dao;
+
+import com.tamguo.config.dao.SuperMapper;
+import com.tamguo.modules.member.model.MemberEntity;
+
+public interface MemberMapper extends SuperMapper{
+
+}
diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/member/model/MemberEntity.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/member/model/MemberEntity.java
new file mode 100644
index 0000000..ef7ee1b
--- /dev/null
+++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/member/model/MemberEntity.java
@@ -0,0 +1,189 @@
+package com.tamguo.modules.member.model;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+import com.baomidou.mybatisplus.annotations.TableField;
+import com.baomidou.mybatisplus.annotations.TableName;
+import com.tamguo.config.dao.SuperEntity;
+
+/**
+ * The persistent class for the tiku_ad database table.
+ *
+ */
+@TableName(value="tiku_member")
+public class MemberEntity extends SuperEntity implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private String subjectId;
+
+ private String courseId;
+
+ private String username;
+
+ private String nickName;
+
+ private String password;
+
+ private String avatar;
+
+ private String mobile;
+
+ private String email;
+
+ private Integer point;
+
+ private BigDecimal amount;
+
+ private Long lastLoginTime;
+
+ private Integer paperNum;
+
+ private Integer questionNum;
+
+ private Integer downNum;
+
+ private Integer hitsNum;
+
+ @TableField(exist=false)
+ private String verifyCode;
+
+ @TableField(exist=false)
+ private String nowPassword;
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getAvatar() {
+ return avatar;
+ }
+
+ public void setAvatar(String avatar) {
+ this.avatar = avatar;
+ }
+
+ public String getMobile() {
+ return mobile;
+ }
+
+ public void setMobile(String mobile) {
+ this.mobile = mobile;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public Integer getPoint() {
+ return point;
+ }
+
+ public void setPoint(Integer point) {
+ this.point = point;
+ }
+
+ public BigDecimal getAmount() {
+ return amount;
+ }
+
+ public void setAmount(BigDecimal amount) {
+ this.amount = amount;
+ }
+
+ public Long getLastLoginTime() {
+ return lastLoginTime;
+ }
+
+ public void setLastLoginTime(Long lastLoginTime) {
+ this.lastLoginTime = lastLoginTime;
+ }
+
+ public Integer getPaperNum() {
+ return paperNum;
+ }
+
+ public void setPaperNum(Integer paperNum) {
+ this.paperNum = paperNum;
+ }
+
+ public Integer getQuestionNum() {
+ return questionNum;
+ }
+
+ public void setQuestionNum(Integer questionNum) {
+ this.questionNum = questionNum;
+ }
+
+ public Integer getHitsNum() {
+ return hitsNum;
+ }
+
+ public void setHitsNum(Integer hitsNum) {
+ this.hitsNum = hitsNum;
+ }
+
+ public Integer getDownNum() {
+ return downNum;
+ }
+
+ public void setDownNum(Integer downNum) {
+ this.downNum = downNum;
+ }
+
+ public String getNickName() {
+ return nickName;
+ }
+
+ public void setNickName(String nickName) {
+ this.nickName = nickName;
+ }
+
+ public String getVerifyCode() {
+ return verifyCode;
+ }
+
+ public void setVerifyCode(String verifyCode) {
+ this.verifyCode = verifyCode;
+ }
+
+ public String getSubjectId() {
+ return subjectId;
+ }
+
+ public void setSubjectId(String subjectId) {
+ this.subjectId = subjectId;
+ }
+
+ public String getCourseId() {
+ return courseId;
+ }
+
+ public void setCourseId(String courseId) {
+ this.courseId = courseId;
+ }
+
+ public String getNowPassword() {
+ return nowPassword;
+ }
+
+ public void setNowPassword(String nowPassword) {
+ this.nowPassword = nowPassword;
+ }
+}
\ No newline at end of file
diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/member/service/IMemberService.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/member/service/IMemberService.java
new file mode 100644
index 0000000..dab94ec
--- /dev/null
+++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/member/service/IMemberService.java
@@ -0,0 +1,44 @@
+package com.tamguo.modules.member.service;
+
+import com.tamguo.common.utils.Result;
+import com.tamguo.modules.member.model.MemberEntity;
+
+public interface IMemberService {
+
+ public Result login(String username , String password);
+
+ public Result checkUsername(String username);
+
+ public Result checkMobile(String mobile);
+
+ public Result register(MemberEntity member);
+
+ public Result checkAccount(String account);
+
+ public Result confirmAccount(String account , String veritycode);
+
+ public Result securityCheck(String username , String isEmail , String vcode);
+
+ public Result resetPassword(String resetPasswordKey , String username , String password, String verifypwd);
+
+ public Integer getLoginFailureCount(MemberEntity member);
+
+ public void updateMember(MemberEntity member);
+
+ public MemberEntity findByUid(String uid);
+
+ public MemberEntity findByUsername(String username);
+
+ public void updateLoginFailureCount(MemberEntity member , Integer loginFailureCount);
+
+ public void updateLastLoginTime(String string);
+
+ public MemberEntity findCurrMember(String id);
+
+ /**
+ * 修改密码
+ * @param member
+ * @return
+ */
+ public Result updatePwd(MemberEntity member);
+}
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
new file mode 100644
index 0000000..8be4eed
--- /dev/null
+++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/member/service/impl/MemberService.java
@@ -0,0 +1,243 @@
+package com.tamguo.modules.member.service.impl;
+
+import java.util.List;
+import java.util.UUID;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shiro.crypto.hash.Sha256Hash;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.baomidou.mybatisplus.mapper.Condition;
+import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.tamguo.common.utils.DateUtil;
+import com.tamguo.common.utils.Result;
+import com.tamguo.common.utils.SystemConstant;
+import com.tamguo.config.redis.CacheService;
+import com.tamguo.modules.member.dao.MemberMapper;
+import com.tamguo.modules.member.model.MemberEntity;
+import com.tamguo.modules.member.service.IMemberService;
+
+@Service
+public class MemberService extends ServiceImpl implements IMemberService{
+
+ @Autowired
+ private MemberMapper memberMapper;
+ @Autowired
+ private CacheService cacheService;
+
+ @Override
+ public Result login(String username, String password) {
+ MemberEntity condition = new MemberEntity();
+ condition.setUsername(username);
+ MemberEntity member = memberMapper.selectOne(condition);
+ if(member == null){
+ return Result.result(201, member, "用户名或密码有误,请重新输入或找回密码");
+ }
+ Integer loginFailureCount = this.getLoginFailureCount(member);
+ if(!new Sha256Hash(password).toHex().equals(member.getPassword())){
+ loginFailureCount++;
+ this.updateLoginFailureCount(member , loginFailureCount);
+ return Result.result(202, member, "用户名或密码有误,请重新输入或找回密码");
+ }
+ this.updateLoginFailureCount(member , 0);
+ return Result.result(200, member, "登录成功");
+ }
+
+ public void updateLoginFailureCount(MemberEntity member , Integer loginFailureCount){
+ cacheService.setObject(SystemConstant.LOGIN_FAILURE_COUNT + member.getId(), loginFailureCount , 2 * 60 * 60);
+ }
+
+ public Integer getLoginFailureCount(MemberEntity member){
+ if(member == null){
+ return 0;
+ }
+ if(!cacheService.isExist(SystemConstant.LOGIN_FAILURE_COUNT + member.getId())){
+ return 0;
+ }
+ return (Integer)cacheService.getObject(SystemConstant.LOGIN_FAILURE_COUNT + member.getId());
+ }
+
+ @Override
+ public Result checkUsername(String username) {
+ MemberEntity condition = new MemberEntity();
+ condition.setUsername(username);
+ MemberEntity member = memberMapper.selectOne(condition);
+ if(member != null){
+ return Result.result(201, null, "该用户名已经存在");
+ }
+ return Result.result(200, null, "该用户名可用");
+ }
+
+ @Override
+ public Result checkMobile(String mobile) {
+ MemberEntity condition = new MemberEntity();
+ condition.setMobile(mobile);
+ MemberEntity member = memberMapper.selectOne(condition);
+ if(member != null){
+ return Result.result(201, null, "该手机号已经存在");
+ }
+ return Result.result(200, null, "该手机号可用");
+ }
+
+ @Transactional(readOnly=false)
+ @Override
+ public Result register(MemberEntity member) {
+ MemberEntity condition = new MemberEntity();
+ condition.setUsername(member.getUsername());
+ MemberEntity m = memberMapper.selectOne(condition);
+ if(m != null){
+ return Result.result(201, null, "该用户已经存在");
+ }
+ condition = new MemberEntity();
+ condition.setMobile(member.getMobile());
+ m = memberMapper.selectOne(condition);
+ if(m != null){
+ return Result.result(202, null, "该手机号已经存在");
+ }
+ if(!cacheService.isExist(SystemConstant.ALIYUN_MOBILE_SMS_PREFIX + member.getMobile())){
+ return Result.result(203, null, "验证码错误");
+ }
+ String code = (String) cacheService.getObject(SystemConstant.ALIYUN_MOBILE_SMS_PREFIX + member.getMobile());
+ if(!code.equals(member.getVerifyCode())){
+ return Result.result(204, null, "验证码错误");
+ }
+ MemberEntity entity = new MemberEntity();
+ entity.setAvatar(SystemConstant.DEFAULT_MEMBER_AVATAR);
+ entity.setMobile(member.getMobile());
+ entity.setPassword(new Sha256Hash(member.getPassword()).toHex());
+ entity.setUsername(member.getUsername());
+ entity.setNickName(member.getUsername());
+ entity.setSubjectId(member.getSubjectId());
+ entity.setCourseId(member.getCourseId());
+ entity.setEmail(member.getEmail());
+ memberMapper.insert(entity);
+ return Result.result(200, entity, "注册成功");
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Result checkAccount(String account) {
+ if(StringUtils.isEmpty(account)){
+ return Result.result(201, null, "帐号不存在!");
+ }
+ List members = memberMapper.selectList(Condition.create().eq("user_name", account).or().eq("mobile", account));
+ if(members.size() == 0){
+ return Result.result(201, null, "帐号不存在!");
+ }
+ return Result.result(200, members.get(0), "该帐号存在");
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Result confirmAccount(String account, String veritycode) {
+ if(StringUtils.isEmpty(account)){
+ return Result.result(201, null, "帐号不存在!");
+ }
+
+ List members = memberMapper.selectList(Condition.create().eq("user_name", account).or().eq("mobile", account));
+ if(members.size() == 0){
+ return Result.result(201, null, "帐号不存在!");
+ }
+ return Result.result(200, members.get(0), "该帐号存在");
+ }
+
+ @Override
+ public Result securityCheck(String username , String isEmail , String vcode) {
+ MemberEntity condition = new MemberEntity();
+ condition.setUsername(username);
+ MemberEntity member = memberMapper.selectOne(condition);
+ if("1".equals(isEmail)){
+ if(!cacheService.isExist(SystemConstant.ALIYUN_MAIL_FIND_PASSWORD_PREFIX + member.getEmail())){
+ return Result.result(201, member, "验证码错误");
+ }
+ String code = (String) cacheService.getObject(SystemConstant.ALIYUN_MAIL_FIND_PASSWORD_PREFIX + member.getEmail());
+ if(!code.equals(vcode)){
+ return Result.result(202, member, "验证码错误");
+ }
+ }else{
+ if(!cacheService.isExist(SystemConstant.ALIYUN_MOBILE_SMS_PREFIX + member.getMobile())){
+ return Result.result(203, member, "验证码错误");
+ }
+ String code = (String) cacheService.getObject(SystemConstant.ALIYUN_MOBILE_SMS_PREFIX + member.getMobile());
+ if(!code.equals(vcode)){
+ return Result.result(204, member, "验证码错误");
+ }
+ }
+ String key = UUID.randomUUID().toString();
+ cacheService.setObject(SystemConstant.SECURITY_CHECK_PREFIX + key, username , 2 * 60 * 60);
+ return Result.result(200, key, "安全验证通过");
+ }
+
+ @Override
+ public Result resetPassword(String resetPasswordKey , String username , String password, String verifypwd) {
+ if(cacheService.isExist(SystemConstant.SECURITY_CHECK_PREFIX + resetPasswordKey)){
+ MemberEntity condition = new MemberEntity();
+ condition.setUsername(username);
+ MemberEntity member = memberMapper.selectOne(condition);
+ if(password.equals(verifypwd)){
+ member.setPassword(new Sha256Hash(password).toHex());
+ memberMapper.updateById(member);
+ }
+ }
+ return Result.result(200, null, "更新成功");
+ }
+
+ @Transactional(readOnly=false)
+ @Override
+ public void updateMember(MemberEntity member) {
+ MemberEntity entity = memberMapper.selectById(member.getId());
+ entity.setAvatar(member.getAvatar());
+ entity.setEmail(member.getEmail());
+ entity.setMobile(member.getMobile());
+ entity.setCourseId(member.getCourseId());
+ entity.setSubjectId(member.getSubjectId());
+ entity.setNickName(member.getNickName());
+
+ memberMapper.updateById(entity);
+ }
+
+ @Transactional(readOnly=true)
+ @Override
+ public MemberEntity findByUid(String uid) {
+ return memberMapper.selectById(uid);
+ }
+
+ @Transactional(readOnly=true)
+ @Override
+ public MemberEntity findByUsername(String username) {
+ MemberEntity condition = new MemberEntity();
+ condition.setUsername(username);
+ return memberMapper.selectOne(condition);
+ }
+
+ @Transactional(readOnly=false)
+ @Override
+ public void updateLastLoginTime(String uid) {
+ MemberEntity member = memberMapper.selectById(uid);
+ member.setLastLoginTime(DateUtil.getTime());
+ memberMapper.updateById(member);
+ }
+
+ @Override
+ public MemberEntity findCurrMember(String id) {
+ MemberEntity member = memberMapper.selectById(id);
+ member.setPassword(null);
+ return member;
+ }
+
+ @Transactional(readOnly=false)
+ @Override
+ public Result updatePwd(MemberEntity member) {
+ MemberEntity entity = memberMapper.selectById(member.getId());
+ if(!entity.getPassword().equals(new Sha256Hash(member.getPassword()).toHex())) {
+ return Result.result(501, null, "旧密码错误!");
+ }
+ if(!cacheService.isExist(SystemConstant.ALIYUN_MOBILE_SMS_PREFIX + member.getMobile())){
+ return Result.result(502, null, "验证码错误");
+ }
+ entity.setPassword(new Sha256Hash(member.getNowPassword()).toHex());
+ return Result.result(0, null, "修改成功");
+ }
+
+}
diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/service/ISmsService.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/service/ISmsService.java
new file mode 100644
index 0000000..e2e59b7
--- /dev/null
+++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/service/ISmsService.java
@@ -0,0 +1,10 @@
+package com.tamguo.modules.sys.service;
+
+import com.aliyuncs.exceptions.ClientException;
+import com.tamguo.common.utils.Result;
+
+public interface ISmsService {
+
+ public Result sendFindPasswordSms(String mobile) throws ClientException;
+
+}
diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/service/impl/SmsServiceImpl.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/service/impl/SmsServiceImpl.java
new file mode 100644
index 0000000..884ce0c
--- /dev/null
+++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/service/impl/SmsServiceImpl.java
@@ -0,0 +1,62 @@
+package com.tamguo.modules.sys.service.impl;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.aliyuncs.DefaultAcsClient;
+import com.aliyuncs.IAcsClient;
+import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
+import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
+import com.aliyuncs.exceptions.ClientException;
+import com.aliyuncs.profile.DefaultProfile;
+import com.aliyuncs.profile.IClientProfile;
+import com.tamguo.common.utils.Result;
+import com.tamguo.common.utils.SystemConstant;
+import com.tamguo.config.redis.CacheService;
+import com.tamguo.modules.sys.service.ISmsService;
+
+@Service
+public class SmsServiceImpl implements ISmsService{
+
+ @Autowired
+ private CacheService cacheService;
+
+ @Override
+ public Result sendFindPasswordSms(String mobile) throws ClientException {
+ //可自助调整超时时间
+ System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
+ System.setProperty("sun.net.client.defaultReadTimeout", "10000");
+
+ //初始化acsClient,暂不支持region化
+ IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", SystemConstant.ALIYUN_ACCESS_KEY_ID, SystemConstant.ALIYUN_ACCESS_KEY_SECRET);
+ DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", "Dysmsapi", "dysmsapi.aliyuncs.com");
+ IAcsClient acsClient = new DefaultAcsClient(profile);
+
+ //组装请求对象-具体描述见控制台-文档部分内容
+ SendSmsRequest request = new SendSmsRequest();
+ //必填:待发送手机号
+ request.setPhoneNumbers(mobile);
+ //必填:短信签名-可在短信控制台中找到
+ request.setSignName("探果网");
+ //必填:短信模板-可在短信控制台中找到
+ request.setTemplateCode("SMS_127152965");
+ Integer vcode = (int) ((Math.random()*9+1)*100000);
+ //可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
+ request.setTemplateParam("{\"code\":\""+vcode+"\"}");
+
+ //选填-上行短信扩展码(无特殊需求用户请忽略此字段)
+ //request.setSmsUpExtendCode("90997");
+
+ //可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
+ request.setOutId("yourOutId");
+
+ //hint 此处可能会抛出异常,注意catch
+ SendSmsResponse response = acsClient.getAcsResponse(request);
+ if("OK".equals(response.getCode())) {
+ cacheService.setObject(SystemConstant.ALIYUN_MOBILE_SMS_PREFIX + mobile , vcode.toString() , 10 * 60);
+ return Result.result(200, null, "发送成功");
+ }
+ return Result.result(501, null, response.getMessage());
+ }
+
+}
diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/model/enums/QuestionTypeEnum.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/model/enums/QuestionTypeEnum.java
new file mode 100644
index 0000000..d37264a
--- /dev/null
+++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/model/enums/QuestionTypeEnum.java
@@ -0,0 +1,54 @@
+package com.tamguo.modules.tiku.model.enums;
+
+import java.io.Serializable;
+/**
+ * 试题类型、、题目类型(1.单选题;2.多选题; 3.解答题)
+ *
+ * @author tamguo
+ *
+ */
+public enum QuestionTypeEnum {
+
+ DANXUANTI("1", "单选题"),
+ DUOXUANTI("2", "多选题"),
+ TIANKONGTI("3", "填空题"),
+ PANDUANTI("4", "判断题"),
+ WENDATI("5", "问答题");
+
+ private String value;
+ private String desc;
+
+ QuestionTypeEnum(final String value, final String desc) {
+ this.value = value;
+ this.desc = desc;
+ }
+
+ public static QuestionTypeEnum getQuestionType(String value) {
+ if("1".equals(value)) {
+ return DANXUANTI;
+ }else if("2".equals(value)) {
+ return DUOXUANTI;
+ }else if("3".equals(value)) {
+ return TIANKONGTI;
+ }else if("4".equals(value)) {
+ return PANDUANTI;
+ }else if("5".equals(value)) {
+ return WENDATI;
+ }
+ return WENDATI;
+ }
+
+ public Serializable getValue() {
+ return this.value;
+ }
+
+ public String getDesc(){
+ return this.desc;
+ }
+
+ @Override
+ public String toString() {
+ return this.value;
+ }
+
+}
diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/IPaperService.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/IPaperService.java
index 5268619..fe534d9 100644
--- a/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/IPaperService.java
+++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/IPaperService.java
@@ -1,8 +1,8 @@
package com.tamguo.modules.tiku.service;
import java.util.List;
-
import com.baomidou.mybatisplus.service.IService;
+import com.tamguo.common.utils.Result;
import com.tamguo.modules.tiku.model.PaperEntity;
public interface IPaperService extends IService{
@@ -12,5 +12,17 @@ public interface IPaperService extends IService{
List findSimulationPaper();
List findHotPaper(String areaId);
+
+ void addPaperQuestionInfo(String paperId, String title, String name, String type);
+
+ void updatePaperQuestionInfo(String paperId, String title, String name,
+ String type, String uid);
+
+ Result deletePaper(String deletePaper , String paperId);
+
+ Result deletePaperQuestionInfoBtn(String currMemberId , String paperId, String cuid);
+
+ void addPaper(PaperEntity paper);
+ Result updatePaper(PaperEntity paper , String currMemberId);
}
diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/IQuestionService.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/IQuestionService.java
index b261fb6..6154817 100644
--- a/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/IQuestionService.java
+++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/IQuestionService.java
@@ -1,8 +1,18 @@
package com.tamguo.modules.tiku.service;
+import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
+import com.tamguo.common.utils.Result;
import com.tamguo.modules.tiku.model.QuestionEntity;
public interface IQuestionService extends IService{
+
+ public Result addQuestion(QuestionEntity question , String currMemberId);
+ public Page queryQuestionList(String questionType, String uid, String content, String paperId, String currMemberId ,
+ Page p);
+
+ public Result updateQuestion(QuestionEntity question, String currMemberId);
+
+ public Result delete(String uid, String currMemberId);
}
diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/ISubjectService.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/ISubjectService.java
index 4d77ac0..1a299b0 100644
--- a/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/ISubjectService.java
+++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/ISubjectService.java
@@ -1,5 +1,6 @@
package com.tamguo.modules.tiku.service;
+import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.tamguo.modules.tiku.model.SubjectEntity;
@@ -24,4 +25,6 @@ public interface ISubjectService extends IService{
/** 删除分类*/
void delete(String uid);
+ JSONArray getCourseCascaderTree();
+
}
diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/impl/PaperServiceImpl.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/impl/PaperServiceImpl.java
index 6769988..898c959 100644
--- a/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/impl/PaperServiceImpl.java
+++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/impl/PaperServiceImpl.java
@@ -1,15 +1,22 @@
package com.tamguo.modules.tiku.service.impl;
import java.util.List;
+import java.util.UUID;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.tamguo.common.utils.Result;
import com.tamguo.common.utils.SystemConstant;
import com.tamguo.config.redis.CacheService;
import com.tamguo.modules.tiku.dao.PaperMapper;
+import com.tamguo.modules.tiku.dao.QuestionMapper;
import com.tamguo.modules.tiku.model.PaperEntity;
import com.tamguo.modules.tiku.service.IPaperService;
@@ -20,6 +27,9 @@ public class PaperServiceImpl extends ServiceImpl impl
private PaperMapper paperMapper;
@Autowired
private CacheService cacheService;
+ @Autowired
+ private QuestionMapper questionMapper;
+
@SuppressWarnings("unchecked")
@Override
public List findHistoryPaper() {
@@ -56,4 +66,97 @@ public class PaperServiceImpl extends ServiceImpl impl
return paperList;
}
+ @Transactional(readOnly=false)
+ @Override
+ public void addPaperQuestionInfo(String paperId, String title, String name, String type) {
+ PaperEntity paper = paperMapper.selectById(paperId);
+ String questionInfo = paper.getQuestionInfo();
+
+ JSONArray qList = JSONArray.parseArray(questionInfo);
+ JSONObject entity = new JSONObject();
+ entity.put("name", name);
+ entity.put("title", title);
+ entity.put("type", type);
+ entity.put("id", UUID.randomUUID().toString());
+ qList.add(entity);
+
+ paper.setQuestionInfo(qList.toString());
+ paperMapper.updateById(paper);
+ }
+
+ @Transactional(readOnly=false)
+ @Override
+ public void updatePaperQuestionInfo(String paperId, String title, String name, String type, String uid) {
+ PaperEntity paper = paperMapper.selectById(paperId);
+ JSONArray qList = JSONArray.parseArray(paper.getQuestionInfo());
+ for(int i =0 ; i implements IQuestionService{
+ @Autowired
+ private PaperMapper paperMapper;
+ @Autowired
+ private QuestionMapper questionMapper;
+
+ @Override
+ public Result addQuestion(QuestionEntity question , String currMemberId) {
+ PaperEntity paper = paperMapper.selectById(question.getPaperId().toString());
+ if(!currMemberId.equals(paper.getCreaterId())) {
+ return Result.result(501, null, "改试卷不属于您!");
+ }
+ question.setCourseId(paper.getCourseId());
+ questionMapper.insert(question);
+ return Result.result(0, null, "添加成功!");
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Page queryQuestionList(String questionType, String id, String content, String paperId, String currMemberId ,
+ Page p) {
+ if(!currMemberId.equals(paperMapper.selectById(paperId).getCreaterId())) {
+ return p.setRecords(null);
+ }
+ Condition condition = new Condition();
+ if(!StringUtils.isEmpty(questionType)) {
+ condition.eq("question_type", questionType);
+ }
+ if(!StringUtils.isEmpty(id)) {
+ condition.eq("id", id);
+ }
+ if(!StringUtils.isEmpty(content)) {
+ condition.like("content", content);
+ }
+ condition.eq("paper_id", paperId);
+ return p.setRecords(questionMapper.selectPage(p, condition));
+ }
+
+ @Transactional(readOnly=false)
+ @Override
+ public Result updateQuestion(QuestionEntity question , String currMemberId) {
+ PaperEntity paper = paperMapper.selectById(question.getPaperId().toString());
+ if(!currMemberId.equals(paper.getCreaterId())) {
+ return Result.result(501, null, "改试卷不属于您!");
+ }
+ questionMapper.updateById(question);
+ return Result.result(0, null, "修改成功!");
+ }
+
+ @Transactional(readOnly=false)
+ @Override
+ public Result delete(String uid , String currMemberId) {
+ QuestionEntity question = questionMapper.selectById(uid);
+ PaperEntity paper = paperMapper.selectById(question.getPaperId().toString());
+ if(!currMemberId.equals(paper.getCreaterId())) {
+ return Result.result(501, null, "改试卷不属于您!");
+ }
+ questionMapper.deleteById(uid);
+ return Result.result(0, null, "删除成功!");
+ }
+
}
diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/impl/SubjectServiceImpl.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/impl/SubjectServiceImpl.java
index 9a675dc..d004f02 100644
--- a/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/impl/SubjectServiceImpl.java
+++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/tiku/service/impl/SubjectServiceImpl.java
@@ -1,14 +1,19 @@
package com.tamguo.modules.tiku.service.impl;
+import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.tamguo.modules.tiku.dao.CourseMapper;
import com.tamguo.modules.tiku.dao.SubjectMapper;
+import com.tamguo.modules.tiku.model.CourseEntity;
import com.tamguo.modules.tiku.model.SubjectEntity;
import com.tamguo.modules.tiku.model.condition.SubjectCondition;
import com.tamguo.modules.tiku.model.enums.SubjectStatusEnum;
@@ -19,6 +24,8 @@ public class SubjectServiceImpl extends ServiceImpl subjectList = subjectMapper.selectList(Condition.EMPTY);
+ for(int i=0 ; i courseList = courseMapper.selectList(Condition.create().eq("subject_id", subject.getId()));
+ for(int k=0 ; korg.springframework.session
spring-session-data-redis
+
+ com.github.theborakompanioni
+ thymeleaf-extras-shiro
+ 1.2.1
+
com.alibaba
fastjson
@@ -124,18 +129,13 @@
commons-email
1.5
-
- com.github.theborakompanioni
- thymeleaf-extras-shiro
- 1.2.1
-
com.bladejava
blade-patchca
1.0.5
-
+
com.tamguo
tamguo-modules-core
diff --git a/tamguo-tms/src/main/java/com/tamguo/config/shiro/MemberRealm.java b/tamguo-tms/src/main/java/com/tamguo/config/shiro/MemberRealm.java
new file mode 100644
index 0000000..6a55f8d
--- /dev/null
+++ b/tamguo-tms/src/main/java/com/tamguo/config/shiro/MemberRealm.java
@@ -0,0 +1,72 @@
+package com.tamguo.config.shiro;
+
+import java.util.Set;
+import org.apache.shiro.authc.AuthenticationException;
+import org.apache.shiro.authc.AuthenticationInfo;
+import org.apache.shiro.authc.AuthenticationToken;
+import org.apache.shiro.authc.IncorrectCredentialsException;
+import org.apache.shiro.authc.LockedAccountException;
+import org.apache.shiro.authc.SimpleAuthenticationInfo;
+import org.apache.shiro.authc.UnknownAccountException;
+import org.apache.shiro.authz.AuthorizationInfo;
+import org.apache.shiro.authz.SimpleAuthorizationInfo;
+import org.apache.shiro.crypto.hash.Sha256Hash;
+import org.apache.shiro.realm.AuthorizingRealm;
+import org.apache.shiro.subject.PrincipalCollection;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.tamguo.modules.member.model.MemberEntity;
+import com.tamguo.modules.member.service.IMemberService;
+
+/**
+ * 认证
+ *
+ */
+public class MemberRealm extends AuthorizingRealm {
+
+ @Autowired
+ private IMemberService iMemberService;
+
+ /**
+ * 授权(验证权限时调用)
+ */
+ @Override
+ protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
+ Set permsSet = null;
+ SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
+ info.setStringPermissions(permsSet);
+
+ return info;
+ }
+
+ /**
+ * 认证(登录时调用)
+ */
+ @Override
+ protected AuthenticationInfo doGetAuthenticationInfo(
+ AuthenticationToken token) throws AuthenticationException {
+ String username = (String) token.getPrincipal();
+ String password = new String((char[]) token.getCredentials());
+
+ MemberEntity member = iMemberService.findByUsername(username);
+ if(member == null) {
+ throw new UnknownAccountException("用户名或密码有误,请重新输入或找回密码");
+ }
+ Integer loginFailureCount = iMemberService.getLoginFailureCount(member);
+ if(loginFailureCount > 10) {
+ throw new LockedAccountException("账号被锁定");
+ }
+
+ if(!new Sha256Hash(password).toHex().equals(member.getPassword())){
+ loginFailureCount++;
+ iMemberService.updateLoginFailureCount(member , loginFailureCount);
+ throw new IncorrectCredentialsException("用户名或密码有误,请重新输入或找回密码");
+ }
+ // 更新登录时间
+ iMemberService.updateLastLoginTime(member.getId());
+
+ SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(member, password, getName());
+ return info;
+ }
+
+}
diff --git a/tamguo-tms/src/main/java/com/tamguo/config/shiro/ShiroConfiguration.java b/tamguo-tms/src/main/java/com/tamguo/config/shiro/ShiroConfiguration.java
new file mode 100644
index 0000000..96f9ab3
--- /dev/null
+++ b/tamguo-tms/src/main/java/com/tamguo/config/shiro/ShiroConfiguration.java
@@ -0,0 +1,69 @@
+package com.tamguo.config.shiro;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.apache.shiro.cache.ehcache.EhCacheManager;
+import org.apache.shiro.spring.LifecycleBeanPostProcessor;
+import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
+import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
+import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
+import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class ShiroConfiguration {
+ private static Map filterChainDefinitionMap = new LinkedHashMap();
+
+ @Bean(name = "shiroRealm")
+ public MemberRealm getShiroRealm() {
+ return new MemberRealm();
+ }
+
+ @Bean(name = "shiroEhcacheManager")
+ public EhCacheManager getEhCacheManager() {
+ EhCacheManager em = new EhCacheManager();
+ em.setCacheManagerConfigFile("classpath:ehcache-shiro.xml");
+ return em;
+ }
+
+ @Bean(name = "lifecycleBeanPostProcessor")
+ public LifecycleBeanPostProcessor getLifecycleBeanPostProcessor() {
+ return new LifecycleBeanPostProcessor();
+ }
+
+ @Bean
+ public DefaultAdvisorAutoProxyCreator getDefaultAdvisorAutoProxyCreator() {
+ DefaultAdvisorAutoProxyCreator daap = new DefaultAdvisorAutoProxyCreator();
+ daap.setProxyTargetClass(true);
+ return daap;
+ }
+
+ @Bean(name = "securityManager")
+ public DefaultWebSecurityManager getDefaultWebSecurityManager() {
+ DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager();
+ dwsm.setRealm(getShiroRealm());
+ dwsm.setCacheManager(getEhCacheManager());
+ return dwsm;
+ }
+
+ @Bean
+ public AuthorizationAttributeSourceAdvisor getAuthorizationAttributeSourceAdvisor() {
+ AuthorizationAttributeSourceAdvisor aasa = new AuthorizationAttributeSourceAdvisor();
+ aasa.setSecurityManager(getDefaultWebSecurityManager());
+ return new AuthorizationAttributeSourceAdvisor();
+ }
+
+ @Bean(name = "shiroFilter")
+ public ShiroFilterFactoryBean getShiroFilterFactoryBean() {
+ ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
+ shiroFilterFactoryBean.setSecurityManager(getDefaultWebSecurityManager());
+ shiroFilterFactoryBean.setLoginUrl("/login");
+ shiroFilterFactoryBean.setSuccessUrl("/index");
+ filterChainDefinitionMap.put("/member/**", "authc");
+ filterChainDefinitionMap.put("/**", "anon");
+ shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
+ return shiroFilterFactoryBean;
+ }
+}
\ No newline at end of file
diff --git a/tamguo-tms/src/main/java/com/tamguo/utils/ShiroUtils.java b/tamguo-tms/src/main/java/com/tamguo/utils/ShiroUtils.java
new file mode 100644
index 0000000..e450f99
--- /dev/null
+++ b/tamguo-tms/src/main/java/com/tamguo/utils/ShiroUtils.java
@@ -0,0 +1,49 @@
+package com.tamguo.utils;
+
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.session.Session;
+import org.apache.shiro.subject.Subject;
+
+import com.tamguo.modules.member.model.MemberEntity;
+
+public class ShiroUtils {
+
+ public static Session getSession() {
+ return SecurityUtils.getSubject().getSession();
+ }
+
+ public static Subject getSubject() {
+ return SecurityUtils.getSubject();
+ }
+
+ public static MemberEntity getMember() {
+ return (MemberEntity)SecurityUtils.getSubject().getPrincipal();
+ }
+
+ public static String getMemberId() {
+ return getMember().getId();
+ }
+
+ public static void setSessionAttribute(Object key, Object value) {
+ getSession().setAttribute(key, value);
+ }
+
+ public static Object getSessionAttribute(Object key) {
+ return getSession().getAttribute(key);
+ }
+
+ public static boolean isLogin() {
+ return SecurityUtils.getSubject().getPrincipal() != null;
+ }
+
+ public static void logout() {
+ SecurityUtils.getSubject().logout();
+ }
+
+ public static String getKaptcha(String key) {
+ String kaptcha = getSessionAttribute(key).toString();
+// getSession().removeAttribute(key);
+ return kaptcha;
+ }
+
+}
diff --git a/tamguo-tms/src/main/java/com/tamguo/web/member/AccountController.java b/tamguo-tms/src/main/java/com/tamguo/web/member/AccountController.java
new file mode 100644
index 0000000..3770880
--- /dev/null
+++ b/tamguo-tms/src/main/java/com/tamguo/web/member/AccountController.java
@@ -0,0 +1,149 @@
+package com.tamguo.web.member;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.tamguo.common.utils.DateUtils;
+import com.tamguo.common.utils.Result;
+import com.tamguo.common.utils.Status;
+import com.tamguo.common.utils.UploaderMessage;
+import com.tamguo.config.redis.CacheService;
+import com.tamguo.modules.member.model.MemberEntity;
+import com.tamguo.modules.member.service.IMemberService;
+import com.tamguo.utils.ShiroUtils;
+
+@Controller
+public class AccountController {
+
+ @Autowired
+ public IMemberService memberService;
+ @Value("${file.storage.path}")
+ private String fileStoragePath;
+ @Value("${domain.name}")
+ private String domainName;
+ @Autowired
+ private CacheService cacheService;
+
+ private static final String AVATOR_NO_FORMAT = "00000";
+ private static final String AVATOR_PREFIX = "MTX";
+
+ public Logger logger = LoggerFactory.getLogger(getClass());
+
+ @RequestMapping(value = "member/account.html", method = RequestMethod.GET)
+ public ModelAndView index(ModelAndView model , HttpSession session){
+ model.setViewName("member/account");
+ MemberEntity member = (MemberEntity) session.getAttribute("currMember");
+ model.addObject("member" , memberService.findByUid(member.getId()));
+ return model;
+ }
+
+ @RequestMapping(value = "member/account/update.html", method = RequestMethod.POST)
+ @ResponseBody
+ public Result updateMember(@RequestBody MemberEntity member){
+ member.setId(ShiroUtils.getMemberId());
+ memberService.updateMember(member);
+ return Result.successResult(member);
+ }
+
+ @RequestMapping(value = "member/password.html", method = RequestMethod.GET)
+ public ModelAndView password(ModelAndView model){
+ model.setViewName("member/password");
+ return model;
+ }
+
+ @RequestMapping(value = "member/password/update.html", method = RequestMethod.POST)
+ @ResponseBody
+ public Result updatePwd(@RequestBody MemberEntity member){
+ member.setId(ShiroUtils.getMemberId());
+ return memberService.updatePwd(member);
+ }
+
+ @RequestMapping(value = "/member/uploadFile.html", method = RequestMethod.POST)
+ @ResponseBody
+ public UploaderMessage uploadFileHandler(@RequestParam("file") MultipartFile file,HttpServletRequest request) throws IOException {
+
+ if (!file.isEmpty()) {
+ InputStream in = null;
+ OutputStream out = null;
+
+ try {
+ String path = fileStoragePath + DateUtils.format(new Date(), "yyyyMMdd");
+ File dir = new File(path);
+ if (!dir.exists()) {
+ dir.mkdirs();
+ }
+ String avatorName = this.getAvatorNo() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
+ in = file.getInputStream();
+ out = new FileOutputStream(path + "/" + avatorName);
+ byte[] b = new byte[1024];
+ int len = 0;
+ while ((len = in.read(b)) > 0) {
+ out.write(b, 0, len);
+ }
+ out.close();
+ in.close();
+ logger.info("Server File Location=" + path + avatorName);
+
+ UploaderMessage msg = new UploaderMessage();
+ msg.setStatus(Status.SUCCESS);
+ msg.setStatusMsg("File upload success");
+ msg.setFilePath("files/" + DateUtils.format(new Date(), "yyyyMMdd") + "/" + avatorName);
+ msg.setFileDomain(domainName);
+ return msg;
+ } catch (Exception e) {
+ UploaderMessage msg = new UploaderMessage();
+ msg.setStatus(Status.ERROR);
+ msg.setError("File upload file");
+ return msg;
+ } finally {
+ if (out != null) {
+ out.close();
+ out = null;
+ }
+
+ if (in != null) {
+ in.close();
+ in = null;
+ }
+ }
+ } else {
+ UploaderMessage msg = new UploaderMessage();
+ msg.setStatus(Status.ERROR);
+ msg.setError("File is empty");
+ return msg;
+ }
+ }
+
+
+ private String getAvatorNo() {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
+ String format = sdf.format(new Date());
+ DecimalFormat df = new DecimalFormat(AVATOR_NO_FORMAT);
+ String key = AVATOR_PREFIX + format;
+ Long incr = cacheService.incr(key);
+ String avatorNo = AVATOR_PREFIX + df.format(incr);
+ return avatorNo;
+ }
+}
diff --git a/tamguo-tms/src/main/java/com/tamguo/web/member/LoginController.java b/tamguo-tms/src/main/java/com/tamguo/web/member/LoginController.java
new file mode 100644
index 0000000..0d85a59
--- /dev/null
+++ b/tamguo-tms/src/main/java/com/tamguo/web/member/LoginController.java
@@ -0,0 +1,107 @@
+package com.tamguo.web.member;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shiro.authc.IncorrectCredentialsException;
+import org.apache.shiro.authc.LockedAccountException;
+import org.apache.shiro.authc.UnknownAccountException;
+import org.apache.shiro.authc.UsernamePasswordToken;
+import org.apache.shiro.subject.Subject;
+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 org.springframework.web.servlet.ModelAndView;
+
+import com.tamguo.common.image.CaptchaUtils;
+import com.tamguo.common.utils.Result;
+import com.tamguo.common.utils.SystemConstant;
+import com.tamguo.utils.ShiroUtils;
+
+@Controller
+public class LoginController {
+
+ @RequestMapping("captcha.jpg")
+ public void captcha(HttpServletResponse response) throws ServletException, IOException {
+ response.setHeader("Cache-Control", "no-store, no-cache");
+ response.setContentType("image/jpeg");
+
+ String a = CaptchaUtils.generateCaptcha(response.getOutputStream());
+ ShiroUtils.setSessionAttribute(SystemConstant.KAPTCHA_SESSION_KEY, a);
+ }
+
+ @RequestMapping(value = "/login.html", method = RequestMethod.GET)
+ public ModelAndView login(ModelAndView model){
+ model.setViewName("login");
+ model.addObject("isVerifyCode" , "0");
+ return model;
+ }
+
+ @RequestMapping(value = "/submitLogin.html", method = RequestMethod.POST)
+ public ModelAndView submitLogin(String username , String password , String verifyCode , ModelAndView model , HttpSession session , HttpServletResponse response) throws IOException{
+ Result result = Result.successResult(null);
+ if(StringUtils.isEmpty(verifyCode)) {
+ result = Result.result(202, null, "请输入验证码");
+ } else if(StringUtils.isNotEmpty(verifyCode)){
+ String kaptcha = ShiroUtils.getKaptcha(SystemConstant.KAPTCHA_SESSION_KEY);
+ if (!verifyCode.equalsIgnoreCase(kaptcha)) {
+ result = Result.result(205, null, "验证码错误");
+ } else {
+ Subject subject = ShiroUtils.getSubject();
+ UsernamePasswordToken token = new UsernamePasswordToken(username, password);
+ try {
+ subject.login(token);
+
+ session.setAttribute("currMember", ShiroUtils.getMember());
+ response.sendRedirect("member/index.html");
+ return null;
+ } catch (UnknownAccountException e) {
+ result = Result.result(201, null, "用户名或密码有误,请重新输入或找回密码");
+ } catch (IncorrectCredentialsException e) {
+ result = Result.result(202, null, "用户名或密码有误,请重新输入或找回密码");
+ } catch (LockedAccountException e) {
+ result = Result.result(203, null, "账号被锁定");
+ }
+ }
+ }
+ model.setViewName("login");
+ model.addObject("code", result.getCode());
+ model.addObject("msg" , result.getMessage());
+ model.addObject("username", username);
+ return model;
+ }
+
+ @RequestMapping(value = "/miniLogin.html", method = RequestMethod.GET)
+ @ResponseBody
+ public Result miniLogin(String username , String password , String captcha, ModelAndView model , HttpSession session) {
+ Result result = null;
+ if(StringUtils.isEmpty(captcha)) {
+ result = Result.result(204, null, "请输入验证码");
+ } else if(StringUtils.isNotEmpty(captcha)){
+ String kaptcha = ShiroUtils.getKaptcha(SystemConstant.KAPTCHA_SESSION_KEY);
+ if (!captcha.equalsIgnoreCase(kaptcha)) {
+ result = Result.result(205, null, "验证码错误");
+ }else {
+ Subject subject = ShiroUtils.getSubject();
+ UsernamePasswordToken token = new UsernamePasswordToken(username, password);
+ try {
+ subject.login(token);
+ session.setAttribute("currMember", ShiroUtils.getMember());
+ result = Result.successResult(ShiroUtils.getMember());
+ } catch (UnknownAccountException e) {
+ result = Result.result(201, null, "用户名或密码有误,请重新输入或找回密码");
+ } catch (IncorrectCredentialsException e) {
+ result = Result.result(202, null, "用户名或密码有误,请重新输入或找回密码");
+ } catch (LockedAccountException e) {
+ result = Result.result(203, null, "账号被锁定");
+ }
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/tamguo-tms/src/main/java/com/tamguo/web/member/LogoutController.java b/tamguo-tms/src/main/java/com/tamguo/web/member/LogoutController.java
new file mode 100644
index 0000000..fe7a48f
--- /dev/null
+++ b/tamguo-tms/src/main/java/com/tamguo/web/member/LogoutController.java
@@ -0,0 +1,28 @@
+package com.tamguo.web.member;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import com.tamguo.utils.ShiroUtils;
+
+@Controller
+public class LogoutController {
+
+ /**
+ * 注销
+ */
+ @RequestMapping(value = "logout.html", method = RequestMethod.GET)
+ public String logout(HttpServletRequest request, HttpServletResponse response, HttpSession session) {
+ if (session.getAttribute("currMember") != null) {
+ session.removeAttribute("currMember");
+ ShiroUtils.logout();
+ }
+ return "redirect:/";
+ }
+
+}
diff --git a/tamguo-tms/src/main/java/com/tamguo/web/member/MemberController.java b/tamguo-tms/src/main/java/com/tamguo/web/member/MemberController.java
new file mode 100644
index 0000000..bbf332c
--- /dev/null
+++ b/tamguo-tms/src/main/java/com/tamguo/web/member/MemberController.java
@@ -0,0 +1,32 @@
+package com.tamguo.web.member;
+
+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 org.springframework.web.servlet.ModelAndView;
+
+import com.tamguo.common.utils.Result;
+import com.tamguo.modules.member.service.IMemberService;
+import com.tamguo.utils.ShiroUtils;
+
+@Controller
+public class MemberController {
+
+ @Autowired
+ IMemberService iMemberService;
+
+ @RequestMapping(value = "/member/index.html", method = RequestMethod.GET)
+ public ModelAndView index(ModelAndView model){
+ model.setViewName("member/index");
+ model.addObject("member" , iMemberService.findByUid(ShiroUtils.getMember().getId()));
+ return model;
+ }
+
+ @RequestMapping(value = "/member/findCurrMember.html", method = RequestMethod.GET)
+ @ResponseBody
+ public Result findCurrMember() {
+ return Result.successResult(iMemberService.findCurrMember(ShiroUtils.getMemberId()));
+ }
+}
diff --git a/tamguo-tms/src/main/java/com/tamguo/web/member/MemberPaperController.java b/tamguo-tms/src/main/java/com/tamguo/web/member/MemberPaperController.java
new file mode 100644
index 0000000..eb4b908
--- /dev/null
+++ b/tamguo-tms/src/main/java/com/tamguo/web/member/MemberPaperController.java
@@ -0,0 +1,127 @@
+package com.tamguo.web.member;
+
+import java.util.Map;
+import javax.servlet.http.HttpSession;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.mapper.Condition;
+import com.baomidou.mybatisplus.plugins.Page;
+import com.tamguo.common.utils.ExceptionSupport;
+import com.tamguo.common.utils.Result;
+import com.tamguo.modules.member.model.MemberEntity;
+import com.tamguo.modules.tiku.model.PaperEntity;
+import com.tamguo.modules.tiku.model.enums.QuestionTypeEnum;
+import com.tamguo.modules.tiku.service.IPaperService;
+import com.tamguo.utils.ShiroUtils;
+
+@Controller
+public class MemberPaperController {
+
+ @Autowired
+ private IPaperService iPaperService;
+
+
+ @RequestMapping(value = "/member/paper.html", method = RequestMethod.GET)
+ public ModelAndView paper(ModelAndView model, HttpSession session){
+ model.setViewName("member/paperList");
+ return model;
+ }
+
+ @RequestMapping(value = "/member/findPaper.html", method = RequestMethod.GET)
+ @ResponseBody
+ public Result findPaper(String paperId) {
+ return Result.successResult(iPaperService.selectById(paperId));
+ }
+
+ @SuppressWarnings({ "unchecked"})
+ @RequestMapping(value = "member/paper/list.html" , method = RequestMethod.GET)
+ @ResponseBody
+ public Map paperList(String name , Integer page , Integer limit , HttpSession session){
+ MemberEntity member = ((MemberEntity)session.getAttribute("currMember"));
+ Page list = iPaperService.selectPage(new Page<>(page , limit) , Condition.create().like("name", name).eq("creater_id", member.getId()));
+ return Result.jqGridResult(list.getRecords(), list.getTotal(), limit, page, list.getPages());
+ }
+
+ @RequestMapping(value="member/paperList/addPaperQuestionInfo.html",method=RequestMethod.POST)
+ @ResponseBody
+ public Result addPaperQuestionInfo(@RequestBody JSONObject data){
+ try {
+ String paperId ; String title ; String name ;String type;
+ paperId = data.getString("uid");
+ title = data.getString("title");
+ type = data.getString("type");
+ name = QuestionTypeEnum.getQuestionType(type).getDesc();
+ iPaperService.addPaperQuestionInfo(paperId , title , name , type);
+ return Result.result(0, null, "修改成功");
+ } catch (Exception e) {
+ return ExceptionSupport.resolverResult("添加questionInfo", this.getClass(), e);
+ }
+ }
+
+ @RequestMapping("member/paperList/updatePaperQuestionInfo.html")
+ @ResponseBody
+ public Result updatePaperQuestionInfo(@RequestBody JSONObject data){
+ try {
+ String paperId ; String title ; String name ; String type ; String uid;
+ paperId = data.getString("uid");
+ title = data.getString("title");
+ type = data.getString("type");
+ name = QuestionTypeEnum.getQuestionType(type).getDesc();
+ uid = data.getString("infoUid");
+ iPaperService.updatePaperQuestionInfo(paperId , title , name , type , uid);
+ return Result.result(0, null, "修改成功");
+ } catch (Exception e) {
+ return ExceptionSupport.resolverResult("修改questionInfo", this.getClass(), e);
+ }
+ }
+
+ @RequestMapping("member/paperList/deletePaper")
+ @ResponseBody
+ public Result deletePaper(String paperId){
+ try {
+ return iPaperService.deletePaper(ShiroUtils.getMemberId() , paperId);
+ } catch (Exception e) {
+ return ExceptionSupport.resolverResult("删除试卷", this.getClass(), e);
+ }
+ }
+
+ @RequestMapping("member/paperList/deletePaperQuestionInfoBtn.html")
+ @ResponseBody
+ public Result deletePaperQuestionInfoBtn(String paperId , String uid){
+ try {
+ return iPaperService.deletePaperQuestionInfoBtn(ShiroUtils.getMemberId() , paperId , uid);
+ } catch (Exception e) {
+ return ExceptionSupport.resolverResult("删除子卷", this.getClass(), e);
+ }
+ }
+
+ @RequestMapping(value="member/paperList/addPaper.html",method=RequestMethod.POST)
+ @ResponseBody
+ public Result addPaper(@RequestBody PaperEntity paper,HttpSession session){
+ try {
+ MemberEntity member = (MemberEntity) session.getAttribute("currMember");
+ paper.setCreaterId(member.getId());
+ iPaperService.addPaper(paper);
+ return Result.result(Result.SUCCESS_CODE, paper, "添加成功");
+ } catch (Exception e) {
+ return ExceptionSupport.resolverResult("添加试卷", this.getClass(), e);
+ }
+ }
+
+ @RequestMapping(value="member/paperList/updatePaper.html",method=RequestMethod.POST)
+ @ResponseBody
+ public Result updatePaper(@RequestBody PaperEntity paper){
+ try {
+ return iPaperService.updatePaper(paper , ShiroUtils.getMemberId());
+ } catch (Exception e) {
+ return ExceptionSupport.resolverResult("修改试卷", this.getClass(), e);
+ }
+ }
+}
diff --git a/tamguo-tms/src/main/java/com/tamguo/web/member/PasswordController.java b/tamguo-tms/src/main/java/com/tamguo/web/member/PasswordController.java
new file mode 100644
index 0000000..75868d7
--- /dev/null
+++ b/tamguo-tms/src/main/java/com/tamguo/web/member/PasswordController.java
@@ -0,0 +1,81 @@
+package com.tamguo.web.member;
+
+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 org.springframework.web.servlet.ModelAndView;
+
+import com.tamguo.common.utils.Result;
+import com.tamguo.common.utils.SystemConstant;
+import com.tamguo.modules.member.service.IMemberService;
+import com.tamguo.utils.ShiroUtils;
+
+@Controller
+public class PasswordController {
+
+ @Autowired
+ private IMemberService iMemberService;
+
+ @RequestMapping(value = "password/find.html", method = RequestMethod.GET)
+ public ModelAndView confirmAccount(ModelAndView model){
+ model.setViewName("password/confirmAccount");
+ return model;
+ }
+
+ @RequestMapping(value = "password/confirmAccount.html", method = RequestMethod.POST)
+ public ModelAndView submitConfirmAccount(String username , String veritycode , ModelAndView model){
+ Result result = iMemberService.confirmAccount(username, veritycode);
+ String kaptcha = ShiroUtils.getKaptcha(SystemConstant.KAPTCHA_SESSION_KEY);
+ if (!veritycode.equalsIgnoreCase(kaptcha)) {
+ result = Result.result(202, null, "验证码错误");
+ }
+ if(result.getCode() == 200){
+ model.setViewName("password/securityCheck");
+ model.addObject("result", result);
+ model.addObject("isEmail", username.contains("@") ? "1" : "0");
+ }else{
+ model.setViewName("password/confirmAccount");
+ model.addObject("account", username);
+ model.addObject("username",username);
+ model.addObject("veritycode", veritycode);
+ model.addObject("code", result.getCode());
+ }
+ return model;
+ }
+
+ @RequestMapping(value = "password/securityCheck.html", method = RequestMethod.POST)
+ public ModelAndView securityCheck(String username , String isEmail , String mobileVcode , ModelAndView model){
+ Result result = iMemberService.securityCheck(username , isEmail , mobileVcode);
+ if(result.getCode() == 200){
+ model.addObject("username", username);
+ model.addObject("resetPasswordKey" , result.getResult());
+ model.setViewName("password/resetPassword");
+ }else{
+ model.addObject("result", result);
+ model.addObject("isEmail", isEmail);
+ model.addObject("codeError", "1");
+ model.setViewName("password/securityCheck");
+ }
+ return model;
+ }
+
+ @RequestMapping(value = "password/resetPassword.html", method = RequestMethod.POST)
+ public ModelAndView resetPassword(String resetPasswordKey , String username , String password , String verifypwd , ModelAndView model){
+ Result result = iMemberService.resetPassword(resetPasswordKey , username , password , verifypwd);
+ if(result.getCode() == 200){
+ model.setViewName("password/resetPwSuccess");
+ }else{
+ model.setViewName("password/resetPassword");
+ }
+ return model;
+ }
+
+ @RequestMapping(value = "password/checkAccount.html", method = RequestMethod.GET)
+ @ResponseBody
+ public Result checkAccount(String account){
+ return iMemberService.checkAccount(account);
+ }
+
+}
diff --git a/tamguo-tms/src/main/java/com/tamguo/web/member/QuestionController.java b/tamguo-tms/src/main/java/com/tamguo/web/member/QuestionController.java
new file mode 100644
index 0000000..7fd9afc
--- /dev/null
+++ b/tamguo-tms/src/main/java/com/tamguo/web/member/QuestionController.java
@@ -0,0 +1,97 @@
+package com.tamguo.web.member;
+
+import java.util.Map;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.plugins.Page;
+import com.tamguo.common.utils.ExceptionSupport;
+import com.tamguo.common.utils.Result;
+import com.tamguo.modules.tiku.model.QuestionEntity;
+import com.tamguo.modules.tiku.service.IPaperService;
+import com.tamguo.modules.tiku.service.IQuestionService;
+import com.tamguo.utils.ShiroUtils;
+
+@Controller(value="memberQuestionController")
+public class QuestionController {
+
+ @Autowired
+ private IQuestionService iQuestionService;
+ @Autowired
+ private IPaperService iPaperService;
+
+ @RequestMapping(value = "/member/addQuestion.html", method = RequestMethod.GET)
+ public ModelAndView index(String paperId , ModelAndView model){
+ model.setViewName("member/addQuestion");
+ model.addObject("paper", iPaperService.selectById(paperId));
+ return model;
+ }
+
+ @RequestMapping(value = "/member/submitQuestion.html", method = RequestMethod.POST)
+ @ResponseBody
+ public Result submitQuestion(QuestionEntity question){
+ try {
+ return iQuestionService.addQuestion(question , ShiroUtils.getMemberId());
+ } catch (Exception e) {
+ return ExceptionSupport.resolverResult("添加试题", this.getClass(), e);
+ }
+ }
+
+ @RequestMapping(value = "/member/questionList.html", method = RequestMethod.GET)
+ public ModelAndView questionList(String paperId , ModelAndView model){
+ model.addObject("paper", iPaperService.selectById(paperId));
+ model.setViewName("member/questionList");
+ return model;
+ }
+
+ @RequestMapping(value = "/member/queryQuestionList.html" , method=RequestMethod.POST)
+ @ResponseBody
+ public Map queryQuestionList(@RequestBody JSONObject data){
+ String questionType ; String uid ; String content ; String paperId ;
+ Integer page ; Integer limit;
+ questionType = data.getString("questionType");
+ uid = data.getString("uid");
+ content = data.getString("content");
+ paperId = data.getString("paperId");
+ page = data.getInteger("page");
+ limit = data.getInteger("limit");
+ Page p = new Page<>();
+ p.setCurrent(page);
+ p.setSize(limit);
+ Page list = iQuestionService.queryQuestionList(questionType , uid , content , paperId , ShiroUtils.getMemberId() , p);
+ return Result.jqGridResult(list.getRecords(), list.getTotal(), limit, page, list.getPages());
+ }
+
+ @RequestMapping(value = "/member/editQuestion.html", method = RequestMethod.GET)
+ public ModelAndView editQuestion(String paperId , String questionId , ModelAndView model){
+ model.setViewName("member/editQuestion");
+ model.addObject("paper", iPaperService.selectById(paperId));
+ model.addObject("questionId" , questionId);
+ return model;
+ }
+
+ @RequestMapping(value = "/member/getQuestion.html", method = RequestMethod.GET)
+ @ResponseBody
+ public Result getQuestion(String questionId) {
+ return Result.successResult(iQuestionService.selectById(questionId));
+ }
+
+ @RequestMapping(value = "/member/updateQuestion.html", method = RequestMethod.POST)
+ @ResponseBody
+ public Result updateQuestion(QuestionEntity question) {
+ return iQuestionService.updateQuestion(question , ShiroUtils.getMemberId());
+ }
+
+
+ @RequestMapping(value = "/member/deleteQuestion.html", method = RequestMethod.GET)
+ @ResponseBody
+ public Result deleteQuestion(@RequestBody String uid) {
+ return iQuestionService.delete(uid , ShiroUtils.getMemberId());
+ }
+}
diff --git a/tamguo-tms/src/main/java/com/tamguo/web/member/RegisterController.java b/tamguo-tms/src/main/java/com/tamguo/web/member/RegisterController.java
new file mode 100644
index 0000000..5bea46e
--- /dev/null
+++ b/tamguo-tms/src/main/java/com/tamguo/web/member/RegisterController.java
@@ -0,0 +1,69 @@
+package com.tamguo.web.member;
+
+import javax.servlet.http.HttpSession;
+import org.apache.shiro.authc.IncorrectCredentialsException;
+import org.apache.shiro.authc.LockedAccountException;
+import org.apache.shiro.authc.UnknownAccountException;
+import org.apache.shiro.authc.UsernamePasswordToken;
+import org.apache.shiro.subject.Subject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.tamguo.common.utils.Result;
+import com.tamguo.modules.member.model.MemberEntity;
+import com.tamguo.modules.member.service.IMemberService;
+import com.tamguo.utils.ShiroUtils;
+
+@Controller
+public class RegisterController {
+
+ @Autowired
+ private IMemberService iMemberService;
+
+ @RequestMapping(value = "/register.html", method = RequestMethod.GET)
+ public ModelAndView register(ModelAndView model , HttpSession session) {
+ model.setViewName("register");
+ return model;
+ }
+
+ @RequestMapping(value = "/checkUsername.html", method = RequestMethod.GET)
+ @ResponseBody
+ public Result checkUsername(String username){
+ return iMemberService.checkUsername(username);
+ }
+
+ @RequestMapping(value = "/checkMobile.html", method = RequestMethod.GET)
+ @ResponseBody
+ public Result checkMobile(String mobile){
+ return iMemberService.checkMobile(mobile);
+ }
+
+ @RequestMapping(value = "/subRegister.html", method = RequestMethod.POST)
+ @ResponseBody
+ public Result subRegister(@RequestBody MemberEntity member , HttpSession session){
+ Result result = iMemberService.register(member);
+ if(result.getCode() == 200) {
+ Subject subject = ShiroUtils.getSubject();
+ MemberEntity memberEntity = (MemberEntity) result.getResult();
+ UsernamePasswordToken token = new UsernamePasswordToken(memberEntity.getUsername(), member.getPassword());
+ try {
+ subject.login(token);
+
+ session.setAttribute("currMember", ShiroUtils.getMember());
+ } catch (UnknownAccountException e) {
+ return Result.result(201, null, "用户名或密码有误,请重新输入或找回密码");
+ } catch (IncorrectCredentialsException e) {
+ return Result.result(202, null, "用户名或密码有误,请重新输入或找回密码");
+ } catch (LockedAccountException e) {
+ return Result.result(203, null, "账号被锁定");
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/tamguo-tms/src/main/java/com/tamguo/web/tiku/SmsController.java b/tamguo-tms/src/main/java/com/tamguo/web/tiku/SmsController.java
new file mode 100644
index 0000000..795def2
--- /dev/null
+++ b/tamguo-tms/src/main/java/com/tamguo/web/tiku/SmsController.java
@@ -0,0 +1,30 @@
+package com.tamguo.web.tiku;
+
+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.aliyuncs.exceptions.ClientException;
+import com.tamguo.common.utils.Result;
+import com.tamguo.modules.sys.service.ISmsService;
+
+@Controller
+public class SmsController {
+
+ @Autowired
+ ISmsService iSmsService;
+
+ @RequestMapping(value = {"sms/sendFindPasswordSms.html"}, method = RequestMethod.GET)
+ @ResponseBody
+ public Result sendFindPasswordSms(String mobile){
+ try {
+ return iSmsService.sendFindPasswordSms(mobile);
+ } catch (ClientException e) {
+ e.printStackTrace();
+ }
+ return Result.result(500, null, "");
+ }
+
+}
diff --git a/tamguo-tms/src/main/java/com/tamguo/web/tiku/SubjectController.java b/tamguo-tms/src/main/java/com/tamguo/web/tiku/SubjectController.java
index 31fb3e5..cf6e3aa 100644
--- a/tamguo-tms/src/main/java/com/tamguo/web/tiku/SubjectController.java
+++ b/tamguo-tms/src/main/java/com/tamguo/web/tiku/SubjectController.java
@@ -8,9 +8,12 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
+import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.mapper.Condition;
+import com.tamguo.common.utils.Result;
import com.tamguo.modules.sys.service.ISysAreaService;
import com.tamguo.modules.tiku.model.BookEntity;
import com.tamguo.modules.tiku.model.ChapterEntity;
@@ -71,6 +74,13 @@ public class SubjectController {
model.setViewName("500");
return model;
}
-
}
+
+ // [{"value":"11","label":"北京市","children":[{"value":"1101","label":"市辖区"}]}]
+ @RequestMapping(value = {"subject/getCourseCascaderTree.html"}, method = RequestMethod.GET)
+ @ResponseBody
+ public Result getCourseCascaderTree() {
+ JSONArray list = iSubjectService.getCourseCascaderTree();
+ return Result.successResult(list);
+ }
}
diff --git a/tamguo-tms/src/main/resources/static/js/member/paperList.js b/tamguo-tms/src/main/resources/static/js/member/paperList.js
index 61f4072..61a5c50 100644
--- a/tamguo-tms/src/main/resources/static/js/member/paperList.js
+++ b/tamguo-tms/src/main/resources/static/js/member/paperList.js
@@ -77,10 +77,10 @@ var vm = new Vue({
methods: {
reload: function (currPage) {
vm.loading = true;
- axios({method: 'get',url: mainHttp + "/member/paper/list.html?name="+vm.q.name+"&page="+currPage+"&limit=6"}).then(function(response){
+ axios({method: 'get',url: mainHttp + "member/paper/list.html?name="+vm.q.name+"&page="+currPage+"&limit=6"}).then(function(response){
vm.paperList = response.data.list;
if(vm.paperList != null && vm.paperList.length > 0 ){
- vm.currPaperUid = vm.paperList[0].uid;
+ vm.currPaperUid = vm.paperList[0].id;
}
vm.totalCount = response.data.totalCount;
vm.loading = false;
@@ -126,7 +126,7 @@ var vm = new Vue({
vm.paper.schoolId = vm.paper.schoolIdList.join(",");
}
var url = null;
- if(/^(undefined|null|\s*)?$/.test(vm.paper.uid)){
+ if(/^(undefined|null|\s*)?$/.test(vm.paper.id)){
url = mainHttp + 'member/paperList/addPaper.html';
}else {
url = mainHttp + 'member/paperList/updatePaper.html';
@@ -176,7 +176,7 @@ var vm = new Vue({
showPaperInfo:function(uid , queInfo){
vm.paperInfo.flag = true;
- vm.paperInfo.uid = uid;
+ vm.paperInfo.id = uid;
vm.paperInfo.queInfo = queInfo;
@@ -216,7 +216,7 @@ var vm = new Vue({
// 实现修改试卷
showUpdatePaperInfo:function(uid , type , title , infoUid){
vm.paperInfo.flag = false;
- vm.paperInfo.uid = uid;
+ vm.paperInfo.id = uid;
vm.paperInfoDialogFormVisible = true
vm.paperInfo.name = name;
diff --git a/tamguo-tms/src/main/resources/templates/404.html b/tamguo-tms/src/main/resources/templates/404.html
index 2fce410..dd556ed 100644
--- a/tamguo-tms/src/main/resources/templates/404.html
+++ b/tamguo-tms/src/main/resources/templates/404.html
@@ -3,10 +3,10 @@
探果题库_资源不存在
-
+
访问的内容不存在!
-返回首页
+返回首页