Merge branch 'master' of https://gitee.com/liu-jiangs-project/RuoYi-Vue
commit
f6cbc6beb2
|
|
@ -17,8 +17,8 @@ import java.util.*;
|
|||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/cache")
|
||||
//@RestController
|
||||
//@RequestMapping("/monitor/cache")
|
||||
public class CacheController {
|
||||
@Autowired
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
|
|
@ -35,7 +35,7 @@ public class CacheController {
|
|||
caches.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "密码错误次数"));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@GetMapping()
|
||||
public AjaxResult getInfo() throws Exception {
|
||||
Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info());
|
||||
|
|
@ -58,20 +58,20 @@ public class CacheController {
|
|||
return AjaxResult.success(result);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@GetMapping("/getNames")
|
||||
public AjaxResult cache() {
|
||||
return AjaxResult.success(caches);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@GetMapping("/getKeys/{cacheName}")
|
||||
public AjaxResult getCacheKeys(@PathVariable String cacheName) {
|
||||
Set<String> cacheKeys = redisTemplate.keys(cacheName + "*");
|
||||
return AjaxResult.success(new TreeSet<>(cacheKeys));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@GetMapping("/getValue/{cacheName}/{cacheKey}")
|
||||
public AjaxResult getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey) {
|
||||
String cacheValue = redisTemplate.opsForValue().get(cacheKey);
|
||||
|
|
@ -79,7 +79,7 @@ public class CacheController {
|
|||
return AjaxResult.success(sysCache);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@DeleteMapping("/clearCacheName/{cacheName}")
|
||||
public AjaxResult clearCacheName(@PathVariable String cacheName) {
|
||||
Collection<String> cacheKeys = redisTemplate.keys(cacheName + "*");
|
||||
|
|
@ -87,14 +87,14 @@ public class CacheController {
|
|||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@DeleteMapping("/clearCacheKey/{cacheKey}")
|
||||
public AjaxResult clearCacheKey(@PathVariable String cacheKey) {
|
||||
redisTemplate.delete(cacheKey);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@DeleteMapping("/clearCacheAll")
|
||||
public AjaxResult clearCacheAll() {
|
||||
Collection<String> cacheKeys = redisTemplate.keys("*");
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/server")
|
||||
//@RestController
|
||||
//@RequestMapping("/monitor/server")
|
||||
public class ServerController {
|
||||
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@GetMapping()
|
||||
public AjaxResult getInfo() throws Exception {
|
||||
Server server = new Server();
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class SysLogininforController extends BaseController {
|
|||
@Autowired
|
||||
private SysPasswordService passwordService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysLogininfor logininfor) {
|
||||
startPage();
|
||||
|
|
@ -39,7 +39,7 @@ public class SysLogininforController extends BaseController {
|
|||
}
|
||||
|
||||
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysLogininfor logininfor) {
|
||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||
|
|
@ -47,14 +47,14 @@ public class SysLogininforController extends BaseController {
|
|||
util.exportExcel(response, list, "登录日志");
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{infoIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] infoIds) {
|
||||
return toAjax(logininforService.deleteLogininforByIds(infoIds));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@Log(title = "登录日志", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/clean")
|
||||
public AjaxResult clean() {
|
||||
|
|
@ -62,7 +62,7 @@ public class SysLogininforController extends BaseController {
|
|||
return success();
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:unlock')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@Log(title = "账户解锁", businessType = BusinessType.OTHER)
|
||||
@GetMapping("/unlock/{userName}")
|
||||
public AjaxResult unlock(@PathVariable("userName") String userName) {
|
||||
|
|
|
|||
|
|
@ -20,13 +20,13 @@ import java.util.List;
|
|||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/operlog")
|
||||
//@RestController
|
||||
//@RequestMapping("/monitor/operlog")
|
||||
public class SysOperlogController extends BaseController {
|
||||
@Autowired
|
||||
private ISysOperLogService operLogService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysOperLog operLog) {
|
||||
startPage();
|
||||
|
|
@ -35,7 +35,7 @@ public class SysOperlogController extends BaseController {
|
|||
}
|
||||
|
||||
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysOperLog operLog) {
|
||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||
|
|
@ -44,14 +44,14 @@ public class SysOperlogController extends BaseController {
|
|||
}
|
||||
|
||||
@Log(title = "操作日志", businessType = BusinessType.DELETE)
|
||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@DeleteMapping("/{operIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] operIds) {
|
||||
return toAjax(operLogService.deleteOperLogByIds(operIds));
|
||||
}
|
||||
|
||||
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
|
||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@DeleteMapping("/clean")
|
||||
public AjaxResult clean() {
|
||||
operLogService.cleanOperLog();
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ import java.util.List;
|
|||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/online")
|
||||
//@RestController
|
||||
//@RequestMapping("/monitor/online")
|
||||
public class SysUserOnlineController extends BaseController {
|
||||
@Autowired
|
||||
private ISysUserOnlineService userOnlineService;
|
||||
|
|
@ -38,7 +38,7 @@ public class SysUserOnlineController extends BaseController {
|
|||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:online:list')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(String ipaddr, String userName) {
|
||||
Collection<String> keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
|
||||
|
|
@ -63,7 +63,7 @@ public class SysUserOnlineController extends BaseController {
|
|||
/**
|
||||
* 强退用户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
||||
@DeleteMapping("/{tokenId}")
|
||||
public AjaxResult forceLogout(@PathVariable String tokenId) {
|
||||
|
|
|
|||
|
|
@ -153,30 +153,4 @@ public class StoreRoleController extends XktBaseController {
|
|||
return R.ok(scope.getCount());
|
||||
}
|
||||
|
||||
// @PreAuthorize("@ss.hasAnyRoles('store')")
|
||||
// @Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
// @ApiOperation("授权角色 - 档口")
|
||||
// @PostMapping("/bindUser")
|
||||
public R<Integer> bindUser(@Validated @RequestBody UserRoleBindReqVO vo) {
|
||||
RoleInfo info = roleService.getRoleById(vo.getRoleId());
|
||||
Assert.isTrue(Objects.equals(info.getStoreId(), SecurityUtils.getStoreId()), "档口ID不匹配");
|
||||
int count = roleService.bindUser(vo.getRoleId(), vo.getUserIds());
|
||||
// 清除用户缓存(退出登录)
|
||||
tokenService.deleteCacheUser(vo.getUserIds());
|
||||
return R.ok(count);
|
||||
}
|
||||
|
||||
// @PreAuthorize("@ss.hasAnyRoles('store')")
|
||||
// @Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
// @ApiOperation("取消授权角色 - 档口")
|
||||
// @PostMapping("/unbindUser")
|
||||
public R<Integer> unbindUser(@Validated @RequestBody UserRoleBindReqVO vo) {
|
||||
RoleInfo info = roleService.getRoleById(vo.getRoleId());
|
||||
Assert.isTrue(Objects.equals(info.getStoreId(), SecurityUtils.getStoreId()), "档口ID不匹配");
|
||||
int count = roleService.unbindUser(vo.getRoleId(), vo.getUserIds());
|
||||
// 清除用户缓存(退出登录)
|
||||
tokenService.deleteCacheUser(vo.getUserIds());
|
||||
return R.ok(count);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,13 +109,13 @@ public class StoreUserController extends BaseController {
|
|||
Long storeId = SecurityUtils.getStoreId();
|
||||
Assert.notNull(storeId);
|
||||
Assert.notEmpty(vo.getPhonenumber(), "手机号不能为空");
|
||||
Assert.notEmpty(vo.getUserName(), "账号名称不能为空");
|
||||
Assert.notEmpty(vo.getNickName(), "用户昵称不能为空");
|
||||
//短信验证码
|
||||
loginService.validateSmsVerificationCode(vo.getPhonenumber(), vo.getCode());
|
||||
UserInfoEdit dto = BeanUtil.toBean(vo, UserInfoEdit.class);
|
||||
dto.setUserId(null);
|
||||
//昵称默认手机号
|
||||
dto.setNickName(dto.getPhonenumber());
|
||||
//账号默认手机号
|
||||
dto.setUserName(dto.getPhonenumber());
|
||||
Set<Long> subRoleIds = roleService.getSubRoleIdsByStore(storeId);
|
||||
if (CollUtil.isEmpty(dto.getRoleIds())) {
|
||||
dto.setRoleIds(Collections.singletonList(ESystemRole.SELLER.getId()));
|
||||
|
|
@ -141,7 +141,7 @@ public class StoreUserController extends BaseController {
|
|||
.forEach(roleId -> Assert.isTrue(subRoleIds.contains(roleId), "角色非法"));
|
||||
UserInfo info = userService.getUserByPhoneNumber(vo.getPhonenumber());
|
||||
Assert.notNull(info, "用户不存在");
|
||||
List<Long> roleIds = new ArrayList<>();
|
||||
Set<Long> roleIds = new HashSet<>();
|
||||
List<Long> csRoleIds = new ArrayList<>();
|
||||
for (RoleInfo roleInfo : CollUtil.emptyIfNull(info.getRoles())) {
|
||||
if (subRoleIds.contains(roleInfo.getRoleId())) {
|
||||
|
|
@ -157,8 +157,8 @@ public class StoreUserController extends BaseController {
|
|||
}
|
||||
UserInfoEdit dto = BeanUtil.toBean(info, UserInfoEdit.class);
|
||||
roleIds.addAll(CollUtil.emptyIfNull(vo.getRoleIds()));
|
||||
dto.setRoleIds(roleIds);
|
||||
dto.setUserName(vo.getUserName());
|
||||
dto.setRoleIds(new ArrayList<>(roleIds));
|
||||
dto.setNickName(vo.getNickName());
|
||||
Long userId = userService.updateUser(dto);
|
||||
// 清除用户缓存(退出登录)
|
||||
tokenService.deleteCacheUser(userId);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class SysConfigController extends BaseController {
|
|||
/**
|
||||
* 获取参数配置列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:list')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysConfig config) {
|
||||
startPage();
|
||||
|
|
@ -39,7 +39,7 @@ public class SysConfigController extends BaseController {
|
|||
}
|
||||
|
||||
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:config:export')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysConfig config) {
|
||||
List<SysConfig> list = configService.selectConfigList(config);
|
||||
|
|
@ -50,7 +50,7 @@ public class SysConfigController extends BaseController {
|
|||
/**
|
||||
* 根据参数编号获取详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:query')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@GetMapping(value = "/{configId}")
|
||||
public AjaxResult getInfo(@PathVariable Long configId) {
|
||||
return success(configService.selectConfigById(configId));
|
||||
|
|
@ -59,6 +59,7 @@ public class SysConfigController extends BaseController {
|
|||
/**
|
||||
* 根据参数键名查询参数值
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@GetMapping(value = "/configKey/{configKey}")
|
||||
public AjaxResult getConfigKey(@PathVariable String configKey) {
|
||||
return success(configService.selectConfigByKey(configKey));
|
||||
|
|
@ -67,7 +68,7 @@ public class SysConfigController extends BaseController {
|
|||
/**
|
||||
* 新增参数配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:add')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysConfig config) {
|
||||
|
|
@ -81,7 +82,7 @@ public class SysConfigController extends BaseController {
|
|||
/**
|
||||
* 修改参数配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:edit')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysConfig config) {
|
||||
|
|
@ -95,7 +96,7 @@ public class SysConfigController extends BaseController {
|
|||
/**
|
||||
* 删除参数配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@Log(title = "参数管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{configIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] configIds) {
|
||||
|
|
@ -106,7 +107,7 @@ public class SysConfigController extends BaseController {
|
|||
/**
|
||||
* 刷新参数缓存
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/refreshCache")
|
||||
public AjaxResult refreshCache() {
|
||||
|
|
|
|||
|
|
@ -1,106 +0,0 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.XktBaseController;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.xkt.domain.SysFile;
|
||||
import com.ruoyi.xkt.service.ISysFileService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* fileController
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-03-26
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/rest/v1/files")
|
||||
@RequiredArgsConstructor
|
||||
public class SysFileController extends XktBaseController {
|
||||
|
||||
final ISysFileService sysFileService;
|
||||
|
||||
@PermitAll
|
||||
@ApiOperation(value = "上传文件/图片等静态资源", httpMethod = "POST", response = R.class)
|
||||
@PostMapping("/upload")
|
||||
public R<Long> upload(@RequestParam("file") MultipartFile file, @RequestParam("module") String module) throws IOException {
|
||||
// String url = uploadFileUtils.uploadMultipartFileToCloud(file, module);
|
||||
// return BaseResponseDTO.buildSuccessRS(fileService.upload(file.getOriginalFilename(), url));
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询file列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:file:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysFile sysFile) {
|
||||
startPage();
|
||||
List<SysFile> list = sysFileService.selectSysFileList(sysFile);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出file列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:file:export')")
|
||||
@Log(title = "file", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysFile sysFile) {
|
||||
List<SysFile> list = sysFileService.selectSysFileList(sysFile);
|
||||
ExcelUtil<SysFile> util = new ExcelUtil<SysFile>(SysFile.class);
|
||||
util.exportExcel(response, list, "file数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取file详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:file:query')")
|
||||
@GetMapping(value = "/{fileId}")
|
||||
public R getInfo(@PathVariable("fileId") Long fileId) {
|
||||
return success(sysFileService.selectSysFileByFileId(fileId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增file
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:file:add')")
|
||||
@Log(title = "file", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R add(@RequestBody SysFile sysFile) {
|
||||
return success(sysFileService.insertSysFile(sysFile));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改file
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:file:edit')")
|
||||
@Log(title = "file", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R edit(@RequestBody SysFile sysFile) {
|
||||
return success(sysFileService.updateSysFile(sysFile));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除file
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:file:remove')")
|
||||
@Log(title = "file", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{fileIds}")
|
||||
public R remove(@PathVariable Long[] fileIds) {
|
||||
return success(sysFileService.deleteSysFileByFileIds(fileIds));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,126 +0,0 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.config.RuoYiConfig;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||
import com.ruoyi.common.utils.file.MimeTypeUtils;
|
||||
import com.ruoyi.framework.web.service.TokenService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 个人信息 业务处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
//@RestController
|
||||
//@RequestMapping("/rest/v1/sys/user/profile")
|
||||
public class SysProfileController extends BaseController {
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
/**
|
||||
* 个人信息
|
||||
*/
|
||||
@GetMapping
|
||||
public AjaxResult profile() {
|
||||
SysUser user = getCurrentUser();
|
||||
AjaxResult ajax = AjaxResult.success(user);
|
||||
// ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult updateProfile(@RequestBody SysUser user) {
|
||||
LoginUser loginUser = getLoginUser();
|
||||
SysUser currentUser = userService.getBaseUser(loginUser.getUserId());
|
||||
currentUser.setNickName(user.getNickName());
|
||||
currentUser.setEmail(user.getEmail());
|
||||
currentUser.setPhonenumber(user.getPhonenumber());
|
||||
currentUser.setSex(user.getSex());
|
||||
if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(currentUser)) {
|
||||
return error("修改用户'" + currentUser.getUserName() + "'失败,手机号码已存在");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(currentUser)) {
|
||||
return error("修改用户'" + currentUser.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
if (userService.updateUserProfile(currentUser) > 0) {
|
||||
// 更新缓存用户信息
|
||||
// loginUser.getUser().updateBaseInfo(currentUser);
|
||||
tokenService.setLoginUser(loginUser);
|
||||
return success();
|
||||
}
|
||||
return error("修改个人信息异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/updatePwd")
|
||||
public AjaxResult updatePwd(@RequestBody Map<String, String> params) {
|
||||
String oldPassword = params.get("oldPassword");
|
||||
String newPassword = params.get("newPassword");
|
||||
LoginUser loginUser = getLoginUser();
|
||||
String userName = loginUser.getUsername();
|
||||
String password = loginUser.getPassword();
|
||||
if (!SecurityUtils.matchesPassword(oldPassword, password)) {
|
||||
return error("修改密码失败,旧密码错误");
|
||||
}
|
||||
if (SecurityUtils.matchesPassword(newPassword, password)) {
|
||||
return error("新密码不能与旧密码相同");
|
||||
}
|
||||
newPassword = SecurityUtils.encryptPassword(newPassword);
|
||||
// if (userService.resetUserPwd(userName, newPassword) > 0) {
|
||||
// // 更新缓存用户密码
|
||||
// loginUser.getUser().setPassword(newPassword);
|
||||
// tokenService.setLoginUser(loginUser);
|
||||
// return success();
|
||||
// }
|
||||
return error("修改密码异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 头像上传
|
||||
*/
|
||||
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/avatar")
|
||||
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws Exception {
|
||||
if (!file.isEmpty()) {
|
||||
LoginUser loginUser = getLoginUser();
|
||||
String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION);
|
||||
if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("imgUrl", avatar);
|
||||
// 更新缓存用户头像
|
||||
loginUser.getUser().setAvatar(avatar);
|
||||
tokenService.setLoginUser(loginUser);
|
||||
return ajax;
|
||||
}
|
||||
}
|
||||
return error("上传图片异常,请联系管理员");
|
||||
}
|
||||
|
||||
private SysUser getCurrentUser() {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
return userService.getBaseUser(userId);
|
||||
}
|
||||
}
|
||||
|
|
@ -135,26 +135,4 @@ public class SysRoleController extends XktBaseController {
|
|||
return R.ok(scope.getCount());
|
||||
}
|
||||
|
||||
// @PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
// @Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
// @ApiOperation("授权角色 - 管理员")
|
||||
// @PostMapping("/bindUser")
|
||||
public R<Integer> bindUser(@Validated @RequestBody UserRoleBindReqVO vo) {
|
||||
int count = roleService.bindUser(vo.getRoleId(), vo.getUserIds());
|
||||
// 清除用户缓存(退出登录)
|
||||
tokenService.deleteCacheUser(vo.getUserIds());
|
||||
return R.ok(count);
|
||||
}
|
||||
|
||||
// @PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
// @Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
// @ApiOperation("取消授权角色 - 管理员")
|
||||
// @PostMapping("/unbindUser")
|
||||
public R<Integer> unbindUser(@Validated @RequestBody UserRoleBindReqVO vo) {
|
||||
int count = roleService.unbindUser(vo.getRoleId(), vo.getUserIds());
|
||||
// 清除用户缓存(退出登录)
|
||||
tokenService.deleteCacheUser(vo.getUserIds());
|
||||
return R.ok(count);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,29 +106,6 @@ public class SysUserController extends BaseController {
|
|||
return R.ok(userId);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
||||
// @ApiOperation("导出 - 管理员")
|
||||
// @PostMapping("/export")
|
||||
public void export(@Validated @RequestBody UserQueryVO vo, HttpServletResponse response) {
|
||||
UserQuery query = BeanUtil.toBean(vo, UserQuery.class);
|
||||
List<UserListItem> list = userService.listUser(query);
|
||||
ExcelUtil<UserListItem> util = new ExcelUtil<>(UserListItem.class);
|
||||
util.exportExcel(response, list, "用户数据");
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
||||
// @ApiOperation("导入 - 管理员")
|
||||
// @PostMapping("/importData")
|
||||
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
List<SysUser> userList = util.importExcel(file.getInputStream());
|
||||
String operName = getUsername();
|
||||
String message = userService.importUser(userList, updateSupport, operName);
|
||||
return success(message);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@ApiOperation("导入模板 - 管理员")
|
||||
@PostMapping("/importTemplate")
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ import io.swagger.annotations.ApiModel;
|
|||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -18,12 +16,12 @@ import java.util.List;
|
|||
@Data
|
||||
public class UserInfoEditByStoreVO {
|
||||
/**
|
||||
* 用户账号
|
||||
* 用户昵称
|
||||
*/
|
||||
@Xss(message = "用户账号不能包含脚本字符")
|
||||
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
|
||||
@ApiModelProperty("用户账号")
|
||||
private String userName;
|
||||
@Xss(message = "用户昵称不能包含脚本字符")
|
||||
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
|
||||
@ApiModelProperty("用户昵称")
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
|
|
|
|||
|
|
@ -1,147 +0,0 @@
|
|||
package com.ruoyi.web.controller.tool;
|
||||
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* swagger 用户测试方法
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Api("用户信息管理")
|
||||
@RestController
|
||||
@RequestMapping("/test/user")
|
||||
public class TestController extends BaseController {
|
||||
private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>();
|
||||
|
||||
{
|
||||
users.put(1, new UserEntity(1, "admin", "admin123", "15888888888"));
|
||||
users.put(2, new UserEntity(2, "ry", "admin123", "15666666666"));
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户列表")
|
||||
@GetMapping("/list")
|
||||
public R<List<UserEntity>> userList() {
|
||||
List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
|
||||
return R.ok(userList);
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户详细")
|
||||
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
|
||||
@GetMapping("/{userId}")
|
||||
public R<UserEntity> getUser(@PathVariable Integer userId) {
|
||||
if (!users.isEmpty() && users.containsKey(userId)) {
|
||||
return R.ok(users.get(userId));
|
||||
} else {
|
||||
return R.fail("用户不存在");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("新增用户")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", dataTypeClass = Integer.class),
|
||||
@ApiImplicitParam(name = "username", value = "用户名称", dataType = "String", dataTypeClass = String.class),
|
||||
@ApiImplicitParam(name = "password", value = "用户密码", dataType = "String", dataTypeClass = String.class),
|
||||
@ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class)
|
||||
})
|
||||
@PostMapping("/save")
|
||||
public R<String> save(UserEntity user) {
|
||||
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) {
|
||||
return R.fail("用户ID不能为空");
|
||||
}
|
||||
users.put(user.getUserId(), user);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ApiOperation("更新用户")
|
||||
@PutMapping("/update")
|
||||
public R<String> update(@RequestBody UserEntity user) {
|
||||
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) {
|
||||
return R.fail("用户ID不能为空");
|
||||
}
|
||||
if (users.isEmpty() || !users.containsKey(user.getUserId())) {
|
||||
return R.fail("用户不存在");
|
||||
}
|
||||
users.remove(user.getUserId());
|
||||
users.put(user.getUserId(), user);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ApiOperation("删除用户信息")
|
||||
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
|
||||
@DeleteMapping("/{userId}")
|
||||
public R<String> delete(@PathVariable Integer userId) {
|
||||
if (!users.isEmpty() && users.containsKey(userId)) {
|
||||
users.remove(userId);
|
||||
return R.ok();
|
||||
} else {
|
||||
return R.fail("用户不存在");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ApiModel(value = "UserEntity", description = "用户实体")
|
||||
class UserEntity {
|
||||
@ApiModelProperty("用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty("用户名称")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty("用户密码")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty("用户手机")
|
||||
private String mobile;
|
||||
|
||||
public UserEntity() {
|
||||
|
||||
}
|
||||
|
||||
public UserEntity(Integer userId, String username, String password, String mobile) {
|
||||
this.userId = userId;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
}
|
||||
|
|
@ -308,9 +308,9 @@ public class SysUserServiceImpl implements ISysUserService {
|
|||
if (StrUtil.equals(user.getUserName(), user.getPhonenumber())) {
|
||||
user.setUserName(phoneNumber);
|
||||
}
|
||||
if (StrUtil.equals(user.getNickName(), user.getPhonenumber())) {
|
||||
user.setNickName(phoneNumber);
|
||||
}
|
||||
// if (StrUtil.equals(user.getNickName(), user.getPhonenumber())) {
|
||||
// user.setNickName(phoneNumber);
|
||||
// }
|
||||
user.setPhonenumber(phoneNumber);
|
||||
updateUserBase(user);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue