Commit 3ad764a7 authored by Quxl's avatar Quxl

新增修改密码接口

parent 342b6ae3
...@@ -85,7 +85,7 @@ public class MemberOpenApiController { ...@@ -85,7 +85,7 @@ public class MemberOpenApiController {
String password = String.valueOf(code); String password = String.valueOf(code);
Fc_member member = memberService.getMemberByEmail(email); Fc_member member = memberService.getMemberByEmail(email);
String encodePwd = Common.encodePassword(password, member.getSalt()); String encodePwd = Common.encodePassword(password, member.getSalt());
memberService.changePassword(member.getId(), encodePwd); memberService.resetPassword(member.getId(), encodePwd);
String name = member.getUsername(); String name = member.getUsername();
String subject = messages.get("email.getPassword.subject"); String subject = messages.get("email.getPassword.subject");
String content = messages.get("email.getPassword.content", name == null ? "" : name, password); String content = messages.get("email.getPassword.content", name == null ? "" : name, password);
......
...@@ -55,4 +55,13 @@ public class MemberInfoController { ...@@ -55,4 +55,13 @@ public class MemberInfoController {
return Rjx.jsonOk(); return Rjx.jsonOk();
} }
@ResponseBody
@PostMapping("changePassword")
@ApiOperation("修改密码")
public Object changePassword(String password, String newPassword) {
LoginToken loginToken = tokenService.getToken();
Integer id = (Integer)loginToken.getId();
boolean boo = memberService.changePasswordByMemberId(id, password, newPassword);
return Rjx.json().setCode(boo ? 200 : 500);
}
} }
...@@ -15,7 +15,7 @@ public interface MemberService { ...@@ -15,7 +15,7 @@ public interface MemberService {
Fc_member getMemberByEmail(String email); Fc_member getMemberByEmail(String email);
void changePassword(Integer id, String newPassword); void resetPassword(Integer id, String newPassword);
void saveMember(Fc_member member); void saveMember(Fc_member member);
...@@ -120,4 +120,6 @@ public interface MemberService { ...@@ -120,4 +120,6 @@ public interface MemberService {
String film_apply_mobile, String film_apply_mobile,
String film_apply_country); String film_apply_country);
boolean changePasswordByMemberId(Integer member_id, String password, String newPassword);
} }
...@@ -27,6 +27,7 @@ import com.egolm.film.bean.Fc_member_film_issuer; ...@@ -27,6 +27,7 @@ import com.egolm.film.bean.Fc_member_film_issuer;
import com.egolm.film.bean.Fc_member_film_playactor; import com.egolm.film.bean.Fc_member_film_playactor;
import com.egolm.film.bean.Fc_member_film_show; import com.egolm.film.bean.Fc_member_film_show;
import com.egolm.film.common.Messages; import com.egolm.film.common.Messages;
import com.egolm.film.config.Common;
import com.egolm.film.config.WebMvcConfig; import com.egolm.film.config.WebMvcConfig;
import com.egolm.film.config.XException; import com.egolm.film.config.XException;
...@@ -41,7 +42,7 @@ public class MemberServiceImpl implements MemberService { ...@@ -41,7 +42,7 @@ public class MemberServiceImpl implements MemberService {
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
@Override @Override
public void changePassword(Integer id, String newPassword) { public void resetPassword(Integer id, String newPassword) {
String sql = "update fc_member set password = ? where id = ?"; String sql = "update fc_member set password = ? where id = ?";
jdbcTemplate.executeUpdate(sql, newPassword, id); jdbcTemplate.executeUpdate(sql, newPassword, id);
} }
...@@ -409,4 +410,15 @@ public class MemberServiceImpl implements MemberService { ...@@ -409,4 +410,15 @@ public class MemberServiceImpl implements MemberService {
jdbcTemplate.executeUpdate(sql, args); jdbcTemplate.executeUpdate(sql, args);
} }
@Override
public boolean changePasswordByMemberId(Integer member_id, String password, String newPassword) {
Fc_member member = this.getMemberById(member_id);
String encodePassword = Common.encodePassword(password, member.getSalt());
if(encodePassword.equals(member.getPassword())) {
String encodeNewPassword = Common.encodePassword(newPassword, member.getSalt());
return jdbcTemplate.executeUpdate("update fc_member set password = ? where id = ?", encodeNewPassword, member.getId()) == 1;
}
return false;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment