基板
This commit is contained in:
17
src/main/java/com/quinn/common/ExceptionCode.java
Normal file
17
src/main/java/com/quinn/common/ExceptionCode.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.quinn.common;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ExceptionCode implements Serializable {
|
||||
public Integer code;
|
||||
public String msg;
|
||||
|
||||
public ExceptionCode(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.msg = message;
|
||||
}
|
||||
|
||||
public static ExceptionCode init(Integer code, String message) {
|
||||
return new ExceptionCode(code, message);
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,18 @@ import org.springframework.security.config.annotation.method.configuration.Enabl
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||
import org.springframework.security.web.authentication.AuthenticationEntryPointFailureHandler;
|
||||
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
@EnableWebSecurity
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||
@@ -29,9 +39,13 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
http.authorizeRequests()
|
||||
.antMatchers("/","/index").permitAll()
|
||||
.antMatchers("/register","/login","/toLogin").permitAll()
|
||||
.antMatchers("/source","/source/view/*").permitAll()
|
||||
.antMatchers("/blog","/blog/read/*").permitAll()
|
||||
.antMatchers("/hotspot").permitAll()
|
||||
.antMatchers("/blog/**").authenticated()
|
||||
.antMatchers("/source/**").authenticated()
|
||||
.antMatchers("/user/**").authenticated()
|
||||
.antMatchers("/wx/**").authenticated()
|
||||
.antMatchers("/*").authenticated();
|
||||
|
||||
// 登录配置
|
||||
@@ -40,6 +54,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.passwordParameter("password")
|
||||
.loginPage("/toLogin")
|
||||
.loginProcessingUrl("/login") // 登陆表单提交请求
|
||||
.failureForwardUrl("/loginError")
|
||||
.defaultSuccessUrl("/index"); // 设置默认登录成功后跳转的页面
|
||||
|
||||
// 注销配置
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.quinn.controller;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.quinn.common.RoleType;
|
||||
import com.quinn.intergration.AttrIcon;
|
||||
import com.quinn.intergration.SendBMail;
|
||||
import com.quinn.pojo.Invite;
|
||||
import com.quinn.pojo.User;
|
||||
import com.quinn.pojo.UserInfo;
|
||||
@@ -18,6 +19,10 @@ import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
@Controller
|
||||
public class LoginController {
|
||||
|
||||
@@ -35,9 +40,10 @@ public class LoginController {
|
||||
return "index";
|
||||
}
|
||||
|
||||
@GetMapping("/error/check")
|
||||
public String error(){
|
||||
return "error/check";
|
||||
@PostMapping("/loginError")
|
||||
public String error(Model model){
|
||||
model.addAttribute("loginMsg","错误的用户名或者密码!");
|
||||
return "forget";
|
||||
}
|
||||
|
||||
@GetMapping("/toLogin")
|
||||
@@ -52,55 +58,57 @@ public class LoginController {
|
||||
|
||||
// 注册业务
|
||||
@PostMapping("/register")
|
||||
public String register(RegisterForm registerForm,Model model){
|
||||
public String register(HttpServletResponse response,RegisterForm registerForm, Model model) throws IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter writer = response.getWriter();
|
||||
// 表单密码重复判断
|
||||
if (!registerForm.getPassword().equals(registerForm.getRepassword())){
|
||||
model.addAttribute("registerMsg","密码输入有误");
|
||||
return "register";
|
||||
return toResult(writer,"两次输入密码不一致!");
|
||||
}
|
||||
// 用户名已存在
|
||||
User hasUser = userService.getOne(new QueryWrapper<User>().eq("username", registerForm.getUsername()));
|
||||
if (hasUser!=null){
|
||||
model.addAttribute("registerMsg","用户名已存在");
|
||||
return "register";
|
||||
return toResult(writer,"用户名太热门了,请更换用户名");
|
||||
}
|
||||
|
||||
// 验证邀请码
|
||||
Invite invite = inviteService.getOne(new QueryWrapper<Invite>().eq("code", registerForm.getCode()));
|
||||
if (invite==null){
|
||||
model.addAttribute("registerMsg","邀请码不存在");
|
||||
return "register";
|
||||
}else {
|
||||
// 邀请码存在,判断邀请码是否有效
|
||||
if (invite.getStatus()==1){
|
||||
model.addAttribute("registerMsg","邀请码已被使用");
|
||||
return "register";
|
||||
}else {
|
||||
// 构建用户对象
|
||||
User user = new User();
|
||||
user.setUid(QuinnUtils.getUuid()); // 用户唯一id
|
||||
user.setRole(RoleType.NORMAL.name());
|
||||
user.setUsername(registerForm.getUsername());
|
||||
// 密码加密
|
||||
String bCryptPassword = new BCryptPasswordEncoder().encode(registerForm.getPassword());
|
||||
user.setAvatar(AttrIcon.INSTANCE.generateImgUrl(registerForm.getUsername()));
|
||||
user.setPassword(bCryptPassword);
|
||||
user.setGmtCreate(QuinnUtils.getTime());
|
||||
user.setLoginDate(QuinnUtils.getTime());
|
||||
// 保存对象!
|
||||
userService.save(user);
|
||||
// 激活邀请码
|
||||
invite.setActiveTime(QuinnUtils.getTime());
|
||||
invite.setStatus(1);
|
||||
invite.setUid(user.getUid());
|
||||
inviteService.updateById(invite);
|
||||
|
||||
userInfoService.save(new UserInfo().setUid(user.getUid()));
|
||||
|
||||
// 注册成功,重定向到登录页面
|
||||
return "redirect:/toLogin";
|
||||
}
|
||||
return toResult(writer,"注册码不存在!");
|
||||
}
|
||||
if (invite.getApplyEmail().equals(registerForm.getEmail())){
|
||||
return toResult(writer,"请使用申请注册码邮箱注册用户!");
|
||||
}
|
||||
// 构建用户对象
|
||||
User user = new User();
|
||||
user.setUid(QuinnUtils.getUuid()); // 用户唯一id
|
||||
user.setRole(RoleType.NORMAL.name());
|
||||
user.setUsername(registerForm.getUsername());
|
||||
// 密码加密
|
||||
String bCryptPassword = new BCryptPasswordEncoder().encode(registerForm.getPassword());
|
||||
user.setAvatar(AttrIcon.INSTANCE.generateImgUrl(registerForm.getUsername()));
|
||||
user.setPassword(bCryptPassword);
|
||||
user.setGmtCreate(QuinnUtils.getTime());
|
||||
user.setLoginDate(QuinnUtils.getTime());
|
||||
// 保存对象!
|
||||
userService.save(user);
|
||||
// 激活邀请码
|
||||
invite.setActiveTime(QuinnUtils.getTime());
|
||||
invite.setStatus(1);
|
||||
invite.setUid(user.getUid());
|
||||
inviteService.updateById(invite);
|
||||
userInfoService.save(new UserInfo().setUid(user.getUid()).setEmail(registerForm.getEmail()));
|
||||
// 发送注册成功通知邮件
|
||||
SendBMail.INSTANCE.sendWelcome(registerForm.getUsername(),registerForm.getEmail());
|
||||
// 注册成功,重定向到登录页面
|
||||
return "redirect:/toLogin";
|
||||
}
|
||||
|
||||
private String toResult(PrintWriter writer, String msg) {
|
||||
writer.write(msg);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
return "register";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.quinn.service.CommentService;
|
||||
import com.quinn.service.SourceCategoryService;
|
||||
import com.quinn.service.SourceService;
|
||||
import com.quinn.service.StarService;
|
||||
import com.quinn.utils.QuinnUtils;
|
||||
import com.quinn.vo.*;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@@ -151,4 +152,16 @@ public class SourceController extends BaseModelController {
|
||||
}
|
||||
}
|
||||
|
||||
// 评论
|
||||
@PostMapping("/source/comment/{sid}")
|
||||
public String comment(@PathVariable("sid") String sid, Comment comment){
|
||||
// 存储评论
|
||||
comment.setCommentId(QuinnUtils.getUuid());
|
||||
comment.setTopicCategory(Category.SOURCE.name());
|
||||
comment.setGmtCreate(QuinnUtils.getTime());
|
||||
commentService.save(comment);
|
||||
// 重定向到列表页面
|
||||
return "redirect:/source/view/"+sid;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
94
src/main/java/com/quinn/controller/WxController.java
Normal file
94
src/main/java/com/quinn/controller/WxController.java
Normal file
@@ -0,0 +1,94 @@
|
||||
package com.quinn.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.quinn.dto.req.SearchPage;
|
||||
import com.quinn.dto.req.SendCode;
|
||||
import com.quinn.dto.res.AboutDTO;
|
||||
import com.quinn.dto.res.ResponseDTO;
|
||||
import com.quinn.intergration.SendBMail;
|
||||
import com.quinn.pojo.About;
|
||||
import com.quinn.pojo.Invite;
|
||||
import com.quinn.pojo.UserInfo;
|
||||
import com.quinn.service.AboutService;
|
||||
import com.quinn.service.InviteService;
|
||||
import com.quinn.service.UserInfoService;
|
||||
import com.quinn.service.UserService;
|
||||
import com.quinn.utils.QuinnUtils;
|
||||
import com.quinn.vo.MyPageParam;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author limqsh
|
||||
* @since 2022-05-01
|
||||
*/
|
||||
@RestController("/wx")
|
||||
public class WxController extends BaseModelController {
|
||||
|
||||
@Resource
|
||||
AboutService aboutService;
|
||||
@Resource
|
||||
UserInfoService userInfoService;
|
||||
@Resource
|
||||
InviteService inviteService;
|
||||
|
||||
@PostMapping("about/us")
|
||||
public ResponseDTO userIndexBlog(SearchPage searchPage){
|
||||
Page<About> pageParam = new Page<>(searchPage.getPage(), searchPage.getPageSize());
|
||||
aboutService.page(pageParam,new QueryWrapper<About>().orderByDesc("gmt_create"));
|
||||
// 结果
|
||||
List<About> sayList = pageParam.getRecords();
|
||||
List<AboutDTO> aboutDTOS = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(sayList)){
|
||||
sayList.forEach(x->{
|
||||
AboutDTO aboutDTO = new AboutDTO();
|
||||
aboutDTO.setId(x.getId());
|
||||
aboutDTO.setTitle(x.getTitle());
|
||||
aboutDTO.setContent(x.getContent());
|
||||
aboutDTO.setGmtCreate(QuinnUtils.getViewStrFromDate(x.getGmtCreate()));
|
||||
aboutDTOS.add(aboutDTO);
|
||||
});
|
||||
}
|
||||
MyPageParam myPageParam = new MyPageParam(searchPage.getPage(),searchPage.getPageSize());
|
||||
myPageParam.setTotal((int) pageParam.getTotal());
|
||||
return ResponseDTO.ok().setPage(myPageParam).setData(aboutDTOS);
|
||||
}
|
||||
|
||||
@PostMapping("send/register/code")
|
||||
public ResponseDTO sendCode(SendCode sendCode){
|
||||
Invite email = inviteService.getOne(new QueryWrapper<Invite>().eq("apply_email", sendCode.getEmail()));
|
||||
if (email != null){
|
||||
return ResponseDTO.ok().setData("该邮箱已经获取过注册码");
|
||||
}
|
||||
String code = inviteService.getCode();
|
||||
Invite invite = new Invite();
|
||||
invite.setUid(QuinnUtils.getUuid());
|
||||
invite.setApplyEmail(sendCode.getEmail());
|
||||
invite.setCode(code);
|
||||
invite.setGmtCreate(QuinnUtils.getTime());
|
||||
inviteService.save(invite);
|
||||
boolean sendFlag = SendBMail.INSTANCE.sendRegisterMail(code, sendCode.getEmail());
|
||||
if (!sendFlag){
|
||||
return ResponseDTO.ok().setData("发送识别,请确认邮箱是否正确!");
|
||||
}
|
||||
return ResponseDTO.ok().setData("success");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
13
src/main/java/com/quinn/dto/req/SearchPage.java
Normal file
13
src/main/java/com/quinn/dto/req/SearchPage.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.quinn.dto.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class SearchPage implements Serializable {
|
||||
|
||||
int page;
|
||||
int pageSize;
|
||||
|
||||
}
|
||||
12
src/main/java/com/quinn/dto/req/SendCode.java
Normal file
12
src/main/java/com/quinn/dto/req/SendCode.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.quinn.dto.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class SendCode implements Serializable {
|
||||
|
||||
String email;
|
||||
|
||||
}
|
||||
35
src/main/java/com/quinn/dto/res/AboutDTO.java
Normal file
35
src/main/java/com/quinn/dto/res/AboutDTO.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package com.quinn.dto.res;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author limqsh
|
||||
* @since 2022-05-01
|
||||
*/
|
||||
@Data
|
||||
public class AboutDTO implements Serializable {
|
||||
|
||||
private String id;
|
||||
|
||||
private String title;
|
||||
|
||||
private String content;
|
||||
|
||||
private String gmtCreate;
|
||||
|
||||
|
||||
}
|
||||
74
src/main/java/com/quinn/dto/res/ResponseDTO.java
Normal file
74
src/main/java/com/quinn/dto/res/ResponseDTO.java
Normal file
@@ -0,0 +1,74 @@
|
||||
package com.quinn.dto.res;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import com.quinn.common.ExceptionCode;
|
||||
import com.quinn.vo.MyPageParam;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
public class ResponseDTO extends LinkedHashMap<String, Object> {
|
||||
public static final String ERR_CODE = "err_code";
|
||||
public static final String ERR_MSG = "err_msg";
|
||||
|
||||
public ResponseDTO() {
|
||||
this(0, "OK");
|
||||
}
|
||||
|
||||
public ResponseDTO(Integer errCode, String errMsg) {
|
||||
this(errCode, errMsg, System.currentTimeMillis() / 1000L);
|
||||
}
|
||||
|
||||
public ResponseDTO(Integer errCode, String errMsg, Long timestamp) {
|
||||
this.addAttribute(ERR_CODE, errCode);
|
||||
this.addAttribute(ERR_MSG, errMsg);
|
||||
this.addAttribute("timestamp", timestamp);
|
||||
}
|
||||
|
||||
public ResponseDTO(ExceptionCode exceptionCode) {
|
||||
this(exceptionCode.code, exceptionCode.msg);
|
||||
}
|
||||
|
||||
public ResponseDTO(Integer errCode, String errMsg, String attrName, Object attrValue) {
|
||||
this(errCode, errMsg);
|
||||
this.addAttribute(attrName, attrValue);
|
||||
}
|
||||
|
||||
public static ResponseDTO ok() {
|
||||
return new ResponseDTO();
|
||||
}
|
||||
|
||||
public static ResponseDTO ok(String msg) {
|
||||
ResponseDTO ret = ok();
|
||||
ret.setErrorMsg(msg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public ResponseDTO addAttribute(String attrName, Object attrValue) {
|
||||
Assert.notNull(attrName, "属性名称不能为空");
|
||||
this.put(attrName, attrValue);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResponseDTO setPage(MyPageParam pagination) {
|
||||
this.addAttribute("page", pagination);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResponseDTO setData(Object obj){
|
||||
this.addAttribute("data",obj);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setExceptionCode(ExceptionCode exceptionCode) {
|
||||
this.addAttribute("err_code", exceptionCode.code);
|
||||
this.addAttribute("err_msg", exceptionCode.msg);
|
||||
}
|
||||
|
||||
public void setErrorCode(Integer errCode) {
|
||||
this.addAttribute("err_code", errCode);
|
||||
}
|
||||
|
||||
public void setErrorMsg(String errMsg) {
|
||||
this.addAttribute("err_msg", errMsg);
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,17 @@ public enum SendBMail {
|
||||
boolean isAuth = true;
|
||||
String from = "quinn.admin@88.com";
|
||||
|
||||
public boolean sendMail(String registerCode,String toEmail){
|
||||
public boolean sendRegisterMail(String registerCode,String email){
|
||||
return sendMail("QUINN注册码",
|
||||
"您好,您的注册码是【" + registerCode + "】",email);
|
||||
}
|
||||
|
||||
public boolean sendWelcome(String username,String email){
|
||||
return sendMail("QUINN-注册成功",
|
||||
username + "您好,欢迎使用!",email);
|
||||
}
|
||||
|
||||
private boolean sendMail(String subject,String content,String toEmail){
|
||||
Properties props = new Properties();
|
||||
props.put("mail.smtp.ssl.enable", isSSL);
|
||||
props.put("mail.smtp.host", host);
|
||||
@@ -42,8 +52,8 @@ public enum SendBMail {
|
||||
try {
|
||||
Message message = new MimeMessage(session);
|
||||
message.setFrom(new InternetAddress(from));
|
||||
message.setSubject("");
|
||||
message.setContent("","text/html;charset=UTF-8");
|
||||
message.setSubject(subject);
|
||||
message.setContent(content,"text/html;charset=UTF-8");
|
||||
message.addRecipient(Message.RecipientType.TO, new InternetAddress(toEmail));
|
||||
Transport.send(message);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -34,6 +34,9 @@ public class Invite implements Serializable {
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private String uid;
|
||||
|
||||
@ApiModelProperty(value = "申请邮箱")
|
||||
private String applyEmail;
|
||||
|
||||
@ApiModelProperty(value = "状态 0 未使用 1 使用")
|
||||
private Integer status;
|
||||
|
||||
|
||||
@@ -13,4 +13,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface InviteService extends IService<Invite> {
|
||||
|
||||
String getCode();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.quinn.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.quinn.pojo.Invite;
|
||||
import com.quinn.mapper.InviteMapper;
|
||||
import com.quinn.service.InviteService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.quinn.utils.QuinnUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
@@ -17,4 +19,17 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class InviteServiceImpl extends ServiceImpl<InviteMapper, Invite> implements InviteService {
|
||||
|
||||
|
||||
@Override
|
||||
public String getCode() {
|
||||
String code = "";
|
||||
while (true){
|
||||
code = QuinnUtils.getCode();
|
||||
int count = count(new QueryWrapper<Invite>().eq("apply_email", code).eq("status",'0'));
|
||||
if (count <= 0){
|
||||
break;
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,14 @@ package com.quinn.utils;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
public class QuinnUtils {
|
||||
|
||||
private static final String ALLCHAR = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
private final static SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMdd");
|
||||
private final static SimpleDateFormat sdfv = new SimpleDateFormat( "yyyy-MM-dd");
|
||||
|
||||
public static String getUuid(){
|
||||
return UUID.randomUUID().toString().replaceAll("-","");
|
||||
@@ -21,4 +24,19 @@ public class QuinnUtils {
|
||||
return sdf.format(date);
|
||||
}
|
||||
|
||||
public static String getViewStrFromDate(Date date){
|
||||
return sdfv.format(date);
|
||||
}
|
||||
|
||||
public static String getCode(){
|
||||
int length = 6;
|
||||
//随机数
|
||||
StringBuffer sb = new StringBuffer();
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < length; i++) {
|
||||
sb.append(ALLCHAR.charAt(random.nextInt(ALLCHAR.length())));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,9 @@ public class RegisterForm {
|
||||
@ApiModelProperty(value = "确认密码")
|
||||
private String repassword;
|
||||
|
||||
@ApiModelProperty(value = "申请邮箱")
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty(value = "邀请码")
|
||||
private String code;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user