完善管理员登录、注册、重置密码接口

master
panqihua 5 years ago
parent 4b38bb063f
commit 5514f029e8
  1. 137
      src/main/java/com/community/pocket/api/web/ManagerController.java
  2. 3
      src/main/java/com/community/pocket/entity/po/EmailCode.java
  3. 10
      src/main/java/com/community/pocket/entity/po/Manager.java
  4. 5
      src/main/java/com/community/pocket/entity/po/ManagerToken.java
  5. 52
      src/main/java/com/community/pocket/entity/vo/JSONResponse.java
  6. 11
      src/main/java/com/community/pocket/entity/vo/Response.java
  7. 3
      src/main/java/com/community/pocket/entity/vo/android/ForumDataResponse.java
  8. 3
      src/main/java/com/community/pocket/entity/vo/android/ForumHotResponse.java
  9. 3
      src/main/java/com/community/pocket/entity/vo/android/ForumMyResponse.java
  10. 3
      src/main/java/com/community/pocket/entity/vo/android/ForumNewResponse.java
  11. 3
      src/main/java/com/community/pocket/entity/vo/android/ForumNoticeResponse.java
  12. 3
      src/main/java/com/community/pocket/entity/vo/android/ForumPostResponse.java
  13. 36
      src/main/java/com/community/pocket/entity/vo/android/GarbageCateGory.java
  14. 3
      src/main/java/com/community/pocket/entity/vo/android/GarbageSortingResponse.java
  15. 3
      src/main/java/com/community/pocket/entity/vo/android/GarbageWasteResponse.java
  16. 3
      src/main/java/com/community/pocket/entity/vo/android/InfoResponse.java
  17. 3
      src/main/java/com/community/pocket/entity/vo/android/LoginResponse.java
  18. 3
      src/main/java/com/community/pocket/entity/vo/android/QueryUserResponse.java
  19. 3
      src/main/java/com/community/pocket/entity/vo/android/RegisterResponse.java
  20. 3
      src/main/java/com/community/pocket/entity/vo/android/ResetPwdResponse.java
  21. 3
      src/main/java/com/community/pocket/entity/vo/android/VisitorMyResponse.java
  22. 3
      src/main/java/com/community/pocket/entity/vo/android/VisitorPeopleResponse.java
  23. 3
      src/main/java/com/community/pocket/entity/vo/android/VisitorReservationResponse.java
  24. 3
      src/main/java/com/community/pocket/entity/vo/android/VisitorResponse.java
  25. 32
      src/main/java/com/community/pocket/entity/vo/web/EmailTypeResponse.java
  26. 37
      src/main/java/com/community/pocket/entity/vo/web/LoginResponse.java
  27. 22
      src/main/java/com/community/pocket/entity/vo/web/LogoutResponse.java
  28. 5
      src/main/java/com/community/pocket/entity/vo/web/ManagerLogin.java
  29. 14
      src/main/java/com/community/pocket/entity/vo/web/ManagerLogout.java
  30. 2
      src/main/java/com/community/pocket/entity/vo/web/ManagerRegister.java
  31. 57
      src/main/java/com/community/pocket/entity/vo/web/ManagerResetPwd.java
  32. 30
      src/main/java/com/community/pocket/entity/vo/web/RegisterResponse.java
  33. 34
      src/main/java/com/community/pocket/entity/vo/web/ResetpwdResponse.java
  34. 10
      src/main/java/com/community/pocket/repository/ForumRepo.java
  35. 15
      src/main/java/com/community/pocket/repository/ManagerDao.java
  36. 11
      src/main/java/com/community/pocket/repository/ManagerRepo.java
  37. 39
      src/main/java/com/community/pocket/repository/ManagerTokenDao.java
  38. 15
      src/main/java/com/community/pocket/repository/android/GarbageDao.java
  39. 14
      src/main/java/com/community/pocket/util/EmailService.java
  40. 43
      src/main/java/com/community/pocket/util/LocaleConfig.java
  41. 21
      src/main/java/com/community/pocket/util/MessageService.java
  42. 5
      src/main/java/com/community/pocket/util/TableName.java
  43. 9
      src/main/resources/application.yaml
  44. 5
      src/main/resources/static/i18n/messages.properties
  45. 5
      src/main/resources/static/i18n/messages_en_US.properties
  46. 5
      src/main/resources/static/i18n/messages_zh_CN.properties
  47. 10
      src/test/java/com/community/pocket/DemoApplicationTests.java

