refactor 接口

V0.5.x
jay 2023-06-06 17:39:27 +08:00
parent 3ce468878d
commit b0a3ed9756
32 changed files with 345 additions and 219 deletions

View File

@ -49,4 +49,8 @@ public interface ISysDeptData extends ICommonData<SysDept, Long> {
*/
List<SysDept> findByDeptId(Long deptId);
boolean checkDeptNameUnique(String deptName, Long parentId, Long deptId);
long selectNormalChildrenDeptById(Long deptId);
}

View File

@ -19,10 +19,7 @@ public interface ISysDictData extends ICommonData<SysDictData, Long> {
*/
List<SysDictData> findByConditions(SysDictData query);
/**
*
*/
Paging<SysDictData> findByConditions(SysDictData query, int page, int size);
/**
*

View File

@ -3,6 +3,7 @@ package cc.iotkit.data.system;
import cc.iotkit.data.ICommonData;
import cc.iotkit.model.system.SysRoleDept;
import java.util.Collection;
import java.util.List;
/**
@ -12,7 +13,7 @@ import java.util.List;
*/
public interface ISysRoleDeptData extends ICommonData<SysRoleDept, Long> {
void deleteByRoleId(List<Long> roleIds);
void deleteByRoleId(Collection<Long> roleIds);
long insertBatch(List<SysRoleDept> list);

View File

@ -3,6 +3,7 @@ package cc.iotkit.data.system;
import cc.iotkit.data.ICommonData;
import cc.iotkit.model.system.SysRoleMenu;
import java.util.Collection;
import java.util.List;
/**
@ -15,6 +16,6 @@ public interface ISysRoleMenuData extends ICommonData<SysRoleMenu, Long> {
long insertBatch(List<SysRoleMenu> list);
long deleteByRoleId(List<Long> ids);
long deleteByRoleId(Collection<Long> ids);
}

View File

@ -6,11 +6,14 @@ import cc.iotkit.common.utils.MapstructUtils;
import cc.iotkit.common.utils.StringUtils;
import cc.iotkit.data.dao.IJPACommData;
import cc.iotkit.data.dao.SysDeptRepository;
import cc.iotkit.data.model.QTbSysRoleDept;
import cc.iotkit.data.model.TbSysDept;
import cc.iotkit.data.system.ISysDeptData;
import cc.iotkit.data.util.PredicateBuilder;
import cc.iotkit.model.system.SysDept;
import cn.hutool.core.util.ObjectUtil;
import com.querydsl.core.types.dsl.BooleanTemplate;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
@ -23,6 +26,7 @@ import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import static cc.iotkit.data.model.QTbSysDept.tbSysDept;
import static cc.iotkit.data.model.QTbSysRoleDept.tbSysRoleDept;
/**
* @Authortfd
@ -68,12 +72,15 @@ public class SysDeptDataImpl implements ISysDeptData, IJPACommData<SysDept, Long
@Override
public List<SysDept> findByRoleId(Long roleId) {
return null;
List<TbSysDept> list = jpaQueryFactory.select(tbSysDept).from(tbSysDept).leftJoin(tbSysRoleDept).on(tbSysDept.id.eq(tbSysRoleDept.deptId))
.where(tbSysRoleDept.roleId.eq(roleId)).orderBy(tbSysDept.parentId.desc(), tbSysDept.orderNum.desc()).fetch();
return MapstructUtils.convert(list,SysDept.class);
}
@Override
public long countByParentId(Long parentId) {
return 0;
return jpaQueryFactory.select(tbSysDept.id.count()).from(tbSysDept).where(tbSysDept.parentId.eq(parentId)).fetchOne();
}
@Override
@ -81,4 +88,27 @@ public class SysDeptDataImpl implements ISysDeptData, IJPACommData<SysDept, Long
return MapstructUtils.convert(deptRepository.findAll().stream().filter(o->o.getAncestors().indexOf(deptId.toString())!=-1)
.collect(Collectors.toList()),SysDept.class);
}
@Override
public boolean checkDeptNameUnique(String deptName, Long parentId, Long deptId) {
PredicateBuilder predicateBuilder = PredicateBuilder.instance().and(tbSysDept.deptName.eq(deptName))
.and(tbSysDept.parentId.eq(parentId));
if (ObjectUtil.isNotNull(deptId)) {
predicateBuilder.and(tbSysDept.id.ne(deptId));
}
Long aLong = jpaQueryFactory.select(tbSysDept.id.count()).where(predicateBuilder.build()).fetchOne();
if (aLong > 0) {
return true;
}
return false;
}
@Override
public long selectNormalChildrenDeptById(Long deptId) {
PredicateBuilder predicateBuilder = PredicateBuilder.instance().and(tbSysDept.status.eq(UserConstants.DEPT_NORMAL));
return jpaQueryFactory.select(tbSysDept.ancestors).where(predicateBuilder.build()).fetch().stream().filter(o->o.indexOf(deptId.toString())!=-1).count();
}
}

View File

@ -60,13 +60,10 @@ public class SysDictDataImpl implements ISysDictData, IJPACommData<SysDictData,
@Override
public List<SysDictData> findByConditions(SysDictData query) {
return null;
return findAllByCondition(query);
}
@Override
public Paging<SysDictData> findByConditions(SysDictData query, int page, int size) {
return null;
}
@Override
public SysDictData findByDictTypeAndDictValue(String dictType, String dictValue) {

View File

@ -13,6 +13,7 @@ import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
import static cc.iotkit.data.model.QTbSysRoleDept.tbSysRoleDept;
@ -32,7 +33,7 @@ public class SysRoleDeptDataImpl implements ISysRoleDeptData, IJPACommData<SysRo
private final JPAQueryFactory jpaQueryFactory;
@Override
public void deleteByRoleId(List<Long> roleIds) {
public void deleteByRoleId(Collection<Long> roleIds) {
jpaQueryFactory.delete(tbSysRoleDept).where(PredicateBuilder.instance().and(tbSysRoleDept.roleId.in(roleIds)).build());
}

View File

@ -65,7 +65,7 @@ public class SysRoleMenuDataImpl implements ISysRoleMenuData, IJPACommData<SysRo
}
@Override
public long deleteByRoleId(List<Long> ids) {
public long deleteByRoleId(Collection<Long> ids) {
return jpaQueryFactory.delete(tbSysRoleMenu).where(tbSysRoleMenu.roleId.in(ids)).execute();
}

View File

@ -1,5 +1,7 @@
package cc.iotkit.system.controller;
import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Request;
import cc.iotkit.common.constant.UserConstants;
import cc.iotkit.common.log.annotation.Log;
import cc.iotkit.common.log.enums.BusinessType;
@ -10,6 +12,7 @@ import cc.iotkit.system.dto.vo.SysDeptVo;
import cc.iotkit.system.service.ISysDeptService;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.convert.Convert;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -33,19 +36,21 @@ public class SysDeptController extends BaseController {
*
*/
@SaCheckPermission("system:dept:list")
@GetMapping("/list")
public List<SysDeptVo> list(SysDeptBo dept) {
return deptService.selectDeptList(dept);
@ApiOperation("获取部门列表")
@PostMapping("/list")
public List<SysDeptVo> list(@RequestBody @Validated PageRequest<SysDeptBo> dept) {
return deptService.selectDeptList(dept.getData());
}
/**
*
*
* @param deptId ID
*/
@ApiOperation("查询部门列表(排除节点)")
@SaCheckPermission("system:dept:list")
@GetMapping("/list/exclude/{deptId}")
public List<SysDeptVo> excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
@PostMapping("/list/exclude")
public List<SysDeptVo> excludeChild(@Validated @RequestBody Request<Long> request) {
Long deptId = request.getData();
List<SysDeptVo> depts = deptService.selectDeptList(new SysDeptBo());
depts.removeIf(d -> d.getId().equals(deptId)
|| StringUtils.splitList(d.getAncestors()).contains(Convert.toStr(deptId)));
@ -55,11 +60,12 @@ public class SysDeptController extends BaseController {
/**
*
*
* @param deptId ID
*/
@SaCheckPermission("system:dept:query")
@GetMapping(value = "/{deptId}")
public SysDeptVo getInfo(@PathVariable Long deptId) {
@ApiOperation("根据部门编号获取详细信息")
@PostMapping(value = "/getInfo")
public SysDeptVo getInfo(@Validated @RequestBody Request<Long> bo) {
Long deptId = bo.getData();
deptService.checkDeptDataScope(deptId);
return deptService.selectDeptById(deptId);
}
@ -68,9 +74,11 @@ public class SysDeptController extends BaseController {
*
*/
@SaCheckPermission("system:dept:add")
@ApiOperation("新增部门")
@Log(title = "部门管理", businessType = BusinessType.INSERT)
@PostMapping
public void add(@Validated @RequestBody SysDeptBo dept) {
public void add(@Validated @RequestBody Request<SysDeptBo> bo) {
SysDeptBo dept = bo.getData();
if (!deptService.checkDeptNameUnique(dept)) {
fail("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
@ -80,10 +88,12 @@ public class SysDeptController extends BaseController {
/**
*
*/
@ApiOperation("修改部门")
@SaCheckPermission("system:dept:edit")
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
@PutMapping
public void edit(@Validated @RequestBody SysDeptBo dept) {
public void edit(@Validated @RequestBody Request<SysDeptBo> bo) {
SysDeptBo dept = bo.getData();
Long deptId = dept.getDeptId();
deptService.checkDeptDataScope(deptId);
if (!deptService.checkDeptNameUnique(dept)) {
@ -100,12 +110,13 @@ public class SysDeptController extends BaseController {
/**
*
*
* @param deptId ID
*/
@SaCheckPermission("system:dept:remove")
@ApiOperation("删除部门")
@Log(title = "部门管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{deptId}")
public void remove(@PathVariable Long deptId) {
@PostMapping("/delete}")
public void remove(@Validated @RequestBody Request<Long> bo) {
Long deptId = bo.getData();
if (deptService.hasChildByDeptId(deptId)) {
warn("存在下级部门,不允许删除");
}

View File

@ -2,6 +2,7 @@ package cc.iotkit.system.controller;
import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging;
import cc.iotkit.common.api.Request;
import cc.iotkit.common.excel.utils.ExcelUtil;
import cc.iotkit.common.log.annotation.Log;
import cc.iotkit.common.log.enums.BusinessType;
@ -11,6 +12,7 @@ import cc.iotkit.system.service.ISysDictDataService;
import cc.iotkit.system.service.ISysDictTypeService;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.util.ObjectUtil;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -37,9 +39,10 @@ public class SysDictDataController {
*
*/
@SaCheckPermission("system:dict:list")
@GetMapping("/list")
public Paging<SysDictDataVo> list(SysDictDataBo dictData, PageRequest<?> query) {
return dictDataService.selectPageDictDataList(dictData, query);
@ApiOperation(value = "查询字典数据列表", notes = "查询字典数据列表")
@PostMapping("/list")
public Paging<SysDictDataVo> list(@Validated @RequestBody PageRequest<SysDictDataBo> query) {
return dictDataService.selectPageDictDataList( query);
}
/**
@ -47,30 +50,34 @@ public class SysDictDataController {
*/
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
@SaCheckPermission("system:dict:export")
@ApiOperation(value = "导出字典数据列表", notes = "导出字典数据列表")
@PostMapping("/export")
public void export(SysDictDataBo dictData, HttpServletResponse response) {
List<SysDictDataVo> list = dictDataService.selectDictDataList(dictData);
public void export(@RequestBody @Validated Request<SysDictDataBo> bo, HttpServletResponse response) {
List<SysDictDataVo> list = dictDataService.selectDictDataList(bo.getData());
ExcelUtil.exportExcel(list, "字典数据", SysDictDataVo.class, response);
}
/**
*
*
* @param dictCode code
*/
@SaCheckPermission("system:dict:query")
@GetMapping(value = "/{dictCode}")
public SysDictDataVo getInfo(@PathVariable Long dictCode) {
return dictDataService.selectDictDataById(dictCode);
@ApiOperation(value = "查询字典数据详细", notes = "查询字典数据详细")
@PostMapping(value = "/getInfo")
public SysDictDataVo getInfo(@Validated @RequestBody Request<Long> bo) {
return dictDataService.selectDictDataById(bo.getData());
}
/**
*
*
* @param dictType
*/
@GetMapping(value = "/type/{dictType}")
public List<SysDictDataVo> dictType(@PathVariable String dictType) {
@ApiOperation(value = "根据字典类型查询字典数据信息", notes = "根据字典类型查询字典数据信息")
@PostMapping(value = "/type")
public List<SysDictDataVo> dictType(@Validated @RequestBody Request<String> bo) {
String dictType = bo.getData();
List<SysDictDataVo> data = dictTypeService.selectDictDataByType(dictType);
if (ObjectUtil.isNull(data)) {
data = new ArrayList<SysDictDataVo>();
@ -84,29 +91,30 @@ public class SysDictDataController {
@SaCheckPermission("system:dict:add")
@Log(title = "字典数据", businessType = BusinessType.INSERT)
@PostMapping
public void add(@Validated @RequestBody SysDictDataBo dict) {
dictDataService.insertDictData(dict);
public void add(@Validated @RequestBody Request<SysDictDataBo> bo) {
dictDataService.insertDictData(bo.getData());
}
/**
*
*/
@ApiOperation(value = "修改保存字典类型", notes = "修改保存字典类型")
@SaCheckPermission("system:dict:edit")
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
@PutMapping
public void edit(@Validated @RequestBody SysDictDataBo dict) {
dictDataService.updateDictData(dict);
public void edit(@Validated @RequestBody Request<SysDictDataBo> bo) {
dictDataService.updateDictData(bo.getData());
}
/**
*
*
* @param dictCodes code
*/
@ApiOperation(value = "删除字典类型", notes = "删除字典类型")
@SaCheckPermission("system:dict:remove")
@Log(title = "字典类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{dictCodes}")
public void remove(@PathVariable Long[] dictCodes) {
dictDataService.deleteDictDataByIds(dictCodes);
@DeleteMapping("/delete")
public void remove(@Validated @RequestBody Request<Long[]> bo) {
dictDataService.deleteDictDataByIds(bo.getData());
}
}

View File

@ -2,6 +2,7 @@ package cc.iotkit.system.controller;
import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging;
import cc.iotkit.common.api.Request;
import cc.iotkit.common.excel.utils.ExcelUtil;
import cc.iotkit.common.log.annotation.Log;
import cc.iotkit.common.log.enums.BusinessType;
@ -10,6 +11,7 @@ import cc.iotkit.system.dto.bo.SysDictTypeBo;
import cc.iotkit.system.dto.vo.SysDictTypeVo;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cc.iotkit.system.service.ISysDictTypeService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -34,19 +36,22 @@ public class SysDictTypeController extends BaseController {
/**
*
*/
@ApiOperation(value = "查询字典类型列表", notes = "查询字典类型列表")
@SaCheckPermission("system:dict:list")
@GetMapping("/list")
public Paging<SysDictTypeVo> list(SysDictTypeBo dictType, PageRequest<?> query) {
return dictTypeService.selectPageDictTypeList(dictType, query);
@PostMapping("/list")
public Paging<SysDictTypeVo> list( PageRequest<SysDictTypeBo> query) {
return dictTypeService.selectPageDictTypeList( query);
}
/**
*
*/
@ApiOperation(value = "导出字典类型列表", notes = "导出字典类型列表")
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
@SaCheckPermission("system:dict:export")
@PostMapping("/export")
public void export(SysDictTypeBo dictType, HttpServletResponse response) {
public void export(@RequestBody SysDictTypeBo dictType, HttpServletResponse response) {
List<SysDictTypeVo> list = dictTypeService.selectDictTypeList(dictType);
ExcelUtil.exportExcel(list, "字典类型", SysDictTypeVo.class, response);
}
@ -54,17 +59,19 @@ public class SysDictTypeController extends BaseController {
/**
*
*
* @param dictId ID
*/
@ApiOperation(value = "查询字典类型详细", notes = "查询字典类型详细")
@SaCheckPermission("system:dict:query")
@GetMapping(value = "/{dictId}")
public SysDictTypeVo getInfo(@PathVariable Long dictId) {
return dictTypeService.selectDictTypeById(dictId);
@PostMapping(value = "/getById")
public SysDictTypeVo getInfo(@Validated @RequestBody Request<Long> bo) {
return dictTypeService.selectDictTypeById(bo.getData());
}
/**
*
*/
@ApiOperation(value = "新增字典类型", notes = "新增字典类型")
@SaCheckPermission("system:dict:add")
@Log(title = "字典类型", businessType = BusinessType.INSERT)
@PostMapping
@ -113,7 +120,7 @@ public class SysDictTypeController extends BaseController {
/**
*
*/
@GetMapping("/optionselect")
@PostMapping("/optionselect")
public List<SysDictTypeVo> optionselect() {
return dictTypeService.selectDictTypeAll();
}

View File

@ -2,6 +2,7 @@ package cc.iotkit.system.controller;
import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging;
import cc.iotkit.common.api.Request;
import cc.iotkit.common.constant.GlobalConstants;
import cc.iotkit.common.excel.utils.ExcelUtil;
import cc.iotkit.common.log.annotation.Log;
@ -38,6 +39,7 @@ public class SysLogininforController extends BaseController {
/**
* 访
*/
@ApiOperation("获取系统访问记录列表")
@SaCheckPermission("monitor:logininfor:list")
@PostMapping("/list")
@ -52,21 +54,21 @@ public class SysLogininforController extends BaseController {
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
@SaCheckPermission("monitor:logininfor:export")
@PostMapping("/export")
public void export(SysLogininforBo logininfor, HttpServletResponse response) {
List<SysLogininforVo> list = logininforService.selectLogininforList(logininfor);
public void export(Request<SysLogininforBo> logininfor, HttpServletResponse response) {
List<SysLogininforVo> list = logininforService.selectLogininforList(logininfor.getData());
ExcelUtil.exportExcel(list, "登录日志", SysLogininforVo.class, response);
}
/**
*
* @param infoIds ids
*/
@ApiOperation("批量删除登录日志")
@SaCheckPermission("monitor:logininfor:remove")
@Log(title = "登录日志", businessType = BusinessType.DELETE)
@DeleteMapping("/{infoIds}")
public void remove(@PathVariable Long[] infoIds) {
logininforService.deleteLogininforByIds(List.of(infoIds));
@PostMapping("/delete")
public void remove(@RequestBody @Validated Request<List<Long>> bo) {
logininforService.deleteLogininforByIds(bo.getData());
}
/**
@ -83,9 +85,9 @@ public class SysLogininforController extends BaseController {
@ApiOperation("账户解锁")
@SaCheckPermission("monitor:logininfor:unlock")
@Log(title = "账户解锁", businessType = BusinessType.OTHER)
@GetMapping("/unlock/{userName}")
public void unlock(@PathVariable("userName") String userName) {
String loginName = GlobalConstants.PWD_ERR_CNT_KEY + userName;
@PostMapping("/unlockByUserName")
public void unlock(@Validated @RequestBody Request<String> bo) {
String loginName = GlobalConstants.PWD_ERR_CNT_KEY + bo.getData();
if (RedisUtils.hasKey(loginName)) {
RedisUtils.deleteObject(loginName);
}

View File

@ -1,5 +1,6 @@
package cc.iotkit.system.controller;
import cc.iotkit.common.api.Request;
import cc.iotkit.common.constant.TenantConstants;
import cc.iotkit.common.constant.UserConstants;
import cc.iotkit.common.log.annotation.Log;
@ -17,6 +18,7 @@ import cn.dev33.satoken.annotation.SaCheckRole;
import cn.dev33.satoken.annotation.SaMode;
import cn.hutool.core.lang.tree.Tree;
import cc.iotkit.system.service.ISysMenuService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -41,7 +43,8 @@ public class SysMenuController extends BaseController {
*
* @return
*/
@GetMapping("/getRouters")
@ApiOperation("获取路由信息")
@PostMapping("/getRouters")
public List<RouterVo> getRouters() {
List<SysMenu> menus = menuService.selectMenuTreeByUserId(LoginHelper.getUserId());
return menuService.buildMenus(menus);
@ -50,14 +53,15 @@ public class SysMenuController extends BaseController {
/**
*
*/
@ApiOperation("获取菜单列表")
@SaCheckRole(value = {
TenantConstants.SUPER_ADMIN_ROLE_KEY,
TenantConstants.TENANT_ADMIN_ROLE_KEY
}, mode = SaMode.OR)
@SaCheckPermission("system:menu:list")
@GetMapping("/list")
public List<SysMenuVo> list(SysMenuBo menu) {
return menuService.selectMenuList(menu, LoginHelper.getUserId());
@PostMapping("/list")
public List<SysMenuVo> list(@RequestBody Request<SysMenuBo> bo) {
return menuService.selectMenuList(bo.getData(), LoginHelper.getUserId());
}
/**
@ -70,7 +74,7 @@ public class SysMenuController extends BaseController {
TenantConstants.TENANT_ADMIN_ROLE_KEY
}, mode = SaMode.OR)
@SaCheckPermission("system:menu:query")
@GetMapping(value = "/{menuId}")
@PostMapping(value = "/{menuId}")
public SysMenuVo getInfo(@PathVariable Long menuId) {
return menuService.selectMenuById(menuId);
}
@ -78,32 +82,33 @@ public class SysMenuController extends BaseController {
/**
*
*/
@ApiOperation("获取菜单下拉树列表")
@SaCheckRole(value = {
TenantConstants.SUPER_ADMIN_ROLE_KEY,
TenantConstants.TENANT_ADMIN_ROLE_KEY
}, mode = SaMode.OR)
@SaCheckPermission("system:menu:query")
@GetMapping("/treeselect")
public List<Tree<Long>> treeselect(SysMenuBo menu) {
List<SysMenuVo> menus = menuService.selectMenuList(menu, LoginHelper.getUserId());
@PostMapping("/treeselect")
public List<Tree<Long>> treeselect(@Validated @RequestBody Request<SysMenuBo> menu) {
List<SysMenuVo> menus = menuService.selectMenuList(menu.getData(), LoginHelper.getUserId());
return menuService.buildMenuTreeSelect(menus);
}
/**
*
*
* @param roleId ID
*/
@ApiOperation("加载对应角色菜单列表树")
@SaCheckRole(value = {
TenantConstants.SUPER_ADMIN_ROLE_KEY,
TenantConstants.TENANT_ADMIN_ROLE_KEY
}, mode = SaMode.OR)
@SaCheckPermission("system:menu:query")
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
public MenuTreeSelectVo roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
@PostMapping(value = "/roleMenuTreeselectByRoleId")
public MenuTreeSelectVo roleMenuTreeselect(@Validated @RequestBody Request<Long> bo) {
List<SysMenuVo> menus = menuService.selectMenuList(LoginHelper.getUserId());
MenuTreeSelectVo selectVo = new MenuTreeSelectVo();
selectVo.setCheckedKeys(menuService.selectMenuListByRoleId(roleId));
selectVo.setCheckedKeys(menuService.selectMenuListByRoleId(bo.getData()));
selectVo.setMenus(menuService.buildMenuTreeSelect(menus));
return selectVo;
}
@ -111,11 +116,13 @@ public class SysMenuController extends BaseController {
/**
*
*/
@ApiOperation("新增菜单")
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
@SaCheckPermission("system:menu:add")
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
@PostMapping
public void add(@Validated @RequestBody SysMenuBo menu) {
public void add(@Validated @RequestBody Request<SysMenuBo> bo) {
SysMenuBo menu = bo.getData();
if (!menuService.checkMenuNameUnique(menu)) {
fail("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) {
@ -130,8 +137,9 @@ public class SysMenuController extends BaseController {
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
@SaCheckPermission("system:menu:edit")
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
@PutMapping
public void edit(@Validated @RequestBody SysMenuBo menu) {
@PostMapping("/edit")
public void edit(@Validated @RequestBody Request<SysMenuBo> bo) {
SysMenuBo menu = bo.getData();
if (!menuService.checkMenuNameUnique(menu)) {
fail("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) {
@ -145,13 +153,14 @@ public class SysMenuController extends BaseController {
/**
*
*
* @param menuId ID
*/
@ApiOperation("删除菜单")
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
@SaCheckPermission("system:menu:remove")
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{menuId}")
public void remove(@PathVariable("menuId") Long menuId) {
@PostMapping("/delete")
public void remove(@Validated @RequestBody Request<Long> bo) {
Long menuId = bo.getData();
if (menuService.hasChildByMenuId(menuId)) {
warn("存在子菜单,不允许删除");
}

View File

@ -2,6 +2,7 @@ package cc.iotkit.system.controller;
import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging;
import cc.iotkit.common.api.Request;
import cc.iotkit.common.log.annotation.Log;
import cc.iotkit.common.log.enums.BusinessType;
import cc.iotkit.common.web.core.BaseController;
@ -9,11 +10,13 @@ import cc.iotkit.system.dto.bo.SysNoticeBo;
import cc.iotkit.system.dto.vo.SysNoticeVo;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cc.iotkit.system.service.ISysNoticeService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Collection;
import java.util.List;
/**
*
@ -32,30 +35,32 @@ public class SysNoticeController extends BaseController {
*
*/
@SaCheckPermission("system:notice:list")
@GetMapping("/list")
public Paging<SysNoticeVo> list(SysNoticeBo notice, PageRequest<?> query) {
return noticeService.selectPageNoticeList(notice, query);
@ApiOperation(value = "获取通知公告列表", notes = "获取通知公告列表")
@PostMapping("/list")
public Paging<SysNoticeVo> list(@Validated @RequestBody PageRequest<SysNoticeBo> query) {
return noticeService.selectPageNoticeList( query);
}
/**
*
*
* @param noticeId ID
*/
@ApiOperation(value = "根据通知公告编号获取详细信息", notes = "根据通知公告编号获取详细信息")
@SaCheckPermission("system:notice:query")
@GetMapping(value = "/{noticeId}")
public SysNoticeVo getInfo(@PathVariable Long noticeId) {
return noticeService.selectNoticeById(noticeId);
@PostMapping(value = "/getDetail")
public SysNoticeVo getInfo(@Validated @RequestBody Request<Long> bo) {
return noticeService.selectNoticeById(bo.getData());
}
/**
*
*/
@ApiOperation(value = "新增通知公告", notes = "新增通知公告")
@SaCheckPermission("system:notice:add")
@Log(title = "通知公告", businessType = BusinessType.INSERT)
@PostMapping
public void add(@Validated @RequestBody SysNoticeBo notice) {
noticeService.insertNotice(notice);
public void add(@Validated @RequestBody Request<SysNoticeBo> bo) {
noticeService.insertNotice(bo.getData());
}
/**
@ -63,20 +68,20 @@ public class SysNoticeController extends BaseController {
*/
@SaCheckPermission("system:notice:edit")
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
@PutMapping
public void edit(@Validated @RequestBody SysNoticeBo notice) {
noticeService.updateNotice(notice);
@PostMapping("/edit")
public void edit(@Validated @RequestBody Request<SysNoticeBo> bo) {
noticeService.updateNotice(bo.getData());
}
/**
*
*
* @param noticeIds ID
*/
@ApiOperation(value = "删除通知公告", notes = "删除通知公告")
@SaCheckPermission("system:notice:remove")
@Log(title = "通知公告", businessType = BusinessType.DELETE)
@DeleteMapping("/{noticeIds}")
public void remove(@PathVariable Collection<Long> noticeIds) {
noticeService.deleteNoticeByIds(noticeIds);
@PostMapping("/delete")
public void remove(@Validated @RequestBody Request<List<Long>> bo) {
noticeService.deleteNoticeByIds(bo.getData());
}
}

View File

@ -2,6 +2,7 @@ package cc.iotkit.system.controller;
import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging;
import cc.iotkit.common.api.Request;
import cc.iotkit.common.log.annotation.Log;
import cc.iotkit.common.log.enums.BusinessType;
import cc.iotkit.common.validate.AddGroup;
@ -12,6 +13,7 @@ import cc.iotkit.system.dto.bo.SysOssConfigBo;
import cc.iotkit.system.dto.vo.SysOssConfigVo;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cc.iotkit.system.service.ISysOssConfigService;
import io.swagger.annotations.ApiOperation;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
@ -38,10 +40,11 @@ public class SysOssConfigController extends BaseController {
/**
*
*/
@ApiOperation(value = "查询对象存储配置列表", notes = "查询对象存储配置列表")
@SaCheckPermission("system:oss:list")
@GetMapping("/list")
public Paging<SysOssConfigVo> list(@Validated(QueryGroup.class) SysOssConfigBo bo, PageRequest<?> query) {
return ossConfigService.queryPageList(bo, query);
@PostMapping("/list")
public Paging<SysOssConfigVo> list(@Validated @RequestBody PageRequest<SysOssConfigBo> query) {
return ossConfigService.queryPageList(query);
}
/**
@ -49,8 +52,9 @@ public class SysOssConfigController extends BaseController {
*
* @param ossConfigId OSSID
*/
@ApiOperation(value = "获取对象存储配置详细信息", notes = "获取对象存储配置详细信息")
@SaCheckPermission("system:oss:query")
@GetMapping("/{ossConfigId}")
@PostMapping("/{ossConfigId}")
public SysOssConfigVo getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long ossConfigId) {
return ossConfigService.queryById(ossConfigId);
@ -59,11 +63,12 @@ public class SysOssConfigController extends BaseController {
/**
*
*/
@ApiOperation(value = "新增对象存储配置", notes = "新增对象存储配置")
@SaCheckPermission("system:oss:add")
@Log(title = "对象存储配置", businessType = BusinessType.INSERT)
@PostMapping()
public void add(@Validated(AddGroup.class) @RequestBody SysOssConfigBo bo) {
ossConfigService.insertByBo(bo);
public void add(@Validated(AddGroup.class) @RequestBody Request<SysOssConfigBo> bo) {
ossConfigService.insertByBo(bo.getData());
}
/**
@ -72,21 +77,19 @@ public class SysOssConfigController extends BaseController {
@SaCheckPermission("system:oss:edit")
@Log(title = "对象存储配置", businessType = BusinessType.UPDATE)
@PutMapping()
public void edit(@Validated(EditGroup.class) @RequestBody SysOssConfigBo bo) {
ossConfigService.updateByBo(bo);
public void edit(@Validated(EditGroup.class) @RequestBody Request<SysOssConfigBo> bo) {
ossConfigService.updateByBo(bo.getData());
}
/**
*
*
* @param ossConfigIds OSSID
*/
@SaCheckPermission("system:oss:remove")
@Log(title = "对象存储配置", businessType = BusinessType.DELETE)
@DeleteMapping("/{ossConfigIds}")
public void remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ossConfigIds) {
ossConfigService.deleteWithValidByIds(List.of(ossConfigIds), true);
@PostMapping("/delete")
public void remove(@Validated @RequestBody Request<List<Long>> bo) {
ossConfigService.deleteWithValidByIds(bo.getData(), true);
}
/**
@ -94,8 +97,8 @@ public class SysOssConfigController extends BaseController {
*/
@SaCheckPermission("system:oss:edit")
@Log(title = "对象存储状态修改", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public void changeStatus(@RequestBody SysOssConfigBo bo) {
ossConfigService.updateOssConfigStatus(bo);
@PostMapping("/changeStatus")
public void changeStatus(@RequestBody Request<SysOssConfigBo> bo) {
ossConfigService.updateOssConfigStatus(bo.getData());
}
}

View File

@ -3,6 +3,7 @@ package cc.iotkit.system.controller;
import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging;
import cc.iotkit.common.api.Request;
import cc.iotkit.common.log.annotation.Log;
import cc.iotkit.common.log.enums.BusinessType;
import cc.iotkit.common.validate.QueryGroup;
@ -13,6 +14,7 @@ import cc.iotkit.system.dto.vo.SysOssVo;
import cc.iotkit.system.service.ISysOssService;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.util.ObjectUtil;
import io.swagger.annotations.ApiOperation;
import jakarta.validation.constraints.NotEmpty;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
@ -42,7 +44,7 @@ public class SysOssController extends BaseController {
* OSS
*/
@SaCheckPermission("system:oss:list")
@GetMapping("/list")
@PostMapping("/list")
public Paging<SysOssVo> list(@Validated(QueryGroup.class) SysOssBo bo, PageRequest<?> query) {
return ossService.queryPageList(bo, query);
}
@ -50,13 +52,12 @@ public class SysOssController extends BaseController {
/**
* OSSid
*
* @param ossIds OSSID
*/
@ApiOperation(value = "查询OSS对象基于id串", notes = "查询OSS对象基于id串")
@SaCheckPermission("system:oss:list")
@GetMapping("/listByIds/{ossIds}")
public List<SysOssVo> listByIds(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ossIds) {
return ossService.listByIds(Arrays.asList(ossIds));
@PostMapping("/listByIds")
public List<SysOssVo> listByIds(@Validated @RequestBody Request<List<Long>> bo) {
return ossService.listByIds(bo.getData());
}
/**
@ -64,6 +65,7 @@ public class SysOssController extends BaseController {
*
* @param file
*/
@ApiOperation(value = "上传OSS对象存储", notes = "上传OSS对象存储")
@SaCheckPermission("system:oss:upload")
@Log(title = "OSS对象存储", businessType = BusinessType.INSERT)
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ -82,25 +84,24 @@ public class SysOssController extends BaseController {
/**
* OSS
*
* @param ossId OSSID
*/
@SaCheckPermission("system:oss:download")
@GetMapping("/download/{ossId}")
public void download(@PathVariable Long ossId, HttpServletResponse response) throws IOException {
ossService.download(ossId);
@PostMapping("/downloadById")
public void download(@RequestBody @Validated Request<Long> bo, HttpServletResponse response) throws IOException {
ossService.download(bo.getData());
}
/**
* OSS
*
* @param ossIds OSSID
*/
@ApiOperation(value = "删除OSS对象存储", notes = "删除OSS对象存储")
@SaCheckPermission("system:oss:remove")
@Log(title = "OSS对象存储", businessType = BusinessType.DELETE)
@DeleteMapping("/{ossIds}")
public void remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ossIds) {
ossService.deleteWithValidByIds(List.of(ossIds), true);
@PostMapping("/delete")
public void remove(@Validated @RequestBody Request<List<Long>> bo) {
ossService.deleteWithValidByIds(bo.getData(), true);
}
}

View File

@ -1,11 +1,13 @@
package cc.iotkit.system.controller;
import cc.iotkit.common.api.Request;
import cc.iotkit.common.log.annotation.Log;
import cc.iotkit.common.log.enums.BusinessType;
import cc.iotkit.common.satoken.utils.LoginHelper;
import cc.iotkit.common.utils.StringUtils;
import cc.iotkit.common.utils.file.MimeTypeUtils;
import cc.iotkit.common.web.core.BaseController;
import cc.iotkit.system.dto.bo.SysChangePwdBo;
import cc.iotkit.system.dto.bo.SysUserBo;
import cc.iotkit.system.dto.bo.SysUserProfileBo;
import cc.iotkit.system.dto.vo.AvatarVo;
@ -17,6 +19,7 @@ import cc.iotkit.system.service.ISysUserService;
import cn.dev33.satoken.secure.BCrypt;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.io.FileUtil;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
@ -42,7 +45,9 @@ public class SysProfileController extends BaseController {
/**
*
*/
@GetMapping
@ApiOperation(value = "个人信息", notes = "个人信息")
@PostMapping
public ProfileVo profile() {
SysUserVo user = userService.selectUserById(LoginHelper.getUserId());
ProfileVo profileVo = new ProfileVo();
@ -55,9 +60,11 @@ public class SysProfileController extends BaseController {
/**
*
*/
@ApiOperation(value = "修改用户", notes = "修改用户")
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping
public void updateProfile(@RequestBody SysUserProfileBo profile) {
@PostMapping
public void updateProfile(@RequestBody Request<SysUserProfileBo> bo) {
SysUserProfileBo profile = bo.getData();
SysUserBo user = BeanUtil.toBean(profile, SysUserBo.class);
if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
fail("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
@ -75,12 +82,14 @@ public class SysProfileController extends BaseController {
/**
*
*
* @param newPassword
* @param oldPassword
*/
@ApiOperation(value = "重置密码", notes = "重置密码")
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping("/updatePwd")
public void updatePwd(String oldPassword, String newPassword) {
@PostMapping("/updatePwd")
public void updatePwd(@RequestBody @Validated Request<SysChangePwdBo> bo) {
SysChangePwdBo data = bo.getData();
String newPassword = data.getNewPassword();
String oldPassword = data.getOldPassword();
SysUserVo user = userService.selectUserById(LoginHelper.getUserId());
String password = user.getPassword();
if (!BCrypt.checkpw(oldPassword, password)) {
@ -101,6 +110,7 @@ public class SysProfileController extends BaseController {
*
* @param avatarfile
*/
@ApiOperation(value = "头像上传", notes = "头像上传")
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
@PostMapping(value = "/avatar", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public AvatarVo avatar(@RequestPart("avatarfile") MultipartFile avatarfile) {

View File

@ -2,6 +2,7 @@ package cc.iotkit.system.controller;
import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging;
import cc.iotkit.common.api.Request;
import cc.iotkit.common.excel.utils.ExcelUtil;
import cc.iotkit.common.log.annotation.Log;
import cc.iotkit.common.log.enums.BusinessType;
@ -17,6 +18,7 @@ import cc.iotkit.system.service.ISysDeptService;
import cc.iotkit.system.service.ISysRoleService;
import cc.iotkit.system.service.ISysUserService;
import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -42,8 +44,9 @@ public class SysRoleController extends BaseController {
/**
*
*/
@ApiOperation(value = "获取角色信息列表", notes = "获取角色信息列表,根据查询条件分页")
@SaCheckPermission("system:role:list")
@GetMapping("/list")
@PostMapping("/list")
public Paging<SysRoleVo> list(PageRequest<SysRoleBo> query) {
return roleService.selectPageRoleList(query);
}
@ -52,10 +55,11 @@ public class SysRoleController extends BaseController {
*
*/
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
@ApiOperation(value = "导出角色信息列表", notes = "导出角色信息列表")
@SaCheckPermission("system:role:export")
@PostMapping("/export")
public void export(SysRoleBo role, HttpServletResponse response) {
List<SysRoleVo> list = roleService.selectRoleList(role);
public void export(@RequestBody @Validated Request<SysRoleBo> role, HttpServletResponse response) {
List<SysRoleVo> list = roleService.selectRoleList(role.getData());
ExcelUtil.exportExcel(list, "角色数据", SysRoleVo.class, response);
}
@ -64,8 +68,9 @@ public class SysRoleController extends BaseController {
*
* @param roleId ID
*/
@ApiOperation(value = "根据角色编号获取详细信息", notes = "根据角色编号获取详细信息")
@SaCheckPermission("system:role:query")
@GetMapping(value = "/{roleId}")
@PostMapping(value = "/{roleId}")
public SysRoleVo getInfo(@PathVariable Long roleId) {
roleService.checkRoleDataScope(roleId);
return roleService.selectRoleById(roleId);
@ -74,10 +79,13 @@ public class SysRoleController extends BaseController {
/**
*
*/
@ApiOperation(value = "新增角色", notes = "新增角色")
@SaCheckPermission("system:role:add")
@Log(title = "角色管理", businessType = BusinessType.INSERT)
@PostMapping
public void add(@Validated @RequestBody SysRoleBo role) {
public void add(@Validated @RequestBody Request<SysRoleBo> bo) {
SysRoleBo role = bo.getData();
if (!roleService.checkRoleNameUnique(role)) {
fail("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
} else if (!roleService.checkRoleKeyUnique(role)) {
@ -90,10 +98,13 @@ public class SysRoleController extends BaseController {
/**
*
*/
@ApiOperation(value = "修改保存角色", notes = "修改保存角色")
@SaCheckPermission("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping
public void edit(@Validated @RequestBody SysRoleBo role) {
@PostMapping
public void edit(@Validated @RequestBody Request<SysRoleBo> bo) {
SysRoleBo role = bo.getData();
roleService.checkRoleAllowed(role.getRoleId());
roleService.checkRoleDataScope(role.getRoleId());
if (!roleService.checkRoleNameUnique(role)) {
@ -111,10 +122,12 @@ public class SysRoleController extends BaseController {
/**
*
*/
@ApiOperation(value = "修改保存数据权限", notes = "修改保存数据权限")
@SaCheckPermission("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping("/dataScope")
public void dataScope(@RequestBody SysRoleBo role) {
@PostMapping("/dataScope")
public void dataScope(@RequestBody Request<SysRoleBo> bo) {
SysRoleBo role = bo.getData();
roleService.checkRoleAllowed(role.getRoleId());
roleService.checkRoleDataScope(role.getRoleId());
roleService.authDataScope(role);
@ -123,9 +136,10 @@ public class SysRoleController extends BaseController {
/**
*
*/
@ApiOperation(value = "状态修改", notes = "状态修改")
@SaCheckPermission("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
@PostMapping("/changeStatus")
public void changeStatus(@RequestBody SysRoleBo role) {
roleService.checkRoleAllowed(role.getRoleId());
roleService.checkRoleDataScope(role.getRoleId());
@ -135,20 +149,22 @@ public class SysRoleController extends BaseController {
/**
*
*
* @param roleIds ID
*/
@ApiOperation(value = "删除角色", notes = "删除角色")
@SaCheckPermission("system:role:remove")
@Log(title = "角色管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{roleIds}")
public void remove(@PathVariable Long[] roleIds) {
roleService.deleteRoleByIds(roleIds);
@PostMapping("/delete")
public void remove(@Validated @RequestBody Request<List<Long>> bo) {
roleService.deleteRoleByIds(bo.getData());
}
/**
*
*/
@ApiOperation(value = "获取角色选择框列表", notes = "获取角色选择框列表")
@SaCheckPermission("system:role:query")
@GetMapping("/optionselect")
@PostMapping("/optionselect")
public List<SysRoleVo> optionselect() {
return roleService.selectRoleAll();
}
@ -156,29 +172,32 @@ public class SysRoleController extends BaseController {
/**
*
*/
@ApiOperation(value = "查询已分配用户角色列表", notes = "查询已分配用户角色列表")
@SaCheckPermission("system:role:list")
@GetMapping("/authUser/allocatedList")
public Paging<SysUserVo> allocatedList(SysUserBo user, PageRequest<?> query) {
return userService.selectAllocatedList(user, query);
@PostMapping("/authUser/allocatedList")
public Paging<SysUserVo> allocatedList(Request<SysUserBo> bo, PageRequest<?> query) {
return userService.selectAllocatedList(bo.getData(), query);
}
/**
*
*/
@ApiOperation(value = "查询未分配用户角色列表", notes = "查询未分配用户角色列表")
@SaCheckPermission("system:role:list")
@GetMapping("/authUser/unallocatedList")
public Paging<SysUserVo> unallocatedList(SysUserBo user, PageRequest<?> query) {
return userService.selectUnallocatedList(user, query);
@PostMapping("/authUser/unallocatedList")
public Paging<SysUserVo> unallocatedList(Request<SysUserBo> bo, PageRequest<?> query) {
return userService.selectUnallocatedList(bo.getData(), query);
}
/**
*
*/
@ApiOperation(value = "取消授权用户", notes = "取消授权用户")
@SaCheckPermission("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/cancel")
public void cancelAuthUser(@RequestBody SysUserRole userRole) {
roleService.deleteAuthUser(userRole);
@PostMapping("/authUser/cancel")
public void cancelAuthUser(@RequestBody Request<SysUserRole> bo) {
roleService.deleteAuthUser(bo.getData());
}
/**
@ -187,9 +206,10 @@ public class SysRoleController extends BaseController {
* @param roleId ID
* @param userIds ID
*/
@ApiOperation(value = "批量取消授权用户", notes = "批量取消授权用户")
@SaCheckPermission("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/cancelAll")
@PostMapping("/authUser/cancelAll")
public void cancelAuthUserAll(Long roleId, Long[] userIds) {
roleService.deleteAuthUsers(roleId, userIds);
}
@ -200,9 +220,10 @@ public class SysRoleController extends BaseController {
* @param roleId ID
* @param userIds ID
*/
@ApiOperation(value = "批量选择用户授权", notes = "批量选择用户授权")
@SaCheckPermission("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/selectAll")
@PostMapping("/authUser/selectAll")
public void selectAuthUserAll(Long roleId, Long[] userIds) {
roleService.checkRoleDataScope(roleId);
roleService.insertAuthUsers(roleId, userIds);
@ -213,8 +234,9 @@ public class SysRoleController extends BaseController {
*
* @param roleId ID
*/
@ApiOperation(value = "获取对应角色部门树列表", notes = "获取对应角色部门树列表")
@SaCheckPermission("system:role:list")
@GetMapping(value = "/deptTree/{roleId}")
@PostMapping(value = "/deptTree/{roleId}")
public DeptTreeSelectVo roleDeptTreeselect(@PathVariable("roleId") Long roleId) {
DeptTreeSelectVo selectVo = new DeptTreeSelectVo();
selectVo.setCheckedKeys(deptService.selectDeptListByRoleId(roleId));

View File

@ -0,0 +1,27 @@
package cc.iotkit.system.dto.bo;
import cc.iotkit.common.api.BaseDto;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
*
*
* @author Michelle.Chung
*/
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class SysChangePwdBo extends BaseDto {
@ApiModelProperty(value = "旧密码")
private String oldPassword;
@ApiModelProperty(value = "新密码")
private String newPassword;
}

View File

@ -21,7 +21,7 @@ public class SystemApplicationRunner implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
ossConfigService.init();
// ossConfigService.init();
log.info("初始化OSS配置成功");
}

View File

@ -15,7 +15,7 @@ import java.util.List;
public interface ISysDictDataService {
Paging<SysDictDataVo> selectPageDictDataList(SysDictDataBo dictData, PageRequest<?> query);
Paging<SysDictDataVo> selectPageDictDataList(PageRequest<SysDictDataBo> query);
/**
*

View File

@ -17,7 +17,7 @@ import java.util.List;
public interface ISysDictTypeService {
Paging<SysDictTypeVo> selectPageDictTypeList(SysDictTypeBo dictType, PageRequest<?> query);
Paging<SysDictTypeVo> selectPageDictTypeList( PageRequest<?> query);
/**
*

View File

@ -17,7 +17,7 @@ import java.util.List;
public interface ISysNoticeService {
Paging<SysNoticeVo> selectPageNoticeList(SysNoticeBo notice, PageRequest<?> query);
Paging<SysNoticeVo> selectPageNoticeList( PageRequest<SysNoticeBo> query);
/**
*

View File

@ -29,7 +29,7 @@ public interface ISysOssConfigService {
/**
*
*/
Paging<SysOssConfigVo> queryPageList(SysOssConfigBo bo, PageRequest<?> query);
Paging<SysOssConfigVo> queryPageList(PageRequest<SysOssConfigBo> query);
/**

View File

@ -6,6 +6,7 @@ import cc.iotkit.model.system.SysUserRole;
import cc.iotkit.system.dto.bo.SysRoleBo;
import cc.iotkit.system.dto.vo.SysRoleVo;
import java.util.Collection;
import java.util.List;
import java.util.Set;
@ -151,7 +152,7 @@ public interface ISysRoleService {
* @param roleIds ID
* @return
*/
void deleteRoleByIds(Long[] roleIds);
void deleteRoleByIds(Collection<Long> roleIds);
/**
*

View File

@ -7,6 +7,7 @@ import cc.iotkit.common.constant.UserConstants;
import cc.iotkit.common.exception.BizException;
import cc.iotkit.common.redis.utils.CacheUtils;
import cc.iotkit.common.service.ConfigService;
import cc.iotkit.common.tenant.helper.TenantHelper;
import cc.iotkit.common.utils.MapstructUtils;
import cc.iotkit.common.utils.SpringUtils;
import cc.iotkit.common.utils.StringUtils;
@ -15,6 +16,7 @@ import cc.iotkit.model.system.SysConfig;
import cc.iotkit.system.dto.bo.SysConfigBo;
import cc.iotkit.system.dto.vo.SysConfigVo;
import cc.iotkit.system.service.ISysConfigService;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
@ -76,14 +78,17 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
*/
@Override
public boolean selectRegisterEnabled(String tenantId) {
// SysConfig retConfig = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>()
// .eq(SysConfig::getConfigKey, "sys.account.registerUser")
// .eq(TenantHelper.isEnable(),SysConfig::getTenantId, tenantId));
// if (ObjectUtil.isNull(retConfig)) {
// return false;
// }
// return Convert.toBool(retConfig.getConfigValue());
return false;
SysConfig query = new SysConfig();
query.setConfigKey("sys.account.registerUser");
if(TenantHelper.isEnable()){
query.setTenantId(tenantId);
}
SysConfig retConfig = sysConfigData.findOneByCondition(query);
if (ObjectUtil.isNull(retConfig)) {
return false;
}
return Convert.toBool(retConfig.getConfigValue());
}
/**
@ -167,10 +172,9 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
*/
@Override
public boolean checkConfigKeyUnique(SysConfigBo config) {
// long configId = ObjectUtil.isNull(config.getId()) ? -1L : config.getId();
// SysConfig old = sysConfigData.findByConfigKey(config.getConfigKey());
// return !ObjectUtil.isNotNull(old) || old.getId() == configId;
return true;
long configId = ObjectUtil.isNull(config.getId()) ? -1L : config.getId();
SysConfig old = sysConfigData.findByConfigKey(config.getConfigKey());
return !ObjectUtil.isNotNull(old) || old.getId() == configId;
}
/**

View File

@ -11,6 +11,7 @@ import cc.iotkit.common.utils.TreeBuildUtils;
import cc.iotkit.data.system.ISysDeptData;
import cc.iotkit.data.system.ISysRoleData;
import cc.iotkit.data.system.ISysUserData;
import cc.iotkit.data.util.PredicateBuilder;
import cc.iotkit.model.system.SysDept;
import cc.iotkit.model.system.SysRole;
import cc.iotkit.system.dto.bo.SysDeptBo;
@ -27,6 +28,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import static cc.iotkit.data.model.QTbSysDept.tbSysDept;
/**
*
*
@ -93,10 +96,8 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
*/
@Override
public List<Long> selectDeptListByRoleId(Long roleId) {
SysRole role = sysRoleData.findById(roleId);
return sysDeptData.findByRoleId(roleId).stream()
.map(SysDept::getId).collect(Collectors.toList());
// return baseMapper.selectDeptListByRoleId(roleId, role.getDeptCheckStrictly());
}
/**
@ -144,10 +145,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
*/
@Override
public long selectNormalChildrenDeptById(Long deptId) {
// return baseMapper.selectCount(new LambdaQueryWrapper<SysDept>()
// .eq(SysDept::getStatus, UserConstants.DEPT_NORMAL)
// .apply(DataBaseHelper.findInSet(deptId, "ancestors")));
return 0;
return sysDeptData.selectNormalChildrenDeptById(deptId);
}
/**
@ -180,12 +178,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
*/
@Override
public boolean checkDeptNameUnique(SysDeptBo dept) {
// boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysDept>()
// .eq(SysDept::getDeptName, dept.getDeptName())
// .eq(SysDept::getParentId, dept.getParentId())
// .ne(ObjectUtil.isNotNull(dept.getDeptId()), SysDept::getDeptId, dept.getDeptId()));
// return !exist;
return false;
return sysDeptData.checkDeptNameUnique( dept.getDeptName(), dept.getParentId(), dept.getDeptId());
}
/**

View File

@ -28,13 +28,8 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
private final ISysDictData sysDictData;
@Override
public Paging<SysDictDataVo> selectPageDictDataList(SysDictDataBo dictData, PageRequest<?> query) {
return MapstructUtils.convert(
sysDictData.findByConditions(
dictData.to(SysDictData.class),
query.getPageNum(),
query.getPageSize()
), SysDictDataVo.class);
public Paging<SysDictDataVo> selectPageDictDataList( PageRequest<SysDictDataBo> query) {
return sysDictData.findAll(query.to(SysDictData.class) ).to(SysDictDataVo.class);
}
/**

View File

@ -39,12 +39,8 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
private final ISysDictData sysDictData;
@Override
public Paging<SysDictTypeVo> selectPageDictTypeList(SysDictTypeBo dictType, PageRequest<?> query) {
return MapstructUtils.convert(
sysDictTypeData.findByConditions(
dictType.to(SysDictType.class),
query.getPageNum(), query.getPageSize()),
SysDictTypeVo.class);
public Paging<SysDictTypeVo> selectPageDictTypeList( PageRequest<?> query) {
return sysDictTypeData.findAll(query.to(SysDictType.class)).to(SysDictTypeVo.class);
}
/**

View File

@ -30,8 +30,8 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
private ISysNoticeData sysNoticeData;
@Override
public Paging<SysNoticeVo> selectPageNoticeList(SysNoticeBo notice, PageRequest<?> query) {
return new Paging<>();
public Paging<SysNoticeVo> selectPageNoticeList( PageRequest<SysNoticeBo> query) {
return sysNoticeData.findAll(query.to(SysNotice.class)).to(SysNoticeVo.class);
}
/**
@ -53,7 +53,8 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
*/
@Override
public List<SysNoticeVo> selectNoticeList(SysNoticeBo notice) {
return new ArrayList<>();
List<SysNotice> allByCondition = sysNoticeData.findAllByCondition(notice.to(SysNotice.class));
return MapstructUtils.convert(allByCondition, SysNoticeVo.class);
}
/**

View File

@ -74,8 +74,8 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
}
@Override
public Paging<SysOssConfigVo> queryPageList(SysOssConfigBo bo, PageRequest<?> query) {
return null;
public Paging<SysOssConfigVo> queryPageList(PageRequest<SysOssConfigBo> query) {
return baseData.findAll(query.to(SysOssConfig.class)).to(SysOssConfigVo.class);
}

View File

@ -330,7 +330,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteRoleByIds(Long[] roleIds) {
public void deleteRoleByIds(Collection<Long> roleIds) {
for (Long roleId : roleIds) {
checkRoleAllowed(roleId);
checkRoleDataScope(roleId);
@ -339,12 +339,12 @@ public class SysRoleServiceImpl implements ISysRoleService {
throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName()));
}
}
List<Long> ids = Arrays.asList(roleIds);
// 删除角色与菜单关联
iSysRoleMenuData.deleteByRoleId(ids);
iSysRoleMenuData.deleteByRoleId(roleIds);
// 删除角色与部门关联
iSysRoleDeptData.deleteByRoleId(ids);
iSysRoleData.deleteByIds(ids);
iSysRoleDeptData.deleteByRoleId(roleIds);
iSysRoleData.deleteByIds(roleIds);
}
/**