feat:企业注入添加默认登录信息
parent
35e32767db
commit
f12baddae0
|
@ -22,6 +22,10 @@
|
|||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.zhiLian</groupId>
|
||||
<artifactId>zhiLian-common-system</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.zhiLian.common.security.annotation.EnableMyFeignClients;
|
|||
import com.zhiLian.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
/**
|
||||
* BingRui.Hou
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package com.zhiLian.business.remote.factory;
|
||||
|
||||
|
||||
import com.zhiLian.common.core.domain.Result;
|
||||
import com.zhiLian.common.log.annotation.Log;
|
||||
import com.zhiLian.common.log.enums.BusinessType;
|
||||
import com.zhiLian.common.system.domain.SysUser;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* BingRui.Hou
|
||||
*
|
||||
* @Description 描述
|
||||
* @ClassName RemoteUserLoginFactory
|
||||
* @Date 2024/05/27 16:31
|
||||
*/
|
||||
@FeignClient("zhiLian-system")
|
||||
public interface RemoteUserLoginFactory {
|
||||
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/user")
|
||||
public Result add (@Validated @RequestBody SysUser user);
|
||||
}
|
|
@ -5,8 +5,12 @@ import java.util.List;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhiLian.business.domain.Business;
|
||||
import com.zhiLian.business.mapper.BusinessMapper;
|
||||
import com.zhiLian.business.remote.factory.RemoteUserLoginFactory;
|
||||
import com.zhiLian.business.service.IBusinessService;
|
||||
import com.zhiLian.common.core.domain.Result;
|
||||
import com.zhiLian.common.core.utils.DateUtils;
|
||||
import com.zhiLian.common.system.domain.SysUser;
|
||||
import com.zhiLian.common.system.remote.RemoteUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -24,6 +28,9 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
|
|||
@Autowired
|
||||
private BusinessMapper businessMapper;
|
||||
|
||||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
/**
|
||||
* 查询企业
|
||||
*
|
||||
|
@ -54,11 +61,21 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
|
|||
* @param business 企业
|
||||
* @return 结果
|
||||
*/
|
||||
@Autowired
|
||||
private RemoteUserLoginFactory remoteUserLoginFactory;
|
||||
@Override
|
||||
public int insertBusiness(Business business)
|
||||
{
|
||||
business.setCreateTime(DateUtils.getNowDate());
|
||||
return businessMapper.insertBusiness(business);
|
||||
int i = businessMapper.insertBusiness(business);
|
||||
System.out.println(business);
|
||||
SysUser sysUser = SysUser.builder()
|
||||
.userName(business.getName() + business.getId())
|
||||
.password("admin123").nickName(business.getName()).userType(String.valueOf(business.getId())).build();
|
||||
Result add = remoteUserService.add(sysUser);
|
||||
System.out.println(sysUser);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,7 +6,9 @@ import com.zhiLian.common.core.domain.Result;
|
|||
import com.zhiLian.common.system.domain.SysUser;
|
||||
import com.zhiLian.common.system.remote.factory.RemoteUserFallbackFactory;
|
||||
import com.zhiLian.common.system.domain.LoginUser;
|
||||
import lombok.extern.java.Log;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
|
@ -37,4 +39,7 @@ public interface RemoteUserService {
|
|||
*/
|
||||
@PostMapping("/user/register")
|
||||
public Result<Boolean> registerUserInfo (@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
@PostMapping("/user")
|
||||
public Result add (@Validated @RequestBody SysUser user);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,13 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
|||
public Result<Boolean> registerUserInfo (SysUser sysUser, String source) {
|
||||
return Result.error("注册用户失败:" + throwable.getMessage());
|
||||
}
|
||||
//好像写有 添加用户 远程调用是这个?不知道启动一下吧应该没问题OK 你先学 我自己再看看
|
||||
|
||||
@Override
|
||||
public Result add(SysUser user) {
|
||||
return Result.error("注册用户失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -190,6 +190,7 @@
|
|||
insert into sys_user(
|
||||
<if test="userId != null and userId != 0">user_id,</if>
|
||||
<if test="deptId != null and deptId != 0">dept_id,</if>
|
||||
<if test="userType != null and userType != 0">user_type,</if>
|
||||
<if test="userName != null and userName != ''">user_name,</if>
|
||||
<if test="nickName != null and nickName != ''">nick_name,</if>
|
||||
<if test="email != null and email != ''">email,</if>
|
||||
|
@ -205,6 +206,7 @@
|
|||
<if test="userId != null and userId != ''">#{userId},</if>
|
||||
<if test="deptId != null and deptId != ''">#{deptId},</if>
|
||||
<if test="userName != null and userName != ''">#{userName},</if>
|
||||
<if test="userType != null and userType != ''">#{userType},</if>
|
||||
<if test="nickName != null and nickName != ''">#{nickName},</if>
|
||||
<if test="email != null and email != ''">#{email},</if>
|
||||
<if test="avatar != null and avatar != ''">#{avatar},</if>
|
||||
|
@ -223,6 +225,7 @@
|
|||
<set>
|
||||
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
|
||||
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
||||
<if test="userType != null and userType != ''">user_type =#{userType},</if>
|
||||
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
|
||||
<if test="email != null ">email = #{email},</if>
|
||||
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
|
||||
|
|
Loading…
Reference in New Issue