diff --git a/tyr-api/src/main/java/cn/axzo/tyr/client/common/enums/ProductTypeEnum.java b/tyr-api/src/main/java/cn/axzo/tyr/client/common/enums/ProductTypeEnum.java new file mode 100644 index 00000000..adb92705 --- /dev/null +++ b/tyr-api/src/main/java/cn/axzo/tyr/client/common/enums/ProductTypeEnum.java @@ -0,0 +1,40 @@ +package cn.axzo.tyr.client.common.enums; + +import com.baomidou.mybatisplus.annotation.EnumValue; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +/** + * @author cn + * @version 1.0 + * @description + * @date 2022/5/18 14:57 + * + * @deprecated 这个类只用在历史代码迁移上,新的业务里不要用这个。 + * 因为一个Feature可能不只是属于一个产品类型。就像一个Feature不只是属于一个产品板块一样。 + * 这种单一化的判断会引来新的BUG。 + * + */ +@Getter +@RequiredArgsConstructor +@Deprecated +public enum ProductTypeEnum { + + /** + * 总包企业产品 + */ + PT_ENT_ZB(1, "PT_ENT_ZB"), //原来叫CEMS,但这个名字跟terminal搅在一起了,所以重新做了枚举值来区分 + /** + * 总包项目产品 + */ + PT_PROJ(2, "PT_PROJ"), //原来叫PMS,但这个名字跟terminal搅在一起了,所以重新做了枚举值来区分 + PT_OMS(6, "PT_OMS") // + ; + + //TODO:以后增加其他的产品类型 -- 3:政企产品 4:分包企业产品 5:班组产品 + + + @EnumValue + private final Integer code; + private final String name; +} diff --git a/tyr-api/src/main/java/cn/axzo/tyr/client/feign/ProductApi.java b/tyr-api/src/main/java/cn/axzo/tyr/client/feign/ProductApi.java index 60dde2a0..be38b13d 100644 --- a/tyr-api/src/main/java/cn/axzo/tyr/client/feign/ProductApi.java +++ b/tyr-api/src/main/java/cn/axzo/tyr/client/feign/ProductApi.java @@ -184,4 +184,14 @@ public interface ProductApi { */ @PostMapping("api/product/listWithOutDelete") CommonResponse> listWithOutDelete(@RequestBody @Valid ProductQueryReq req); + + /** + * 用于创建/获取OMS的产品使用 + * 主要用于OMS第一次创建服务包时进行数据处理使用 + * + * 首先会获取OMS类型的基础产品,获取成功就直接返回 + * 未获取到会直接创建一个类型是OMS的产品,默认选中所有的OMS类型菜单 + */ + @PostMapping("api/product/createOrGetOmsProduct") + CommonResponse createOrGetOmsProduct(); } diff --git a/tyr-api/src/main/java/cn/axzo/tyr/client/feign/SaasRoleApi.java b/tyr-api/src/main/java/cn/axzo/tyr/client/feign/SaasRoleApi.java index 1218c26a..5b28092a 100644 --- a/tyr-api/src/main/java/cn/axzo/tyr/client/feign/SaasRoleApi.java +++ b/tyr-api/src/main/java/cn/axzo/tyr/client/feign/SaasRoleApi.java @@ -50,4 +50,10 @@ public interface SaasRoleApi { */ @PostMapping("api/saas/role/batchFindSuperAdmin") CommonResponse> batchFindSuperAdmin(@RequestBody @Valid List adminReqs); + + /** + * 根据 工作台id + 单位id 查询已关联的人员列表 work for: 工作流 + */ + @PostMapping("api/saas/role/findSuperAdmin") + CommonResponse findSuperAdmin(@RequestBody @Valid QuerySuperAdminReq req); } diff --git a/tyr-api/src/main/java/cn/axzo/tyr/client/model/req/AddValidGroup.java b/tyr-api/src/main/java/cn/axzo/tyr/client/model/req/AddValidGroup.java new file mode 100644 index 00000000..9aa93dc9 --- /dev/null +++ b/tyr-api/src/main/java/cn/axzo/tyr/client/model/req/AddValidGroup.java @@ -0,0 +1,9 @@ +package cn.axzo.tyr.client.model.req; + +/** + * @author: wangli + * @date: 2022/1/26 10:44 + */ +public interface AddValidGroup { + +} diff --git a/tyr-api/src/main/java/cn/axzo/tyr/client/model/req/SaasProductSaveOrUpdateReq.java b/tyr-api/src/main/java/cn/axzo/tyr/client/model/req/SaasProductSaveOrUpdateReq.java new file mode 100644 index 00000000..ee7dca65 --- /dev/null +++ b/tyr-api/src/main/java/cn/axzo/tyr/client/model/req/SaasProductSaveOrUpdateReq.java @@ -0,0 +1,53 @@ +package cn.axzo.tyr.client.model.req; + +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @author : liuchuntao + * @date : 2022/5/16 15:15 + * @description : saas 产品新增或修改 + */ +@Data +public class SaasProductSaveOrUpdateReq { + + /** + * id + */ + @NotNull(message = "修改产品Id不能为空",groups = UpdateValidGroup.class) + protected Long id; + + /** + * 1:总包企业产品 2:总包项目产品 3:政企产品 4:分包企业产品 5:班组产品 + */ + @NotNull(message = "产品类型不能为空",groups = {AddValidGroup.class,UpdateValidGroup.class}) + private Integer productType; + + /** + * 产品名字 + */ + @NotNull(message = "产品名字不能为空", groups = {AddValidGroup.class, UpdateValidGroup.class}) + @Length(max = 50, message = "产品名字长度不能超过50", groups = {AddValidGroup.class, + UpdateValidGroup.class}) + private String productName; + + /** + * 基础产品与否 0:基础产品 1:普通产品 + */ + @NotNull(message = "基础产品与否不能为空",groups = {AddValidGroup.class,UpdateValidGroup.class}) + private Integer commonProduct; + /** + * 产品板块备注 + */ + private String remark; + + /** + * 功能列表 + */ + @NotNull(message = "产品绑定的功能列表不能为空",groups = {AddValidGroup.class,UpdateValidGroup.class}) + private List featureIds; + +} diff --git a/tyr-api/src/main/java/cn/axzo/tyr/client/model/req/UpdateValidGroup.java b/tyr-api/src/main/java/cn/axzo/tyr/client/model/req/UpdateValidGroup.java new file mode 100644 index 00000000..6fa63a83 --- /dev/null +++ b/tyr-api/src/main/java/cn/axzo/tyr/client/model/req/UpdateValidGroup.java @@ -0,0 +1,9 @@ +package cn.axzo.tyr.client.model.req; + +/** + * @author: wangli + * @date: 2022/1/26 10:44 + */ +public interface UpdateValidGroup { + +} diff --git a/tyr-api/src/main/java/cn/axzo/tyr/client/model/res/SaasProductResp.java b/tyr-api/src/main/java/cn/axzo/tyr/client/model/res/SaasProductResp.java new file mode 100644 index 00000000..9f94412b --- /dev/null +++ b/tyr-api/src/main/java/cn/axzo/tyr/client/model/res/SaasProductResp.java @@ -0,0 +1,47 @@ +package cn.axzo.tyr.client.model.res; + +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * @author : liuchuntao + * @date : 2022/5/16 15:33 + * @description : + */ +@Data +public class SaasProductResp { + + /** + * 主键 + */ + private Long id; + /** + * 1:总包企业产品 2:总包项目产品 3:政企产品 4:分包企业产品 5:班组产品 + */ + private Integer productType; + /** + * 产品板块名字 + */ + private String productName; + /** + * 基础产品与否 0:基础产品 1:普通产品 + */ + private Integer commonProduct; + /** + * 产品板块备注 + */ + private String remark; + + private Date createAt; + + + private Date updateAt; + + /** + * 获取产品绑定的功能列表 + */ + private List featureIds; + +} diff --git a/tyr-server/src/main/java/cn/axzo/tyr/server/controller/permission/SaasRoleApiImpl.java b/tyr-server/src/main/java/cn/axzo/tyr/server/controller/permission/SaasRoleApiImpl.java index 7d5a68d6..b704447c 100644 --- a/tyr-server/src/main/java/cn/axzo/tyr/server/controller/permission/SaasRoleApiImpl.java +++ b/tyr-server/src/main/java/cn/axzo/tyr/server/controller/permission/SaasRoleApiImpl.java @@ -1,11 +1,15 @@ package cn.axzo.tyr.server.controller.permission; +import cn.axzo.tyr.client.model.permission.IdentityKey; +import cn.axzo.basics.profiles.api.IdentityProfileApi; import cn.axzo.basics.profiles.api.OperatorProfileServiceApi; import cn.axzo.basics.profiles.api.RegulatorProfileApi; import cn.axzo.basics.profiles.api.UserProfileServiceApi; import cn.axzo.basics.profiles.api.vo.profiles.PersonPostVo; import cn.axzo.basics.profiles.api.vo.profiles.PractitionerAndPersonPostVO; +import cn.axzo.basics.profiles.api.vo.request.FindIdentityProfileReq; import cn.axzo.basics.profiles.common.enums.IdentityType; +import cn.axzo.basics.profiles.dto.basic.IdentityProfileDto; import cn.axzo.basics.profiles.dto.basic.OperatorProfileDto; import cn.axzo.basics.profiles.dto.basic.PersonProfileDto; import cn.axzo.basics.profiles.dto.basic.PersonUnion; @@ -31,6 +35,7 @@ import cn.axzo.tyr.server.util.RpcInternalUtil; import cn.azxo.framework.common.model.CommonResponse; import cn.hutool.core.collection.CollUtil; import cn.hutool.extra.pinyin.PinyinUtil; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.google.common.collect.Lists; import lombok.extern.slf4j.Slf4j; import lombok.var; @@ -57,6 +62,8 @@ public class SaasRoleApiImpl implements SaasRoleApi { private SaasAccountApi saasAccountApi; @Autowired private SaasRoleUserRelationService saasRoleUserRelationService; + @Autowired + private IdentityProfileApi identityProfileApi; @Override @Transactional(rollbackFor = Exception.class) @@ -197,4 +204,38 @@ public class SaasRoleApiImpl implements SaasRoleApi { return CommonResponse.success(saasRoleUserRelationService.findBathSuperAdmin(adminReqs)); } + + @Override + public CommonResponse findSuperAdmin(QuerySuperAdminReq req) { + return CommonResponse.success(doFindSuperAdmin(req)); + } + + private SuperAminInfoResp doFindSuperAdmin(QuerySuperAdminReq req) { + List ids = saasRoleUserRelationService.getSuperAdminIdsByWorkspaceAndOu( + req.getWorkspaceId(), req.getOuId()); + if (CollectionUtils.isEmpty(ids)) { + return null; + } + + IdentityProfileDto profile = RpcInternalUtil.checkAndGetData(identityProfileApi.findIdentityProfile(FindIdentityProfileReq.builder() + .identityId(ids.get(0).getIdentityId()) + .identityType(ids.get(0).getIdentityType()) + .build())); + + if (profile == null) { + return null; + } + + SuperAminInfoResp resp = new SuperAminInfoResp(); + resp.setOuId(req.getOuId()); + resp.setIdentityId(ids.get(0).getIdentityId()); + resp.setIdentityType(ids.get(0).getIdentityType()); + if (profile.getPersonProfile() != null) { + resp.setPhone(profile.getPersonProfile().getPhone()); + resp.setRealName(profile.getPersonProfile().getRealName()); + } + resp.setWorkspaceId(req.getWorkspaceId()); + + return resp; + } } diff --git a/tyr-server/src/main/java/cn/axzo/tyr/server/controller/product/ProductController.java b/tyr-server/src/main/java/cn/axzo/tyr/server/controller/product/ProductController.java index 057d2c8d..dd3ebd08 100644 --- a/tyr-server/src/main/java/cn/axzo/tyr/server/controller/product/ProductController.java +++ b/tyr-server/src/main/java/cn/axzo/tyr/server/controller/product/ProductController.java @@ -1,9 +1,14 @@ package cn.axzo.tyr.server.controller.product; import cn.axzo.basics.common.BeanMapper; +import cn.axzo.basics.common.page.PageResult; +import cn.axzo.framework.auth.domain.TerminalInfo; import cn.axzo.framework.domain.web.result.ApiPageResult; import cn.axzo.framework.domain.web.result.ApiResult; +import cn.axzo.pudge.core.service.ServiceException; +import cn.axzo.tyr.client.common.enums.ProductTypeEnum; import cn.axzo.tyr.client.feign.ProductApi; +import cn.axzo.tyr.client.model.permission.SaasFeatureBO; import cn.axzo.tyr.client.model.product.OldUpdateFeatureRelationRequestV2; import cn.axzo.tyr.client.model.product.ProductAddReq; import cn.axzo.tyr.client.model.product.ProductDetailReq; @@ -17,16 +22,20 @@ import cn.axzo.tyr.client.model.product.ProductVO; import cn.axzo.tyr.client.model.req.ProductQueryReq; import cn.axzo.tyr.client.model.req.ProductSaveReq; import cn.axzo.tyr.client.model.req.SaasProductQueryReq; +import cn.axzo.tyr.client.model.req.SaasProductSaveOrUpdateReq; import cn.axzo.tyr.client.model.req.UpdateProductStatusReq; import cn.axzo.tyr.client.model.res.GovernmentTerminalResp; import cn.axzo.tyr.client.model.res.ProductQueryResp; +import cn.axzo.tyr.client.model.res.SaasProductResp; import cn.axzo.tyr.client.model.res.WorkspaceProductResp; import cn.axzo.tyr.server.model.PermissionCacheKey; import cn.axzo.tyr.server.repository.entity.ProductModule; import cn.axzo.tyr.server.service.PermissionCacheService; import cn.axzo.tyr.server.service.ProductFeatureRelationService; import cn.axzo.tyr.server.service.ProductService; +import cn.axzo.tyr.server.service.SaasFeatureResourceService; import cn.azxo.framework.common.model.CommonResponse; +import cn.hutool.core.collection.CollectionUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.util.CollectionUtils; @@ -35,6 +44,7 @@ import org.springframework.web.bind.annotation.RestController; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; /** * 产品相关 API 实现 @@ -50,6 +60,8 @@ public class ProductController implements ProductApi { private final ProductService productService; private final ProductFeatureRelationService productFeatureRelationService; private final PermissionCacheService permissionCacheService; + private final SaasFeatureResourceService saasFeatureResourceService; + /** * 获取产品基础信息的列表 * @@ -213,4 +225,37 @@ public class ProductController implements ProductApi { List resps = BeanMapper.copyList(respList,ProductQueryResp.class); return CommonResponse.success(resps); } + + @Override + public CommonResponse createOrGetOmsProduct() { + SaasProductQueryReq saasProductQueryReq = new SaasProductQueryReq(); + saasProductQueryReq.setProductType(ProductTypeEnum.PT_OMS.getCode()); + saasProductQueryReq.setCommonProduct(0); + + PageResult saasProductRespPageResult = productService.saasProductList(saasProductQueryReq); + Long totalCount = saasProductRespPageResult.getTotalCount(); + if (totalCount!=null&& totalCount> 0) { + List omsBaseProduct = saasProductRespPageResult.getData(); + if (CollectionUtil.isNotEmpty(omsBaseProduct)) { + // 随便取哪一个ID都可以,主要用于数据初始化 + return CommonResponse.success(omsBaseProduct.get(0).getId()); + } + } + // 没有默认产品,创建 + SaasProductSaveOrUpdateReq saasProductSaveOrUpdateReq = new SaasProductSaveOrUpdateReq(); + saasProductSaveOrUpdateReq.setProductType(ProductTypeEnum.PT_OMS.getCode()); + saasProductSaveOrUpdateReq.setProductName("OMS基础产品"); + saasProductSaveOrUpdateReq.setCommonProduct(0); + saasProductSaveOrUpdateReq.setRemark("OMS基础产品"); + + + List saasFeatureBOS = saasFeatureResourceService.listAllFeatureByTerminal(TerminalInfo.NT_OMS_WEB); + + if (CollectionUtil.isEmpty(saasFeatureBOS)) { + throw new ServiceException("生成OMS产品错误,未维护对应的菜单"); + } + saasProductSaveOrUpdateReq.setFeatureIds(saasFeatureBOS.stream().filter(e -> + e.getFeatureType().equals(3)).map(SaasFeatureBO::getId).collect(Collectors.toList())); + return CommonResponse.success(productService.productModuleCreate(saasProductSaveOrUpdateReq)); + } } diff --git a/tyr-server/src/main/java/cn/axzo/tyr/server/repository/dao/ProductModuleDao.java b/tyr-server/src/main/java/cn/axzo/tyr/server/repository/dao/ProductModuleDao.java index 1799733a..b9dd45ad 100644 --- a/tyr-server/src/main/java/cn/axzo/tyr/server/repository/dao/ProductModuleDao.java +++ b/tyr-server/src/main/java/cn/axzo/tyr/server/repository/dao/ProductModuleDao.java @@ -1,9 +1,12 @@ package cn.axzo.tyr.server.repository.dao; +import cn.axzo.basics.common.constant.enums.TableIsDeleteEnum; +import cn.axzo.basics.common.exception.ServiceException; import cn.axzo.tyr.client.model.req.SaasProductQueryReq; import cn.axzo.tyr.server.repository.entity.ProductModule; import cn.axzo.tyr.server.repository.mapper.ProductModuleMapper; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; @@ -29,5 +32,31 @@ public class ProductModuleDao extends ServiceImpl listByNameType(SaasProductQueryReq req) { + + if (StrUtil.isNotEmpty(req.getProductName()) && (req.getProductName().contains("%") || req.getProductName().contains("_"))) { + throw new ServiceException("涉及模糊查询禁止传入特殊字符串"); + } + + + + return lambdaQuery().like(StrUtil.isNotEmpty(req.getProductName()), ProductModule::getProductName, + req.getProductName()) + .eq(req.getProductType() != null, ProductModule::getProductType, req.getProductType()) + .eq(req.getCommonProduct() != null, ProductModule::getCommonProduct, req.getCommonProduct()) + .eq(ProductModule::getIsDelete, TableIsDeleteEnum.NORMAL.value) + .orderByDesc(ProductModule::getCreateAt) + .page(req.toPage()); + } + + public ProductModule queryByName(String productName) { + List list = lambdaQuery().eq(ProductModule::getProductName, productName) + .eq(ProductModule::getIsDelete, TableIsDeleteEnum.NORMAL.value).list(); + if (CollectionUtils.isNotEmpty(list)) { + return list.get(0); + } + return null; + } } diff --git a/tyr-server/src/main/java/cn/axzo/tyr/server/repository/dao/SaasFeatureDao.java b/tyr-server/src/main/java/cn/axzo/tyr/server/repository/dao/SaasFeatureDao.java index 33c5b29e..7e0f92bc 100644 --- a/tyr-server/src/main/java/cn/axzo/tyr/server/repository/dao/SaasFeatureDao.java +++ b/tyr-server/src/main/java/cn/axzo/tyr/server/repository/dao/SaasFeatureDao.java @@ -1,5 +1,6 @@ package cn.axzo.tyr.server.repository.dao; +import cn.axzo.pudge.core.persistence.BaseEntity; import cn.axzo.tyr.server.repository.entity.SaasFeature; import com.baomidou.mybatisplus.extension.service.IService; @@ -31,4 +32,6 @@ public interface SaasFeatureDao extends IService { List getChildByParentId(Long parentId); List listAllFeature(); + + List listAllFeatureByTerminal(String terminal); } \ No newline at end of file diff --git a/tyr-server/src/main/java/cn/axzo/tyr/server/repository/dao/SaasRoleUserRelationDao.java b/tyr-server/src/main/java/cn/axzo/tyr/server/repository/dao/SaasRoleUserRelationDao.java index 3060df1d..7e449534 100644 --- a/tyr-server/src/main/java/cn/axzo/tyr/server/repository/dao/SaasRoleUserRelationDao.java +++ b/tyr-server/src/main/java/cn/axzo/tyr/server/repository/dao/SaasRoleUserRelationDao.java @@ -8,6 +8,7 @@ import cn.axzo.tyr.client.model.BaseWorkspaceModel; import cn.axzo.tyr.client.model.enums.IdentityType; import cn.axzo.tyr.client.model.enums.SaasJobTypeEnum; import cn.axzo.tyr.client.model.permission.IdentityAndAccountDTO; +import cn.axzo.tyr.client.model.permission.IdentityKey; import cn.axzo.tyr.client.model.permission.QueryIdentityByPermissionDTO; import cn.axzo.tyr.client.model.roleuser.dto.IdentityInfo; import cn.axzo.tyr.server.job.UserRoleRelationCleanJob; @@ -233,5 +234,10 @@ public class SaasRoleUserRelationDao extends ServiceImpl findBathSuperAdmin(List req) { return saasRoleUserRelationMapper.findBathSuperAdmin(req); } + + //TODO: 加一个roleIds + public List listIdentityKeysByParams(QueryUserRoleReq req) { + return saasRoleUserRelationMapper.listIdentityKeysByParams(req); + } } diff --git a/tyr-server/src/main/java/cn/axzo/tyr/server/repository/dao/impl/SaasFeatureDaoImpl.java b/tyr-server/src/main/java/cn/axzo/tyr/server/repository/dao/impl/SaasFeatureDaoImpl.java index 1340e5f2..a87b1875 100644 --- a/tyr-server/src/main/java/cn/axzo/tyr/server/repository/dao/impl/SaasFeatureDaoImpl.java +++ b/tyr-server/src/main/java/cn/axzo/tyr/server/repository/dao/impl/SaasFeatureDaoImpl.java @@ -65,4 +65,12 @@ public class SaasFeatureDaoImpl extends ServiceImpl listAllFeature() { return lambdaQuery().eq(BaseEntity::getIsDelete, 0).list(); } + + @Override + public List listAllFeatureByTerminal(String terminal) { + return lambdaQuery() + .eq(BaseEntity::getIsDelete, 0) + .eq(SaasFeature::getTerminal, terminal) + .list(); + } } \ No newline at end of file diff --git a/tyr-server/src/main/java/cn/axzo/tyr/server/repository/mapper/SaasRoleUserRelationMapper.java b/tyr-server/src/main/java/cn/axzo/tyr/server/repository/mapper/SaasRoleUserRelationMapper.java index 4adf977f..3b042492 100644 --- a/tyr-server/src/main/java/cn/axzo/tyr/server/repository/mapper/SaasRoleUserRelationMapper.java +++ b/tyr-server/src/main/java/cn/axzo/tyr/server/repository/mapper/SaasRoleUserRelationMapper.java @@ -4,6 +4,7 @@ import cn.axzo.basics.profiles.common.enums.IdentityType; import cn.axzo.karma.client.model.dto.ProjectWorkBaseDTO; import cn.axzo.tyr.client.model.enums.SaasJobTypeEnum; import cn.axzo.tyr.client.model.permission.IdentityAndAccountDTO; +import cn.axzo.tyr.client.model.permission.IdentityKey; import cn.axzo.tyr.client.model.permission.QueryIdentityByPermissionDTO; import cn.axzo.tyr.server.model.QueryUserRoleReq; import cn.axzo.tyr.server.model.SaasUserRoleExBO; @@ -51,6 +52,8 @@ public interface SaasRoleUserRelationMapper extends BaseMapper findBathSuperAdmin(@Param("req") List req); + List listIdentityKeysByParams(@Param("req") QueryUserRoleReq req); + @Data @Builder @NoArgsConstructor diff --git a/tyr-server/src/main/java/cn/axzo/tyr/server/service/ProductService.java b/tyr-server/src/main/java/cn/axzo/tyr/server/service/ProductService.java index e0cc867f..e06a82ca 100644 --- a/tyr-server/src/main/java/cn/axzo/tyr/server/service/ProductService.java +++ b/tyr-server/src/main/java/cn/axzo/tyr/server/service/ProductService.java @@ -1,5 +1,6 @@ package cn.axzo.tyr.server.service; +import cn.axzo.basics.common.page.PageResult; import cn.axzo.framework.domain.web.result.ApiPageResult; import cn.axzo.framework.domain.web.result.ApiResult; import cn.axzo.tyr.client.model.product.ProductAddReq; @@ -9,8 +10,10 @@ import cn.axzo.tyr.client.model.product.ProductUpdateReq; import cn.axzo.tyr.client.model.product.ProductVO; import cn.axzo.tyr.client.model.req.ProductSaveReq; import cn.axzo.tyr.client.model.req.SaasProductQueryReq; +import cn.axzo.tyr.client.model.req.SaasProductSaveOrUpdateReq; import cn.axzo.tyr.client.model.req.UpdateProductStatusReq; import cn.axzo.tyr.client.model.res.GovernmentTerminalResp; +import cn.axzo.tyr.client.model.res.SaasProductResp; import cn.axzo.tyr.client.model.res.WorkspaceProductResp; import cn.axzo.tyr.server.repository.entity.ProductModule; @@ -45,4 +48,17 @@ public interface ProductService { ApiResult getWorkspaceProduct(String workspaceType); List saasProductListWithOutDelete(SaasProductQueryReq queryReq); + + /*** + * 获取产品列表 + * @param req + * @return + */ + PageResult saasProductList(SaasProductQueryReq req); + + /** + * 创建产品 + * @param req + */ + Long productModuleCreate(SaasProductSaveOrUpdateReq req); } diff --git a/tyr-server/src/main/java/cn/axzo/tyr/server/service/SaasFeatureResourceService.java b/tyr-server/src/main/java/cn/axzo/tyr/server/service/SaasFeatureResourceService.java index 4b36b4e7..6322bfd1 100644 --- a/tyr-server/src/main/java/cn/axzo/tyr/server/service/SaasFeatureResourceService.java +++ b/tyr-server/src/main/java/cn/axzo/tyr/server/service/SaasFeatureResourceService.java @@ -1,6 +1,7 @@ package cn.axzo.tyr.server.service; import cn.axzo.foundation.page.PageResp; +import cn.axzo.tyr.client.model.permission.SaasFeatureBO; import cn.axzo.tyr.client.model.req.DeleteFeatureResourceReq; import cn.axzo.tyr.client.model.req.FeatureResourceTreeSaveReq; import cn.axzo.tyr.client.model.req.GetFeatureResourceTreeReq; @@ -70,6 +71,8 @@ public interface SaasFeatureResourceService extends IService listAllFeatureByTerminal(String terminal); + @Data @Builder @NoArgsConstructor diff --git a/tyr-server/src/main/java/cn/axzo/tyr/server/service/SaasProductModuleFeatureRelationService.java b/tyr-server/src/main/java/cn/axzo/tyr/server/service/SaasProductModuleFeatureRelationService.java new file mode 100644 index 00000000..3aeca33f --- /dev/null +++ b/tyr-server/src/main/java/cn/axzo/tyr/server/service/SaasProductModuleFeatureRelationService.java @@ -0,0 +1,19 @@ +package cn.axzo.tyr.server.service; + + +import cn.axzo.tyr.server.repository.entity.SaasProductModuleFeatureRelation; + +import java.util.List; + +/** + * 产品-菜单关联关系(SaasProductModuleFeatureRelation)表服务接口 + * + * @author makejava + * @since 2022-05-24 11:18:41 + */ +public interface SaasProductModuleFeatureRelationService { + + + boolean saveBatch(List relations); +} + diff --git a/tyr-server/src/main/java/cn/axzo/tyr/server/service/SaasRoleUserRelationService.java b/tyr-server/src/main/java/cn/axzo/tyr/server/service/SaasRoleUserRelationService.java index c6bd890e..1c7c79bd 100644 --- a/tyr-server/src/main/java/cn/axzo/tyr/server/service/SaasRoleUserRelationService.java +++ b/tyr-server/src/main/java/cn/axzo/tyr/server/service/SaasRoleUserRelationService.java @@ -3,6 +3,7 @@ package cn.axzo.tyr.server.service; import cn.axzo.basics.profiles.common.enums.IdentityType; import cn.axzo.framework.domain.page.PageResp; import cn.axzo.tyr.client.model.permission.IdentityAndAccountDTO; +import cn.axzo.tyr.client.model.permission.IdentityKey; import cn.axzo.tyr.client.model.permission.QueryIdentityByPermissionDTO; import cn.axzo.tyr.client.model.req.QuerySuperAdminReq; import cn.axzo.tyr.client.model.req.UpdateUserJobReq; @@ -47,4 +48,6 @@ public interface SaasRoleUserRelationService extends IService findBathSuperAdmin(List req); + + List getSuperAdminIdsByWorkspaceAndOu(Long workspaceId, Long ouId); } diff --git a/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/ProductServiceImpl.java b/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/ProductServiceImpl.java index d89a0ce5..2da39b7b 100644 --- a/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/ProductServiceImpl.java +++ b/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/ProductServiceImpl.java @@ -1,6 +1,7 @@ package cn.axzo.tyr.server.service.impl; import cn.axzo.basics.common.BeanMapper; +import cn.axzo.basics.common.page.PageResult; import cn.axzo.basics.common.util.AssertUtil; import cn.axzo.basics.profiles.api.UserProfileServiceApi; import cn.axzo.basics.profiles.dto.basic.PersonProfileDto; @@ -8,6 +9,7 @@ import cn.axzo.framework.domain.page.PageResp; import cn.axzo.framework.domain.web.result.ApiPageResult; import cn.axzo.framework.domain.web.result.ApiResult; import cn.axzo.pokonyan.config.mybatisplus.BaseEntity; +import cn.axzo.pudge.core.service.ServiceException; import cn.axzo.tyr.client.common.enums.PermissionRelationOperateLogSceneEnum; import cn.axzo.tyr.client.common.enums.ProductModuleFeatureRelationTypeEnum; import cn.axzo.tyr.client.model.dict.request.BasicDictQueryReq; @@ -25,8 +27,10 @@ import cn.axzo.tyr.client.model.product.ProductVO; import cn.axzo.tyr.client.model.req.PermissionOperateLogReq; import cn.axzo.tyr.client.model.req.ProductSaveReq; import cn.axzo.tyr.client.model.req.SaasProductQueryReq; +import cn.axzo.tyr.client.model.req.SaasProductSaveOrUpdateReq; import cn.axzo.tyr.client.model.req.UpdateProductStatusReq; import cn.axzo.tyr.client.model.res.GovernmentTerminalResp; +import cn.axzo.tyr.client.model.res.SaasProductResp; import cn.axzo.tyr.client.model.res.WorkspaceProductResp; import cn.axzo.tyr.server.model.RelationOperateLogProductBindResourceDO; import cn.axzo.tyr.server.repository.dao.ProductModuleDao; @@ -40,6 +44,7 @@ import cn.axzo.tyr.server.service.ProductService; import cn.axzo.tyr.server.service.SaasBasicDictService; import cn.axzo.tyr.server.service.SaasFeatureResourceService; import cn.axzo.tyr.server.service.SaasPgroupPermissionRelationOperateLogService; +import cn.axzo.tyr.server.service.SaasProductModuleFeatureRelationService; import cn.axzo.tyr.server.util.RpcInternalUtil; import cn.azxo.framework.common.constatns.Constants; import cn.hutool.core.collection.CollectionUtil; @@ -89,6 +94,7 @@ public class ProductServiceImpl implements ProductService { private final UserProfileServiceApi userProfileServiceApi; private final SaasPgroupPermissionRelationOperateLogService saasPgroupPermissionRelationOperateLogService; private final SaasFeatureResourceDao saasFeatureResourceDao; + private final SaasProductModuleFeatureRelationService saasProductModuleFeatureRelationService; @Override public ApiResult> list(ProductSearchListReq req) { @@ -578,4 +584,63 @@ public class ProductServiceImpl implements ProductService { return productModuleDao.listByNameTypeWithOutDelete(queryReq); } + + /** + * 获取产品列表 + * @param req + * @return + */ + @Override + public PageResult saasProductList(SaasProductQueryReq req) { + PageResult result = new PageResult(); + IPage productList = productModuleDao.listByNameType(req); + if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isEmpty(productList.getRecords())) { + return result; + } + List respList = BeanMapper.mapList(productList.getRecords(),SaasProductResp.class); + result.setData(respList); + result.setTotalCount(productList.getTotal()); + return result; + } + + /** + * 创建产品 + * @param req + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Long productModuleCreate(SaasProductSaveOrUpdateReq req) { + ProductModule productModule = saasProductCreate(req); + if(com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isNotEmpty(req.getFeatureIds())){ + List relations = new ArrayList<>(); + req.getFeatureIds().forEach(item -> { + SaasProductModuleFeatureRelation relation = new SaasProductModuleFeatureRelation(); + relation.setFeatureId(item); + relation.setProductModuleId(productModule.getId()); + relations.add(relation); + }); + saasProductModuleFeatureRelationService.saveBatch(relations); + + } + return productModule.getId(); + } + + /** + * 创建产品 + * @param req + */ + private ProductModule saasProductCreate(SaasProductSaveOrUpdateReq req) { + //校验对应产品是否存在 + ProductModule productModule = productModuleDao.queryByName(req.getProductName()); + if (productModule != null) { + throw new ServiceException("该名称对应产品已存在"); + } + ProductModule product = new ProductModule(); + product.setProductType(req.getProductType()); + product.setProductName(req.getProductName()); + product.setCommonProduct(req.getCommonProduct()); + product.setRemark(req.getRemark()); + productModuleDao.save(product); + return product; + } } diff --git a/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/SaasFeatureResourceServiceImpl.java b/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/SaasFeatureResourceServiceImpl.java index e6b701dc..69906f06 100644 --- a/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/SaasFeatureResourceServiceImpl.java +++ b/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/SaasFeatureResourceServiceImpl.java @@ -16,6 +16,7 @@ import cn.axzo.tyr.client.common.enums.FeatureResourceStatus; import cn.axzo.tyr.client.common.enums.FeatureResourceType; import cn.axzo.tyr.client.common.enums.PageElementFeatureResourceRelationTypeEnum; import cn.axzo.tyr.client.model.enums.DelegatedType; +import cn.axzo.tyr.client.model.permission.SaasFeatureBO; import cn.axzo.tyr.client.model.req.DeleteFeatureResourceReq; import cn.axzo.tyr.client.model.req.FeatureComponentSaveReq; import cn.axzo.tyr.client.model.req.FeatureResourceTreeSaveReq; @@ -914,4 +915,12 @@ public class SaasFeatureResourceServiceImpl extends ServiceImpl listAllFeatureByTerminal(String terminal) { + + List saasFeatures = saasFeatureDao.listAllFeatureByTerminal(terminal); + + return BeanMapper.mapList(saasFeatures, SaasFeatureBO.class); + } } diff --git a/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/SaasProductModuleFeatureRelationServiceImpl.java b/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/SaasProductModuleFeatureRelationServiceImpl.java new file mode 100644 index 00000000..98ba9efa --- /dev/null +++ b/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/SaasProductModuleFeatureRelationServiceImpl.java @@ -0,0 +1,36 @@ +package cn.axzo.tyr.server.service.impl; + +import cn.axzo.tyr.server.repository.dao.SaasProductModuleFeatureRelationDao; +import cn.axzo.tyr.server.repository.entity.SaasProductModuleFeatureRelation; +import cn.axzo.tyr.server.service.SaasProductModuleFeatureRelationService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * @author : liuchuntao + * @date : 2022/6/7 22:14 + * @description : 产品关联功能树实现 + */ +@Service +public class SaasProductModuleFeatureRelationServiceImpl implements + SaasProductModuleFeatureRelationService { + + @Autowired + private SaasProductModuleFeatureRelationDao relationDao; + + + /** + * 产品-feature批量保存 + * @param relations + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public boolean saveBatch(List relations) { + return relationDao.saveBatch(relations); + } + +} diff --git a/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/SaasRoleUserRelationServiceImpl.java b/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/SaasRoleUserRelationServiceImpl.java index 4744fb4d..a396c5d1 100644 --- a/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/SaasRoleUserRelationServiceImpl.java +++ b/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/SaasRoleUserRelationServiceImpl.java @@ -22,6 +22,7 @@ import cn.axzo.pudge.core.service.ServiceException; import cn.axzo.tyr.client.common.enums.RoleTypeEnum; import cn.axzo.tyr.client.model.enums.SaasJobTypeEnum; import cn.axzo.tyr.client.model.permission.IdentityAndAccountDTO; +import cn.axzo.tyr.client.model.permission.IdentityKey; import cn.axzo.tyr.client.model.permission.QueryIdentityByPermissionDTO; import cn.axzo.tyr.client.model.req.QuerySuperAdminReq; import cn.axzo.tyr.client.model.req.UpdateUserJobReq; @@ -579,4 +580,14 @@ public class SaasRoleUserRelationServiceImpl extends ServiceImpl getSuperAdminIdsByWorkspaceAndOu(Long workspaceId, Long ouId) { + return saasRoleUserRelationDao.listIdentityKeysByParams( + QueryUserRoleReq.builder() + .workspaceId(workspaceId) + .ouId(ouId) + .roleTypes(Arrays.asList(RoleTypeEnum.SUPER_ADMIN.getValue())) + .build()); + } } diff --git a/tyr-server/src/main/resources/mapper/SaasRoleUserRelationMapper.xml b/tyr-server/src/main/resources/mapper/SaasRoleUserRelationMapper.xml index 7730578f..b20c4c74 100644 --- a/tyr-server/src/main/resources/mapper/SaasRoleUserRelationMapper.xml +++ b/tyr-server/src/main/resources/mapper/SaasRoleUserRelationMapper.xml @@ -149,7 +149,7 @@ - SELECT t1.* FROM saas_role_user_relation t1 inner join saas_role t2 on t1.role_id = t2.id WHERE t2.role_type = 'super_admin' AND @@ -161,4 +161,42 @@ AND t1.is_delete = 0 AND t2.is_delete = 0 + + \ No newline at end of file