重构企业项目,并可以添加数据

master
xiaohuang 2024-06-05 14:31:25 +08:00
parent 3477a3921d
commit 3dbcd574cc
6 changed files with 56 additions and 12 deletions

View File

@ -89,6 +89,7 @@ public class SysUser extends BaseEntity {
/**
* (00 )
*/
@Excel(name = "企业ID")
private String userType;
/**

View File

@ -7,6 +7,7 @@ import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.remote.factory.RemoteUserFallbackFactory;
import com.muyu.common.system.domain.LoginUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
@ -26,7 +27,6 @@ public interface RemoteUserService {
*/
@GetMapping("/user/info/{username}")
public Result<LoginUser> getUserInfo (@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
*
*
@ -37,4 +37,18 @@ 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);
@GetMapping("/user/info/{username}")
public Result<LoginUser> info (@PathVariable("username") String username);
@GetMapping("/user/authRole/{userId}")
public Result authRole (@PathVariable("userId") Long userId);
@GetMapping("/user/selectByUserId/{userId}")
public SysUser selectByUserId (@PathVariable("userId") Long userId);
}

View File

@ -31,6 +31,26 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
public Result<Boolean> registerUserInfo (SysUser sysUser, String source) {
return Result.error("注册用户失败:" + throwable.getMessage());
}
@Override
public Result add(SysUser user) {
return Result.error("注册用户失败:" + throwable.getMessage());
}
@Override
public Result<LoginUser> info(String username) {
return Result.error("注册用户失败:" + throwable.getMessage());
}
@Override
public Result authRole(Long userId) {
return Result.error("注册用户失败:" + throwable.getMessage());
}
@Override
public SysUser selectByUserId(Long userId) {
return null;
}
};
}
}

View File

@ -93,6 +93,8 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business> i
public int updateBusiness(Business business) {
business.setUpdateTime(DateUtils.getNowDate());
httpConnectMysql(business);
return businessMapper.updateBusiness(business);
}
@ -105,10 +107,7 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business> i
public void httpConnectMysql(Business business){
if (business.getBusinessStates().equals(2) ) {
if (!redisTemplate.hasKey(business.getId()+business.getName())){
redisTemplate.opsForValue()
.set(business.getId()+
business.getName()
,String.valueOf(3306+business.getId()));
redisTemplate.opsForValue().set(business.getId()+ business.getName(),String.valueOf(3306+business.getId()));
extracted(business);
}
}
@ -118,7 +117,7 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business> i
private static void extracted(Business business) {
String postUrl="http://122.51.111.225:10006/webhook/%E6%96%B0%E5%BB%BA%E4%BC%81%E4%B8%9A%E6%95%B0%E6%8D%AE%E6%BA%90";
String postUrl="http://175.24.138.82:10006/webhook/%E6%9C%AA%E5%91%BD%E5%90%8D%E9%A1%B9%E7%9B%AE";
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("businessId", business.getId()+ business.getName());
hashMap.put("mysqlPort",String.valueOf(3306+ business.getId()));

View File

@ -66,6 +66,11 @@ public class SysUserController extends BaseController {
List<SysUser> list = userService.selectUserList(user);
return getDataTable(list);
}
@GetMapping("/selectByUserId/{userId}")
public SysUser selectByUserId (@PathVariable("userId") Long userId) {
SysUser user = userService.selectUserById(userId);
return user;
}
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:user:export")

View File

@ -9,6 +9,7 @@
<result property="deptId" column="dept_id"/>
<result property="userName" column="user_name"/>
<result property="nickName" column="nick_name"/>
<result property="userType" column="user_type"/>
<result property="email" column="email"/>
<result property="phonenumber" column="phonenumber"/>
<result property="sex" column="sex"/>
@ -56,6 +57,7 @@
u.phonenumber,
u.password,
u.sex,
u.user_type,
u.status,
u.del_flag,
u.login_ip,
@ -83,7 +85,7 @@
</sql>
<select id="selectUserList" parameterType="com.muyu.common.system.domain.SysUser" resultMap="SysUserResult">
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status,
select u.user_id, u.dept_id, u.nick_name, u.user_type,u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status,
u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user
u
left join sys_dept d on u.dept_id = d.dept_id
@ -115,7 +117,7 @@
</select>
<select id="selectAllocatedList" parameterType="com.muyu.common.system.domain.SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
select distinct u.user_id, u.dept_id,u.user_type, u.user_name,u.user_type, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id
@ -132,7 +134,7 @@
</select>
<select id="selectUnallocatedList" parameterType="com.muyu.common.system.domain.SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
select distinct u.user_id, u.dept_id, u.user_name,u.user_type, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id
@ -165,7 +167,7 @@
from sys_user
where user_name = #{userName}
and del_flag = '0'
limit 1
limit 1
</select>
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
@ -173,7 +175,7 @@
from sys_user
where phonenumber = #{phonenumber}
and del_flag = '0'
limit 1
limit 1
</select>
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
@ -181,13 +183,14 @@
from sys_user
where email = #{email}
and del_flag = '0'
limit 1
limit 1
</select>
<insert id="insertUser" parameterType="com.muyu.common.system.domain.SysUser" useGeneratedKeys="true" keyProperty="userId">
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>
@ -203,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>
@ -221,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>