diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/domain/XhpcTenantDomain.java b/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/domain/XhpcTenantDomain.java index 478fd149..ef2557ac 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/domain/XhpcTenantDomain.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/xhpc/system/domain/XhpcTenantDomain.java @@ -57,6 +57,11 @@ public class XhpcTenantDomain implements Serializable { */ private Integer stationPileQuote; + /** + * 运营商限额 + */ + private Integer operatorQuote; + /** * 过期时间 */ diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/XhpcTenantMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/XhpcTenantMapper.xml index 8c144675..50ce631d 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/XhpcTenantMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/XhpcTenantMapper.xml @@ -11,6 +11,7 @@ + @@ -22,7 +23,7 @@ tenant_id, tenant_name, `domain`, background_url, linkman, contact_number, address, - station_quote, station_pile_quote, expire_time, create_user, create_dept, create_time, + station_quote, station_pile_quote, operator_quote, expire_time, create_user, create_dept, create_time, update_user, update_time, `status`, is_deleted @@ -88,13 +89,13 @@ insert into xhpc_tenant (tenant_id, tenant_name, `domain`, background_url, - linkman, contact_number, address, + linkman, contact_number, address, operator_quote, station_quote, station_pile_quote, expire_time, create_user, create_dept, create_time, update_user, update_time, `status`, is_deleted) values (#{tenantId, jdbcType=VARCHAR}, #{tenantName,jdbcType=VARCHAR}, #{domain,jdbcType=VARCHAR}, #{backgroundUrl,jdbcType=VARCHAR}, - #{linkman,jdbcType=VARCHAR}, #{contactNumber,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, + #{linkman,jdbcType=VARCHAR}, #{contactNumber,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, #{operatorQuote} #{stationQuote,jdbcType=INTEGER}, #{stationPileQuote,jdbcType=INTEGER}, #{expireTime,jdbcType=TIMESTAMP}, #{createUser,jdbcType=BIGINT}, #{createDept,jdbcType=BIGINT}, sysdate(), #{updateUser,jdbcType=BIGINT}, sysdate(), #{status,jdbcType=INTEGER}, @@ -124,6 +125,9 @@ address, + + operator_quote, + station_quote, @@ -171,6 +175,9 @@ #{address,jdbcType=VARCHAR}, + + #{operatorQuote}, + #{stationQuote,jdbcType=INTEGER}, @@ -218,6 +225,9 @@ address = #{address,jdbcType=VARCHAR}, + + operator_quote = #{operatorQuote}, + station_quote = #{stationQuote,jdbcType=INTEGER}, @@ -248,6 +258,7 @@ linkman = #{linkman,jdbcType=VARCHAR}, contact_number = #{contactNumber,jdbcType=VARCHAR}, address = #{address,jdbcType=VARCHAR}, + operator_quote = #{operatorQuote}, station_quote = #{stationQuote,jdbcType=INTEGER}, station_pile_quote = #{stationPileQuote,jdbcType=INTEGER}, expire_time = #{expireTime,jdbcType=TIMESTAMP}, diff --git a/sql/v2.1.sql b/sql/v2.1.sql index b82072b4..6c4caa5b 100644 --- a/sql/v2.1.sql +++ b/sql/v2.1.sql @@ -110,6 +110,7 @@ CREATE TABLE `xhpc_tenant` `address` VARCHAR(255) NULL DEFAULT NULL COMMENT '联系地址', `station_quote` INT(11) NULL DEFAULT '-1' COMMENT '场站限额', `station_pile_quote` INT(11) NULL DEFAULT '-1' COMMENT '每站桩限额', + `operator_quote` int(11) DEFAULT '1' COMMENT '运营商限额', `expire_time` DATETIME NULL DEFAULT NULL COMMENT '过期时间', `create_user` BIGINT(64) NULL DEFAULT NULL COMMENT '创建人', `create_dept` BIGINT(64) NULL DEFAULT NULL COMMENT '创建部门', diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/TenantService.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/TenantService.java index 35a95df3..64a3c777 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/TenantService.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/TenantService.java @@ -16,4 +16,8 @@ public interface TenantService { @GetMapping("/tenant/getTenantIdTime") R gettenantIdTime(@RequestParam(value = "tenantId") String tenantId); + + + @GetMapping("/tenant/detail") + R getTenantDetail(@RequestParam(value = "tenantId") String tenantId); } diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/TenantFallbackFactory.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/TenantFallbackFactory.java index 4a20b1a3..f69991dc 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/TenantFallbackFactory.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/TenantFallbackFactory.java @@ -18,6 +18,12 @@ public class TenantFallbackFactory implements FallbackFactory { public R gettenantIdTime(String tenantId) { return R.fail("租户服务发送失败:" + cause.getMessage()); } + + + @Override + public R getTenantDetail(String tenantId) { + return R.fail("租户服务发送失败:" + cause.getMessage()); + } }; } } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcOperatorController.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcOperatorController.java index 1aaa7d2b..f85e1153 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcOperatorController.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcOperatorController.java @@ -1,7 +1,9 @@ package com.xhpc.user.controller; +import com.xhpc.common.api.TenantService; import com.xhpc.common.core.constant.HttpStatus; import com.xhpc.common.core.constant.StatusConstants; +import com.xhpc.common.core.domain.R; import com.xhpc.common.core.utils.SecurityUtils; import com.xhpc.common.core.utils.StringUtils; import com.xhpc.common.core.web.controller.BaseController; @@ -21,6 +23,7 @@ import org.apache.shiro.authz.annotation.RequiresRoles; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; import javax.validation.Valid; import java.math.BigDecimal; import java.util.List; @@ -42,6 +45,8 @@ public class XhpcOperatorController extends BaseController { private IXhpcUserService iXhpcUserService; @Autowired private TokenService tokenService; + @Resource + TenantService tenantService; /** * 新增运营商 @@ -87,6 +92,17 @@ public class XhpcOperatorController extends BaseController { return AjaxResult.error("请选择角色"); } + R r = tenantService.getTenantDetail(xhpcOperator.getTenantId()); + if(r.getCode() != 200){ + return AjaxResult.error("该租户已过期或已停用,请联系管理员"); + } + Map data =(Map) r.getData(); + int operatorQuote = data.get("operatorQuote") == null ? 1: Integer.parseInt(data.get("operatorQuote").toString()); + List operators = iXhpcOperatorService.getOperatorListByTenantId(xhpcOperator.getTenantId()); + if(operators.size() >= operatorQuote){ + return AjaxResult.error("该租户运营商已超限额,无法创建"); + } + sysUser.setUserName(xhpcOperator.getPhone()); sysUser.setNickName(xhpcOperator.getName()); sysUser.setEmail(xhpcOperator.getEmail()); diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcOperatorMapper.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcOperatorMapper.java index 443832ce..76117060 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcOperatorMapper.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcOperatorMapper.java @@ -110,4 +110,6 @@ public interface XhpcOperatorMapper { * @return 结果 */ public List> getOperatorId(); + + List selectListByTenantId(@Param("tenantId")String tenantId); } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcOperatorService.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcOperatorService.java index 35c91236..dde3c0c9 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcOperatorService.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcOperatorService.java @@ -78,4 +78,6 @@ public interface IXhpcOperatorService { * @return 结果 */ public void status(Long operatorId); + + List getOperatorListByTenantId(String tenantId); } \ No newline at end of file diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcOperatorServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcOperatorServiceImpl.java index f538f834..27292e6e 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcOperatorServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcOperatorServiceImpl.java @@ -164,4 +164,10 @@ public class XhpcOperatorServiceImpl implements IXhpcOperatorService { update(xhpcOperator); } + + @Override + public List getOperatorListByTenantId(String tenantId){ + return xhpcOperatorMapper.selectListByTenantId(tenantId); + } + } diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcOperatorMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcOperatorMapper.xml index ad1766f0..b8f4a81c 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcOperatorMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcOperatorMapper.xml @@ -45,7 +45,7 @@ xo.maintenance_commission_rate maintenanceCommissionRate, xo.business_license_id businessLicenseId, xo.withdrawal_time withdrawalTime, xo.soc, xo.status, xo.del_flag delFlag, xo.create_time createTime, - xo.create_by createBy, xo.update_time updateTime, xo.update_by updateBy, xo.remark, + xo.create_by createBy, xo.update_time updateTime, xo.update_by updateBy, xo.remark select - + , xo.operator_id_evcs operatorIdEvcs, xdb.dict_value attributenName,`xa`.merger_name mergerName, xo.business_license_id businessLicenseUrl @@ -376,6 +376,14 @@ + + + delete from sys_role where role_name = #{roleName}