Kaynağa Gözat

用户权限及菜单

tags/v1.0.0^2
chengwang 1 yıl önce
ebeveyn
işleme
0e6b2c635d
7 değiştirilmiş dosya ile 257 ekleme ve 12 silme
  1. +50
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/RoleController.java
  2. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Role.java
  3. +18
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/query/RoleQuery.java
  4. +7
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/role/IRoleService.java
  5. +111
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/role/RoleServiceImpl.java
  6. +70
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/RoleListVo.java
  7. +0
    -7
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/WorkOrderServiceImpl.java

+ 50
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/RoleController.java Dosyayı Görüntüle

@@ -1,9 +1,14 @@
package com.tuoheng.admin.controller;

import com.tuoheng.admin.entity.Role;
import com.tuoheng.admin.query.RoleQuery;
import com.tuoheng.admin.service.report.IReportService;
import com.tuoheng.admin.service.role.IRoleService;
import com.tuoheng.common.core.annotation.Log;
import com.tuoheng.common.core.enums.LogType;
import com.tuoheng.common.core.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

/**
* @Author ChengWang
@@ -13,9 +18,50 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("role")
public class RoleController {


@Autowired
private IReportService reportService;
private IRoleService roleService;

/**
* 获取角色列表
* @param roleQuery
* @return
*/
@GetMapping("/index")
public JsonResult index(RoleQuery roleQuery){
return roleService.getRoleList(roleQuery);
}

/**
* 添加角色
* @param entity
* @return
*/
@PostMapping("/add")
public JsonResult add(@RequestBody Role entity){
return roleService.editRole(entity);
}

/**
* 编辑角色
* @param entity
* @return
*/
@PutMapping("/edit")
public JsonResult edit(@RequestBody Role entity){
return roleService.editRole(entity);
}

/**
* 删除角色
*
* @param roleIds 角色ID
* @return
*/
@Log(title = "角色管理", logType = LogType.DELETE)
// @RequiresPermissions("sys:role:delete")
@DeleteMapping("/delete/{roleIds}")
public JsonResult delete(@PathVariable("roleIds") Integer[] roleIds) {
return roleService.deleteByList(roleIds);

}
}

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Role.java Dosyayı Görüntüle

