From bd56c1c79b51c9a513d262c9f04f097cd64dd13d Mon Sep 17 00:00:00 2001 From: tamguo Date: Sun, 5 Aug 2018 18:27:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=99=E5=B8=88=E6=8B=9B=E5=8B=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tamguo/modules/sys/dao/TeacherMapper.java | 8 + .../modules/sys/model/TeacherEntity.java | 164 ++++++++++++++++++ .../sys/model/enums/TeacherStatus.java | 32 ++++ .../modules/sys/service/ITeacherService.java | 23 +++ .../sys/service/impl/TeacherService.java | 52 ++++++ tamguo-tms/pom.xml | 2 +- .../tamguo/config/web/ThymeleafConfig.java | 1 + .../com/tamguo/web/sys/JoinusController.java | 45 +++++ .../resources/templates/teacher/joinus.html | 18 +- 9 files changed, 335 insertions(+), 10 deletions(-) create mode 100644 tamguo-modules-core/src/main/java/com/tamguo/modules/sys/dao/TeacherMapper.java create mode 100644 tamguo-modules-core/src/main/java/com/tamguo/modules/sys/model/TeacherEntity.java create mode 100644 tamguo-modules-core/src/main/java/com/tamguo/modules/sys/model/enums/TeacherStatus.java create mode 100644 tamguo-modules-core/src/main/java/com/tamguo/modules/sys/service/ITeacherService.java create mode 100644 tamguo-modules-core/src/main/java/com/tamguo/modules/sys/service/impl/TeacherService.java create mode 100644 tamguo-tms/src/main/java/com/tamguo/web/sys/JoinusController.java diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/dao/TeacherMapper.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/dao/TeacherMapper.java new file mode 100644 index 0000000..2b644b8 --- /dev/null +++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/dao/TeacherMapper.java @@ -0,0 +1,8 @@ +package com.tamguo.modules.sys.dao; + +import com.tamguo.config.dao.SuperMapper; +import com.tamguo.modules.sys.model.TeacherEntity; + +public interface TeacherMapper extends SuperMapper{ + +} diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/model/TeacherEntity.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/model/TeacherEntity.java new file mode 100644 index 0000000..255153f --- /dev/null +++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/model/TeacherEntity.java @@ -0,0 +1,164 @@ +package com.tamguo.modules.sys.model; + +import java.io.Serializable; +import com.alibaba.fastjson.annotation.JSONField; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.baomidou.mybatisplus.annotations.TableName; +import com.tamguo.config.dao.SuperEntity; +import com.tamguo.modules.sys.model.enums.TeacherStatus; + + +/** + * The persistent class for the tiku_teacher database table. + * + */ +@TableName(value="tiku_teacher") +public class TeacherEntity extends SuperEntity implements Serializable { + private static final long serialVersionUID = 1L; + + private String mobile; + + private String email; + + private String name; + + private String motto; + + private String provinceId; + + private String cityId; + + private String subjectId; + + private String courseId; + + private String cardId; + + private String cardPhoto; + + private String occupationPapers; + + private Long createTime; + + @JSONField(serialzeFeatures= SerializerFeature.WriteEnumUsingToString) + private TeacherStatus status; + + private String qq; + + public String getMobile() { + return mobile; + } + + public void setMobile(String mobile) { + this.mobile = mobile; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getMotto() { + return motto; + } + + public void setMotto(String motto) { + this.motto = motto; + } + + public String getCourseId() { + return courseId; + } + + public void setCourseId(String courseId) { + this.courseId = courseId; + } + + public String getCardId() { + return cardId; + } + + public void setCardId(String cardId) { + this.cardId = cardId; + } + + public String getCardPhoto() { + return cardPhoto; + } + + public void setCardPhoto(String cardPhoto) { + this.cardPhoto = cardPhoto; + } + + public String getOccupationPapers() { + return occupationPapers; + } + + public void setOccupationPapers(String occupationPapers) { + this.occupationPapers = occupationPapers; + } + + public String getQq() { + return qq; + } + + public void setQq(String qq) { + this.qq = qq; + } + + public static long getSerialversionuid() { + return serialVersionUID; + } + + public String getSubjectId() { + return subjectId; + } + + public void setSubjectId(String subjectId) { + this.subjectId = subjectId; + } + + public String getProvinceId() { + return provinceId; + } + + public void setProvinceId(String provinceId) { + this.provinceId = provinceId; + } + + public String getCityId() { + return cityId; + } + + public void setCityId(String cityId) { + this.cityId = cityId; + } + + public Long getCreateTime() { + return createTime; + } + + public void setCreateTime(Long createTime) { + this.createTime = createTime; + } + + public TeacherStatus getStatus() { + return status; + } + + public void setStatus(TeacherStatus status) { + this.status = status; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + +} \ No newline at end of file diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/model/enums/TeacherStatus.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/model/enums/TeacherStatus.java new file mode 100644 index 0000000..854f28c --- /dev/null +++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/model/enums/TeacherStatus.java @@ -0,0 +1,32 @@ +package com.tamguo.modules.sys.model.enums; + +import java.io.Serializable; + +public enum TeacherStatus { + + APPLY("apply", "申请"), + PASS("pass", "通过"), + UNPASS("unpass", "不通过"); + + private String value; + private String desc; + + TeacherStatus(final String value, final String desc) { + this.value = value; + this.desc = desc; + } + + 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/sys/service/ITeacherService.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/service/ITeacherService.java new file mode 100644 index 0000000..70b2278 --- /dev/null +++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/service/ITeacherService.java @@ -0,0 +1,23 @@ +package com.tamguo.modules.sys.service; + +import com.tamguo.common.utils.Result; +import com.tamguo.modules.sys.model.TeacherEntity; + +public interface ITeacherService { + + /** + * 获取教师档案 + * @param mobile + * @param verifyCode + * @return + */ + Result getTeacherByMobile(String mobile , String verifyCode); + + /** + * 加入我们 + * @param teacher + * @return + */ + void joinus(TeacherEntity teacher); + +} diff --git a/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/service/impl/TeacherService.java b/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/service/impl/TeacherService.java new file mode 100644 index 0000000..ed7ce36 --- /dev/null +++ b/tamguo-modules-core/src/main/java/com/tamguo/modules/sys/service/impl/TeacherService.java @@ -0,0 +1,52 @@ +package com.tamguo.modules.sys.service.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +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.sys.dao.TeacherMapper; +import com.tamguo.modules.sys.model.TeacherEntity; +import com.tamguo.modules.sys.model.enums.TeacherStatus; +import com.tamguo.modules.sys.service.ITeacherService; + +@Service +public class TeacherService extends ServiceImpl implements ITeacherService { + + @Autowired + TeacherMapper teacherMapper; + @Autowired + CacheService cacheService; + + @Transactional(readOnly=false) + @Override + public Result getTeacherByMobile(String mobile, String verifyCode) { + // 校验短信验证码 + if(!cacheService.isExist(SystemConstant.ALIYUN_MOBILE_SMS_PREFIX + mobile)){ + return Result.result(201, null, "请发送验证码"); + } + if(!((String)cacheService.getObject(SystemConstant.ALIYUN_MOBILE_SMS_PREFIX + mobile)).equals(verifyCode)) { + return Result.result(202, null, "验证码错误"); + } + TeacherEntity condition = new TeacherEntity(); + condition.setMobile(mobile); + TeacherEntity teacher = teacherMapper.selectOne(condition); + if(teacher == null) { + return Result.result(203, null, "欢迎"); + } + return Result.successResult(teacher); + } + + @Transactional(readOnly=false) + @Override + public void joinus(TeacherEntity teacher) { + teacher.setCreateTime(DateUtil.getTime()); + teacher.setStatus(TeacherStatus.APPLY); + teacherMapper.insert(teacher); + } + +} diff --git a/tamguo-tms/pom.xml b/tamguo-tms/pom.xml index 4d8075e..5c8b1c5 100644 --- a/tamguo-tms/pom.xml +++ b/tamguo-tms/pom.xml @@ -156,7 +156,7 @@ - tamguo-tms + tms org.springframework.boot diff --git a/tamguo-tms/src/main/java/com/tamguo/config/web/ThymeleafConfig.java b/tamguo-tms/src/main/java/com/tamguo/config/web/ThymeleafConfig.java index 85d3909..65fd509 100644 --- a/tamguo-tms/src/main/java/com/tamguo/config/web/ThymeleafConfig.java +++ b/tamguo-tms/src/main/java/com/tamguo/config/web/ThymeleafConfig.java @@ -20,6 +20,7 @@ public class ThymeleafConfig implements EnvironmentAware{ if(viewResolver != null) { Map vars = new HashMap<>(); vars.put("domainName", env.getProperty("domain.name")); + vars.put("adminDomain", env.getProperty("admin.domain.name")); vars.put("PAPER_TYPE_ZHENTI", "1"); vars.put("PAPER_TYPE_MONI", "2"); vars.put("PAPER_TYPE_YATI", "3"); diff --git a/tamguo-tms/src/main/java/com/tamguo/web/sys/JoinusController.java b/tamguo-tms/src/main/java/com/tamguo/web/sys/JoinusController.java new file mode 100644 index 0000000..4b76361 --- /dev/null +++ b/tamguo-tms/src/main/java/com/tamguo/web/sys/JoinusController.java @@ -0,0 +1,45 @@ +package com.tamguo.web.sys; + +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.tamguo.common.utils.Result; +import com.tamguo.modules.sys.model.TeacherEntity; +import com.tamguo.modules.sys.service.ITeacherService; + +@Controller +public class JoinusController { + + @Autowired + private ITeacherService iTeacherService; + + @RequestMapping(value = "teacher/joinus.html", method = RequestMethod.GET) + public ModelAndView register(ModelAndView model , HttpSession session) { + model.setViewName("teacher/joinus"); + return model; + } + + @RequestMapping(value = "teacher/info.html", method = RequestMethod.POST) + @ResponseBody + public Result getTeacher(@RequestBody Map param) { + String mobile = (String) param.get("mobile"); + String verifyCode = (String) param.get("verifyCode"); + Result result = iTeacherService.getTeacherByMobile(mobile, verifyCode); + return result; + } + + @RequestMapping(value = "teacher/joinus.html", method = RequestMethod.POST) + @ResponseBody + public Result teacherJoinus(@RequestBody TeacherEntity teacher) { + iTeacherService.joinus(teacher); + return Result.successResult(null); + } +} diff --git a/tamguo-tms/src/main/resources/templates/teacher/joinus.html b/tamguo-tms/src/main/resources/templates/teacher/joinus.html index 28f6b30..ce01e39 100644 --- a/tamguo-tms/src/main/resources/templates/teacher/joinus.html +++ b/tamguo-tms/src/main/resources/templates/teacher/joinus.html @@ -7,10 +7,10 @@ - - - - + + + + @@ -18,8 +18,8 @@
+