|
@ -11,6 +11,7 @@ import java.util.concurrent.TimeUnit;
|
11
|
11
|
|
12
|
12
|
import javax.mail.MessagingException;
|
13
|
13
|
|
|
14
|
import org.apache.log4j.Logger;
|
14
|
15
|
import org.jfw.apt.annotation.Autowrie;
|
15
|
16
|
import org.jfw.apt.annotation.Nullable;
|
16
|
17
|
import org.jfw.apt.web.annotation.Path;
|
|
@ -37,6 +38,7 @@ import com.ekexiu.portal.pojo.SessionUser;
|
37
|
38
|
public class SysService {
|
38
|
39
|
public static final String DEFAULT_PASS_WORD = "11111111111111111111111111111111";
|
39
|
40
|
public static SimpleDateFormat DATE = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
41
|
private Logger logger = Logger.getLogger(SysService.class);
|
40
|
42
|
|
41
|
43
|
@Autowrie
|
42
|
44
|
private UserDao userDao;
|
|
@ -518,8 +520,6 @@ public class SysService {
|
518
|
520
|
if (user.getInviteCode() == null) {
|
519
|
521
|
throw new JfwBaseException("该用户没有邀请码");
|
520
|
522
|
}
|
521
|
|
if (user != null && user.getEmail() != null && user.getInviteCode() != null) {
|
522
|
|
}
|
523
|
523
|
String mailContent = this.inviteMailContentTempalte;
|
524
|
524
|
mailContent = mailContent.replaceAll(this.inviteReplaceEmail, user.getEmail());
|
525
|
525
|
mailContent = mailContent.replaceAll(this.inviteReplaceCode, user.getInviteCode());
|
|
@ -925,7 +925,43 @@ public class SysService {
|
925
|
925
|
JfwAppContext.removeCachedObject(state);
|
926
|
926
|
}
|
927
|
927
|
}
|
928
|
|
|
|
928
|
|
|
929
|
/**
|
|
930
|
* 给指定邮箱发送邀请邮件
|
|
931
|
* @param con
|
|
932
|
* @param mobilePhones 手机号数组
|
|
933
|
* @param emails 邮箱
|
|
934
|
* @param inviteCodes 邀请码
|
|
935
|
* @throws SQLException
|
|
936
|
* @throws MessagingException
|
|
937
|
*/
|
|
938
|
@Post
|
|
939
|
@Path("/sendmail")
|
|
940
|
public int sendmail(@JdbcConn Connection con,@Nullable String[] mobilePhones,String[] emails,String[] inviteCodes) throws SQLException, MessagingException{
|
|
941
|
for (int i = 0; i < emails.length; i++){
|
|
942
|
if(mobilePhones[i] == ""){
|
|
943
|
mobilePhones[i] = null;
|
|
944
|
}
|
|
945
|
this.sendInviteMail(con, emails[i], mobilePhones[i], inviteCodes[i]);
|
|
946
|
this.logger.info("成功发送邀请邮件:"+emails[i]);
|
|
947
|
}
|
|
948
|
return emails.length;
|
|
949
|
}
|
|
950
|
|
|
951
|
public void sendInviteMail(@JdbcConn Connection con,String email,@Nullable String mobilePhone,String inviteCode)throws SQLException, MessagingException{
|
|
952
|
String mailContent = this.inviteMailContentTempalte;
|
|
953
|
mailContent = mailContent.replaceAll(this.inviteReplaceEmail, email);
|
|
954
|
mailContent = mailContent.replaceAll(this.inviteReplaceCode, inviteCode);
|
|
955
|
String phoneReplace = "";
|
|
956
|
if (mobilePhone != null && mobilePhone.trim().length() == 11) {
|
|
957
|
String mobile = mobilePhone.trim();
|
|
958
|
mobile = mobile.substring(0, 3) + "****" + mobile.substring(7);
|
|
959
|
phoneReplace = this.phoneContentTemplate.replaceAll(this.phoneReplaceKey, mobile);
|
|
960
|
}
|
|
961
|
mailContent = mailContent.replaceAll(this.inviteReplacePhone, phoneReplace);
|
|
962
|
this.mailservice.sendSimpleMail(email, mailContent, null, this.inviteMailSubject);
|
|
963
|
}
|
|
964
|
|
929
|
965
|
public static void main(String[] args) {
|
930
|
966
|
System.out.println(String.format("%04d", new Random().nextInt(10000)));
|
931
|
967
|
}
|