|
@@ -1,9 +1,18 @@
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
|
|
+import com.ruoyi.common.constant.UserConstants;
|
|
|
+import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
+import com.ruoyi.common.core.domain.entity.SysRole;
|
|
|
+import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.core.domain.entity.StaffManage;
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.system.mapper.StaffManageMapper;
|
|
|
+import com.ruoyi.system.mapper.SysRoleMapper;
|
|
|
import com.ruoyi.system.service.IStaffManageService;
|
|
|
+import com.ruoyi.system.service.ISysDictDataService;
|
|
|
+import com.ruoyi.system.service.ISysUserService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -20,6 +29,12 @@ public class StaffManageServiceImpl implements IStaffManageService
|
|
|
{
|
|
|
@Autowired
|
|
|
private StaffManageMapper staffManageMapper;
|
|
|
+ @Autowired
|
|
|
+ private SysRoleMapper roleMapper;
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService userService;
|
|
|
+ @Autowired
|
|
|
+ private ISysDictDataService dictDataService;
|
|
|
|
|
|
/**
|
|
|
* 查询员工管理
|
|
@@ -52,10 +67,32 @@ public class StaffManageServiceImpl implements IStaffManageService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int insertStaffManage(StaffManage staffManage)
|
|
|
+ public AjaxResult insertStaffManage(StaffManage staffManage)
|
|
|
{
|
|
|
+ //新增账号信息
|
|
|
+ SysUser user = new SysUser();
|
|
|
+ user.setUserName(staffManage.getPhoneNumber());
|
|
|
+ if (!userService.checkUserNameUnique(user))
|
|
|
+ {
|
|
|
+ return AjaxResult.error(user.getUserName() + "'失败,手机号已存在");
|
|
|
+ }
|
|
|
+ user.setPassword(SecurityUtils.encryptPassword(UserConstants.PASSWORD));
|
|
|
+ user.setPhonenumber(staffManage.getPhoneNumber());
|
|
|
+ user.setNickName(staffManage.getStaffName());
|
|
|
+ //todo 部门 岗位
|
|
|
+ user.setSex(staffManage.getGender());
|
|
|
+ user.setStatus(UserConstants.DEPT_NORMAL);
|
|
|
+ //查询角色id
|
|
|
+ String roleKey = dictDataService.selectDictLabel(UserConstants.SYS_EMP_ROLE_TYPE, staffManage.getStaffCategory());
|
|
|
+ SysRole info = roleMapper.checkRoleKeyUnique(roleKey);
|
|
|
+ Long[] roleIds = {info.getRoleId()};
|
|
|
+ user.setRoleIds(roleIds);
|
|
|
+ userService.insertUser(user);
|
|
|
+
|
|
|
+ staffManage.setUserId(user.getUserId());
|
|
|
staffManage.setCreateTime(DateUtils.getNowDate());
|
|
|
- return staffManageMapper.insertStaffManage(staffManage);
|
|
|
+ int i = staffManageMapper.insertStaffManage(staffManage);
|
|
|
+ return i > 0 ? AjaxResult.success() : AjaxResult.error();
|
|
|
}
|
|
|
|
|
|
/**
|