Forráskód Böngészése

add
修改医院租户信息

18339543638 4 hónapja
szülő
commit
188ef5f3b3
16 módosított fájl, 240 hozzáadás és 124 törlés
  1. 4 0
      tr-modules/tr-module-mobile/pom.xml
  2. 20 1
      tr-modules/tr-module-mobile/src/main/java/cn/tr/module/mobile/ServerEventListenerImpl.java
  3. 21 0
      tr-modules/tr-module-mobile/src/main/java/cn/tr/module/mobile/dto/MsgDTO.java
  4. 23 0
      tr-modules/tr-module-mobile/src/main/java/cn/tr/module/mobile/enums/MsgContentType.java
  5. 18 0
      tr-modules/tr-module-mobile/src/main/java/cn/tr/module/mobile/enums/MsgRoleType.java
  6. 2 3
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/oauth2/psw/operator/LoginOAuth2PswUserOperator.java
  7. 14 24
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/controller/SysTenantController.java
  8. 12 23
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/dto/SysTenantAddDTO.java
  9. 3 11
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/dto/SysTenantCommonDTO.java
  10. 3 7
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/dto/SysTenantQueryDTO.java
  11. 3 2
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/repository/SysTenantRepository.java
  12. 4 3
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/service/ISysTenantService.java
  13. 3 2
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/service/impl/SysTenantPackageMenuServiceImpl.java
  14. 15 29
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/service/impl/SysTenantServiceImpl.java
  15. 53 0
      tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/vo/SysTenantCommonVO.java
  16. 42 19
      tr-modules/tr-module-system/src/main/resources/mapper/tenant/SysTenantMapper.xml

+ 4 - 0
tr-modules/tr-module-mobile/pom.xml

@@ -21,6 +21,10 @@
             <artifactId>gson</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>cn.tr</groupId>
+            <artifactId>tr-spring-boot-starter-plugin-satoken</artifactId>
+        </dependency>
 
         <!-- 依赖的netty库 -->
         <dependency>

+ 20 - 1
tr-modules/tr-module-mobile/src/main/java/cn/tr/module/mobile/ServerEventListenerImpl.java

@@ -1,5 +1,7 @@
 package cn.tr.module.mobile;
 
+import cn.hutool.json.JSONUtil;
+import cn.tr.module.mobile.dto.MsgDTO;
 import io.netty.channel.Channel;
 import lombok.extern.slf4j.Slf4j;
 import net.x52im.mobileimsdk.server.event.ServerEventListener;
@@ -7,6 +9,8 @@ import net.x52im.mobileimsdk.server.processor.OnlineProcessor;
 import net.x52im.mobileimsdk.server.protocal.Protocal;
 import net.x52im.mobileimsdk.server.protocal.s.PKickoutInfo;
 
