|
@@ -17,15 +17,19 @@ import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
import com.yonge.cooleshow.common.security.SecurityConstants;
|
|
|
import com.yonge.cooleshow.tenant.io.request.SysUserWrapper;
|
|
|
import com.yonge.cooleshow.tenant.io.request.TenantInfoVo;
|
|
|
+import com.yonge.toolset.base.exception.BizException;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanInstantiationException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* @Author:haonan
|
|
@@ -86,11 +90,11 @@ public class TenantInfoController extends BaseController {
|
|
|
@ApiOperation(value = "修改机构信息", notes = "传入TenantInfo")
|
|
|
// @PreAuthorize("@pcs.hasPermissions('tenantInfoUpdate/update')")
|
|
|
public HttpResponseResult<Boolean> updateTenantInfo(@Valid @RequestBody TenantInfoVo.TenantInfo info) {
|
|
|
- SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
- Long id = sysUser.getId();
|
|
|
- TenantStaff staff = tenantStaffService.lambdaQuery().eq(TenantStaff::getUserId, id).list().get(0);
|
|
|
- Long tenantId = staff.getTenantId();
|
|
|
- return succeed(tenantInfoService.updateTenantInfo(JSON.parseObject(info.jsonString(), TenantInfo.class), tenantId));
|
|
|
+
|
|
|
+ TenantInfo tenantInfo = JSON.parseObject(info.jsonString(), TenantInfo.class);
|
|
|
+ tenantInfoService.updateById(tenantInfo);
|
|
|
+
|
|
|
+ return HttpResponseResult.succeed(true);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -107,10 +111,13 @@ public class TenantInfoController extends BaseController {
|
|
|
TenantInfoWrapper.TenantInfo info = new TenantInfoWrapper.TenantInfo();
|
|
|
SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
Long id = sysUser.getId();
|
|
|
- TenantStaff staff = tenantStaffService.lambdaQuery().eq(TenantStaff::getUserId, id).list().get(0);
|
|
|
- Long tenantId = staff.getTenantId();
|
|
|
- if (!(tenantId == null)){
|
|
|
- info = tenantInfoService.detailTenantInfo(tenantId);
|
|
|
+ List<TenantStaff> list = tenantStaffService.lambdaQuery().eq(TenantStaff::getUserId, id).list();
|
|
|
+ if (CollectionUtils.isNotEmpty(list)){
|
|
|
+ TenantStaff staff = list.get(0);
|
|
|
+ Long tenantId = staff.getTenantId();
|
|
|
+ if (!(tenantId == null)){
|
|
|
+ info = tenantInfoService.detailTenantInfo(tenantId);
|
|
|
+ }
|
|
|
}
|
|
|
return succeed(info);
|
|
|
}
|
|
@@ -138,33 +145,42 @@ public class TenantInfoController extends BaseController {
|
|
|
@ApiOperation(value = "用户修改", notes = "用户修改")
|
|
|
// @PreAuthorize("@pcs.hasPermissions('tenantInfoUpdate/sysUserUpdate')")
|
|
|
public HttpResponseResult<Boolean> sysUserUpdate(SysUserWrapper.SysUser sysUser) {
|
|
|
+ String code = sysUser.getCode();
|
|
|
+ String phone = sysUser.getPhone();
|
|
|
+
|
|
|
+ boolean re = smsCodeService.verifyValidCode(phone, code, "PHONE");
|
|
|
+
|
|
|
com.yonge.cooleshow.biz.dal.entity.SysUser sysUser1 = JSON.parseObject(sysUser.jsonString(), com.yonge.cooleshow.biz.dal.entity.SysUser.class);
|
|
|
- SysUser user = sysUserFeignService.queryUserInfo();
|
|
|
- tenantInfoService.updateSysUser(sysUser1,user.getId());
|
|
|
|
|
|
- //判断更改的手机所属的机构信息
|
|
|
- String phone = sysUser.getPhone();
|
|
|
+ if (re) {
|
|
|
+ SysUser user = sysUserFeignService.queryUserInfo();
|
|
|
+ tenantInfoService.updateSysUser(sysUser1, user.getId());
|
|
|
|
|
|
//设置默认头像
|
|
|
- if (sysUser.getAvatar().isEmpty()){
|
|
|
+ if (sysUser.getAvatar().isEmpty()) {
|
|
|
sysUser.setAvatar(sysConfigService.findConfigValue(SysConfigConstant.DEFAULT_HEARD));
|
|
|
}
|
|
|
-
|
|
|
- TenantInfo info = tenantInfoService.lambdaQuery().eq(TenantInfo::getPhone, phone).list().get(0);
|
|
|
- if (!(info == null)){
|
|
|
- //更新tennatInfo
|
|
|
- tenantInfoService.lambdaUpdate().set(TenantInfo::getPhone,phone)
|
|
|
- .eq(TenantInfo::getUserId,user.getId());
|
|
|
-
|
|
|
- //更新员工表
|
|
|
- tenantStaffService.lambdaUpdate().set(TenantStaff::getNickname,sysUser.getUsername())
|
|
|
- .set(TenantStaff::getAvatar,sysUser.getAvatar())
|
|
|
- .eq(TenantStaff::getUserId,user.getId());
|
|
|
+ //判断更改的手机所属的机构信息
|
|
|
+ List<TenantInfo> list = tenantInfoService.lambdaQuery().eq(TenantInfo::getPhone, phone).list();
|
|
|
+ if (CollectionUtils.isNotEmpty(list)){
|
|
|
+ TenantInfo info = list.get(0);
|
|
|
+ if (info != null) {
|
|
|
+ //更新tennatInfo
|
|
|
+ info.setPhone(phone);
|
|
|
+ tenantInfoService.updateById(info);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //更新员工表
|
|
|
+ Long id = user.getId();
|
|
|
+ TenantStaff staff = tenantStaffService.getByUserId(id);
|
|
|
+ if (staff != null){
|
|
|
+ staff.setNickname(sysUser.getUsername());
|
|
|
+ staff.setAvatar(sysUser.getAvatar());
|
|
|
+ tenantStaffService.updateById(staff);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new BizException("手机号校验有误");
|
|
|
+ }
|
|
|
+ return HttpResponseResult.succeed(true);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- return HttpResponseResult.succeed(true);
|
|
|
- }
|
|
|
-
|
|
|
}
|