mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-23 05:00:25 +08:00
refactor:代码优化
This commit is contained in:
parent
ee2969a3a8
commit
fd3c02582e
@ -93,7 +93,7 @@ public class BrandController {
|
||||
return Result.judge(status);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改品牌(部分更新)", httpMethod = "PATCH")
|
||||
@ApiOperation(value = "修改品牌", httpMethod = "PATCH")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "用户id", required = true, paramType = "path", dataType = "Long"),
|
||||
@ApiImplicitParam(name = "brand", value = "实体JSON对象", required = true, paramType = "body", dataType = "PmsBrand")
|
||||
|
@ -4,6 +4,8 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.youlai.admin.common.constant.AdminConstant;
|
||||
import com.youlai.admin.pojo.entity.SysDept;
|
||||
import com.youlai.admin.pojo.vo.DeptVO;
|
||||
import com.youlai.admin.pojo.vo.TreeVO;
|
||||
import com.youlai.admin.service.ISysDeptService;
|
||||
import com.youlai.common.enums.QueryModeEnum;
|
||||
import com.youlai.common.result.Result;
|
||||
@ -50,20 +52,19 @@ public class DeptController {
|
||||
.orderByDesc(SysDept::getGmtCreate);
|
||||
QueryModeEnum queryModeEnum = QueryModeEnum.getValue(queryMode);
|
||||
|
||||
List list;
|
||||
switch (queryModeEnum) {
|
||||
case LIST:
|
||||
baseQuery = baseQuery.like(StrUtil.isNotBlank(name), SysDept::getName, name)
|
||||
baseQuery = baseQuery
|
||||
.like(StrUtil.isNotBlank(name), SysDept::getName, name)
|
||||
.eq(status != null, SysDept::getStatus, status);
|
||||
list = iSysDeptService.listDeptVO(baseQuery);
|
||||
break;
|
||||
List<DeptVO> list = iSysDeptService.listDeptVO(baseQuery);
|
||||
return Result.success(list);
|
||||
case TREE:
|
||||
list = iSysDeptService.listTreeVO(baseQuery);
|
||||
break;
|
||||
List<TreeVO> treeList = iSysDeptService.listTreeVO(baseQuery);
|
||||
return Result.success(treeList);
|
||||
default:
|
||||
return Result.failed(ResultCode.QUERY_MODE_IS_NULL);
|
||||
}
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "部门详情", httpMethod = "GET")
|
||||
|
@ -119,7 +119,7 @@ public class DictController {
|
||||
return Result.judge(status);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改字典(部分更新)", httpMethod = "PATCH")
|
||||
@ApiOperation(value = "修改字典", httpMethod = "PATCH")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "用户id", required = true, paramType = "path", dataType = "Long"),
|
||||
@ApiImplicitParam(name = "dictItem", value = "实体JSON对象", required = true, paramType = "body", dataType = "SysDictItem")
|
||||
|
@ -105,7 +105,7 @@ public class DictItemController {
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "修改字典(部分更新)", httpMethod = "PATCH")
|
||||
@ApiOperation(value = "修改字典", httpMethod = "PATCH")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "用户id", required = true, paramType = "path", dataType = "Long"),
|
||||
@ApiImplicitParam(name = "dictItem", value = "实体JSON对象", required = true, paramType = "body", dataType = "SysDictItem")
|
||||
|
@ -98,27 +98,23 @@ public class MenuController {
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除菜单", httpMethod = "DELETE")
|
||||
@ApiImplicitParam(name = "ids", value = "id集合", required = true, paramType = "query", dataType = "String")
|
||||
@ApiImplicitParam(name = "ids", value = "id集合字符串,以,分割", required = true, paramType = "query", dataType = "String")
|
||||
@DeleteMapping("/{ids}")
|
||||
public Result delete(@PathVariable("ids") String ids) {
|
||||
boolean status = iSysMenuService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.judge(status);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改菜单【局部更新】", httpMethod = "PATCH")
|
||||
@ApiOperation(value = "修改菜单", httpMethod = "PATCH")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "用户id", required = true, paramType = "path", dataType = "Long"),
|
||||
@ApiImplicitParam(name = "menu", value = "实体JSON对象", required = true, paramType = "body", dataType = "SysMenu")
|
||||
})
|
||||
@PatchMapping(value = "/{id}")
|
||||
public Result patch(@PathVariable Integer id, @RequestBody SysMenu menu) {
|
||||
LambdaUpdateWrapper<SysMenu> luw = new LambdaUpdateWrapper<SysMenu>().eq(SysMenu::getId, id);
|
||||
if (menu.getVisible() != null) { // 状态更新
|
||||
luw.set(SysMenu::getVisible, menu.getVisible());
|
||||
} else {
|
||||
return Result.success();
|
||||
}
|
||||
boolean update = iSysMenuService.update(luw);
|
||||
return Result.success(update);
|
||||
LambdaUpdateWrapper<SysMenu> updateWrapper = new LambdaUpdateWrapper<SysMenu>().eq(SysMenu::getId, id);
|
||||
updateWrapper.set(menu.getVisible() != null, SysMenu::getVisible, menu.getVisible());
|
||||
boolean result = iSysMenuService.update(updateWrapper);
|
||||
return Result.judge(result);
|
||||
}
|
||||
}
|
||||
|
@ -27,11 +27,11 @@ public class MinIOController {
|
||||
@ApiOperation(value = "文件上传", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "file", value = "文件", paramType = "form", dataType = "__file"),
|
||||
@ApiImplicitParam(name = "bucket_name", value = "桶名称", paramType = "query", dataType = "string")
|
||||
@ApiImplicitParam(name = "bucketName", value = "桶名称", paramType = "query", dataType = "string")
|
||||
})
|
||||
public Result<String> upload(
|
||||
@RequestParam(value = "file") MultipartFile file,
|
||||
@RequestParam(value = "bucket_name", required = false, defaultValue = "default") String bucketName
|
||||
@RequestParam(value = "bucketName", required = false, defaultValue = "default") String bucketName
|
||||
) {
|
||||
try {
|
||||
String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1);
|
||||
|
@ -170,14 +170,19 @@ public class UserController extends BaseController {
|
||||
public Result<UserVO> getCurrentUser() {
|
||||
UserVO userVO = new UserVO();
|
||||
|
||||
// 用户基本信息
|
||||
Long userId = RequestUtils.getUserId();
|
||||
SysUser user = iSysUserService.getById(userId);
|
||||
BeanUtil.copyProperties(user, userVO);
|
||||
|
||||
// 用户角色信息
|
||||
List<Long> roleIds = RequestUtils.getRoleIds();
|
||||
List<String> perms = iSysPermissionService.listPermsByRoleIds(roleIds, PermTypeEnum.BUTTON.getValue());
|
||||
userVO.setRoles(roleIds);
|
||||
|
||||
// 用户按钮权限信息
|
||||
List<String> perms = iSysPermissionService.listPermsByRoleIds(roleIds, PermTypeEnum.BUTTON.getValue());
|
||||
userVO.setPerms(perms);
|
||||
|
||||
return Result.success(userVO);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user