Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
member-api
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
member-api
Commits
8543f53a
Commit
8543f53a
authored
Oct 10, 2018
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
找回密码,国际化修改
parent
9a30ef67
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
125 additions
and
14 deletions
+125
-14
MemberOpenApiController.java
...main/java/com/egolm/film/api/MemberOpenApiController.java
+24
-6
EmailService.java
src/main/java/com/egolm/film/common/EmailService.java
+7
-0
MemberService.java
src/main/java/com/egolm/film/common/MemberService.java
+11
-0
Messages.java
src/main/java/com/egolm/film/common/Messages.java
+1
-1
DefaultMessages.java
...main/java/com/egolm/film/common/impl/DefaultMessages.java
+2
-1
EmailServiceImpl.java
...ain/java/com/egolm/film/common/impl/EmailServiceImpl.java
+23
-0
MemberServiceImpl.java
...in/java/com/egolm/film/common/impl/MemberServiceImpl.java
+31
-0
MemberTokenServiceImpl.java
...egolm/film/login/service/impl/MemberTokenServiceImpl.java
+10
-5
application.properties
src/main/resources/application.properties
+7
-1
message.properties
src/main/resources/i18n/message.properties
+9
-0
No files found.
src/main/java/com/egolm/film/api/MemberOpenApiController.java
View file @
8543f53a
...
...
@@ -5,6 +5,7 @@ import java.util.Locale;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpSession
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.i18n.LocaleContextHolder
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
...
@@ -12,6 +13,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.egolm.common.bean.Rjx
;
import
com.egolm.film.bean.Fc_member
;
import
com.egolm.film.common.EmailService
;
import
com.egolm.film.common.MemberService
;
import
com.egolm.film.common.Messages
;
import
com.egolm.film.config.interceptor.LocaleSessionInterceptor
;
import
io.swagger.annotations.Api
;
...
...
@@ -24,6 +29,15 @@ import io.swagger.annotations.ApiOperation;
@RequestMapping
(
"open/member"
)
public
class
MemberOpenApiController
{
@Autowired
private
EmailService
emailService
;
@Autowired
private
Messages
messages
;
@Autowired
private
MemberService
memberService
;
@ResponseBody
@PostMapping
(
"register"
)
@ApiOperation
(
"会员注册"
)
...
...
@@ -39,19 +53,22 @@ public class MemberOpenApiController {
@ResponseBody
@PostMapping
(
"getPassword"
)
@ApiOperation
(
"找回密码"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"string"
,
required
=
true
,
name
=
"email"
),
})
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"string"
,
required
=
true
,
name
=
"email"
)})
public
Object
getPassword
(
String
email
)
{
int
code
=
(
int
)
((
Math
.
random
()
*
9
+
1
)
*
10000000
);
String
newPassword
=
String
.
valueOf
(
code
);
Fc_member
member
=
memberService
.
getMemberByEmail
(
email
);
memberService
.
changePassword
(
member
.
getAddress
(),
newPassword
);
String
subject
=
messages
.
get
(
"email.getPassword.subject"
);
String
content
=
messages
.
get
(
"email.getPassword.subject"
,
member
.
getRealname
(),
newPassword
);
emailService
.
send
(
subject
,
content
,
email
);
return
Rjx
.
jsonOk
();
}
@ResponseBody
@PostMapping
(
"setLocale"
)
@ApiOperation
(
"设置语言环境"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"string"
,
required
=
true
,
name
=
"i18n_language"
,
defaultValue
=
"zh_CN"
),
})
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"string"
,
required
=
true
,
name
=
"i18n_language"
,
defaultValue
=
"zh_CN"
)})
public
Object
setLocale
(
HttpSession
session
,
String
i18n_language
)
{
Locale
locale
=
new
Locale
(
i18n_language
);
session
.
setAttribute
(
LocaleSessionInterceptor
.
I18N_LANGUAGE_SESSION
,
locale
);
...
...
@@ -64,4 +81,5 @@ public class MemberOpenApiController {
public
Object
getLocale
(
HttpServletRequest
request
)
{
return
Rjx
.
jsonOk
().
setMessage
(
LocaleContextHolder
.
getLocale
().
toString
());
}
}
src/main/java/com/egolm/film/common/EmailService.java
0 → 100644
View file @
8543f53a
package
com
.
egolm
.
film
.
common
;
public
interface
EmailService
{
void
send
(
String
subject
,
String
content
,
String
...
emailAddress
);
}
src/main/java/com/egolm/film/common/MemberService.java
0 → 100644
View file @
8543f53a
package
com
.
egolm
.
film
.
common
;
import
com.egolm.film.bean.Fc_member
;
public
interface
MemberService
{
Fc_member
getMemberByEmail
(
String
email
);
void
changePassword
(
String
id
,
String
newPassword
);
}
src/main/java/com/egolm/film/
messages
/Messages.java
→
src/main/java/com/egolm/film/
common
/Messages.java
View file @
8543f53a
package
com
.
egolm
.
film
.
messages
;
package
com
.
egolm
.
film
.
common
;
public
interface
Messages
{
...
...
src/main/java/com/egolm/film/
messages
/DefaultMessages.java
→
src/main/java/com/egolm/film/
common/impl
/DefaultMessages.java
View file @
8543f53a
package
com
.
egolm
.
film
.
messages
;
package
com
.
egolm
.
film
.
common
.
impl
;
import
java.util.Locale
;
...
...
@@ -8,6 +8,7 @@ import org.springframework.context.NoSuchMessageException;
import
org.springframework.context.i18n.LocaleContextHolder
;
import
org.springframework.stereotype.Component
;
import
com.egolm.film.common.Messages
;
import
com.egolm.film.config.XException
;
@Component
...
...
src/main/java/com/egolm/film/common/impl/EmailServiceImpl.java
0 → 100644
View file @
8543f53a
package
com
.
egolm
.
film
.
common
.
impl
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
com.egolm.common.MailUtil
;
import
com.egolm.film.common.EmailService
;
@Service
public
class
EmailServiceImpl
implements
EmailService
{
@Value
(
"${com.egolm.film.email.smtp.host}"
)
private
String
host
;
@Value
(
"${com.egolm.film.email.smtp.port}"
)
private
Integer
port
;
@Value
(
"${com.egolm.film.email.smtp.is_auth}"
)
private
Boolean
is_auth
;
@Value
(
"${com.egolm.film.email.smtp.from}"
)
private
String
from
;
@Value
(
"${com.egolm.film.email.smtp.password}"
)
private
String
password
;
@Override
public
void
send
(
String
subject
,
String
content
,
String
...
emailAddress
)
{
MailUtil
.
sendBySmtp
(
host
,
port
,
is_auth
,
content
,
password
,
subject
,
content
,
null
,
emailAddress
);
}
}
src/main/java/com/egolm/film/common/impl/MemberServiceImpl.java
0 → 100644
View file @
8543f53a
package
com
.
egolm
.
film
.
common
.
impl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.egolm.common.StringUtil
;
import
com.egolm.common.jdbc.JdbcTemplate
;
import
com.egolm.film.bean.Fc_member
;
import
com.egolm.film.common.MemberService
;
@Service
public
class
MemberServiceImpl
implements
MemberService
{
@Autowired
private
JdbcTemplate
jdbcTemplate
;
@Override
public
void
changePassword
(
String
id
,
String
newPassword
)
{
String
sql
=
"update fc_member set password = ? where id = ?"
;
String
md5Pwd
=
StringUtil
.
toMD5HexString
(
newPassword
);
jdbcTemplate
.
executeUpdate
(
sql
,
md5Pwd
,
id
);
}
@Override
public
Fc_member
getMemberByEmail
(
String
email
)
{
String
sql
=
"select * from fc_member where email = ?"
;
return
jdbcTemplate
.
queryForBean
(
sql
,
Fc_member
.
class
,
email
);
}
}
src/main/java/com/egolm/film/login/service/impl/MemberTokenServiceImpl.java
View file @
8543f53a
...
...
@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
import
com.egolm.common.StringUtil
;
import
com.egolm.common.jdbc.JdbcTemplate
;
import
com.egolm.film.common.Messages
;
import
com.egolm.film.config.WebMvcConfig
;
import
com.egolm.film.config.XException
;
import
com.egolm.film.login.service.MemberTokenService
;
...
...
@@ -18,6 +19,9 @@ import com.egolm.film.model.LoginToken;
@Service
public
class
MemberTokenServiceImpl
implements
MemberTokenService
{
@Autowired
private
Messages
messages
;
@Autowired
private
JdbcTemplate
jdbcTemplate
;
...
...
@@ -37,17 +41,17 @@ public class MemberTokenServiceImpl implements MemberTokenService {
session
.
setAttribute
(
TOKEN_NAME
,
token
);
return
token
;
}
else
if
(
state
==
2
)
{
throw
new
XException
(
"用户已禁用"
);
throw
new
XException
(
messages
.
get
(
"sys.err.user_disabled"
)
);
}
else
{
throw
new
XException
(
"用户状态未知"
);
throw
new
XException
(
messages
.
get
(
"sys.err"
)
);
}
}
else
if
(
list
.
size
()
==
0
)
{
throw
new
XException
(
"用户名或密码错误"
);
throw
new
XException
(
messages
.
get
(
"sys.err.user_or_pwd"
)
);
}
else
{
throw
new
XException
(
"用户登陆信息重复,请联系管理员"
);
throw
new
XException
(
messages
.
get
(
"sys.err"
)
);
}
}
else
{
throw
new
XException
(
"用户名或密码错误"
);
throw
new
XException
(
messages
.
get
(
"sys.err.user_or_pwd"
)
);
}
}
...
...
@@ -69,4 +73,5 @@ public class MemberTokenServiceImpl implements MemberTokenService {
public
boolean
isLogin
()
{
return
this
.
getToken
()
!=
null
;
}
}
src/main/resources/application.properties
View file @
8543f53a
...
...
@@ -15,4 +15,10 @@ spring.http.encoding.charset=utf-8
spring.messages.basename
=
classpath:i18n/messages
spring.messages.cache-seconds
=
3600
spring.messages.encoding
=
UTF-8
\ No newline at end of file
spring.messages.encoding
=
UTF-8
com.egolm.film.email.smtp.host
=
smtp.163.com
com.egolm.film.email.smtp.port
=
25
com.egolm.film.email.smtp.is_auth
=
true
com.egolm.film.email.smtp.from
=
15601712556@163.com
com.egolm.film.email.smtp.password
=
Liang12345
src/main/resources/i18n/message.properties
View file @
8543f53a
email.getPassword.subject
=
\u
4E2D
\u
56FD
\u7535\u
5F71
\u8282
[
\u
627E
\u
56DE
\u
5BC6
\u7801
]
\u
90AE
\u
4EF6
email.getPassword.content
=
{0},
\u
60A8
\u
597D,
\u
60A8
\u7684\u
65B0
\u
5BC6
\u7801\u
662F: [{1}]
sys.err
=
\u
7CFB
\u
7EDF
\u9519\u
8BEF
sys.err.user_disabled
=
\u7528\u6237\u
5DF2
\u
7ECF
\u7981\u7528
sys.err.user_or_pwd=
\u7528\u6237\u6216\u
5BC6
\u7801\u9519\u
8BEF
msg.hello
=
\u
60A8
\u
597D
msg.your_pwd
=
\u
60A8
\u7684\u
5BC6
\u7801\u
662F
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment