Browse Source

迁移代码

jichaobo 2 years ago
parent
commit
b5622c2a85

+ 84 - 0
service-system/service-system-biz/src/main/java/com/usky/system/controller/web/TenantConfigController.java

@@ -0,0 +1,84 @@
+package com.usky.system.controller.web;
+
+
+import com.usky.common.core.bean.ApiResult;
+import com.usky.common.core.bean.CommonPage;
+import com.usky.system.domain.SysPlatform;
+import com.usky.system.domain.SysTenant;
+import com.usky.system.service.SysPlatformService;
+import com.usky.system.service.SysTenantService;
+import com.usky.system.service.vo.SysTenantOneVo;
+import com.usky.system.service.vo.SysTenantTwoVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 个人中心
+ *
+ * @author ya
+ * @since 2022-05-05
+ */
+@RestController
+@RequestMapping("/tenantConfig")
+public class TenantConfigController {
+
+    @Autowired
+    private SysTenantService sysTenantService;
+
+    @Autowired
+    private SysPlatformService sysPlatformService;
+
+
+    /**
+     * 租户管理-租户单位配置-列表查询
+     *
+     * @param sysTenantOneVo
+     * @return
+     */
+    @PostMapping("getTenantData")
+    public ApiResult<CommonPage<SysTenantTwoVo>> getTenantData(@RequestBody SysTenantOneVo sysTenantOneVo) {
+        return ApiResult.success(sysTenantService.getTenantData(sysTenantOneVo));
+    }
+
+
+    /**
+     * 租户管理-租户单位配置-新增
+     *
+     * @param sysTenant
+     * @return
+     */
+//    @Log(title = "租户管理-单位管理", businessType = BusinessType.INSERT)
+    @PostMapping("addTenantData")
+    public ApiResult<Void> addTenantData(@RequestBody SysTenant sysTenant) {
+        sysTenantService.addTenantData(sysTenant);
+        return ApiResult.success();
+    }
+
+    /**
+     * 租户管理-租户单位配置-修改
+     *
+     * @param sysTenant
+     * @return
+     */
+//    @Log(title = "租户管理-单位管理", businessType = BusinessType.UPDATE)
+    @PostMapping("updateTenantData")
+    public ApiResult<Void> updateTenantData(@RequestBody SysTenant sysTenant) {
+        sysTenantService.updateTenantData(sysTenant);
+        return ApiResult.success();
+    }
+
+
+    /**
+     * 租户管理-租户单位配置-系统平台下拉框数据查询
+     *
+     * @return
+     */
+    @GetMapping("/getPlatformBoxList")
+    public ApiResult<List<SysPlatform>> getPlatformBoxList() {
+        return ApiResult.success(sysPlatformService.getPlatformBoxList());
+    }
+
+}
+

+ 156 - 0
service-system/service-system-biz/src/main/java/com/usky/system/controller/web/UserConfigController.java

@@ -0,0 +1,156 @@
+package com.usky.system.controller.web;
+
+import com.ruoyi.common.security.utils.SecurityUtils;
+import com.usky.common.core.bean.ApiResult;
+import com.usky.common.core.bean.CommonPage;
+import com.usky.common.core.exception.BusinessErrorCode;
+import com.usky.system.domain.SysUser;
+import com.usky.system.domain.constants.UserConstants;
+import com.usky.system.service.ISysUserService;
+import com.usky.system.service.SysTenantService;
+import com.usky.system.service.vo.SysTenantTwoVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Date;
+
+/**
+ * 租户管理-管理员配置
+ *
+ * @author yq
+ */
+@RestController
+@RequestMapping("/userconfig")
+public class UserConfigController extends BaseController {
+    @Autowired
+    private ISysUserService userService;
+
+    @Autowired
+    private SysTenantService sysTenantService;
+
+
+    /**
+     * 租户管理-管理员配置-新增
+     *
+     * @param user
+     * @return
+     */
+//    @Log(title = "租户管理-管理员配置", businessType = BusinessType.INSERT)
+    @Transactional
+    @PostMapping("/addUserData")
+    public ApiResult<Void> addUserData(@Validated @RequestBody SysUser user) {
+        if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName()))) {
+            return ApiResult.error(BusinessErrorCode.BIZ_BUSINESS_ERROR.getCode(), "新增用户'" + user.getUserName() + "'失败,登录账号已存在");
+        }
+        user.setCreateBy(SecurityUtils.getUsername());
+        user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
+        user.setCreateTime(new Date());
+        user.setUserType("01");
+        user.setFullName(user.getNickName());
+//        user.setStatus("0");
+        user.setDelFlag("0");
+        int row = userService.addUser(user);
+        return toAjax(row);
+    }
+
+
+    /**
+     * 租户管理-管理员配置-修改
+     *
+     * @param user
+     * @return
+     */
+//    @Log(title = "租户管理-管理员配置", businessType = BusinessType.UPDATE)
+    @Transactional
+    @PostMapping("/updateserData")
+    public ApiResult<Void> updateserData(@Validated @RequestBody SysUser user) {
+        user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
+        user.setUpdateBy(SecurityUtils.getUsername());
+        user.setUpdateTime(new Date());
+        return toAjax(userService.updateUserData(user));
+    }
+
+
+    /**
+     * 租户管理-管理员配置-删除
+     *
+     * @param userId 用户ID
+     * @return
+     */
+//    @Log(title = "租户管理-管理员配置", businessType = BusinessType.DELETE)
+    @GetMapping("/delUsers")
+    public ApiResult<Void> delUsers(@RequestParam Long userId) {
+        SysUser user = new SysUser();
+        if (userId == 0 && userId == null) {
+            return ApiResult.error(BusinessErrorCode.BIZ_BUSINESS_ERROR.getCode(), "用户ID不能为空");
+        }
+        user.setUserId(userId);
+        userService.checkUserAllowed(user);
+        user.setUpdateBy(SecurityUtils.getUsername());
+        user.setUpdateTime(new Date());
+        user.setRemark("注销用户");
+        user.setDelFlag("2");
+        return toAjax(userService.updateUserData(user));
+    }
+
+
+    /**
+     * 租户管理-管理员配置-重置密码
+     *
+     * @param newPassword 新密码
+     * @param UserId      用户ID
+     * @return
+     */
+//    @Log(title = "租户管理-管理员配置", businessType = BusinessType.UPDATE)
+    @PutMapping("/updatePwd")
+    public ApiResult updatePwd(String newPassword, Long UserId) {
+        SysUser sysUser = userService.selectUserById(UserId);
+        if (sysUser.getUserId() == 0 && sysUser.getUserId() == null) {
+            return ApiResult.error(BusinessErrorCode.BIZ_BUSINESS_ERROR.getCode(), "无此用户,请联系管理员");
+        }
+        if (SecurityUtils.matchesPassword(newPassword, sysUser.getPassword())) {
+            return ApiResult.error(BusinessErrorCode.BIZ_BUSINESS_ERROR.getCode(), "新密码不能与旧密码相同");
+        }
+        userService.resetUserPwdOne(UserId, SecurityUtils.encryptPassword(newPassword));
+        return ApiResult.success();
+    }
+
+
+    /**
+     * 租户管理-管理员配置-管理员信息查询
+     *
+     * @param tenantId 租户ID
+     * @param page     当前页
+     * @param size     每页条数
+     * @return
+     */
+    @GetMapping("getUserList")
+    public ApiResult<CommonPage<SysUser>> getUserList(@RequestParam(value = "tenantId", required = false, defaultValue = "0") Integer tenantId,
+                                                      @RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
+                                                      @RequestParam(value = "size", required = false, defaultValue = "0") Integer size,
+                                                      @RequestParam(value = "userId", required = false, defaultValue = "0") long userId) {
+        return ApiResult.success(userService.userList(tenantId, page, size, userId));
+    }
+
+
+    /**
+     * 租户管理-管理员配置-列表查询
+     *
+     * @param tenantName    租户名称
+     * @param tenantManager 租户责任人名称
+     * @param page          当前页
+     * @param size          每页条数
+     * @return
+     */
+    @GetMapping("getTenantDataOne")
+    public ApiResult<CommonPage<SysTenantTwoVo>> getTenantDataOne(@RequestParam(value = "tenantName", required = false) String tenantName,
+                                                                  @RequestParam(value = "tenantManager", required = false) String tenantManager,
+                                                                  @RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
+                                                                  @RequestParam(value = "size", required = false, defaultValue = "0") Integer size) {
+        return ApiResult.success(sysTenantService.getTenantDataOne(tenantName, tenantManager, page, size));
+    }
+
+
+}

+ 37 - 0
service-system/service-system-biz/src/main/java/com/usky/system/domain/SysUser.java

@@ -92,11 +92,28 @@ public class SysUser extends BaseEntity
     @TableField(exist = false)
     private Integer tenantId;
 
+    /** 地址 */
+    private String address;
+
+    /** 用户类型 */
+    private String userType;
+
+    /** 姓名 */
+    private String fullName;
+
     public SysUser()
     {
 
     }
 
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
     public Integer getTenantId()
     {
         return tenantId;
@@ -122,6 +139,16 @@ public class SysUser extends BaseEntity
         this.userId = userId;
     }
 
+    public String getUserType()
+    {
+        return userType;
+    }
+
+    public void setUserType(String userType)
+    {
+        this.userType = userType;
+    }
+
     public boolean isAdmin()
     {
         return isAdmin(this.userId);
@@ -198,6 +225,16 @@ public class SysUser extends BaseEntity
         this.sex = sex;
     }
 
+    public String getFullName()
+    {
+        return fullName;
+    }
+
+    public void setFullName(String fullName)
+    {
+        this.fullName = fullName;
+    }
+
     public String getAvatar()
     {
         return avatar;

+ 4 - 0
service-system/service-system-biz/src/main/java/com/usky/system/mapper/SysUserMapper.java

@@ -130,4 +130,8 @@ public interface SysUserMapper extends CrudMapper<SysUser>
      * @return 结果
      */
     public SysUser checkEmailUnique(String email);
+
+    public int resetUserPwdOne(@Param("userId") Long userId, @Param("password") String password);
+
+    public List<SysUser> getUserData(Integer tenantId,Integer current,Integer size,long userId);
 }

+ 10 - 0
service-system/service-system-biz/src/main/java/com/usky/system/service/ISysUserService.java

@@ -1,6 +1,7 @@
 package com.usky.system.service;
 
 
+import com.usky.common.core.bean.CommonPage;
 import com.usky.common.mvc.base.CrudService;
 import com.usky.system.domain.SysUser;
 import com.usky.system.model.LoginUser;
@@ -199,6 +200,15 @@ public interface ISysUserService extends CrudService<SysUser> {
 
     public Boolean register(SysUser sysUser);
 
+    public int addUser(SysUser user);
+
+
+    public int updateUserData(SysUser user);
+
+    public int resetUserPwdOne(Long userId, String password);
+
+    public CommonPage<SysUser> userList(Integer tenantId, Integer page, Integer size, long userId);
+
 
 
 }

+ 41 - 0
service-system/service-system-biz/src/main/java/com/usky/system/service/impl/SysUserServiceImpl.java

@@ -1,6 +1,7 @@
 package com.usky.system.service.impl;
 
 
+import com.usky.common.core.bean.CommonPage;
 import com.usky.common.core.exception.BusinessException;
 import com.usky.common.core.util.BeanMapperUtils;
 import com.usky.common.core.util.StringUtils;
@@ -463,4 +464,44 @@ public class SysUserServiceImpl extends AbstractCrudService<SysUserMapper, SysUs
         }
         return this.registerUser(sysUser);
     }
+
+    /**
+     * 租户管理-管理员配置-新增
+     *
+     * @param user
+     * @return
+     */
+    @Override
+    public int addUser(SysUser user) {
+        // 新增用户信息
+        int rows = userMapper.insertUser(user);
+        return rows;
+    }
+
+    @Override
+    public int updateUserData(SysUser user) {
+        return userMapper.updateUser(user);
+    }
+
+
+    @Override
+    public int resetUserPwdOne(Long userId, String password) {
+        return userMapper.resetUserPwdOne(userId, password);
+    }
+
+
+    @Override
+    public CommonPage<SysUser> userList(Integer tenantId, Integer page, Integer size, long userId) {
+        List<SysUser> list1 = userMapper.getUserData(tenantId,null,null,userId);
+        int total = 0;
+        if (list1.size() > 0) {
+            total = list1.size();
+        }
+        Integer current = null;
+        if (page!=null&&size>0){
+            current = (page - 1) * size;
+        }
+        List<SysUser> list = userMapper.getUserData(tenantId, current, size,userId);
+        return new CommonPage<>(list, total, size, page);
+    }
 }

+ 50 - 19
service-system/service-system-biz/src/main/resources/mapper/system/SysUserMapper.xml

@@ -9,9 +9,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<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"          />
+		<result property="fullName"          column="full_name"          />
 		<result property="avatar"       column="avatar"       />
 		<result property="password"     column="password"     />
 		<result property="status"       column="status"       />
@@ -25,6 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<result property="remark"       column="remark"       />
 		<result property="centerUserId"       column="center_user_id"       />
 		<result property="tenantId"       column="tenant_id"       />
+		<result property="address"       column="address"       />
 		<association property="dept" column="dept_id" javaType="com.usky.system.domain.SysDeptVO" resultMap="deptResult" />
 		<collection  property="roles"   javaType="java.util.List"        resultMap="RoleResult" />
 	</resultMap>
@@ -150,6 +153,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="deptId != null and deptId != 0">dept_id,</if>
  			<if test="userName != null and userName != ''">user_name,</if>
  			<if test="nickName != null and nickName != ''">nick_name,</if>
+			<if test="userType != null and userType != ''">user_type,</if>
  			<if test="email != null and email != ''">email,</if>
  			<if test="avatar != null and avatar != ''">avatar,</if>
  			<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
@@ -158,12 +162,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="status != null and status != ''">status,</if>
  			<if test="createBy != null and createBy != ''">create_by,</if>
  			<if test="remark != null and remark != ''">remark,</if>
+			<if test="tenantId != null and tenantId != ''">tenant_id,</if>
  			create_time
  		)values(
  			<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="nickName != null and nickName != ''">#{nickName},</if>
+			<if test="userType != null and userType != ''">#{userType},</if>
  			<if test="email != null and email != ''">#{email},</if>
  			<if test="avatar != null and avatar != ''">#{avatar},</if>
  			<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
@@ -172,29 +178,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="status != null and status != ''">#{status},</if>
  			<if test="createBy != null and createBy != ''">#{createBy},</if>
  			<if test="remark != null and remark != ''">#{remark},</if>
+			<if test="tenantId != null and tenantId != ''">#{tenantId},</if>
  			sysdate()
  		)
 	</insert>
-	
+
 	<update id="updateUser" parameterType="com.usky.system.domain.SysUser">
- 		update sys_user
- 		<set>
- 			<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
- 			<if test="userName != null and userName != ''">user_name = #{userName},</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>
- 			<if test="sex != null and sex != ''">sex = #{sex},</if>
- 			<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
- 			<if test="password != null and password != ''">password = #{password},</if>
- 			<if test="status != null and status != ''">status = #{status},</if>
- 			<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
- 			<if test="loginDate != null">login_date = #{loginDate},</if>
- 			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
- 			<if test="remark != null">remark = #{remark},</if>
- 			update_time = sysdate()
- 		</set>
- 		where user_id = #{userId}
+		update sys_user
+		<set>
+			<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
+			<if test="userName != null and userName != ''">user_name = #{userName},</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>
+			<if test="sex != null and sex != ''">sex = #{sex},</if>
+			<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
+			<if test="password != null and password != ''">password = #{password},</if>
+			<if test="status != null and status != ''">status = #{status},</if>
+			<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
+			<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
+			<if test="loginDate != null">login_date = #{loginDate},</if>
+			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
+			<if test="remark != null">remark = #{remark},</if>
+			<if test="tenantId != null">tenant_id = #{tenantId},</if>
+			<if test="address != null and address != ''">address = #{address},</if>
+			update_time = sysdate()
+		</set>
+		where user_id = #{userId}
 	</update>
 
 	
@@ -216,5 +226,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			#{userId}
         </foreach> 
  	</delete>
+
+	<update id="resetUserPwdOne" parameterType="com.usky.system.domain.SysUser">
+		update sys_user set password = #{password} where user_id = #{userId}
+	</update>
+
+	<select id="getUserData" parameterType="com.usky.system.domain.SysUser"
+			resultType="com.usky.system.domain.SysUser">
+		SELECT * FROM sys_user
+		where
+		del_flag=0 and user_type='01'
+		<if test="tenantId != null and tenantId != 0">
+			and 	tenant_id = #{tenantId}
+		</if>
+		<if test="userId != null and userId != 0">
+			and 	user_id = #{userId}
+		</if>
+		order by user_id
+		<if test="current != null and size != null and size != 0">
+			limit #{current},#{size}
+		</if>
+	</select>
 	
 </mapper>