+import javax.xml.transform.sax.SAXTransformerFactory;
+
 /**
  * @author wangzl
  * @description: TODO
@@ -59,7 +63,6 @@ public class ServerEventListenerImpl implements ServerEventListener {
     }
     /**
      * 收到客户端发送给“服务端”的数据回调通知(即:消息路径为“C2S”的消息)前的处理逻辑。
-     *
      * @param p 消息/指令的完整协议包对象
      * @param session 消息发送者的“会话”引用(也就是客户端的网络连接对象)
      * @return true表示经过本方法后将正常进入 {@link #onTransferMessage4C2S(Protocal, Channel)}继续正常逻辑  ,false表示该条指令将不会继续处理(直接被丢弃)
@@ -81,6 +84,22 @@ public class ServerEventListenerImpl implements ServerEventListener {
      */
     @Override
     public boolean onTransferMessage4C2CBefore(Protocal p, Channel session) {
+        String dataContent = p.getDataContent();
+        log.debug("收到C2C消息前处理: from={}, to={}, fp={}, typeu={}, dataContent={}",
+                p.getFrom(), p.getTo(), p.getFp(), p.getTypeu(), dataContent);
+
+        if(!JSONUtil.isTypeJSON(dataContent)){
+            log.warn("收到的C2C消息不是有效的JSON格式: {}", dataContent);
+            return false;
+        }
+        try {
+            MsgDTO msg = JSONUtil.toBean(dataContent, MsgDTO.class);
+            log.debug("解析C2C消息成功: clinicId={}, type={}, role={}",
+                    msg.getClinicId(), msg.getType(), msg.getRole());
+        } catch (Exception e) {
+            log.error("解析C2C消息失败: dataContent={}, error={}", dataContent, e.getMessage());
+            return false;
+        }
         return true;
     }
     /**

+ 21 - 0
tr-modules/tr-module-mobile/src/main/java/cn/tr/module/mobile/dto/MsgDTO.java

@@ -0,0 +1,21 @@
+package cn.tr.module.mobile.dto;
+
+import lombok.Data;
+
+@Data
+public class MsgDTO {
+    private String clinicId;
+
+    /**
+     * {@link cn.tr.module.mobile.enums.MsgContentType}
+     */
+    private String type;
+
+    private String content;
+
+    /**
+     * doctor/patient/ai
+     * {@link cn.tr.module.mobile.enums.MsgRoleType}
+     */
+    private String role;
+}

+ 23 - 0
tr-modules/tr-module-mobile/src/main/java/cn/tr/module/mobile/enums/MsgContentType.java

@@ -0,0 +1,23 @@
+package cn.tr.module.mobile.enums;
+
+public interface MsgContentType {
+    /**
+     * 普通文本
+     */
+    String TEXT="text";
+
+    /**
+     * 图片
+     */
+    String IMG="img";
+
+    /**
+     * 语音
+     */
+    String AUDIO="audio";
+
+    /**
+     * 附件
+     */
+    String ATTACHMENT="attachment";
+}

+ 18 - 0
tr-modules/tr-module-mobile/src/main/java/cn/tr/module/mobile/enums/MsgRoleType.java

@@ -0,0 +1,18 @@
+package cn.tr.module.mobile.enums;
+
+public interface MsgRoleType {
+    /**
+     * 医生消息
+     */
+    String DOCTOR="doctor";
+
+    /**
+     * 患者消息
+     */
+    String PATIENT="patient";
+
+    /**
+     * AI消息
+     */
+    String AI="ai";
+}

+ 2 - 3
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/oauth2/psw/operator/LoginOAuth2PswUserOperator.java

@@ -23,13 +23,12 @@ import cn.tr.module.sys.oauth2.mapper.OAuth2Mapper;
 import cn.tr.module.sys.oauth2.dto.OAuth2PswReqDTO;
 import cn.tr.module.sys.tenant.dto.SysTenantCommonDTO;
 import cn.tr.module.sys.tenant.service.ISysTenantService;
+import cn.tr.module.sys.tenant.vo.SysTenantCommonVO;
 import cn.tr.module.sys.user.dto.SysOrgDTO;
-import cn.tr.module.sys.user.dto.SysPositionDTO;
 import cn.tr.module.sys.user.dto.SysRoleDTO;
 import cn.tr.module.sys.user.dto.SysUserDTO;
 import cn.tr.module.sys.user.enums.UserStatusEnum;
 import cn.tr.module.sys.user.mapper.SysOrgMapper;
-import cn.tr.module.sys.user.mapper.SysPositionMapper;
 import cn.tr.module.sys.user.mapper.SysRoleMapper;
 import cn.tr.module.sys.user.po.SysUserPO;
 import cn.tr.module.sys.user.repository.SysUserRepository;
