Commit 711cab91 by guojuxing

新增子管理员,如果是自动生成密码,则发送短信

parent 8ccd8a63
......@@ -154,6 +154,11 @@
<artifactId>gic-open-platform-api</artifactId>
<version>${gic-open-platform-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-marketing-process-api</artifactId>
<version>${gic-marketing-process-api}</version>
</dependency>
</dependencies>
<build>
......
package com.gic.auth.web.controller;
import com.gic.auth.constant.UserConstants;
import com.gic.marketing.process.api.service.sms.SmsSendApiService;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -29,20 +32,34 @@ public class UserController {
@Autowired
private UserApiService userApiService;
@Autowired
private SmsSendApiService smsSendApiService;
@RequestMapping("/save-or-update-user")
public RestResponse editUser(@Validated({ UserDTO.UserQoValid.class }) UserDTO userDTO) {
public RestResponse editUser(@Validated({UserDTO.UserQoValid.class}) UserDTO userDTO) {
if (UserDetailUtils.getUserDetail().getUserInfo().getSuperAdmin().intValue() == 0) {
return RestResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "子管理员不能编辑");
}
Integer operationPassword = userDTO.getOperPasswordType();
userDTO.setEnterpriseId(UserDetailUtils.getUserDetail().getEnterpriseId());
boolean isNeedSendSms = false;
//发送短信的参数
String[] smsArr = new String[0];
if (operationPassword != null && operationPassword.intValue() == 1) {
//如果是1,则不用验证密码
} else {
String password = UserPasswordUtils.validPassword(userDTO.getPasswordType(), userDTO.getPassword());
userDTO.setPassword(UserPasswordUtils.getEncryptPassword(password));
isNeedSendSms = UserConstants.CREATE_AUTO == userDTO.getPasswordType().intValue();
if (isNeedSendSms) {
//发送短信,通知自动生成密码
if (StringUtils.isBlank(userDTO.getPhoneAreaCode())) {
userDTO.setPhoneAreaCode("86");
}
smsArr = new String[]{UserDetailUtils.getUserDetail().getEnterpriseInfo().getEnterpriseName(), userDTO.getPhoneNumber(), password};
}
}
ServiceResponse userResult;
//普通用户
......@@ -53,6 +70,13 @@ public class UserController {
userResult = userApiService.editUser(userDTO);
}
if (userResult.isSuccess()) {
if (isNeedSendSms) {
ServiceResponse<Void> smsSendResult = smsSendApiService.sendPlatformSms("GICpassword001",
UserDetailUtils.getUserDetail().getEnterpriseInfo().getEnterpriseId(), userDTO.getPhoneAreaCode(), userDTO.getPhoneNumber(), smsArr);
if (!smsSendResult.isSuccess()) {
logger.warn(smsSendResult.getMessage());
}
}
if (userDTO.getUserId() == null) {
LogUtils.createLog(OperationResultUtils.LOG_NEW + "管理员", userDTO.getUserName());
} else {
......@@ -66,12 +90,13 @@ public class UserController {
/**
* 用户详情
* @Title: getUserById

* @Description:

 * @author guojuxing
* @param userId

* @return com.gic.commons.webapi.reponse.RestResponse


 */
*
* @param userId
* @return com.gic.commons.webapi.reponse.RestResponse
*
* @Title: getUserById
* @Description: 
 * @author guojuxing
*/
@RequestMapping("/get-user-by-id")
public RestResponse getUserById(Integer userId) {
return ResultControllerUtils.commonResultOne(userApiService.getUserById(userId), UserDetailVO.class);
......@@ -98,14 +123,15 @@ public class UserController {
/**
* 逻辑删除用户对应分组数据
* @Title: removeUserAccountGroup

* @Description:

 * @author guojuxing
*
* @param type
* @param accountGroupId
* @param userId

* @return com.gic.commons.webapi.reponse.RestResponse


 */
* @param userId
* @return com.gic.commons.webapi.reponse.RestResponse
*
* @Title: removeUserAccountGroup
* @Description: 
 * @author guojuxing
*/
@RequestMapping("/remove-user-account-group")
public RestResponse removeUserAccountGroup(Integer type, Integer accountGroupId, Integer userId) {
ServiceResponse<String> result = userApiService.removeAccountGroup(accountGroupId, userId, type);
......
......@@ -68,4 +68,6 @@
<dubbo:reference interface="com.gic.open.api.service.AppTokenApiService" id="appTokenApiService" timeout="6000"/>
<!--运营管理员-->
<dubbo:reference interface="com.gic.auth.service.OperationUserApiService" id="operationUserApiService" timeout="6000" />
<!--短信发送-->
<dubbo:reference interface="com.gic.marketing.process.api.service.sms.SmsSendApiService" id="smsSendApiService" timeout="60000" />
</beans>
\ 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