更新租户创建运营商限额

This commit is contained in:
panshuling321 2022-04-29 10:21:49 +08:00
parent 4ddf07ce51
commit 71a75a1cfa
10 changed files with 66 additions and 5 deletions

View File

@ -57,6 +57,11 @@ public class XhpcTenantDomain implements Serializable {
*/ */
private Integer stationPileQuote; private Integer stationPileQuote;
/**
* 运营商限额
*/
private Integer operatorQuote;
/** /**
* 过期时间 * 过期时间
*/ */

View File

@ -11,6 +11,7 @@
<result column="address" jdbcType="VARCHAR" property="address" /> <result column="address" jdbcType="VARCHAR" property="address" />
<result column="station_quote" jdbcType="INTEGER" property="stationQuote" /> <result column="station_quote" jdbcType="INTEGER" property="stationQuote" />
<result column="station_pile_quote" jdbcType="INTEGER" property="stationPileQuote" /> <result column="station_pile_quote" jdbcType="INTEGER" property="stationPileQuote" />
<result column="operator_quote" property="operatorQuote" />
<result column="expire_time" jdbcType="TIMESTAMP" property="expireTime" /> <result column="expire_time" jdbcType="TIMESTAMP" property="expireTime" />
<result column="create_user" jdbcType="BIGINT" property="createUser" /> <result column="create_user" jdbcType="BIGINT" property="createUser" />
<result column="create_dept" jdbcType="BIGINT" property="createDept" /> <result column="create_dept" jdbcType="BIGINT" property="createDept" />
@ -22,7 +23,7 @@
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
tenant_id, tenant_name, `domain`, background_url, linkman, contact_number, address, 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 update_user, update_time, `status`, is_deleted
</sql> </sql>
@ -88,13 +89,13 @@
<insert id="insert" keyColumn="tenant_id" keyProperty="tenantId" parameterType="com.xhpc.system.domain.XhpcTenantDomain" useGeneratedKeys="true"> <insert id="insert" keyColumn="tenant_id" keyProperty="tenantId" parameterType="com.xhpc.system.domain.XhpcTenantDomain" useGeneratedKeys="true">
insert into xhpc_tenant (tenant_id, tenant_name, `domain`, background_url, 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, station_quote, station_pile_quote, expire_time,
create_user, create_dept, create_time, create_user, create_dept, create_time,
update_user, update_time, `status`, update_user, update_time, `status`,
is_deleted) is_deleted)
values (#{tenantId, jdbcType=VARCHAR}, #{tenantName,jdbcType=VARCHAR}, #{domain,jdbcType=VARCHAR}, #{backgroundUrl,jdbcType=VARCHAR}, 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}, #{stationQuote,jdbcType=INTEGER}, #{stationPileQuote,jdbcType=INTEGER}, #{expireTime,jdbcType=TIMESTAMP},
#{createUser,jdbcType=BIGINT}, #{createDept,jdbcType=BIGINT}, sysdate(), #{createUser,jdbcType=BIGINT}, #{createDept,jdbcType=BIGINT}, sysdate(),
#{updateUser,jdbcType=BIGINT}, sysdate(), #{status,jdbcType=INTEGER}, #{updateUser,jdbcType=BIGINT}, sysdate(), #{status,jdbcType=INTEGER},
@ -124,6 +125,9 @@
<if test="address != null"> <if test="address != null">
address, address,
</if> </if>
<if test="operatorQuote != null">
operator_quote,
</if>
<if test="stationQuote != null"> <if test="stationQuote != null">
station_quote, station_quote,
</if> </if>
@ -171,6 +175,9 @@
<if test="address != null"> <if test="address != null">
#{address,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR},
</if> </if>
<if test="operatorQuote != null">
#{operatorQuote},
</if>
<if test="stationQuote != null"> <if test="stationQuote != null">
#{stationQuote,jdbcType=INTEGER}, #{stationQuote,jdbcType=INTEGER},
</if> </if>
@ -218,6 +225,9 @@
<if test="address != null"> <if test="address != null">
address = #{address,jdbcType=VARCHAR}, address = #{address,jdbcType=VARCHAR},
</if> </if>
<if test="operatorQuote != null">
operator_quote = #{operatorQuote},
</if>
<if test="stationQuote != null"> <if test="stationQuote != null">
station_quote = #{stationQuote,jdbcType=INTEGER}, station_quote = #{stationQuote,jdbcType=INTEGER},
</if> </if>
@ -248,6 +258,7 @@
linkman = #{linkman,jdbcType=VARCHAR}, linkman = #{linkman,jdbcType=VARCHAR},
contact_number = #{contactNumber,jdbcType=VARCHAR}, contact_number = #{contactNumber,jdbcType=VARCHAR},
address = #{address,jdbcType=VARCHAR}, address = #{address,jdbcType=VARCHAR},
operator_quote = #{operatorQuote},
station_quote = #{stationQuote,jdbcType=INTEGER}, station_quote = #{stationQuote,jdbcType=INTEGER},
station_pile_quote = #{stationPileQuote,jdbcType=INTEGER}, station_pile_quote = #{stationPileQuote,jdbcType=INTEGER},
expire_time = #{expireTime,jdbcType=TIMESTAMP}, expire_time = #{expireTime,jdbcType=TIMESTAMP},

View File

@ -110,6 +110,7 @@ CREATE TABLE `xhpc_tenant`
`address` VARCHAR(255) NULL DEFAULT NULL COMMENT '联系地址', `address` VARCHAR(255) NULL DEFAULT NULL COMMENT '联系地址',
`station_quote` INT(11) NULL DEFAULT '-1' COMMENT '场站限额', `station_quote` INT(11) NULL DEFAULT '-1' COMMENT '场站限额',
`station_pile_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 '过期时间', `expire_time` DATETIME NULL DEFAULT NULL COMMENT '过期时间',
`create_user` BIGINT(64) NULL DEFAULT NULL COMMENT '创建人', `create_user` BIGINT(64) NULL DEFAULT NULL COMMENT '创建人',
`create_dept` BIGINT(64) NULL DEFAULT NULL COMMENT '创建部门', `create_dept` BIGINT(64) NULL DEFAULT NULL COMMENT '创建部门',

View File

@ -16,4 +16,8 @@ public interface TenantService {
@GetMapping("/tenant/getTenantIdTime") @GetMapping("/tenant/getTenantIdTime")
R gettenantIdTime(@RequestParam(value = "tenantId") String tenantId); R gettenantIdTime(@RequestParam(value = "tenantId") String tenantId);
@GetMapping("/tenant/detail")
R getTenantDetail(@RequestParam(value = "tenantId") String tenantId);
} }

View File

@ -18,6 +18,12 @@ public class TenantFallbackFactory implements FallbackFactory<TenantService> {
public R gettenantIdTime(String tenantId) { public R gettenantIdTime(String tenantId) {
return R.fail("租户服务发送失败:" + cause.getMessage()); return R.fail("租户服务发送失败:" + cause.getMessage());
} }
@Override
public R getTenantDetail(String tenantId) {
return R.fail("租户服务发送失败:" + cause.getMessage());
}
}; };
} }
} }

View File

@ -1,7 +1,9 @@
package com.xhpc.user.controller; package com.xhpc.user.controller;
import com.xhpc.common.api.TenantService;
import com.xhpc.common.core.constant.HttpStatus; import com.xhpc.common.core.constant.HttpStatus;
import com.xhpc.common.core.constant.StatusConstants; 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.SecurityUtils;
import com.xhpc.common.core.utils.StringUtils; import com.xhpc.common.core.utils.StringUtils;
import com.xhpc.common.core.web.controller.BaseController; 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.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid; import javax.validation.Valid;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
@ -42,6 +45,8 @@ public class XhpcOperatorController extends BaseController {
private IXhpcUserService iXhpcUserService; private IXhpcUserService iXhpcUserService;
@Autowired @Autowired
private TokenService tokenService; private TokenService tokenService;
@Resource
TenantService tenantService;
/** /**
* 新增运营商 * 新增运营商
@ -87,6 +92,17 @@ public class XhpcOperatorController extends BaseController {
return AjaxResult.error("请选择角色"); 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<XhpcOperator> operators = iXhpcOperatorService.getOperatorListByTenantId(xhpcOperator.getTenantId());
if(operators.size() >= operatorQuote){
return AjaxResult.error("该租户运营商已超限额,无法创建");
}
sysUser.setUserName(xhpcOperator.getPhone()); sysUser.setUserName(xhpcOperator.getPhone());
sysUser.setNickName(xhpcOperator.getName()); sysUser.setNickName(xhpcOperator.getName());
sysUser.setEmail(xhpcOperator.getEmail()); sysUser.setEmail(xhpcOperator.getEmail());

View File

@ -110,4 +110,6 @@ public interface XhpcOperatorMapper {
* @return 结果 * @return 结果
*/ */
public List<Map<String, Object>> getOperatorId(); public List<Map<String, Object>> getOperatorId();
List<XhpcOperator> selectListByTenantId(@Param("tenantId")String tenantId);
} }

View File

@ -78,4 +78,6 @@ public interface IXhpcOperatorService {
* @return 结果 * @return 结果
*/ */
public void status(Long operatorId); public void status(Long operatorId);
List<XhpcOperator> getOperatorListByTenantId(String tenantId);
} }

View File

@ -164,4 +164,10 @@ public class XhpcOperatorServiceImpl implements IXhpcOperatorService {
update(xhpcOperator); update(xhpcOperator);
} }
@Override
public List<XhpcOperator> getOperatorListByTenantId(String tenantId){
return xhpcOperatorMapper.selectListByTenantId(tenantId);
}
} }

View File

@ -45,7 +45,7 @@
xo.maintenance_commission_rate maintenanceCommissionRate, xo.maintenance_commission_rate maintenanceCommissionRate,
xo.business_license_id businessLicenseId, xo.withdrawal_time withdrawalTime, xo.soc, xo.business_license_id businessLicenseId, xo.withdrawal_time withdrawalTime, xo.soc,
xo.status, xo.del_flag delFlag, xo.create_time createTime, 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
</sql> </sql>
<insert id="insert" parameterType="com.xhpc.user.domain.XhpcOperator" useGeneratedKeys="true" <insert id="insert" parameterType="com.xhpc.user.domain.XhpcOperator" useGeneratedKeys="true"
@ -284,7 +284,7 @@
<select id="info" parameterType="java.lang.Long" resultType="java.util.Map"> <select id="info" parameterType="java.lang.Long" resultType="java.util.Map">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>,
xo.operator_id_evcs operatorIdEvcs, xo.operator_id_evcs operatorIdEvcs,
xdb.dict_value attributenName,`xa`.merger_name mergerName, xdb.dict_value attributenName,`xa`.merger_name mergerName,
xo.business_license_id businessLicenseUrl xo.business_license_id businessLicenseUrl
@ -376,6 +376,14 @@
</select> </select>
<select id="selectListByTenantId" resultType="com.xhpc.user.domain.XhpcOperator">
select
<include refid="Base_Column_List"/>
from xhpc_operator xo
where xo.del_flag=0 and xo.tenant_id=#{tenantId}
</select>
<delete id="deleteRoleByName" parameterType="java.lang.String"> <delete id="deleteRoleByName" parameterType="java.lang.String">
delete from sys_role delete from sys_role
where role_name = #{roleName} where role_name = #{roleName}