@@ -114,7 +113,7 @@ public class LoginOAuth2PswUserOperator extends AbstractOAuth2PswUserOperator{
         if(Boolean.TRUE.equals(tenantEnable)){
             //查看租户是否被禁用
             String tenantId = user.getTenantId();
-            SysTenantCommonDTO tenant = tenantService.selectSysTenantById(tenantId);
+            SysTenantCommonVO tenant = tenantService.selectSysTenantById(tenantId);
             if(tenant==null){
                 throw new ServiceException(TRExcCode.USER_ERROR_A0205);
             }

+ 14 - 24
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/controller/SysTenantController.java

@@ -1,15 +1,15 @@
 package cn.tr.module.sys.tenant.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
-import cn.dev33.satoken.annotation.SaIgnore;
 import cn.tr.core.annotation.TenantIgnore;
-import cn.tr.core.enums.CreateEnum;
 import cn.tr.core.pojo.CommonResult;
+import cn.tr.core.strategy.LoginUserStrategy;
 import cn.tr.core.validation.Insert;
 import cn.tr.core.validation.Update;
 import cn.tr.module.api.sys.log.annotation.OperateLog;
 import cn.tr.module.sys.tenant.dto.*;
 import cn.tr.module.sys.tenant.service.ISysTenantService;
+import cn.tr.module.sys.tenant.vo.SysTenantCommonVO;
 import cn.tr.plugin.mybatis.base.BaseController;
 import cn.tr.plugin.security.context.LoginUserContextHolder;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
@@ -22,12 +22,12 @@ import org.springframework.web.bind.annotation.*;
 import java.util.Collection;
 import java.util.List;
 /**
- * 租户列表控制器
+ * 医院列表控制器
  *
  * @author lf
  * @date  2023/04/15 15:27
  */
-@Api(tags = "租户列表")
+@Api(tags = "医院列表")
 @RestController
 @RequestMapping("/sys/tenant")
 @AllArgsConstructor
@@ -36,54 +36,44 @@ public class SysTenantController extends BaseController{
     private final ISysTenantService sysTenantService;
 
     @ApiOperationSupport(author = "lf",order = 1)
-    @ApiOperation(value="根据条件查询租户列表",notes = "权限: 无")
+    @ApiOperation(value="根据条件查询医院列表",notes = "权限: 无")
     @PostMapping("/query/page")
-    public CommonResult<List<SysTenantCommonDTO>> selectList(@RequestBody SysTenantQueryDTO query) {
+    @TenantIgnore
+    public CommonResult<List<SysTenantCommonVO>> selectList(@RequestBody SysTenantQueryDTO query) {
         startPage();
         return CommonResult.success(sysTenantService.selectSysTenantList(query));
     }
 
-
     @ApiOperationSupport(author = "lf",order = 2)
-    @ApiOperation(value = "根据id查询租户列表",notes = "权限: sys:tenant:query")
+    @ApiOperation(value = "根据id查询医院详情",notes = "权限: sys:tenant:query")
     @GetMapping("/detail/{id}")
     @SaCheckPermission("sys:tenant:query")
-    public CommonResult<SysTenantCommonDTO> findById(@PathVariable("id") String id){
+    public CommonResult<SysTenantCommonVO> findById(@PathVariable("id") String id){
         return CommonResult.success(sysTenantService.selectSysTenantById(id));
     }
 
     @ApiOperationSupport(author = "lf",order = 3)
-    @ApiOperation(value="添加租户列表",notes = "权限: sys:tenant:add")
+    @ApiOperation(value="添加医院列表",notes = "权限: sys:tenant:add")
     @PostMapping("/add")
     @SaCheckPermission("sys:tenant:add")
     @OperateLog
     public CommonResult<Boolean> add(@RequestBody@Validated(Insert.class) SysTenantAddDTO source) {
-        source.setType(CreateEnum.custom.name());
         return CommonResult.success(sysTenantService.insertSysTenant(source));
     }
 
     @ApiOperationSupport(author = "lf",order = 4)
-    @ApiOperation(value="通过主键id编辑租户列表",notes = "权限: sys:tenant:edit")
+    @ApiOperation(value="通过主键id编辑医院列表",notes = "权限: sys:tenant:edit")
     @PostMapping("/edit")
     @SaCheckPermission("sys:tenant:edit")
     @OperateLog
-    public CommonResult<Boolean> edit(@RequestBody@Validated(Update.class) SysTenantCommonDTO source) {
+    public CommonResult<Boolean> edit(@RequestBody@Validated(Update.class) SysTenantAddDTO source) {
         return CommonResult.success(sysTenantService.updateSysTenantById(source));
     }
 
-    @ApiOperationSupport(author = "lf",order = 5)
-    @ApiOperation(value="删除租户列表",notes = "权限: sys:tenant:remove")
-    @PostMapping("/removeByIds")
-    @SaCheckPermission("sys:tenant:remove")
-    @OperateLog
-    public CommonResult<Integer> delete(@RequestBody Collection<String> ids) {
-        return CommonResult.success(sysTenantService.removeSysTenantByIds(ids));
-    }
-
     @ApiOperationSupport(author = "lf",order = 6)
     @ApiOperation(value="查询当前用户的租户信息",notes = "权限: 无")
     @PostMapping("/query/current")
-    public CommonResult<SysTenantCommonDTO> selectList() {
-        return CommonResult.success(sysTenantService.selectSysTenantById(LoginUserContextHolder.getUser().getTenantId()));
+    public CommonResult<SysTenantCommonVO> selectList() {
+        return CommonResult.success(sysTenantService.selectSysTenantById(LoginUserStrategy.tr.getTenantId()));
     }
 }

+ 12 - 23
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/dto/SysTenantAddDTO.java

@@ -15,43 +15,32 @@ import java.io.Serializable;
 
 /**
  * @ClassName : SysTenantPO
- * @Description : 租户新增对象
+ * @Description : 医院新增对象
  * @Author : LF
  * @Date: 2023年04月05日
  */
 @Data
-@ApiModel("租户新增对象")
+@ApiModel("医院新增对象")
 public class SysTenantAddDTO implements Serializable {
     private static final long serialVersionUID = 1841053739406204228L;
-    @ApiModelProperty(value = "租户名称",required = true)
+    @ApiModelProperty(value = "医院名称",required = true)
     @NotBlank(message = "名称不能为空",groups = {Insert.class, Update.class})
     private String name;
 
-    @ApiModelProperty(value = "租户套餐id",required = true)
+    @ApiModelProperty(value = "医院套餐id",required = true)
     @NotBlank(message = "套餐不能为空",groups = {Insert.class, Update.class})
     private String packageId;
 
-    @ApiModelProperty(value = "租户联系人",required = true)
-    @NotBlank(message = "联系人不能为空",groups = {Insert.class, Update.class})
-    private String contractUser;
-
-    @ApiModelProperty(value = "租户类型",hidden = true)
-    private String type;
+    @ApiModelProperty(value = "状态 0、开启 1、关闭",required = true)
+    @NotNull(message = "状态不能为空",groups = {Insert.class, Update.class})
+    private Boolean disable;
 
-    @ApiModelProperty(value = "管理账号",required = true)
-    @NotBlank(message = "管理账号不能为空",groups = {Insert.class, Update.class})
-    @Length(min = 4,max = 16,message = "管理账号长度在4~16之间",groups = {Insert.class, Update.class})
-    @Pattern(regexp = "^[A-Za-z0-9]+$", message = "管理账号格式为数字以及字母",groups = {Insert.class,Update.class})
-    private String username;
+    @ApiModelProperty("网络泵的医院编码")
+    private String code;
 
-    @ApiModelProperty(value = "联系人电话",required = true)
-    @NotBlank(message = "联系人电话不能为空",groups = {Insert.class, Update.class})
-    private String contactMobile;
+    @ApiModelProperty("医院头像")
+    private String tenantAvatar;
 
-    @ApiModelProperty("租户备注")
+    @ApiModelProperty("医院备注")
     private String remark;
-
-    @ApiModelProperty(value = "状态 0、开启 1、关闭",required = true)
-    @NotNull(message = "状态不能为空",groups = {Insert.class, Update.class})
-    private Boolean disable;
 }

+ 3 - 11
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/dto/SysTenantCommonDTO.java

@@ -45,21 +45,13 @@ public class SysTenantCommonDTO extends BaseDTO {
     @Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
     private String username;
 
-    @ApiModelProperty(value = "租户类型")
-    private String type;
-
-    @ApiModelProperty(value = "联系人",required = true)
-    @NotBlank(message = "联系人不能为空",groups = {Insert.class,Update.class})
-    private String contractUser;
-
-    @ApiModelProperty(value = "联系人电话",required = true)
-    @NotBlank(message = "联系人电话不能为空",groups = {Insert.class,Update.class})
-    private String contactMobile;
-
     @ApiModelProperty("租户备注")
     private String remark;
 
     @ApiModelProperty(value = "状态 0、开启 1、关闭",required = true)
     @NotNull(message = "状态不能为空",groups = {Update.class})
     private Boolean disable;
+
+    @ApiModelProperty("网络泵编码")
+    private String code;
 }

+ 3 - 7
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/dto/SysTenantQueryDTO.java

@@ -11,16 +11,12 @@ import lombok.Data;
  * @Date: 2023年04月05日
  */
 @Data
-@ApiModel("租户查询参数")
+@ApiModel("医院查询参数")
 public class SysTenantQueryDTO {
-    @ApiModelProperty("租户名")
+    @ApiModelProperty("医院名")
     private String name;
-    @ApiModelProperty("联系人")
-    private String contractUser;
-    @ApiModelProperty("联系电话")
-    private String contactMobile;
     @ApiModelProperty("租户状态")
     private Boolean disable;
     @ApiModelProperty(value = "套餐id",hidden = true)
     private String packageId;
-}
+}

+ 3 - 2
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/repository/SysTenantRepository.java

@@ -3,6 +3,7 @@ package cn.tr.module.sys.tenant.repository;
 import cn.tr.module.sys.tenant.dto.SysTenantCommonDTO;
 import cn.tr.module.sys.tenant.dto.SysTenantQueryDTO;
 import cn.tr.module.sys.tenant.po.SysTenantPO;
+import cn.tr.module.sys.tenant.vo.SysTenantCommonVO;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -17,7 +18,7 @@ import java.util.*;
 @Mapper
 @Repository
 public interface SysTenantRepository extends BaseMapper<SysTenantPO> {
-    List<SysTenantCommonDTO> stdSelectList(@Param("query") SysTenantQueryDTO query);
+    List<SysTenantCommonVO> stdSelectList(@Param("query") SysTenantQueryDTO query);
 
-    SysTenantCommonDTO stdSelectById(@Param("id") String id);
+    SysTenantCommonVO stdSelectById(@Param("id") String id);
 }

+ 4 - 3
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/service/ISysTenantService.java

@@ -3,6 +3,7 @@ package cn.tr.module.sys.tenant.service;
 import cn.hutool.core.util.StrUtil;
 import cn.tr.core.tenant.TenantContextHolder;
 import cn.tr.module.sys.tenant.dto.*;
+import cn.tr.module.sys.tenant.vo.SysTenantCommonVO;
 import cn.tr.module.sys.user.dto.SysMenuDTO;
 
 import java.util.Collection;
@@ -25,7 +26,7 @@ public interface ISysTenantService {
      * @param query 查询参数
      * @return
      */
-    List<SysTenantCommonDTO> selectSysTenantList(SysTenantQueryDTO query);
+    List<SysTenantCommonVO> selectSysTenantList(SysTenantQueryDTO query);
 
     /**
      * 根据id查询操作租户
@@ -33,7 +34,7 @@ public interface ISysTenantService {
      * @param id 租户id
      * @return 租户
      */
-    SysTenantCommonDTO selectSysTenantById(String id);
+    SysTenantCommonVO selectSysTenantById(String id);
 
     /**
      * 更新租户
@@ -41,7 +42,7 @@ public interface ISysTenantService {
      * @param source 更新租户
      * @return true:更新成功
      */
-    boolean updateSysTenantById(SysTenantCommonDTO source);
+    boolean updateSysTenantById(SysTenantAddDTO source);
 
     /**
      * 新增租户

+ 3 - 2
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/service/impl/SysTenantPackageMenuServiceImpl.java

@@ -14,6 +14,7 @@ import cn.tr.module.sys.tenant.repository.SysTenantPackageMenuRepository;
 import cn.tr.module.sys.tenant.service.ISysTenantPackageMenuService;
 import cn.tr.module.sys.tenant.service.ISysTenantPackageService;
 import cn.tr.module.sys.tenant.service.ISysTenantService;
+import cn.tr.module.sys.tenant.vo.SysTenantCommonVO;
 import cn.tr.module.sys.user.dto.SysMenuDTO;
 import cn.tr.module.sys.user.dto.SysPortalDTO;
 import cn.tr.module.sys.user.dto.SysRoleDTO;
@@ -96,9 +97,9 @@ public class SysTenantPackageMenuServiceImpl  extends ServiceImpl<SysTenantPacka
         //对套餐绑定的租户进行操作
         SysTenantQueryDTO query = new SysTenantQueryDTO();
         query.setPackageId(packageId);
-        List<SysTenantCommonDTO> tenants = tenantService.selectSysTenantList(query);
+        List<SysTenantCommonVO> tenants = tenantService.selectSysTenantList(query);
         if (CollectionUtil.isNotEmpty(tenants)) {
-            for (SysTenantCommonDTO tenant : tenants) {
+            for (SysTenantCommonVO tenant : tenants) {
                 TenantUtils.execute(tenant.getId(),()->{
                     Collection<SysRoleDTO> sysRoles = roleService.findAllSysRoles();
                     Collection<SysPortalDTO> sysPortals = portalService.findAllSysPortals();

+ 15 - 29
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/service/impl/SysTenantServiceImpl.java

@@ -19,6 +19,7 @@ import cn.tr.module.sys.tenant.po.SysTenantPO;
 import cn.tr.module.sys.tenant.repository.SysTenantRepository;
 import cn.tr.module.sys.tenant.service.ISysTenantPackageMenuService;
 import cn.tr.module.sys.tenant.service.ISysTenantService;
+import cn.tr.module.sys.tenant.vo.SysTenantCommonVO;
 import cn.tr.module.sys.user.dto.*;
 import cn.tr.module.sys.user.enums.UserStatusEnum;
 import cn.tr.module.sys.user.service.*;
@@ -77,20 +78,20 @@ public class SysTenantServiceImpl implements ISysTenantService {
 
     @Override
     @TenantIgnore
-    public List<SysTenantCommonDTO> selectSysTenantList(SysTenantQueryDTO query) {
+    public List<SysTenantCommonVO> selectSysTenantList(SysTenantQueryDTO query) {
         validate();
         return tenantRepository.stdSelectList(query);
     }
 
     @Override
     @TenantIgnore
-    public SysTenantCommonDTO selectSysTenantById(String id) {
+    public SysTenantCommonVO selectSysTenantById(String id) {
         validate();
         return tenantRepository.stdSelectById(id);
     }
 
     @Override
-    public boolean updateSysTenantById(SysTenantCommonDTO source) {
+    public boolean updateSysTenantById(SysTenantAddDTO source) {
         validate();
         validateSource(source);
         return tenantRepository.updateById(SysTenantMapper.INSTANCE.toPO(source)) != 0;
@@ -101,31 +102,8 @@ public class SysTenantServiceImpl implements ISysTenantService {
     public boolean insertSysTenant(SysTenantAddDTO source) {
         validate();
         validateSource(source);
-        String orgId = IdWorker.getIdStr();
-        String userId = IdWorker.getIdStr();
-        String roleId = IdWorker.getIdStr();
-        String portalId = IdWorker.getIdStr();
         SysTenantPO tenant = SysTenantMapper.INSTANCE.toPO(source);
-        tenant.setTenantUserId(userId);
-        boolean result = tenantRepository.insert(tenant) != 0;
-        if (!result) {
-            return false;
-        }
-        String tenantId = tenant.getId();
-        TenantUtils.execute(tenantId, () -> {
-            //创建门面
-            portalService.insertInnerSysPortal(buildPortal(portalId));
-            //创建部门
-            orgService.insertSysOrg(buildOrg(orgId, source.getName()));
-            //创建角色
-            roleService.insertInnerSysRole(buildRole(roleId));
-            //创建租户用户
-            userService.insertSysUser(buildUser(userId, portalId, roleId, orgId, source.
-                    getUsername(), configManager.getCurrent().getDefaultPsw(), source.getName()));
-            //关联用户和门户
-            userPortalService.assignUserPortal(userId, Collections.singleton(portalId));
-        });
-        return result;
+        return tenantRepository.insert(tenant) != 0;
     }
 
     private List<SysUserPortalDTO> buildUserPortal(String userId, String portalId) {
@@ -169,7 +147,9 @@ public class SysTenantServiceImpl implements ISysTenantService {
 
     private void validateSource(SysTenantAddDTO source) {
         SysTenantPO sysTenantPO = tenantRepository.selectOne(new LambdaQueryWrapper<SysTenantPO>()
-                .eq(SysTenantPO::getName, source.getName()));
+                .eq(SysTenantPO::getName, source.getName())
+                .or()
+                .eq(SysTenantPO::getCode, source.getCode()));
         if (ObjectUtil.isNotNull(sysTenantPO)) {
             throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001, "租户名称不能重复");
         }
@@ -178,7 +158,13 @@ public class SysTenantServiceImpl implements ISysTenantService {
     private void validateSource(SysTenantCommonDTO source) {
         SysTenantPO sysTenantPO = tenantRepository.selectOne(new LambdaQueryWrapper<SysTenantPO>()
                 .ne(StrUtil.isNotEmpty(source.getId()), SysTenantPO::getId, source.getId())
-                .eq(SysTenantPO::getName, source.getName()));
+                .nested(i->
+                        i.eq(SysTenantPO::getName, source.getName())
+                                .or()
+                                .eq(SysTenantPO::getCode, source.getCode())
+
+                )
+        );
         if (ObjectUtil.isNotNull(sysTenantPO)) {
             throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001, "租户名称不能重复");
         }

+ 53 - 0
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/tenant/vo/SysTenantCommonVO.java

@@ -0,0 +1,53 @@
+package cn.tr.module.sys.tenant.vo;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @ClassName : SysTenantQueryDTO
+ * @Description : 医院通用对象
+ * @Author : LF
+ * @Date: 2023年04月05日
+ */
+@Data
+@ApiModel("医院查询对象")
+public class SysTenantCommonVO implements Serializable {
+    private static final long serialVersionUID = 1841053739406204228L;
+    @ApiModelProperty(value = "医院id")
+    private String id;
+
+    @ApiModelProperty(value = "名称")
+    private String name;
+
+    @ApiModelProperty(value = "套餐id")
+    private String packageId;
+
+    @ApiModelProperty(value = "医院套餐名称")
+    private String packageName;
+
+
+    @ApiModelProperty(value = "医院管理用户名")
+    private String username;
+
+    @ApiModelProperty(value = "状态 0、开启 1、关闭")
+    private Boolean disable;
+
+    @ApiModelProperty("邀请码")
+    private String inviteCode;
+    
+    @ApiModelProperty("网络泵的医院编码")
+    private String code;
+
+    @ApiModelProperty("医院头像")
+    private String tenantAvatar;
+
+    @ApiModelProperty("医院备注")
+    private String remark;
+
+    @ApiModelProperty("创建时间")
+    private Date createTime;
+}

+ 42 - 19
tr-modules/tr-module-system/src/main/resources/mapper/tenant/SysTenantMapper.xml

@@ -3,32 +3,41 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.tr.module.sys.tenant.repository.SysTenantRepository">
-    <resultMap id="CommonResult" type="cn.tr.module.sys.tenant.dto.SysTenantCommonDTO">
+    <resultMap id="CommonResult" type="cn.tr.module.sys.tenant.vo.SysTenantCommonVO">
         <result column="id" property="id"/>
         <result column="name" property="name"/>
+        <result column="package_id" property="packageId"/>
         <result column="package_name" property="packageName"/>
         <result column="username" property="username"/>
-        <result column="type" property="type"/>
-        <result column="contract_user" property="contractUser"/>
-        <result column="contact_mobile" property="contactMobile"/>
         <result column="remark" property="remark"/>
         <result column="disable" property="disable"/>
+        <result column="invite_code" property="inviteCode"/>
+        <result column="code" property="code"/>
+        <result column="tenant_avatar" property="tenantAvatar"/>
     </resultMap>
 
-    <select id="stdSelectList" resultType="cn.tr.module.sys.tenant.dto.SysTenantCommonDTO" parameterType="cn.tr.module.sys.tenant.dto.SysTenantQueryDTO">
-            select t.*,tp.package_name,u.username from
-            sys_tenant as t LEFT JOIN sys_tenant_package as tp on t.package_id=tp.id
-            LEFT JOIN sys_user as u on u.id=t.tenant_user_id
+    <select id="stdSelectList" resultMap="CommonResult" parameterType="cn.tr.module.sys.tenant.dto.SysTenantQueryDTO">
+        select
+        t.id as  id,
+        t.name as name,
+        t.package_id as package_id,
+        tp.package_name as package_name,
+        t.disable as  disable,
+        t.invite_code as invite_code,
+        t.code as  code,
+        t.avatar as tenant_avatar,
+        t.remark as  remark,
+        t.avatar as tenant_avatar,
+        t.create_time,
+        u.username as username
+        from
+        sys_tenant as t
+        LEFT JOIN sys_tenant_package as tp on t.package_id=tp.id
+        LEFT JOIN sys_user as u on u.id=t.tenant_user_id
         <where>
             t.deleted = 0
             <if test="query.name != null">
-                    and t.name like  concat('%',#{query.name},'%')
-            </if>
-            <if test="query.contractUser != null">
-                and t.contract_user like  concat('%',#{query.contractUser},'%')
-            </if>
-            <if test="query.contactMobile != null">
-                and t.contact_mobile like  concat('%',#{query.contactMobile},'%')
+                and t.name like  concat('%',#{query.name},'%')
             </if>
             <if test="query.disable != null">
                 and t.disable = #{query.disable}
@@ -36,10 +45,24 @@
         </where>
     </select>
 
-    <select id="stdSelectById" resultType="cn.tr.module.sys.tenant.dto.SysTenantCommonDTO" parameterType="java.lang.String">
-        select t.*,tp.package_name,u.username from
-        sys_tenant as t LEFT JOIN sys_tenant_package as tp on t.package_id=tp.id
+    <select id="stdSelectById" resultMap="CommonResult" parameterType="java.lang.String">
+        select
+        t.id as  id,
+        t.name as name,
+        t.package_id as package_id,
+        tp.package_name as package_name,
+        t.disable as  disable,
+        t.invite_code as invite_code,
+        t.code as  code,
+        t.avatar as tenant_avatar,
+        t.remark as  remark,
+        t.avatar as tenant_avatar,
+        t.create_time,
+        u.username as username
+        from
+        sys_tenant as t
+        LEFT JOIN sys_tenant_package as tp on t.package_id=tp.id
         LEFT JOIN sys_user as u on u.id=t.tenant_user_id
-        where t.id = #{id} and  t.deleted = 0
+        where t.id = #{id}
     </select>
 </mapper>