Commit bed43d86 authored by Quxl's avatar Quxl

x

parent 75b07e08
package com.egolm.film.api.service; package com.egolm.film.api.service;
import java.util.Map;
public interface EmailService { public interface EmailService {
void send(Integer sender_type_id, Integer sender_id, String subject, String content, String email); void send(Integer sender_type_id, Integer sender_id, String subject, String content, String email);
/**
* {0} 姓名
* {1} 影片编号
* {2} 影片名称
* @param member_film_id
* @param template
*/
Map<String, Object> sendByTemplate_01(Long member_film_id, String template);
} }
package com.egolm.film.api.service.impl; package com.egolm.film.api.service.impl;
import java.text.MessageFormat;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -9,8 +13,15 @@ import org.springframework.stereotype.Service; ...@@ -9,8 +13,15 @@ import org.springframework.stereotype.Service;
import com.egolm.common.MailUtil; import com.egolm.common.MailUtil;
import com.egolm.common.StringUtil; import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate; import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.film.api.service.AdminTokenService;
import com.egolm.film.api.service.EmailService; import com.egolm.film.api.service.EmailService;
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_email_record; import com.egolm.film.bean.Fc_email_record;
import com.egolm.film.bean.Fc_member;
import com.egolm.film.bean.Fc_member_film;
import com.egolm.film.util.Common;
@Service @Service
public class EmailServiceImpl implements EmailService { public class EmailServiceImpl implements EmailService {
...@@ -51,6 +62,52 @@ public class EmailServiceImpl implements EmailService { ...@@ -51,6 +62,52 @@ public class EmailServiceImpl implements EmailService {
}.start(); }.start();
} }
@Autowired
MemberService memberService;
@Autowired
FilmService filmService;
@Autowired
AdminTokenService adminTokenService;
@Autowired
Messages messages;
public Map<String, Object> sendByTemplate_01(Long member_film_id, String template) {
Map<String, Object> map = new HashMap<String, Object>();
Integer adminid = (Integer)adminTokenService.getToken().getId();
Fc_member_film memberFilm = filmService.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(template + "_" + locale.getLanguage().toLowerCase() + "_" + locale.getCountry().toUpperCase() + ".txt");
String filmName = null;
if(locale.getLanguage().toLowerCase().equals("zh")) {
filmName = memberFilm.getCn_name();
} else if(locale.getLanguage().toLowerCase().equals("en")) {
filmName = memberFilm.getEn_name();
}
if(filmName == null || filmName.trim().length() == 0) {
filmName = memberFilm.getOrigion_name();
}
if(filmName == null || filmName.trim().length() == 0) {
filmName = memberFilm.getEn_name();
}
if(filmName == null || filmName.trim().length() == 0) {
filmName = memberFilm.getCn_name();
}
String film_no = StringUtil.formatLength(memberFilm.getFilm_no(), "0000");
content = MessageFormat.format(content, member.getUsername(), film_no, filmName == null ? "" : filmName);
this.send(2, adminid, subject, content, member.getEmail());
map.put("email", member.getEmail());
map.put("film_no", film_no);
return map;
}
public static void main(String[] args) { public static void main(String[] args) {
String host = "smtp.siff.com"; String host = "smtp.siff.com";
Integer port = 25; Integer port = 25;
......
...@@ -2,7 +2,6 @@ package com.egolm.film.api.web.admin; ...@@ -2,7 +2,6 @@ package com.egolm.film.api.web.admin;
import java.text.MessageFormat; 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 javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -16,16 +15,12 @@ import org.springframework.web.bind.annotation.PostMapping; ...@@ -16,16 +15,12 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.StringUtil;
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.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.api.service.ReviewService; import com.egolm.film.api.service.ReviewService;
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_enroll; import com.egolm.film.bean.Fc_member_film_enroll;
import com.egolm.film.config.XRException; import com.egolm.film.config.XRException;
...@@ -58,12 +53,6 @@ public class AdminFirstController { ...@@ -58,12 +53,6 @@ public class AdminFirstController {
@Autowired @Autowired
EmailService emailService; EmailService emailService;
@Autowired
MemberService memberService;
@Autowired
Messages messages;
@Autowired @Autowired
ReviewService reviewService; ReviewService reviewService;
...@@ -119,8 +108,6 @@ public class AdminFirstController { ...@@ -119,8 +108,6 @@ public class AdminFirstController {
@ApiImplicitParam(paramType="query", dataType="string", required=true, name="film_type_name_short", value="影片分类扩展分类"), @ApiImplicitParam(paramType="query", dataType="string", required=true, name="film_type_name_short", value="影片分类扩展分类"),
}) })
public Object pass(Long member_film_id, String film_type_name_short) { public Object pass(Long member_film_id, String film_type_name_short) {
LoginToken token = tokenService.getToken();
Integer adminid = (Integer)token.getId();
memberFilmService.verifyFilmDuplicate(member_film_id); memberFilmService.verifyFilmDuplicate(member_film_id);
Fc_member_film film = new Fc_member_film(); Fc_member_film film = new Fc_member_film();
film.setId(member_film_id); film.setId(member_film_id);
...@@ -145,36 +132,10 @@ public class AdminFirstController { ...@@ -145,36 +132,10 @@ public class AdminFirstController {
} else { } else {
reviewService.toFirstRound(member_film_id, 4); reviewService.toFirstRound(member_film_id, 4);
} }
Map<String, Object> map = emailService.sendByTemplate_01(member_film_id, "doc/first_pass");
Rjx rjx = Rjx.jsonOk();
rjx.putAll(map);
Fc_member_film memberFilm = memberFilmService.queryMemberFilmById(member_film_id); return rjx;
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("doc/first_pass_" + locale.getLanguage().toLowerCase() + "_" + locale.getCountry().toUpperCase() + ".txt");
String filmName = null;
if(locale.getLanguage().toLowerCase().equals("zh")) {
filmName = memberFilm.getCn_name();
} else if(locale.getLanguage().toLowerCase().equals("en")) {
filmName = memberFilm.getEn_name();
}
if(filmName == null || filmName.trim().length() == 0) {
filmName = memberFilm.getOrigion_name();
}
if(filmName == null || filmName.trim().length() == 0) {
filmName = memberFilm.getEn_name();
}
if(filmName == null || filmName.trim().length() == 0) {
filmName = memberFilm.getCn_name();
}
String film_no = StringUtil.formatLength(memberFilm.getFilm_no(), "0000");
content = MessageFormat.format(content, member.getUsername(), film_no, filmName == null ? "" : filmName);
emailService.send(2, adminid, subject, content, member.getEmail());
return Rjx.jsonOk().set("email", member.getEmail()).set("film_no", memberFilm.getFilm_no());
} }
@ResponseBody @ResponseBody
......
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