Commit af74dcae authored by Quxl's avatar Quxl

初审成功邮件通知

parent a7b37774
...@@ -6,6 +6,8 @@ public interface Messages { ...@@ -6,6 +6,8 @@ public interface Messages {
public String get(String name, String... args); public String get(String name, String... args);
public String get(String name, Locale locale, String... args);
public Locale getLocale(); public Locale getLocale();
} }
...@@ -17,11 +17,16 @@ public class DefaultMessages implements Messages { ...@@ -17,11 +17,16 @@ public class DefaultMessages implements Messages {
@Autowired @Autowired
protected MessageSource messageSource; protected MessageSource messageSource;
@Override
public String get(String name, Locale locale, String... args) {
return messageSource.getMessage(name, args, locale);
}
public String get(String name, String... args) { public String get(String name, String... args) {
try { try {
Locale locale = LocaleContextHolder.getLocale(); Locale locale = LocaleContextHolder.getLocale();
locale = locale == null ? Locale.CHINA : locale; locale = locale == null ? Locale.CHINA : locale;
return messageSource.getMessage(name, args, locale); return this.get(name, locale, args);
} catch (NoSuchMessageException e) { } catch (NoSuchMessageException e) {
return name; return name;
} catch (Exception e) { } catch (Exception e) {
......
package com.egolm.film.api.web.admin; package com.egolm.film.api.web.admin;
import java.text.MessageFormat;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -13,12 +15,17 @@ import org.springframework.web.bind.annotation.ResponseBody; ...@@ -13,12 +15,17 @@ import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.bean.Rjx; import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page; import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.AdminTokenService; import com.egolm.film.api.service.AdminTokenService;
import com.egolm.film.api.service.EmailService;
import com.egolm.film.api.service.FilmService; import com.egolm.film.api.service.FilmService;
import com.egolm.film.api.service.MemberService;
import com.egolm.film.api.service.Messages;
import com.egolm.film.bean.Fc_member;
import com.egolm.film.bean.Fc_member_film; import com.egolm.film.bean.Fc_member_film;
import com.egolm.film.bean.Fc_member_film_issuer; 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.bean.model.Fc_member_film_base_model; import com.egolm.film.bean.model.Fc_member_film_base_model;
import com.egolm.film.util.Common;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
...@@ -41,6 +48,15 @@ public class AdminFirstController { ...@@ -41,6 +48,15 @@ public class AdminFirstController {
@Autowired @Autowired
AdminTokenService tokenService; AdminTokenService tokenService;
@Autowired
EmailService emailService;
@Autowired
MemberService memberService;
@Autowired
Messages messages;
@ResponseBody @ResponseBody
@PostMapping("list") @PostMapping("list")
@ApiOperation("初审列表分页查询") @ApiOperation("初审列表分页查询")
...@@ -96,6 +112,16 @@ public class AdminFirstController { ...@@ -96,6 +112,16 @@ public class AdminFirstController {
film.setFilm_type_name_short(film_type_name_short); film.setFilm_type_name_short(film_type_name_short);
memberFilmService.mergeMemberFilm(film); memberFilmService.mergeMemberFilm(film);
memberFilmService.pass(member_film_id); memberFilmService.pass(member_film_id);
Fc_member_film memberFilm = memberFilmService.queryMemberFilmById(member_film_id);
Fc_member member = memberService.getMemberById(memberFilm.getMember_id());
Locale locale = new Locale("zh", "CN");
if("en".equals(member.getLang())) {
locale = new Locale("en", "US");
}
String subject = messages.get("email.getPassword.subject", locale);
String content = Common.getStringAsStream("classpath:/doc/" + member.getLang() + "/first_pass.txt");
MessageFormat.format(content, member.getUsername(), memberFilm.getId());
emailService.send(subject, content, member.getEmail());
return Rjx.jsonOk(); return Rjx.jsonOk();
} }
......
package com.egolm.film.util; package com.egolm.film.util;
import java.io.InputStream;
import java.util.Random; import java.util.Random;
import com.egolm.common.FileUtil;
import com.egolm.common.StringUtil; import com.egolm.common.StringUtil;
public class Common { public class Common {
...@@ -21,6 +23,11 @@ public class Common { ...@@ -21,6 +23,11 @@ public class Common {
return StringUtil.toMD5HexString(StringUtil.toMD5HexString(password + salt).toLowerCase().substring(4, 24)).toLowerCase(); return StringUtil.toMD5HexString(StringUtil.toMD5HexString(password + salt).toLowerCase().substring(4, 24)).toLowerCase();
} }
public static String getStringAsStream(String filename) {
InputStream stream = Common.class.getClassLoader().getResourceAsStream(filename);
return new String(FileUtil.streamToBytes(stream));
}
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(encodePassword("123456", "XPm3m5")); System.out.println(encodePassword("123456", "XPm3m5"));
System.out.println(getGenerateString(6)); System.out.println(getGenerateString(6));
......
The first trial pass
Username: {0}
Film NO: {1}
\ No newline at end of file
初审通过
用户 {0}
影片编号 {1}
\ No newline at end of file
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