代码优化,员工授权新增!
This commit is contained in:
parent
24af3720db
commit
1ac25ab2bd
|
|
@ -16,9 +16,11 @@ import com.cwhelp.component.actionLog.annotation.ActionLog;
|
|||
import com.cwhelp.component.actionLog.annotation.EntityParam;
|
||||
import com.cwhelp.component.shiro.ShiroUtil;
|
||||
import com.cwhelp.modules.business.domain.BssEmployee;
|
||||
import com.cwhelp.modules.system.domain.Dict;
|
||||
import com.cwhelp.modules.system.domain.Menu;
|
||||
import com.cwhelp.modules.system.domain.Role;
|
||||
import com.cwhelp.modules.system.domain.User;
|
||||
import com.cwhelp.modules.system.enums.DictTypeEnum;
|
||||
import com.cwhelp.modules.system.service.MenuService;
|
||||
import com.cwhelp.modules.system.service.RoleService;
|
||||
import com.cwhelp.modules.system.service.UserService;
|
||||
|
|
@ -34,6 +36,7 @@ import org.springframework.util.ObjectUtils;
|
|||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
|
@ -82,7 +85,27 @@ public class RoleController {
|
|||
public String toRole(@RequestParam(value = "ids") BssEmployee bssEmployee, Model model) {
|
||||
User user = userService.getByName(bssEmployee.getPhoneNum());
|
||||
if (ObjectUtils.isEmpty(user)) {
|
||||
throw new ResultException(ResultEnum.USER_NOE_EXIST);
|
||||
User sessionUser = ShiroUtil.getSubject();
|
||||
User newUser = new User();
|
||||
newUser.setUsername(bssEmployee.getPhoneNum());
|
||||
newUser.setNickname(bssEmployee.getName());
|
||||
// 对密码进行加密
|
||||
String salt = ShiroUtil.getRandomSalt();
|
||||
//默认密码为身份证号
|
||||
String encrypt = ShiroUtil.encrypt(bssEmployee.getCard(), salt);
|
||||
newUser.setPassword(encrypt);
|
||||
newUser.setSalt(salt);
|
||||
newUser.setBssPlatform(bssEmployee.getBssDept().getBssPlatform());
|
||||
newUser.setSex(bssEmployee.getSex());
|
||||
newUser.setDept(sessionUser.getDept());
|
||||
newUser.setType("2");
|
||||
newUser.setEmail(bssEmployee.getEmail());
|
||||
newUser.setPhone(bssEmployee.getPhoneNum());
|
||||
newUser.setRemark("系统生成");
|
||||
newUser.setCreateDate(new Date());
|
||||
newUser.setUpdateDate(new Date());
|
||||
user = userService.save(newUser);
|
||||
// throw new ResultException(ResultEnum.USER_NOE_EXIST);
|
||||
}
|
||||
// 获取指定用户角色列表
|
||||
Set<Role> authRoles = user.getRoles();
|
||||
|
|
|
|||
|
|
@ -296,7 +296,6 @@ public class UserController {
|
|||
UploadProjectProperties properties = SpringContextUtil.getBean(UploadProjectProperties.class);
|
||||
String fuPath = properties.getFilePath();
|
||||
String spPath = properties.getStaticPath().replace("*", "");
|
||||
String s = fuPath + p.replace(spPath, "");
|
||||
File file = new File(fuPath + p.replace(spPath, ""));
|
||||
if (file.exists()) {
|
||||
FileCopyUtils.copy(new FileInputStream(file), response.getOutputStream());
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 15 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.9 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 30 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 63 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 77 KiB |
|
|
@ -40,6 +40,13 @@
|
|||
<input class="layui-input" type="text" name="card" placeholder="请输入身份证号码" th:value="${bssEmployee?.card}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">选择性别</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="sex" value="1" title="男" checked><div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon"></i><div>男</div></div>
|
||||
<input type="radio" name="sex" value="2" title="女" th:checked="${bssEmployee?.sex} eq 2"><div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i><div>女</div></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">邮箱</label>
|
||||
<div class="layui-input-inline">
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@
|
|||
<tr>
|
||||
<th>邮箱</th>
|
||||
<td th:text="${bssEmployee.email}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>性别</th>
|
||||
<td th:text="${#dicts.keyValue('USER_SEX', bssEmployee.sex)}"></td>
|
||||
<th>学历</th>
|
||||
<td th:text="${#dicts.keyValue('EDUCATION', bssEmployee.education)}"></td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@
|
|||
<th>职位</th>
|
||||
<th>手机号码</th>
|
||||
<th>身份证号码</th>
|
||||
<th>性别</th>
|
||||
<th>邮箱</th>
|
||||
<th>学历</th>
|
||||
<th>创建时间</th>
|
||||
|
|
@ -81,6 +82,7 @@
|
|||
<td th:text="${item.phoneNum}">手机号码</td>
|
||||
<td th:text="${item.card}">身份证号码</td>
|
||||
<td th:text="${item.email}">邮箱</td>
|
||||
<td th:text="${#dicts.keyValue('USER_SEX', item.sex)}">邮箱</td>
|
||||
<td th:text="${#dicts.keyValue('EDUCATION', item.education)}">学历</td>
|
||||
<td th:text="${#dates.format(item.createDate, 'yyyy-MM-dd HH:mm:ss')}">创建时间</td>
|
||||
<td th:text="${#dates.format(item.updateDate, 'yyyy-MM-dd HH:mm:ss')}">更新时间</td>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
</div>
|
||||
<form class="user-edit" th:action="@{/userInfo}">
|
||||
<input type="hidden" name="username" th:value="${user.username}"/>
|
||||
<input type="hidden" name="bssDept" th:value="${user.bssDept?.id}"/>
|
||||
<input type="hidden" name="bssDept" th:value="${user.dept?.id}"/>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">用户昵称</label>
|
||||
<div class="layui-input-inline">
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
<label class="layui-form-label required">所属</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="bssPlatform" mo-selected="${user?.bssPlatform?.id}" mo-empty="" lay-verify="bssPlatform">
|
||||
<option th:each="bssPlatform,userStat:${bssPlatforms}" th:value="${bssPlatform.id}" th:text="${bssPlatform.name}" th:selected="${bssPlatform.id == dept?.bssPlatform?.id}"></option>
|
||||
<option th:each="bssPlatform,userStat:${bssPlatforms}" th:value="${bssPlatform.id}" th:text="${bssPlatform.name}" th:selected="${bssPlatform.id == user?.bssPlatform?.id}"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ public class BssEmployee implements Serializable {
|
|||
private String phoneNum;
|
||||
// 身份证号码
|
||||
private String card;
|
||||
private String sex;
|
||||
// 邮箱
|
||||
private String email;
|
||||
// 学历
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in New Issue