更新新增租户接口判断ID和名称是否重复
This commit is contained in:
parent
d7238058ab
commit
4fb0e210e5
@ -23,6 +23,10 @@ public interface XhpcTenantMapper {
|
||||
|
||||
XhpcTenantDomain selectByPrimaryKey(String tenantId);
|
||||
|
||||
XhpcTenantDomain selectByName(String tenantName);
|
||||
|
||||
XhpcTenantDomain selectByPkOrName(String tenantId, String tenantName);
|
||||
|
||||
int updateByPrimaryKeySelective(XhpcTenantDomain record);
|
||||
|
||||
int updateByPrimaryKey(XhpcTenantDomain record);
|
||||
|
||||
@ -46,9 +46,9 @@ public class XhpcTenantServiceImpl implements XhpcTenantService {
|
||||
throw new CustomException("必填字段为空");
|
||||
}
|
||||
|
||||
XhpcTenantDomain tenantDomain = tenantMapper.selectByPrimaryKey(domain.getTenantId());
|
||||
XhpcTenantDomain tenantDomain = tenantMapper.selectByPkOrName(domain.getTenantId(), domain.getTenantName());
|
||||
if(tenantDomain != null){
|
||||
throw new CustomException("租户ID已存在");
|
||||
throw new CustomException("租户ID或名称已存在");
|
||||
}
|
||||
|
||||
return tenantMapper.insertSelective(domain) > 0;
|
||||
|
||||
@ -58,6 +58,21 @@
|
||||
from xhpc_tenant
|
||||
where tenant_id = #{tenantId,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<select id="selectByName" resultType="com.xhpc.tenant.domain.XhpcTenantDomain">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from xhpc_tenant
|
||||
where tenant_name = #{tenantName,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<select id="selectByPkOrName" resultType="com.xhpc.tenant.domain.XhpcTenantDomain">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from xhpc_tenant
|
||||
where tenant_id = #{tenantId,jdbcType=VARCHAR} OR tenant_name = #{tenantName,jdbcType=VARCHAR} limit 1
|
||||
</select>
|
||||
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
|
||||
delete from xhpc_tenant
|
||||
where tenant_id = #{tenantId,jdbcType=VARCHAR}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user