|
|
|
@ -14,18 +14,19 @@ import io.swagger.annotations.ApiOperation; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
|
import org.apache.shiro.SecurityUtils; |
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions; |
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresRoles; |
|
|
|
|
import org.jeecg.common.api.vo.Result; |
|
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog; |
|
|
|
|
import org.jeecg.common.aspect.annotation.PermissionData; |
|
|
|
|
import org.jeecg.common.constant.CommonConstant; |
|
|
|
|
import org.jeecg.common.system.api.ISysBaseAPI; |
|
|
|
|
import org.jeecg.modules.base.service.BaseCommonService; |
|
|
|
|
import org.jeecg.common.system.query.QueryGenerator; |
|
|
|
|
import org.jeecg.common.system.util.JwtUtil; |
|
|
|
|
import org.jeecg.common.system.vo.LoginUser; |
|
|
|
|
import org.jeecg.common.util.*; |
|
|
|
|
import org.jeecg.common.util.ImportExcelUtil; |
|
|
|
|
import org.jeecg.common.util.PasswordUtil; |
|
|
|
|
import org.jeecg.common.util.RedisUtil; |
|
|
|
|
import org.jeecg.common.util.oConvertUtils; |
|
|
|
|
import org.jeecg.modules.base.service.BaseCommonService; |
|
|
|
|
import org.jeecg.modules.system.entity.*; |
|
|
|
|
import org.jeecg.modules.system.model.DepartIdModel; |
|
|
|
|
import org.jeecg.modules.system.model.SysUserSysDepartModel; |
|
|
|
@ -57,7 +58,7 @@ import java.util.stream.Collectors; |
|
|
|
|
* </p> |
|
|
|
|
* |
|
|
|
|
* @Author scott |
|
|
|
|
* @since 2018-12-20 |
|
|
|
|
* @since 2023-04-12 |
|
|
|
|
*/ |
|
|
|
|
@Slf4j |
|
|
|
|
@RestController |
|
|
|
@ -193,12 +194,12 @@ public class SysUserController { |
|
|
|
|
|
|
|
|
|
//@RequiresRoles({"admin"})
|
|
|
|
|
//@RequiresPermissions("user:add")
|
|
|
|
|
@AutoLog |
|
|
|
|
@RequestMapping(value = "/add", method = RequestMethod.POST) |
|
|
|
|
public Result<SysUser> add(@RequestBody JSONObject jsonObject) { |
|
|
|
|
Result<SysUser> result = new Result<SysUser>(); |
|
|
|
|
String selectedRoles = jsonObject.getString("selectedroles"); |
|
|
|
|
String selectedDeparts = jsonObject.getString("selecteddeparts"); |
|
|
|
|
// System.out.println("我的测试" + selectedRoles);
|
|
|
|
|
try { |
|
|
|
|
SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class); |
|
|
|
|
user.setCreateTime(new Date());//设置创建时间
|
|
|
|
@ -208,9 +209,11 @@ public class SysUserController { |
|
|
|
|
user.setPassword(passwordEncode); |
|
|
|
|
user.setStatus(1); |
|
|
|
|
user.setDelFlag(CommonConstant.DEL_FLAG_0); |
|
|
|
|
//用户表字段org_code不能在这里设置他的值
|
|
|
|
|
user.setOrgCode(null); |
|
|
|
|
// 保存用户走一个service 保证事务
|
|
|
|
|
this.sysUserService.save(user); |
|
|
|
|
// sysUserService.saveUser(user, selectedRoles, selectedDeparts);
|
|
|
|
|
sysUserService.saveUser(user, selectedRoles, selectedDeparts); |
|
|
|
|
// baseCommonService.addLog("添加用户,username: " + user.getUsername(), CommonConstant.LOG_TYPE_2, 2);
|
|
|
|
|
result.success("添加成功!"); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error(e.getMessage(), e); |
|
|
|
@ -221,6 +224,7 @@ public class SysUserController { |
|
|
|
|
|
|
|
|
|
//@RequiresRoles({"admin"})
|
|
|
|
|
//@RequiresPermissions("user:edit")
|
|
|
|
|
@AutoLog |
|
|
|
|
@RequestMapping(value = "/edit", method = RequestMethod.PUT) |
|
|
|
|
public Result<SysUser> edit(@RequestBody JSONObject jsonObject) { |
|
|
|
|
Result<SysUser> result = new Result<SysUser>(); |
|
|
|
@ -237,8 +241,8 @@ public class SysUserController { |
|
|
|
|
String roles = jsonObject.getString("selectedroles"); |
|
|
|
|
String departs = jsonObject.getString("selecteddeparts"); |
|
|
|
|
// 修改用户走一个service 保证事务
|
|
|
|
|
sysUserService.updateById(user); |
|
|
|
|
// sysUserService.editUser(user, roles, departs);
|
|
|
|
|
// sysUserService.updateById(user);
|
|
|
|
|
sysUserService.editUser(user, roles, departs); |
|
|
|
|
result.success("修改成功!"); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
@ -252,6 +256,7 @@ public class SysUserController { |
|
|
|
|
* 删除用户 |
|
|
|
|
*/ |
|
|
|
|
//@RequiresRoles({"admin"})
|
|
|
|
|
@AutoLog |
|
|
|
|
@RequestMapping(value = "/delete", method = RequestMethod.DELETE) |
|
|
|
|
public Result<?> delete(@RequestParam(name = "id", required = true) String id) { |
|
|
|
|
this.sysUserService.removeById(id); |
|
|
|
@ -266,8 +271,8 @@ public class SysUserController { |
|
|
|
|
//@RequiresRoles({"admin"})
|
|
|
|
|
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE) |
|
|
|
|
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { |
|
|
|
|
baseCommonService.addLog("批量删除用户, ids: " + ids, CommonConstant.LOG_TYPE_2, 3); |
|
|
|
|
this.sysUserService.deleteBatchUsers(ids); |
|
|
|
|
// baseCommonService.addLog("批量删除用户, ids: " + ids, CommonConstant.LOG_TYPE_2, 3);
|
|
|
|
|
this.sysUserService.removeByIds(Arrays.asList(ids.split(","))); |
|
|
|
|
return Result.ok("批量删除用户成功"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|