@ -1,9 +1,13 @@
package com.community.pocket.api.web; package com.community.pocket.api.web;
import com.community.pocket.entity.po.Manager; import com.community.pocket.entity.po.Manager;
import com.community.pocket.entity.po.Token; import com.community.pocket.entity.po.ManagerToken;
import com.community.pocket.entity.vo.*; import com.community.pocket.entity.vo.EmailTypeConfig;
import com.community.pocket.entity.vo.Result;
import com.community.pocket.entity.vo.web.*;
import com.community.pocket.repository.EmailDao;
import com.community.pocket.repository.ManagerDao; import com.community.pocket.repository.ManagerDao;
import com.community.pocket.repository.ManagerTokenDao;
import com.community.pocket.util.EmailService; import com.community.pocket.util.EmailService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.DigestUtils; import org.springframework.util.DigestUtils;
@ -12,7 +16,6 @@ import org.springframework.web.bind.annotation.*;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List;
@RestController @RestController
@RequestMapping("/api/manager") @RequestMapping("/api/manager")
@ -32,30 +35,38 @@ public class ManagerController {
@Autowired @Autowired
private EmailService emailService; private EmailService emailService;
@Autowired
private ManagerTokenDao managerTokenDao;
@Autowired
private EmailDao emailDao;
// 登陆 // 登陆
@PostMapping("login") @PostMapping("login")
public JSONResponse<Token> login(@RequestBody ManagerLogin managerLogin){ public LoginResponse login(@RequestBody ManagerLogin managerLogin) {
if (StringUtils.isEmpty(managerLogin.getManagerName())) { if (StringUtils.isEmpty(managerLogin.getManagerName())) {
return new JSONResponse<>(Result.FAIL,"管理员不能为空!",null); return new LoginResponse(Result.FAIL, LoginResponse.Msg.manager);
} else if (StringUtils.isEmpty(managerLogin.getPassword())) { } else if (StringUtils.isEmpty(managerLogin.getPassword())) {
return new JSONResponse<>(Result.FAIL,"密码不能为空!",null); return new LoginResponse(Result.FAIL, LoginResponse.Msg.password);
//校验账号密码 //校验账号密码
} else if (!managerDao.login(managerLogin)) { } else if (!managerDao.login(managerLogin)) {
return new JSONResponse<>(Result.FAIL,"账号或密码错误!",null); return new LoginResponse(Result.FAIL, LoginResponse.Msg.fail);
} } else {
else{
// 验证通过生成令牌响应给服务端 // 验证通过生成令牌响应给服务端
Token token=new Token(); ManagerToken managerToken = new ManagerToken();
Calendar c = Calendar.getInstance(); Calendar c = Calendar.getInstance();
c.setTime(new Date()); c.setTime(new Date());
token.setCreateTime(c.getTimeInMillis()); managerToken.setCreateTime(c.getTimeInMillis());
// 令牌有效时间1小时 // 令牌有效时间1
c.add(Calendar.HOUR,1); c.add(Calendar.DAY_OF_MONTH, 1);
token.setUseTime(c.getTimeInMillis()); managerToken.setUseTime(c.getTimeInMillis());
// 生成token // 生成token
token.setToken(DigestUtils.md5DigestAsHex((token.getCreateTime()+""+token.getUseTime()+"").getBytes())); managerToken.setToken(DigestUtils.md5DigestAsHex((managerToken.getCreateTime() + "" + managerToken.getUseTime() + "").getBytes()));
token.setManagerName(managerLogin.getManagerName()); managerToken.setManagerName(managerLogin.getManagerName());
return new JSONResponse<>(Result.OK,"登陆成功",token); managerTokenDao.save(managerToken);
LoginResponse response = new LoginResponse(Result.OK, LoginResponse.Msg.ok);
response.setManagerToken(managerToken);
return response;
} }
} }
@ -63,36 +74,29 @@ public class ManagerController {
* 获取邮箱类型 * 获取邮箱类型
*/ */
@GetMapping("emailType") @GetMapping("emailType")
public JSONResponse<List<EmailType>> getEmailType(){ public EmailTypeResponse getEmailType() {
return new JSONResponse<>(Result.OK,"获取邮箱类型成功", emailTypeConfig.getSupportType()); EmailTypeResponse response = new EmailTypeResponse(Result.OK, EmailTypeResponse.Msg.ok);
} response.setEmailTypeList(emailTypeConfig.getSupportType());
return response;
@PostMapping("sendcode")
public JSONResponse<String> sendEmail(String sender){
if(emailService.sendManagerCode(sender)){
return new JSONResponse<>(Result.OK,"发送邮件成功",null);
}else{
return new JSONResponse<>(Result.OK,"发送邮件失败",null);
}
} }
// 注册 // 注册
@PostMapping("register") @PostMapping("register")
public JSONResponse<String> register(@RequestBody ManagerRegister manager){ public RegisterResponse register(@RequestBody ManagerRegister manager) {
if (StringUtils.isEmpty(manager.getManagerName())) { if (StringUtils.isEmpty(manager.getManagerName())) {
return new JSONResponse<>(Result.FAIL,"管理员不能为空",null); return new RegisterResponse(Result.FAIL, RegisterResponse.Msg.manager);
} else if (StringUtils.isEmpty(manager.getPassword())) { } else if (StringUtils.isEmpty(manager.getPassword())) {
return new JSONResponse<>(Result.FAIL,"密码不能为空",null); return new RegisterResponse(Result.FAIL, RegisterResponse.Msg.password);
} else if (StringUtils.isEmpty(manager.getConfirmPassword())) { } else if (StringUtils.isEmpty(manager.getConfirmPassword())) {
return new JSONResponse<>(Result.FAIL,"确认密码不能为空",null); return new RegisterResponse(Result.FAIL, RegisterResponse.Msg.confirmPassword);
} else if (!manager.getPassword().equals(manager.getConfirmPassword())) { } else if (!manager.getPassword().equals(manager.getConfirmPassword())) {
return new JSONResponse<>(Result.FAIL, "两次密码输入不一致", null); return new RegisterResponse(Result.FAIL, RegisterResponse.Msg.passwordNotMatch);
} else if (StringUtils.isEmpty(manager.getMobile())) { } else if (StringUtils.isEmpty(manager.getMobile())) {
return new JSONResponse<>(Result.FAIL, "手机号不能为空", null); return new RegisterResponse(Result.FAIL, RegisterResponse.Msg.mobie);
} else if (StringUtils.isEmpty(manager.getEmail())) { } else if (StringUtils.isEmpty(manager.getEmail())) {
return new JSONResponse<>(Result.FAIL, "邮箱不能为空", null); return new RegisterResponse(Result.FAIL, RegisterResponse.Msg.email);
} else if (managerDao.hasUser(manager.getManagerName())) { } else if (managerDao.hasUser(manager.getManagerName())) {
return new JSONResponse<>(Result.FAIL, "用户已存在", null); return new RegisterResponse(Result.FAIL, RegisterResponse.Msg.username);
} else { } else {
// 表单数据转换到管理员实体,调用dao层持久化到数据库 // 表单数据转换到管理员实体,调用dao层持久化到数据库
Manager m = new Manager(); Manager m = new Manager();
@ -101,8 +105,67 @@ public class ManagerController {
m.setMobile(manager.getMobile()); m.setMobile(manager.getMobile());
m.setEmail(manager.getEmail()); m.setEmail(manager.getEmail());
managerDao.save(m); managerDao.save(m);
return new JSONResponse<>(Result.OK,"注册成功",null); return new RegisterResponse(Result.OK, RegisterResponse.Msg.ok);
} }
} }
//注销
@PostMapping("logout")
public LogoutResponse logout(@RequestBody ManagerLogout managerLogout) {
if (StringUtils.isEmpty(managerLogout.getManagerName())) {
return new LogoutResponse(Result.FAIL, LogoutResponse.Msg.fail);
} else {
if (managerTokenDao.logout(managerLogout)) {
return new LogoutResponse(Result.OK, LogoutResponse.Msg.ok);
} else {
return new LogoutResponse(Result.FAIL, LogoutResponse.Msg.fail);
}
}
}
//检查账号邮箱
@PostMapping("reset/checkEmail")
public ResetpwdResponse checkUserWithEmail(@RequestBody ManagerResetPwd managerResetPwd) {
if (managerDao.checkUserWithEmail(managerResetPwd)) {
return new ResetpwdResponse(Result.OK, ResetpwdResponse.Msg.check_ok);
} else {
return new ResetpwdResponse(Result.FAIL, ResetpwdResponse.Msg.check_fail);
}
}
/**
* 发送邮件
*/
@PostMapping("reset/code")
public ResetpwdResponse sendEmail(@RequestBody ManagerResetPwd managerResetPwd) {
if (emailService.sendManagerCode(managerResetPwd)) {
return new ResetpwdResponse(Result.OK, ResetpwdResponse.Msg.send_code_ok);
} else {
return new ResetpwdResponse(Result.FAIL, ResetpwdResponse.Msg.send_code_fail);
}
}
/**
* 校验验证码
*/
@PostMapping("reset/checkCode")
public ResetpwdResponse validCode(@RequestBody ManagerResetPwd managerResetPwd) {
if (emailDao.checkCode(managerResetPwd.getEmail() + managerResetPwd.getEmailType(), managerResetPwd.getVerificationCode())) {
return new ResetpwdResponse(Result.OK, ResetpwdResponse.Msg.valid_code_ok);
} else {
return new ResetpwdResponse(Result.FAIL, ResetpwdResponse.Msg.valid_code_fail);
}
}
/**
* 重置密码
*/
@PostMapping("reset/resetPwd")
public ResetpwdResponse resetpwd(@RequestBody ManagerResetPwd managerResetPwd) {
if (managerDao.resetpwd(managerResetPwd)) {
return new ResetpwdResponse(Result.OK, ResetpwdResponse.Msg.resetpwd_ok);
} else {
return new ResetpwdResponse(Result.FAIL, ResetpwdResponse.Msg.resetpwd_fail);
}
}
} }

@ -13,9 +13,8 @@ public class EmailCode {
//验证码 //验证码
private String code; private String code;
//发送时间 //发送时间
private Long sendTime=System.currentTimeMillis(); private final Long sendTime = System.currentTimeMillis();
//有效时间 //有效时间
public String getCode() { public String getCode() {
return code; return code;
} }

@ -17,7 +17,7 @@ public class Manager {
// 邮箱 // 邮箱
private String email; private String email;
//令牌 //令牌
private Token token; private ManagerToken managerToken;
public String getManagerName() { public String getManagerName() {
return managerName; return managerName;
@ -51,11 +51,11 @@ public class Manager {
this.email = email; this.email = email;
} }
public Token getToken() { public ManagerToken getManagerToken() {
return token; return managerToken;
} }
public void setToken(Token token) { public void setManagerToken(ManagerToken managerToken) {
this.token = token; this.managerToken = managerToken;
} }
} }

@ -1,9 +1,12 @@
package com.community.pocket.entity.po; package com.community.pocket.entity.po;
import com.community.pocket.util.TableName;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
//登陆成功记录的令牌信息 //登陆成功记录的令牌信息
public class Token { @Document(TableName.managerToken)
public class ManagerToken {
//令牌 //令牌
@Id @Id
private String token; private String token;

@ -1,52 +0,0 @@
package com.community.pocket.entity.vo;
//接口统一返回json响应体
public class JSONResponse<T> {
// 响应结果
private Result result;
// 响应详细结果
private String message;
// 自定义其他响应信息
@Deprecated
private T body;
public JSONResponse() {
}
public JSONResponse(Result result, String message) {
this.result = result;
this.message = message;
}
@Deprecated
public JSONResponse(Result result, String message, T body) {
this.result = result;
this.message = message;
this.body = body;
}
public Result getResult() {
return result;
}
public void setResult(Result result) {
this.result = result;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public T getBody() {
return body;
}
public void setBody(T body) {
this.body = body;
}
}

@ -1,12 +1,13 @@
package com.community.pocket.entity.vo.android; package com.community.pocket.entity.vo;
import com.community.pocket.entity.vo.Result; import com.community.pocket.entity.vo.android.CustomMessage;
/** /**
* android接口响应体 * 接口响应体
*
* @param <T> * @param <T>
*/ */
public abstract class AndroidResponse<T extends CustomMessage> { public abstract class Response<T extends CustomMessage> {
//操作结果 //操作结果
private Result result; private Result result;
@ -15,7 +16,7 @@ public abstract class AndroidResponse<T extends CustomMessage> {
private Object[] args; private Object[] args;
public AndroidResponse(Result result, T message,Object ...args) { public Response(Result result, T message, Object... args) {
this.result = result; this.result = result;
this.message = message; this.message = message;
this.args = args; this.args = args;

@ -1,10 +1,11 @@
package com.community.pocket.entity.vo.android; package com.community.pocket.entity.vo.android;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result; import com.community.pocket.entity.vo.Result;
import java.util.List; import java.util.List;
public class ForumDataResponse extends AndroidResponse<ForumDataResponse.Msg> { public class ForumDataResponse extends Response<ForumDataResponse.Msg> {
private List<ForumContentVo> forumContentList; private List<ForumContentVo> forumContentList;
public ForumDataResponse(Result result, Msg message, Object... args) { public ForumDataResponse(Result result, Msg message, Object... args) {

@ -1,11 +1,12 @@
package com.community.pocket.entity.vo.android; package com.community.pocket.entity.vo.android;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result; import com.community.pocket.entity.vo.Result;
/** /**
* 热榜信息响应体 * 热榜信息响应体
*/ */
public class ForumHotResponse extends AndroidResponse<ForumHotResponse.Msg> { public class ForumHotResponse extends Response<ForumHotResponse.Msg> {
private Hot hot; private Hot hot;
public Hot getHot() { public Hot getHot() {

@ -1,5 +1,6 @@
package com.community.pocket.entity.vo.android; package com.community.pocket.entity.vo.android;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result; import com.community.pocket.entity.vo.Result;
import java.util.List; import java.util.List;
@ -7,7 +8,7 @@ import java.util.List;
/** /**
* 我的帖子响应结果 * 我的帖子响应结果
*/ */
public class ForumMyResponse extends AndroidResponse<ForumMyResponse.Msg>{ public class ForumMyResponse extends Response<ForumMyResponse.Msg> {
private List<ForumVo> forumList; private List<ForumVo> forumList;
public ForumMyResponse(Result result, Msg message, Object... args) { public ForumMyResponse(Result result, Msg message, Object... args) {

@ -1,5 +1,6 @@
package com.community.pocket.entity.vo.android; package com.community.pocket.entity.vo.android;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result; import com.community.pocket.entity.vo.Result;
import java.util.List; import java.util.List;
@ -7,7 +8,7 @@ import java.util.List;
/** /**
* 最新帖子响应 * 最新帖子响应
*/ */
public class ForumNewResponse extends AndroidResponse<ForumNewResponse.Msg> { public class ForumNewResponse extends Response<ForumNewResponse.Msg> {
private List<ForumVo> forumList; private List<ForumVo> forumList;

@ -1,6 +1,7 @@
package com.community.pocket.entity.vo.android; package com.community.pocket.entity.vo.android;
import com.community.pocket.entity.po.Notice; import com.community.pocket.entity.po.Notice;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result; import com.community.pocket.entity.vo.Result;
import java.util.List; import java.util.List;
@ -8,7 +9,7 @@ import java.util.List;
/** /**
* 公告响应体 * 公告响应体
*/ */
public class ForumNoticeResponse extends AndroidResponse<ForumNoticeResponse.Msg> { public class ForumNoticeResponse extends Response<ForumNoticeResponse.Msg> {
private List<Notice> noticeList; private List<Notice> noticeList;

@ -1,11 +1,12 @@
package com.community.pocket.entity.vo.android; package com.community.pocket.entity.vo.android;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result; import com.community.pocket.entity.vo.Result;
/** /**
* 发帖响应 * 发帖响应
*/ */
public class ForumPostResponse extends AndroidResponse<ForumPostResponse.Msg>{ public class ForumPostResponse extends Response<ForumPostResponse.Msg> {
public ForumPostResponse(Result result, Msg message, Object... args) { public ForumPostResponse(Result result, Msg message, Object... args) {
super(result, message, args); super(result, message, args);
} }

@ -1,6 +1,6 @@
package com.community.pocket.entity.vo.android; package com.community.pocket.entity.vo.android;
public enum GarbageCateGory { public enum GarbageCateGory implements CustomMessage {
/** /**
* 1 (可回收垃圾) * 1 (可回收垃圾)
* 2 (有害垃圾) * 2 (有害垃圾)
@ -8,33 +8,15 @@ public enum GarbageCateGory {
* 8 (干垃圾) * 8 (干垃圾)
* 16 (大件垃圾) * 16 (大件垃圾)
*/ */
type1(1, "可回收垃圾"), type1,
type2(2, "有害垃圾"), type2,
type4(4, "湿垃圾"), type4,
type8(8, "干垃圾"), type8,
type16(16, "大件垃圾"); type16;
private Integer type;
private String name;
GarbageCateGory(Integer type, String name) { @Override
this.type = type; public String toString() {
this.name = name; return "waste." + name();
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
} }
} }

@ -1,5 +1,6 @@
package com.community.pocket.entity.vo.android; package com.community.pocket.entity.vo.android;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result; import com.community.pocket.entity.vo.Result;
import java.util.List; import java.util.List;
@ -7,7 +8,7 @@ import java.util.List;
/** /**
* 垃圾分类信息 * 垃圾分类信息
*/ */
public class GarbageSortingResponse extends AndroidResponse<GarbageSortingResponse.Msg> { public class GarbageSortingResponse extends Response<GarbageSortingResponse.Msg> {
private List<GarbageVo> garbageSortings; private List<GarbageVo> garbageSortings;
public GarbageSortingResponse(Result result, Msg message, Object... args) { public GarbageSortingResponse(Result result, Msg message, Object... args) {

@ -2,6 +2,7 @@ package com.community.pocket.entity.vo.android;
import com.community.pocket.entity.po.android.GarbageWasteManage; import com.community.pocket.entity.po.android.GarbageWasteManage;
import com.community.pocket.entity.po.android.GarbageWastePrice; import com.community.pocket.entity.po.android.GarbageWastePrice;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result; import com.community.pocket.entity.vo.Result;
import java.util.List; import java.util.List;
@ -9,7 +10,7 @@ import java.util.List;
/** /**
* 废品返回信息 * 废品返回信息
*/ */
public class GarbageWasteResponse extends AndroidResponse<GarbageWasteResponse.Msg> { public class GarbageWasteResponse extends Response<GarbageWasteResponse.Msg> {
public GarbageWasteResponse(Result result, Msg message, Object... args) { public GarbageWasteResponse(Result result, Msg message, Object... args) {
super(result, message, args); super(result, message, args);

@ -1,11 +1,12 @@
package com.community.pocket.entity.vo.android; package com.community.pocket.entity.vo.android;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result; import com.community.pocket.entity.vo.Result;
/** /**
* 个人信息响应 * 个人信息响应
*/ */
public class InfoResponse extends AndroidResponse<InfoResponse.Msg>{ public class InfoResponse extends Response<InfoResponse.Msg> {
private Info myInfo; private Info myInfo;
public InfoResponse(Result result, Msg message, Object... args) { public InfoResponse(Result result, Msg message, Object... args) {

@ -1,12 +1,13 @@
package com.community.pocket.entity.vo.android; package com.community.pocket.entity.vo.android;
import com.community.pocket.entity.po.android.Token; import com.community.pocket.entity.po.android.Token;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result; import com.community.pocket.entity.vo.Result;
/** /**
* 登陆响应 * 登陆响应
*/ */
public class LoginResponse extends AndroidResponse<LoginResponse.Msg> { public class LoginResponse extends Response<LoginResponse.Msg> {
private Token token; private Token token;
public Token getToken() { public Token getToken() {

@ -1,5 +1,6 @@
package com.community.pocket.entity.vo.android; package com.community.pocket.entity.vo.android;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result; import com.community.pocket.entity.vo.Result;
import java.util.List; import java.util.List;
@ -7,7 +8,7 @@ import java.util.List;
/** /**
* 查询用户 * 查询用户
*/ */
public class QueryUserResponse extends AndroidResponse<QueryUserResponse.Msg>{ public class QueryUserResponse extends Response<QueryUserResponse.Msg> {
private List<String> peopleList; private List<String> peopleList;
public QueryUserResponse(Result result, Msg message, Object... args) { public QueryUserResponse(Result result, Msg message, Object... args) {

@ -1,11 +1,12 @@
package com.community.pocket.entity.vo.android; package com.community.pocket.entity.vo.android;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result; import com.community.pocket.entity.vo.Result;
/** /**
* 注册响应 * 注册响应
*/ */
public class RegisterResponse extends AndroidResponse<RegisterResponse.Msg> { public class RegisterResponse extends Response<RegisterResponse.Msg> {
public RegisterResponse(Result result, Msg message, Object... args) { public RegisterResponse(Result result, Msg message, Object... args) {

@ -1,11 +1,12 @@
package com.community.pocket.entity.vo.android; package com.community.pocket.entity.vo.android;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result; import com.community.pocket.entity.vo.Result;
/** /**
* 重置密码响应 * 重置密码响应
*/ */
public class ResetPwdResponse extends AndroidResponse<ResetPwdResponse.Msg>{ public class ResetPwdResponse extends Response<ResetPwdResponse.Msg> {
public ResetPwdResponse(Result result, Msg message, Object... args) { public ResetPwdResponse(Result result, Msg message, Object... args) {
super(result, message, args); super(result, message, args);

@ -1,6 +1,7 @@
package com.community.pocket.entity.vo.android; package com.community.pocket.entity.vo.android;
import com.community.pocket.entity.po.android.Visitor; import com.community.pocket.entity.po.android.Visitor;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result; import com.community.pocket.entity.vo.Result;
import java.util.List; import java.util.List;
@ -8,7 +9,7 @@ import java.util.List;
/** /**
* 我的访客信息 * 我的访客信息
*/ */
public class VisitorMyResponse extends AndroidResponse<VisitorMyResponse.Msg> { public class VisitorMyResponse extends Response<VisitorMyResponse.Msg> {
private List<Visitor> visitorList; private List<Visitor> visitorList;

@ -1,6 +1,7 @@
package com.community.pocket.entity.vo.android; package com.community.pocket.entity.vo.android;
import com.community.pocket.entity.po.android.VisitorPeople; import com.community.pocket.entity.po.android.VisitorPeople;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result; import com.community.pocket.entity.vo.Result;
import java.util.List; import java.util.List;
@ -8,7 +9,7 @@ import java.util.List;
/** /**
* 查询预约人返回结果 * 查询预约人返回结果
*/ */
public class VisitorPeopleResponse extends AndroidResponse<VisitorPeopleResponse.Msg> { public class VisitorPeopleResponse extends Response<VisitorPeopleResponse.Msg> {
private List<VisitorPeople> visitorPeopleList; private List<VisitorPeople> visitorPeopleList;

@ -1,12 +1,13 @@
package com.community.pocket.entity.vo.android; package com.community.pocket.entity.vo.android;
import com.community.pocket.entity.po.android.Visitor; import com.community.pocket.entity.po.android.Visitor;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result; import com.community.pocket.entity.vo.Result;
import java.util.List; import java.util.List;
//我的预约信息 //我的预约信息
public class VisitorReservationResponse extends AndroidResponse<VisitorReservationResponse.Msg> { public class VisitorReservationResponse extends Response<VisitorReservationResponse.Msg> {
private List<Visitor> visitorList; private List<Visitor> visitorList;
public VisitorReservationResponse(Result result, Msg message, Object... args) { public VisitorReservationResponse(Result result, Msg message, Object... args) {

@ -1,11 +1,12 @@
package com.community.pocket.entity.vo.android; package com.community.pocket.entity.vo.android;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result; import com.community.pocket.entity.vo.Result;
/** /**
* 访客预约结果 * 访客预约结果
*/ */
public class VisitorResponse extends AndroidResponse<VisitorResponse.Msg> { public class VisitorResponse extends Response<VisitorResponse.Msg> {
public VisitorResponse(Result result, Msg message, Object... args) { public VisitorResponse(Result result, Msg message, Object... args) {
super(result, message, args); super(result, message, args);

@ -0,0 +1,32 @@
package com.community.pocket.entity.vo.web;
import com.community.pocket.entity.vo.EmailType;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result;
import com.community.pocket.entity.vo.android.CustomMessage;
import java.util.List;
/**
* 邮箱类型响应
*/
public class EmailTypeResponse extends Response<EmailTypeResponse.Msg> {
private List<EmailType> emailTypeList;
public EmailTypeResponse(Result result, Msg message, Object... args) {
super(result, message, args);
}
public List<EmailType> getEmailTypeList() {
return emailTypeList;
}
public void setEmailTypeList(List<EmailType> emailTypeList) {
this.emailTypeList = emailTypeList;
}
public enum Msg implements CustomMessage {
ok,
fail
}
}

@ -0,0 +1,37 @@
package com.community.pocket.entity.vo.web;
import com.community.pocket.entity.po.ManagerToken;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result;
import com.community.pocket.entity.vo.android.CustomMessage;
/**
* 管理员响应
*/
public class LoginResponse extends Response<LoginResponse.Msg> {
private ManagerToken managerToken;
public ManagerToken getManagerToken() {
return managerToken;
}
public void setManagerToken(ManagerToken managerToken) {
this.managerToken = managerToken;
}
public LoginResponse(Result result, Msg message, Object... args) {
super(result, message, args);
}
public enum Msg implements CustomMessage {
//管理员不能为空
manager,
//密码不能为空
password,
//账号或密码错误
fail,
//登陆成功
ok
}
}

@ -0,0 +1,22 @@
package com.community.pocket.entity.vo.web;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result;
import com.community.pocket.entity.vo.android.CustomMessage;
/**
* 注销响应
*/
public class LogoutResponse extends Response<LogoutResponse.Msg> {
public LogoutResponse(Result result, Msg message, Object... args) {
super(result, message, args);
}
public enum Msg implements CustomMessage {
//注销成功
ok,
//注销失败
fail
}
}

@ -1,5 +1,8 @@
package com.community.pocket.entity.vo; package com.community.pocket.entity.vo.web;
/**
* 管理员登录
*/
public class ManagerLogin { public class ManagerLogin {
private String managerName; private String managerName;
private String password; private String password;

@ -0,0 +1,14 @@
package com.community.pocket.entity.vo.web;
//注销表单
public class ManagerLogout {
private String managerName;
public String getManagerName() {
return managerName;
}
public void setManagerName(String managerName) {
this.managerName = managerName;
}
}

@ -1,4 +1,4 @@
package com.community.pocket.entity.vo; package com.community.pocket.entity.vo.web;
/** /**
* 管理员注册 * 管理员注册

@ -0,0 +1,57 @@
package com.community.pocket.entity.vo.web;
/**
* 重置密码表单
*/
public class ManagerResetPwd {
//管理员名
private String managerName;
//邮箱
private String email;
//验证码
private String verificationCode;
//新密码
private String password;
//邮箱类型
private String emailType;
public String getEmailType() {
return emailType;
}
public void setEmailType(String emailType) {
this.emailType = emailType;
}
public String getManagerName() {
return managerName;
}
public void setManagerName(String managerName) {
this.managerName = managerName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getVerificationCode() {
return verificationCode;
}
public void setVerificationCode(String verificationCode) {
this.verificationCode = verificationCode;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}

@ -0,0 +1,30 @@
package com.community.pocket.entity.vo.web;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result;
import com.community.pocket.entity.vo.android.CustomMessage;
public class RegisterResponse extends Response<RegisterResponse.Msg> {
public RegisterResponse(Result result, Msg message, Object... args) {
super(result, message, args);
}
public enum Msg implements CustomMessage {
//管理员不能为空
manager,
//密码不能为空
password,
//确认密码不能为空
confirmPassword,
//两次密码输入不一致
passwordNotMatch,
//手机号不能为空
mobie,
//邮箱不能为空
email,
//用户已存在
username,
//注册成功
ok
}
}

@ -0,0 +1,34 @@
package com.community.pocket.entity.vo.web;
import com.community.pocket.entity.vo.Response;
import com.community.pocket.entity.vo.Result;
import com.community.pocket.entity.vo.android.CustomMessage;
/**
* 重置密码响应
*/
public class ResetpwdResponse extends Response<CustomMessage> {
public ResetpwdResponse(Result result, CustomMessage message, Object... args) {
super(result, message, args);
}
public enum Msg implements CustomMessage {
//校验成功
check_ok,
//账号或邮箱错误
check_fail,
//验证码发送成功,请查收验证码
send_code_ok,
//验证码发送失败,请重试或联系管理员
send_code_fail,
//校验成功
valid_code_ok,
//验证码不正确,请重新输入
valid_code_fail,
//重置密码成功
resetpwd_ok,
//重置密码失败
resetpwd_fail
}
}

@ -1,10 +0,0 @@
package com.community.pocket.repository;
import com.community.pocket.entity.po.Forum;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
//论坛Restful接口
@RepositoryRestResource
public interface ForumRepo extends MongoRepository<Forum,String> {
}

@ -2,11 +2,13 @@ package com.community.pocket.repository;
import com.community.pocket.entity.po.Manager; import com.community.pocket.entity.po.Manager;
import com.community.pocket.entity.vo.ManagerLogin; import com.community.pocket.entity.vo.web.ManagerLogin;
import com.community.pocket.entity.vo.web.ManagerResetPwd;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import org.springframework.util.DigestUtils; import org.springframework.util.DigestUtils;
@ -57,6 +59,17 @@ public class ManagerDao extends BaseDao<Manager>{
return null; return null;
} }
//检查账号邮箱是否匹配
public boolean checkUserWithEmail(ManagerResetPwd managerResetPwd) {
return mongoTemplate.exists(new Query(Criteria.where("managerName").is(managerResetPwd.getManagerName()).and("email").is(managerResetPwd.getEmail())), entityClass());
}
//重置密码
public boolean resetpwd(ManagerResetPwd managerResetPwd) {
String md5password = DigestUtils.md5DigestAsHex(managerResetPwd.getPassword().getBytes());
return mongoTemplate.updateFirst(new Query(Criteria.where("managerName").is(managerResetPwd.getManagerName())), Update.update("password", md5password), entityClass()).wasAcknowledged();
}
@Override @Override
public Class<Manager> entityClass() { public Class<Manager> entityClass() {
return Manager.class; return Manager.class;

@ -1,11 +0,0 @@
package com.community.pocket.repository;
import com.community.pocket.entity.po.Manager;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
//管理员Restful接口
@RepositoryRestResource
public interface ManagerRepo extends MongoRepository<Manager,String> {
}

@ -0,0 +1,39 @@
package com.community.pocket.repository;
import com.community.pocket.entity.po.ManagerToken;
import com.community.pocket.entity.vo.web.ManagerLogout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;
/**
* 管理员令牌
*/
@Repository
public class ManagerTokenDao extends BaseDao<ManagerToken> {
private static final Logger LOG = LoggerFactory.getLogger(ManagerTokenDao.class);
@Override
public ManagerToken save(ManagerToken managerToken) {
try {
return mongoTemplate.save(managerToken);
} catch (Exception e) {
e.printStackTrace();
LOG.error(e.toString());
}
return null;
}
//注销
public boolean logout(ManagerLogout managerLogout) {
return mongoTemplate.remove(new Query(Criteria.where("managerName").is(managerLogout.getManagerName())), entityClass()).wasAcknowledged();
}
@Override
public Class<ManagerToken> entityClass() {
return ManagerToken.class;
}
}

@ -5,8 +5,10 @@ import com.community.pocket.entity.vo.android.GarbageCateGory;
import com.community.pocket.entity.vo.android.GarbageVo; import com.community.pocket.entity.vo.android.GarbageVo;
import com.community.pocket.entity.vo.android.QueryGarbageForm; import com.community.pocket.entity.vo.android.QueryGarbageForm;
import com.community.pocket.repository.BaseDao; import com.community.pocket.repository.BaseDao;
import com.community.pocket.util.MessageService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -20,6 +22,9 @@ import java.util.regex.Pattern;
public class GarbageDao extends BaseDao<Garbage> { public class GarbageDao extends BaseDao<Garbage> {
private static final Logger LOG = LoggerFactory.getLogger(GarbageDao.class); private static final Logger LOG = LoggerFactory.getLogger(GarbageDao.class);
@Autowired
private MessageService messageService;
//查询垃圾分类信息 //查询垃圾分类信息
public List<GarbageVo> query(QueryGarbageForm garbageForm) { public List<GarbageVo> query(QueryGarbageForm garbageForm) {
List<GarbageVo> garbageVos = new ArrayList<>(); List<GarbageVo> garbageVos = new ArrayList<>();
@ -29,19 +34,19 @@ public class GarbageDao extends BaseDao<Garbage> {
garbageVo.setName(garbage.getName()); garbageVo.setName(garbage.getName());
switch (garbage.getCategory()) { switch (garbage.getCategory()) {
case 1: case 1:
garbageVo.setSorting(GarbageCateGory.type1.getName()); garbageVo.setSorting(messageService.getMessage(GarbageCateGory.type1));
break; break;
case 2: case 2:
garbageVo.setSorting(GarbageCateGory.type2.getName()); garbageVo.setSorting(messageService.getMessage(GarbageCateGory.type2));
break; break;
case 4: case 4:
garbageVo.setSorting(GarbageCateGory.type4.getName()); garbageVo.setSorting(messageService.getMessage(GarbageCateGory.type4));
break; break;
case 8: case 8:
garbageVo.setSorting(GarbageCateGory.type8.getName()); garbageVo.setSorting(messageService.getMessage(GarbageCateGory.type8));
break; break;
case 16: case 16:
garbageVo.setSorting(GarbageCateGory.type16.getName()); garbageVo.setSorting(messageService.getMessage(GarbageCateGory.type16));
break; break;
} }
garbageVos.add(garbageVo); garbageVos.add(garbageVo);

@ -2,6 +2,7 @@ package com.community.pocket.util;
import com.community.pocket.entity.po.EmailCode; import com.community.pocket.entity.po.EmailCode;
import com.community.pocket.entity.vo.EmailTypeConfig; import com.community.pocket.entity.vo.EmailTypeConfig;
import com.community.pocket.entity.vo.web.ManagerResetPwd;
import com.community.pocket.repository.EmailDao; import com.community.pocket.repository.EmailDao;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -22,17 +23,17 @@ public class EmailService {
private EmailDao emailDao; private EmailDao emailDao;
/** /**
* 发送管理员注册激活邮件 * 发送管理员重置密码邮件
* @param sender 发送人
*/ */
public boolean sendManagerCode(String sender) { public boolean sendManagerCode(ManagerResetPwd managerResetPwd) {
if (emailDao.clearEmail(managerResetPwd.getEmail() + managerResetPwd.getEmailType())) {
EmailCode emailCode = new EmailCode(); EmailCode emailCode = new EmailCode();
emailCode.setCode(RandomStringUtils.randomNumeric(emailTypeConfig.getLength())); emailCode.setCode(RandomStringUtils.randomNumeric(emailTypeConfig.getLength()));
emailCode.setEmailAddress(sender); emailCode.setEmailAddress(managerResetPwd.getEmail() + managerResetPwd.getEmailType());
SimpleMailMessage message = new SimpleMailMessage(); SimpleMailMessage message = new SimpleMailMessage();
message.setSubject(emailTypeConfig.getSubject()); message.setSubject(emailTypeConfig.getSubject());
message.setText(String.format(emailTypeConfig.getManagerCodeMessage(), emailCode.getCode())); message.setText(String.format(emailTypeConfig.getManagerCodeMessage(), emailCode.getCode()));
message.setTo(sender); message.setTo(emailCode.getEmailAddress());
message.setFrom(emailTypeConfig.getFrom()); message.setFrom(emailTypeConfig.getFrom());
try { try {
javaMailSender.send(message); javaMailSender.send(message);
@ -43,6 +44,9 @@ public class EmailService {
e.printStackTrace(); e.printStackTrace();
return false; return false;
} }
} else {
return false;
}
} }
/** /**

@ -0,0 +1,43 @@
package com.community.pocket.util;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
import java.util.Locale;
/**
* 配置国际化语言
*/
@Configuration
public class LocaleConfig {
/**
* 默认解析器 其中locale表示默认语言
*/
@Bean
public LocaleResolver localeResolver() {
SessionLocaleResolver localeResolver = new SessionLocaleResolver();
localeResolver.setDefaultLocale(Locale.US);
return localeResolver;
}
/**
* 默认拦截器 其中lang表示切换语言的参数名
*/
@Bean
public WebMvcConfigurer localeInterceptor() {
return new WebMvcConfigurer() {
@Override
public void addInterceptors(InterceptorRegistry registry) {
LocaleChangeInterceptor localeInterceptor = new LocaleChangeInterceptor();
localeInterceptor.setParamName("lang");
registry.addInterceptor(localeInterceptor);
}
};
}
}

@ -0,0 +1,21 @@
package com.community.pocket.util;
import com.community.pocket.entity.vo.android.CustomMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;
/**
* 国际化配置
*/
@Service
public class MessageService {
@Autowired
private MessageSource messageSource;
public <T extends CustomMessage> String getMessage(T code, Object... args) {
return messageSource.getMessage(code.toString(), args, LocaleContextHolder.getLocale());
}
}

@ -22,7 +22,12 @@ public class TableName {
public static final String notice = "notice"; public static final String notice = "notice";
//访客信息 //访客信息
public static final String visitor = "visitor"; public static final String visitor = "visitor";
//预约配置信息
public static final String visitorPeople = "visitorPeople"; public static final String visitorPeople = "visitorPeople";
//垃圾分类信息
public static final String garbage = "garbage"; public static final String garbage = "garbage";
//废品回收价格
public static final String garbageWastePrice = "garbageWastePrice"; public static final String garbageWastePrice = "garbageWastePrice";
//管理员令牌
public static final String managerToken = "managerToken";
} }

@ -1,5 +1,5 @@
#数据库配置
spring: spring:
#数据库配置
data: data:
mongodb: mongodb:
database: demo database: demo
@ -12,6 +12,9 @@ spring:
smtp: smtp:
ssl: ssl:
enable: true enable: true
#国际化配置
messages:
basename: static/i18n/messages #相对路径 开头请勿添加斜杠
#邮箱配置 #邮箱配置
email: email:
@ -28,9 +31,9 @@ email:
#长度 #长度
length: 6 length: 6
#管理员激活邮件模版 #管理员激活邮件模版
manager: 欢迎注册口袋社区后台服务,您获取到的验证码是:%s manager: 尊敬的管理员您好,欢迎使用重置密码服务,您获取到的验证码是:%s
#用户重置密码邮件模版 #用户重置密码邮件模版
user: 重置密码,您获取到的验证码是:%s user: 尊敬的用户您好,欢迎使用重置密码服务,您获取到的验证码是:%s
#令牌配置 #令牌配置
token: token:

@ -0,0 +1,5 @@
waste.type1=recoverable
waste.type16=Bulky Waste
waste.type2=hazardous waste
waste.type4=wet garbage
waste.type8=dry refuse

@ -0,0 +1,5 @@
waste.type1=recoverable
waste.type16=Bulky Waste
waste.type2=hazardous waste
waste.type4=wet garbage
waste.type8=dry refuse

@ -0,0 +1,5 @@
waste.type1=可回收垃圾
waste.type16=大件垃圾
waste.type2=有害垃圾
waste.type4=湿垃圾
waste.type8=干垃圾

@ -2,11 +2,13 @@ package com.community.pocket;
import com.community.pocket.entity.po.android.Garbage; import com.community.pocket.entity.po.android.Garbage;
import com.community.pocket.entity.po.android.GarbageWastePrice; import com.community.pocket.entity.po.android.GarbageWastePrice;
import com.community.pocket.entity.vo.android.GarbageCateGory;
import com.community.pocket.entity.vo.android.QueryUserForm; import com.community.pocket.entity.vo.android.QueryUserForm;
import com.community.pocket.repository.android.GarbageDao; import com.community.pocket.repository.android.GarbageDao;
import com.community.pocket.repository.android.GarbagePriceDao; import com.community.pocket.repository.android.GarbagePriceDao;
import com.community.pocket.repository.android.UserDao; import com.community.pocket.repository.android.UserDao;
import com.community.pocket.repository.android.VisitorPeopleDao; import com.community.pocket.repository.android.VisitorPeopleDao;
import com.community.pocket.util.MessageService;
import com.google.gson.Gson; import com.google.gson.Gson;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -35,6 +37,9 @@ class DemoApplicationTests {
@Autowired @Autowired
private GarbagePriceDao garbagePriceDao; private GarbagePriceDao garbagePriceDao;
@Autowired
private MessageService messageService;
private static final Logger LOG = LoggerFactory.getLogger(DemoApplicationTests.class); private static final Logger LOG = LoggerFactory.getLogger(DemoApplicationTests.class);
@Test @Test
@ -73,4 +78,9 @@ class DemoApplicationTests {
} }
} }
@Test
void testMessage() {
LOG.info(messageService.getMessage(GarbageCateGory.type1));
}
} }

Loading…
Cancel
Save