@@ -25,7 +25,7 @@ public class Role extends BaseEntity {
/**
* 租户id
*/
private Integer tenantId;
private String tenantId;

/**
* 角色名称

+ 18
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/query/RoleQuery.java Dosyayı Görüntüle

@@ -0,0 +1,18 @@
package com.tuoheng.admin.query;


import com.tuoheng.common.core.common.BaseQuery;
import lombok.Data;

/**
* 角色查询条件
*/
@Data
public class RoleQuery extends BaseQuery {

/**
* 角色名称
*/
private String roleName;

}

+ 7
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/role/IRoleService.java Dosyayı Görüntüle

@@ -1,11 +1,18 @@
package com.tuoheng.admin.service.role;

import com.tuoheng.admin.entity.Role;
import com.tuoheng.admin.query.RoleQuery;
import com.tuoheng.common.core.common.IBaseService;
import com.tuoheng.common.core.utils.JsonResult;

/**
* @Author ChengWang
* @Date 2022/12/16
*/
public interface IRoleService extends IBaseService<Role> {
JsonResult getRoleList(RoleQuery roleQuery);

JsonResult editRole(Role entity);

JsonResult deleteByList(Integer[] roleIds);
}

+ 111
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/role/RoleServiceImpl.java Dosyayı Görüntüle

@@ -1,14 +1,125 @@
package com.tuoheng.admin.service.role;


import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.admin.entity.Role;
import com.tuoheng.admin.mapper.RoleMapper;
import com.tuoheng.admin.query.RoleQuery;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.admin.vo.RoleListVo;
import com.tuoheng.common.core.common.BaseEntity;
import com.tuoheng.common.core.common.BaseServiceImpl;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
* @Author ChengWang
* @Date 2022/12/16
*/
@Service
public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, Role> implements IRoleService {

@Autowired
private RoleMapper roleMapper;

/**
* 获取角色列表
* @param roleQuery
* @return
*/
@Override
public JsonResult getRoleList(RoleQuery roleQuery) {
IPage<Role> page = new Page<>(roleQuery.getPage(), roleQuery.getLimit());
// 查询条件
QueryWrapper<Role> queryWrapper = new QueryWrapper<>();
// 租户ID
queryWrapper.eq("tenant_id", CurrentUserUtil.getTenantId());
// 角色名称
if (!StringUtils.isEmpty(roleQuery.getRoleName())) {
queryWrapper.like("role_name", roleQuery.getRoleName());
}
queryWrapper.eq("mark", 1);
//queryWrapper.orderByAsc("sort");
queryWrapper.orderByAsc("create_time");
queryWrapper.ne("code", "super");
// 查询分页数据
IPage<Role> pageData = roleMapper.selectPage(page, queryWrapper);
pageData.convert(x -> {
RoleListVo roleListVo = Convert.convert(RoleListVo.class, x);
// TODO...
return roleListVo;
});
return JsonResult.success(pageData);
}

/**
* 添加或编辑
* @param entity
* @return
*/
@Override
public JsonResult editRole(Role entity) {
if (StringUtils.isNotEmpty(entity.getId())) {
// 更新
Integer count = roleMapper.selectCount(new LambdaQueryWrapper<Role>()
.ne(Role::getId, entity.getId())
.eq(Role::getTenantId, CurrentUserUtil.getTenantId())
.eq(Role::getCode, entity.getCode())
.eq(Role::getMark, 1));
//当前用户
entity.setUpdateUser(CurrentUserUtil.getUserId());
if (count > 0) {
return JsonResult.error("系统中已存在相同的角色编码");
}
} else {
// 添加
Integer count = roleMapper.selectCount(new LambdaQueryWrapper<Role>()
.eq(Role::getTenantId, CurrentUserUtil.getTenantId())
.eq(Role::getCode, entity.getCode())
.eq(Role::getMark, 1));
if (count > 0) {
return JsonResult.error("系统中已存在相同的角色编码");
}
entity.setCreateUser(CurrentUserUtil.getUserId());
entity.setTenantId(CurrentUserUtil.getTenantId());
}

return super.edit(entity);

}

/**
*删除角色
* @param roleIds
* @return
*/
@Override
public JsonResult deleteByList(Integer[] roleIds) {
List<Role> roles = roleMapper.selectList(new LambdaQueryWrapper<Role>()
.eq(Role::getStatus, 1)
.eq(BaseEntity::getMark, 1)
.eq(Role::getTenantId, CurrentUserUtil.getTenantId()));
List<String> collect = roles.stream().filter(t -> !t.getCode().equals("001"))
.filter(t -> t.getCode().equals("003"))
.filter(t -> t.getCode().equals("004"))
.filter(t -> t.getCode().equals("006"))
.filter(t -> t.getCode().equals("007"))
.filter(t -> t.getCode().equals("008"))
.map(t -> t.getId()).collect(Collectors.toList());
if (collect.contains(roleIds)) {
return JsonResult.error("初始化配置角色不能删除");
}


return null;
}
}

+ 70
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/RoleListVo.java Dosyayı Görüntüle

@@ -0,0 +1,70 @@
package com.tuoheng.admin.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
* 角色列表Vo
*/
@Data
public class RoleListVo {

/**
* 角色ID
*/
private Integer id;

/**
* 角色名称
*/
private String roleName;

/**
* 角色标签
*/
private String code;

/**
* 状态:1正常 2禁用
*/
private Integer status;

/**
* 备注
*/
private String remark;


/**
* 添加人
*/
private Integer createUser;

/**
* 创建时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;

/**
* 更新人
*/
private Integer updateUser;

/**
* 更新时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;

/**
* 有效标识
*/
private Integer mark;

}

+ 0
- 7
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/WorkOrderServiceImpl.java Dosyayı Görüntüle

@@ -390,10 +390,6 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
.eq(WorkOrder::getTenantId, tenantId)
.between(null != query.getOrderStartTime() && null != query.getOrderEndTime(), WorkOrder::getCreateTime, query.getOrderStartTime(), query.getOrderEndTime())
.eq(WorkOrder::getMark, 1));
//判空
if(StringUtils.isEmpty(workPageData.getRecords())){
return null;
}
//设置每条工单对应的已完成问题数量 问题状态为25问题已处理
List<WorkOrderInfoVo> collect = workPageData.getRecords().stream().map(s -> {
WorkOrderInfoVo vo = new WorkOrderInfoVo();
@@ -443,9 +439,6 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
.eq(WorkOrder::getTenantId, tenantId)
.between(null != query.getOrderStartTime() && null != query.getOrderEndTime(), WorkOrder::getCreateTime, query.getOrderStartTime(), query.getOrderEndTime())
.eq(WorkOrder::getMark, 1));
if(StringUtils.isEmpty(workPageData1.getRecords())){
return null;
}
//设置每条工单对应的状态问题数量
List<WorkOrderInfoVo> collect1 = workPageData1.getRecords().stream().map(g -> {
WorkOrderInfoVo vo = new WorkOrderInfoVo();

Yükleniyor…
İptal
Kaydet