短信发送增加字段
This commit is contained in:
parent
b5c761b810
commit
55283b2ce5
@ -1,5 +1,7 @@
|
||||
package ink.wgink.properties.sms;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
@ -12,11 +14,20 @@ package ink.wgink.properties.sms;
|
||||
**/
|
||||
public class SmsDefaultProperties {
|
||||
|
||||
private String url;
|
||||
private String account;
|
||||
private String password;
|
||||
private String sign;
|
||||
private SmsDefaultTemplateProperties template;
|
||||
|
||||
public String getUrl() {
|
||||
return StringUtils.isEmpty(url) ? "https://dx.ipyy.net/sms.aspx" : url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account == null ? "" : account.trim();
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import ink.wgink.pojo.pos.DepartmentPO;
|
||||
import ink.wgink.pojo.pos.GroupPO;
|
||||
import ink.wgink.pojo.pos.PositionPO;
|
||||
import ink.wgink.pojo.pos.RolePO;
|
||||
import ink.wgink.properties.app.AppTokenProperties;
|
||||
import ink.wgink.service.department.service.IDepartmentUserService;
|
||||
import ink.wgink.service.user.pojo.pos.UserPO;
|
||||
import ink.wgink.util.AesUtil;
|
||||
@ -44,6 +45,8 @@ public class BaseAppSignService extends DefaultBaseService {
|
||||
private IPositionUserBaseService positionUserBaseService;
|
||||
@Autowired(required = false)
|
||||
private IGroupUserBaseService groupUserBaseService;
|
||||
@Autowired
|
||||
private AppTokenProperties appTokenProperties;
|
||||
|
||||
/**
|
||||
* 获取token
|
||||
@ -53,17 +56,21 @@ public class BaseAppSignService extends DefaultBaseService {
|
||||
* @throws Exception
|
||||
*/
|
||||
protected String getToken(UserPO userPO) throws UnsupportedEncodingException {
|
||||
return getToken(userPO, false);
|
||||
return getToken(userPO, appTokenProperties.getHasDepartment(), appTokenProperties.getHasRole(), appTokenProperties.getHasPosition(), appTokenProperties.getHasGroup());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取token
|
||||
*
|
||||
* @param userPO 用户信息
|
||||
* @param isFull 是否包含全部信息(部门、角色、职位、组)
|
||||
* @param userPO 用户信息
|
||||
* @param hasDepartment 包含部门
|
||||
* @param hasRole 包含角色
|
||||
* @param hasPosition 包含职位
|
||||
* @param hasGroup 包含组
|
||||
* @return
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
protected String getToken(UserPO userPO, boolean isFull) throws UnsupportedEncodingException {
|
||||
protected String getToken(UserPO userPO, boolean hasDepartment, boolean hasRole, boolean hasPosition, boolean hasGroup) throws UnsupportedEncodingException {
|
||||
Map<String, Object> userInfo = new HashMap<>(8);
|
||||
// 这个参数是token认证标识
|
||||
userInfo.put(ISystemConstant.APP_TOKEN_SIGN, ISystemConstant.APP_TOKEN_VERIFY + System.currentTimeMillis());
|
||||
@ -74,7 +81,7 @@ public class BaseAppSignService extends DefaultBaseService {
|
||||
userInfo.put("phone", userPO.getUserPhone());
|
||||
userInfo.put("email", userPO.getUserEmail());
|
||||
|
||||
if (isFull) {
|
||||
if (hasDepartment) {
|
||||
LOG.debug("人员部门列表");
|
||||
List<DepartmentPO> departmentPOs = departmentUserService.listDepartmentPOByUserId(userPO.getUserId());
|
||||
List<Map<String, Object>> departments = new ArrayList<>();
|
||||
@ -85,42 +92,42 @@ public class BaseAppSignService extends DefaultBaseService {
|
||||
departments.add(departmentMap);
|
||||
}
|
||||
userInfo.put("departments", departments);
|
||||
if (roleUserBaseService != null) {
|
||||
LOG.debug("人员角色列表");
|
||||
List<RolePO> rolePOs = roleUserBaseService.listRolePOByUserId(userPO.getUserId());
|
||||
List<Map<String, Object>> roles = new ArrayList<>();
|
||||
for (RolePO rolePO : rolePOs) {
|
||||
Map<String, Object> roleMap = new HashMap<>(4);
|
||||
roleMap.put("roleId", rolePO.getRoleId());
|
||||
roleMap.put("roleName", rolePO.getRoleName());
|
||||
roles.add(roleMap);
|
||||
}
|
||||
userInfo.put("roles", roles);
|
||||
}
|
||||
if (hasRole && roleUserBaseService != null) {
|
||||
LOG.debug("人员角色列表");
|
||||
List<RolePO> rolePOs = roleUserBaseService.listRolePOByUserId(userPO.getUserId());
|
||||
List<Map<String, Object>> roles = new ArrayList<>();
|
||||
for (RolePO rolePO : rolePOs) {
|
||||
Map<String, Object> roleMap = new HashMap<>(4);
|
||||
roleMap.put("roleId", rolePO.getRoleId());
|
||||
roleMap.put("roleName", rolePO.getRoleName());
|
||||
roles.add(roleMap);
|
||||
}
|
||||
if (positionUserBaseService != null) {
|
||||
LOG.debug("人员职位列表");
|
||||
List<PositionPO> positionPOs = positionUserBaseService.listPositionPOByUserId(userPO.getUserId());
|
||||
List<Map<String, Object>> positions = new ArrayList<>();
|
||||
for (PositionPO positionPO : positionPOs) {
|
||||
Map<String, Object> positionMap = new HashMap<>(2);
|
||||
positionMap.put("positionId", positionPO.getPositionId());
|
||||
positionMap.put("positionName", positionPO.getPositionName());
|
||||
positions.add(positionMap);
|
||||
}
|
||||
userInfo.put("positions", positions);
|
||||
userInfo.put("roles", roles);
|
||||
}
|
||||
if (hasPosition && positionUserBaseService != null) {
|
||||
LOG.debug("人员职位列表");
|
||||
List<PositionPO> positionPOs = positionUserBaseService.listPositionPOByUserId(userPO.getUserId());
|
||||
List<Map<String, Object>> positions = new ArrayList<>();
|
||||
for (PositionPO positionPO : positionPOs) {
|
||||
Map<String, Object> positionMap = new HashMap<>(2);
|
||||
positionMap.put("positionId", positionPO.getPositionId());
|
||||
positionMap.put("positionName", positionPO.getPositionName());
|
||||
positions.add(positionMap);
|
||||
}
|
||||
if (groupUserBaseService != null) {
|
||||
LOG.debug("人员组列表");
|
||||
List<GroupPO> groupPOs = groupUserBaseService.listGroupPOByUserId(userPO.getUserId());
|
||||
List<Map<String, Object>> groups = new ArrayList<>();
|
||||
for (GroupPO groupPO : groupPOs) {
|
||||
Map<String, Object> groupMap = new HashMap<>(2);
|
||||
groupMap.put("groupId", groupPO.getGroupId());
|
||||
groupMap.put("groupName", groupPO.getGroupName());
|
||||
groups.add(groupMap);
|
||||
}
|
||||
userInfo.put("groups", groups);
|
||||
userInfo.put("positions", positions);
|
||||
}
|
||||
if (hasGroup && groupUserBaseService != null) {
|
||||
LOG.debug("人员组列表");
|
||||
List<GroupPO> groupPOs = groupUserBaseService.listGroupPOByUserId(userPO.getUserId());
|
||||
List<Map<String, Object>> groups = new ArrayList<>();
|
||||
for (GroupPO groupPO : groupPOs) {
|
||||
Map<String, Object> groupMap = new HashMap<>(2);
|
||||
groupMap.put("groupId", groupPO.getGroupId());
|
||||
groupMap.put("groupName", groupPO.getGroupName());
|
||||
groups.add(groupMap);
|
||||
}
|
||||
userInfo.put("groups", groups);
|
||||
}
|
||||
LOG.debug("userInfo: " + userInfo);
|
||||
return Base64.encodeBase64String(AesUtil.aesCommonEncoder(ISystemConstant.APP_TOKEN_AES_KEY, JSONObject.toJSONString(userInfo)).getBytes("UTF-8"));
|
||||
|
@ -23,7 +23,7 @@ import org.springframework.web.client.RestTemplate;
|
||||
public class DefaultSmsSendImpl implements ISmsSend {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DefaultSmsSendImpl.class);
|
||||
private static final String URL_SMS = "https://dx.ipyy.net/sms.aspx?action=send&userid=&account={account}&password={password}&mobile={mobile}&content={content}&sendTime=&extno={extno}";
|
||||
private static final String URL_SMS = "{url}?action=send&userid=&account={account}&password={password}&mobile={mobile}&content={content}&sendTime=&extno={extno}";
|
||||
private SmsDefaultProperties smsDefaultProperties;
|
||||
|
||||
public DefaultSmsSendImpl(SmsDefaultProperties smsDefaultProperties) {
|
||||
@ -50,6 +50,7 @@ public class DefaultSmsSendImpl implements ISmsSend {
|
||||
*/
|
||||
private void send(String phone, String content) {
|
||||
String[] paramArray = new String[]{
|
||||
smsDefaultProperties.getUrl(),
|
||||
smsDefaultProperties.getAccount(),
|
||||
smsDefaultProperties.getPassword(),
|
||||
phone,
|
||||
|
Loading…
Reference in New Issue
Block a user