diff --git a/cloud-etl-common/src/main/java/com/muyu/domain/req/AccreditReq.java b/cloud-etl-common/src/main/java/com/muyu/domain/req/AccreditReq.java index 0e53f3e..d6849e7 100644 --- a/cloud-etl-common/src/main/java/com/muyu/domain/req/AccreditReq.java +++ b/cloud-etl-common/src/main/java/com/muyu/domain/req/AccreditReq.java @@ -1,15 +1,18 @@ package com.muyu.domain.req; +import com.muyu.common.core.web.domain.BaseEntity; import lombok.AllArgsConstructor; -import lombok.Builder; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; @Data @AllArgsConstructor @NoArgsConstructor -@Builder -public class AccreditReq { +@SuperBuilder +@EqualsAndHashCode(callSuper = true) +public class AccreditReq extends BaseEntity { private Integer basicId; private Integer tableId; private Integer userId; diff --git a/cloud-etl-server/src/main/java/com/muyu/cloud/etl/controller/AccreditController.java b/cloud-etl-server/src/main/java/com/muyu/cloud/etl/controller/AccreditController.java index e03a866..b73f865 100644 --- a/cloud-etl-server/src/main/java/com/muyu/cloud/etl/controller/AccreditController.java +++ b/cloud-etl-server/src/main/java/com/muyu/cloud/etl/controller/AccreditController.java @@ -5,11 +5,9 @@ import com.muyu.common.core.domain.Result; import com.muyu.domain.Accredit; import com.muyu.domain.rep.AccreditDeptRep; import com.muyu.domain.rep.AccreditUserRep; +import com.muyu.domain.req.AccreditReq; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -39,5 +37,19 @@ public class AccreditController { return Result.success(repList); } + //根据数据源ID,和表Id,部门Id和用户Id 进行添加中间表 添加权限 + @PostMapping("/addMiddle") + public Result addMiddle(@RequestBody AccreditReq accreditReq) { + Integer i=accreditService.addMiddle(accreditReq); + return i>0?Result.success(i):Result.error(); + } + + //根据数据源Id,和表Id,部门Id和用户Id 删除中间表取消授权 + @PostMapping("/remove") + public Result remove(@RequestBody AccreditReq accreditReq) { + Integer i = accreditService.remove(accreditReq); + return i>0?Result.success(i):Result.error(); + } + } diff --git a/cloud-etl-server/src/main/java/com/muyu/cloud/etl/mapper/AccreditMapper.java b/cloud-etl-server/src/main/java/com/muyu/cloud/etl/mapper/AccreditMapper.java index 5294f86..b29a413 100644 --- a/cloud-etl-server/src/main/java/com/muyu/cloud/etl/mapper/AccreditMapper.java +++ b/cloud-etl-server/src/main/java/com/muyu/cloud/etl/mapper/AccreditMapper.java @@ -3,6 +3,7 @@ package com.muyu.cloud.etl.mapper; import com.muyu.domain.Accredit; import com.muyu.domain.rep.AccreditDeptRep; import com.muyu.domain.rep.AccreditUserRep; +import com.muyu.domain.req.AccreditReq; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -15,4 +16,8 @@ public interface AccreditMapper { List findDeptListStatus(@Param("tableId") Long tableId, @Param("basicId") Long basicId); List findUserListStatus(@Param("tableId") Long tableId, @Param("basicId") Long basicId); + + Integer addMiddle(AccreditReq accreditReq); + + Integer remove(AccreditReq accreditReq); } diff --git a/cloud-etl-server/src/main/java/com/muyu/cloud/etl/service/AccreditService.java b/cloud-etl-server/src/main/java/com/muyu/cloud/etl/service/AccreditService.java index 493ce37..cc25fa1 100644 --- a/cloud-etl-server/src/main/java/com/muyu/cloud/etl/service/AccreditService.java +++ b/cloud-etl-server/src/main/java/com/muyu/cloud/etl/service/AccreditService.java @@ -3,6 +3,7 @@ package com.muyu.cloud.etl.service; import com.muyu.domain.Accredit; import com.muyu.domain.rep.AccreditDeptRep; import com.muyu.domain.rep.AccreditUserRep; +import com.muyu.domain.req.AccreditReq; import java.util.List; @@ -12,4 +13,9 @@ public interface AccreditService { List findDeptListStatus(Long tableId, Long basicId); List findUserListStatus(Long tableId, Long basicId); + + Integer addMiddle(AccreditReq accreditReq); + + Integer remove(AccreditReq accreditReq); + } diff --git a/cloud-etl-server/src/main/java/com/muyu/cloud/etl/service/impl/AccreditServiceImpl.java b/cloud-etl-server/src/main/java/com/muyu/cloud/etl/service/impl/AccreditServiceImpl.java index 213161b..1dbcec1 100644 --- a/cloud-etl-server/src/main/java/com/muyu/cloud/etl/service/impl/AccreditServiceImpl.java +++ b/cloud-etl-server/src/main/java/com/muyu/cloud/etl/service/impl/AccreditServiceImpl.java @@ -5,6 +5,7 @@ import com.muyu.cloud.etl.service.AccreditService; import com.muyu.domain.Accredit; import com.muyu.domain.rep.AccreditDeptRep; import com.muyu.domain.rep.AccreditUserRep; +import com.muyu.domain.req.AccreditReq; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -30,4 +31,14 @@ public class AccreditServiceImpl implements AccreditService{ public List findUserListStatus(Long tableId, Long basicId) { return accreditMapper.findUserListStatus(tableId,basicId); } + + @Override + public Integer addMiddle(AccreditReq accreditReq) { + return accreditMapper.addMiddle(accreditReq); + } + + @Override + public Integer remove(AccreditReq accreditReq) { + return accreditMapper.remove(accreditReq); + } } diff --git a/cloud-etl-server/src/main/resources/mapper/AccreditMapper.xml b/cloud-etl-server/src/main/resources/mapper/AccreditMapper.xml index 5b6fd0e..89ce156 100644 --- a/cloud-etl-server/src/main/resources/mapper/AccreditMapper.xml +++ b/cloud-etl-server/src/main/resources/mapper/AccreditMapper.xml @@ -44,6 +44,18 @@ + + INSERT INTO `text`.`middle` + (`basic_id`, `user_id`, `table_id`, + `dept_id`, `create_by`, `create_time`, `update_by`, + `update_time`) VALUES ( #{basicId}, #{userId}, #{tableId}, #{deptId}); + + + + DELETE FROM middle WHERE basic_id=#{basicId} AND table_id=#{tableId} + AND (user_id=#{userId} OR dept_id=#{deptId}) + +