parent
4b38bb063f
commit
5514f029e8
@ -1,15 +1,18 @@ |
||||
package com.community.pocket.entity.po; |
||||
|
||||
import com.community.pocket.util.TableName; |
||||
import org.springframework.data.annotation.Id; |
||||
import org.springframework.data.mongodb.core.mapping.Document; |
||||
|
||||
//登陆成功记录的令牌信息
|
||||
public class Token { |
||||
@Document(TableName.managerToken) |
||||
public class ManagerToken { |
||||
//令牌
|
||||
@Id |
||||
private String token; |
||||
//创建时间
|
||||
private Long createTime; |
||||
// 有效时间
|
||||
// 有效时间
|
||||
private Long useTime; |
||||
// 管理员名
|
||||
private String managerName; |
@ -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; |
||||
} |
||||
} |
@ -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 { |
||||
private String managerName; |
||||
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> { |
||||
} |
@ -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; |
||||
} |
||||
} |
@ -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()); |
||||
} |
||||
} |
@ -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=干垃圾 |
Loading…
Reference in new issue