diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java index e45f2967..7bab38e0 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java @@ -147,33 +147,6 @@ public class YudaoSwaggerAutoConfiguration { .securityContexts(securityContexts()); } - @Bean("ERP") - @SuppressWarnings("all") - public Docket createErpApi() { - SwaggerProperties properties = swaggerProperties(); - ParameterBuilder ticketPar = new ParameterBuilder(); - List pars = new ArrayList<>(); - ticketPar.name("token").description("token") - .modelRef(new ModelRef("string")) - .parameterType("header") - .defaultValue("token" + " ") - .required(true) - .build(); - pars.add(ticketPar.build()); - return new Docket(DocumentationType.SWAGGER_2) - .groupName("进销存") - .enable(true) - .apiInfo(apiInfo(properties)) - .select() - .apis(RequestHandlerSelectors.basePackage("com.zsw.erp")) - .paths(PathSelectors.regex("/error.*").negate()) - .build() - .globalOperationParameters(pars) - //添加登陆认证 - .securitySchemes(securitySchemes()) - .globalRequestParameters(globalRequestParameters()) - .securityContexts(securityContexts()); - } // ========== apiInfo ========== diff --git a/yudao-ui-admin b/yudao-ui-admin index 940f54e8..beb44f8a 160000 --- a/yudao-ui-admin +++ b/yudao-ui-admin @@ -1 +1 @@ -Subproject commit 940f54e876f1c6ccc6e239c5990d34e83fb02b78 +Subproject commit beb44f8aa54a4e20a48985d771a0353641df4787 diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/config/FarmPermissionRuleCustomizer.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/config/FarmPermissionRuleCustomizer.java new file mode 100644 index 00000000..6b44d4a4 --- /dev/null +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/config/FarmPermissionRuleCustomizer.java @@ -0,0 +1,25 @@ +package cn.iocoder.yudao.module.farm.config; + +import cn.iocoder.yudao.framework.datapermission.core.dept.rule.DeptDataPermissionRuleCustomizer; +import cn.iocoder.yudao.module.farm.dal.dataobject.project.ProjectDO; +import cn.iocoder.yudao.module.farm.dal.dataobject.task.TaskDO; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class FarmPermissionRuleCustomizer { + + @Bean + public DeptDataPermissionRuleCustomizer farmCustomizer(){ + return rule -> { + rule.addDeptColumn(ProjectDO.class); + // user隔离不起作用 + rule.addUserColumn(ProjectDO.class,"creator"); + + rule.addDeptColumn(TaskDO.class); + rule.addUserColumn(TaskDO.class,"creator"); + }; + } + + +} diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/area/dto/AreaDTO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/area/dto/AreaDTO.java index 3c762a4e..746bfa12 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/area/dto/AreaDTO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/area/dto/AreaDTO.java @@ -8,4 +8,5 @@ public class AreaDTO { String firstAreaName; String secondAreaName; + } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/area/vo/AreaBaseVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/area/vo/AreaBaseVO.java index c9f50f3b..ee0822aa 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/area/vo/AreaBaseVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/area/vo/AreaBaseVO.java @@ -19,6 +19,8 @@ public class AreaBaseVO { private Long parentId; + private Double area; + private Boolean pretendDelete; diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/area/vo/AreaExcelVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/area/vo/AreaExcelVO.java index 6240b924..02389ed6 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/area/vo/AreaExcelVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/area/vo/AreaExcelVO.java @@ -22,6 +22,8 @@ public class AreaExcelVO { private Long parentId; + private Double area; + @ExcelProperty("") private Date createTime; diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/area/vo/AreaExportReqVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/area/vo/AreaExportReqVO.java index 1a5899c4..888aaf3d 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/area/vo/AreaExportReqVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/area/vo/AreaExportReqVO.java @@ -17,6 +17,8 @@ public class AreaExportReqVO { private Long parentId; + private Double area; + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @ApiModelProperty(value = "开始") private Date beginCreateTime; diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/ProjectController.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/ProjectController.java index 2b7ce290..cd4fffc3 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/ProjectController.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/ProjectController.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.farm.controller.admin.project; import cn.iocoder.yudao.framework.common.page.PageVO; +import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; import cn.iocoder.yudao.module.farm.annotation.FarmMsg; import cn.iocoder.yudao.module.farm.annotation.FarmMsgTypeEnum; import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectListDTO; @@ -87,6 +88,7 @@ public class ProjectController { @GetMapping("/page") @ApiOperation("获得农场项目分页") + @DataPermission @PreAuthorize("@ss.hasPermission('farm:project:query')") public CommonResult> getProjectPage(@Valid ProjectPageReqVO pageVO) { PageResult pageResult = projectService.getProjectPage(pageVO); diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java index 65ca30e4..f2c85e87 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.farm.controller.admin.task; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.NumberUtil; import cn.iocoder.yudao.framework.common.page.PageVO; +import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; import cn.iocoder.yudao.module.farm.annotation.FarmMsg; import cn.iocoder.yudao.module.farm.annotation.FarmMsgTypeEnum; import cn.iocoder.yudao.module.farm.controller.admin.task.dto.*; @@ -90,6 +91,7 @@ public class TaskController { @GetMapping("/page") @ApiOperation("获得农场项目分页") + @DataPermission @PreAuthorize("@ss.hasPermission('farm:task:query')") public CommonResult> getTaskPage(@Valid TaskPageReqVO pageVO) { PageResult pageResult = taskService.getTaskPage(pageVO); diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/area/AreaDO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/area/AreaDO.java index 9fb36541..59522c28 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/area/AreaDO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/area/AreaDO.java @@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.farm.dal.dataobject.area; import io.swagger.annotations.ApiModelProperty; import lombok.*; + +import java.math.BigDecimal; import java.util.*; import com.baomidou.mybatisplus.annotation.*; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; @@ -32,6 +34,8 @@ public class AreaDO extends BaseDO { private Long parentId; + private Double area; + @ApiModelProperty("假装删除") private Boolean pretendDelete; diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/project/ProjectDO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/project/ProjectDO.java index 1668dabf..872b800f 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/project/ProjectDO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/project/ProjectDO.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.farm.dal.dataobject.project; import cn.iocoder.yudao.module.farm.enums.ProjectStateEnum; +import cn.iocoder.yudao.module.system.dict.Dict; import com.alibaba.fastjson.JSONArray; import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import com.fasterxml.jackson.annotation.JsonFormat; @@ -77,4 +78,7 @@ public class ProjectDO extends BaseDO { @ApiModelProperty("假装删除") private Boolean pretendDelete; + @Dict(dictTable = "system_dept",dicCode = "id",dicText = "name") + private Long deptId; + } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/task/TaskDO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/task/TaskDO.java index 064e06a7..c74fafcf 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/task/TaskDO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/task/TaskDO.java @@ -1,9 +1,16 @@ package cn.iocoder.yudao.module.farm.dal.dataobject.task; +import cn.hutool.extra.spring.SpringUtil; import cn.iocoder.yudao.framework.mybatis.core.handler.ListIntToListLongTypeHandler; +import cn.iocoder.yudao.framework.security.core.LoginUser; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; +import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO; +import cn.iocoder.yudao.module.system.dict.Dict; +import cn.iocoder.yudao.module.system.service.permission.RoleService; import com.alibaba.fastjson.JSONArray; import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler; import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; +import com.google.common.collect.Maps; import io.swagger.annotations.ApiModelProperty; import cn.iocoder.yudao.module.farm.enums.TaskStatus; import lombok.*; @@ -85,4 +92,29 @@ public class TaskDO extends BaseDO { @ApiModelProperty("假装删除") private Boolean pretendDelete; + @ApiModelProperty("部门Id") + @Dict(dictTable = "system_dept",dicCode = "id",dicText = "name") + private Long deptId; + + @TableField(exist = false) + private Map actions; + + public Map getActions() { + actions = Maps.newHashMap(); + // 当前用户是否有资格编辑删除这个项目 + RoleService roleService = SpringUtil.getBean("roleServiceImpl"); + + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + assert loginUser != null; + List roles = roleService.getRolesFromCache(loginUser.getRoleIds()); + + Optional admin = roles.stream().filter(roleDO -> roleDO.getName().contains("管理员") || roleDO.getCode().contains("admin")).findAny(); + // 是创建者 或者 是 租户的管理员,可以更改项目 + actions.put("edit",getCreator().equals(loginUser.getId().toString()) || admin.isPresent()); + + // 应该加上,项目下面没有运行中的任务才可以删除 ,或者是在删除部分再做判断 ,此处只做权限显示 + actions.put("delete",getCreator().equals(loginUser.getId().toString()) || admin.isPresent()); + + return actions; + } } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java index db11a127..1470a305 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java @@ -10,6 +10,7 @@ import cn.hutool.system.oshi.CpuInfo; import cn.iocoder.yudao.framework.common.page.PageUtil; import cn.iocoder.yudao.framework.common.page.PageVO; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectListDTO; import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectPageDTO; import cn.iocoder.yudao.module.farm.controller.admin.task.dto.TaskAssemblyDTO; @@ -81,6 +82,7 @@ public class ProjectServiceImpl implements ProjectService { public Long createProject(ProjectCreateReqVO createReqVO) { // 插入 ProjectDO project = ProjectConvert.INSTANCE.convert(createReqVO); + project.setDeptId(Objects.requireNonNull(SecurityFrameworkUtils.getLoginUser()).getDeptId()); projectMapper.insert(project); // 返回 return project.getId();