Procházet zdrojové kódy

1.机构模块问题修改

yuanliang před 2 roky
rodič
revize
2c6a6e20eb

+ 27 - 47
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/TenantInfoController.java

@@ -1,14 +1,14 @@
 package com.yonge.cooleshow.admin.controller;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.yonge.cooleshow.biz.dal.dto.req.TeacherSubmitReq;
+import com.yonge.cooleshow.admin.io.request.TenantInfoVo;
 import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
 import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
 import com.yonge.cooleshow.biz.dal.wrapper.TenantInfoWrapper;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.toolset.base.page.PageInfo;
-import com.yonge.toolset.base.util.StringUtil;
 import com.yonge.toolset.mybatis.support.PageUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -39,64 +39,43 @@ public class TenantInfoController extends BaseController {
      */
     @PostMapping("/page")
     @ApiOperation(value = "查询分页", notes = "TenantInfo")
-    //@PreAuthorize("@pcs.hasPermissions('tenantInfo/page')")
+    @PreAuthorize("@pcs.hasPermissions('tenantInfo/page')")
     public HttpResponseResult<PageInfo<TenantInfoWrapper.TenantInfo>> page(@RequestBody TenantInfoWrapper.TenantInfoQuery query) {
 
-        IPage<TenantInfoWrapper.TenantInfo> pages = tenantInfoService.selectPage(PageUtil.getPage(query), query);
+        IPage<TenantInfoWrapper.TenantInfo> pages = tenantInfoService.selectPage(query);
         return succeed(PageUtil.pageInfo(pages));
     }
 
 
-
     /**
-     * 修改数据
-     */
-    @PostMapping("/update")
-    @ApiOperation(value = "修改", notes = "传入TenantInfo")
-    //@PreAuthorize("@pcs.hasPermissions('tenantInfo/update')")
-    public HttpResponseResult<Boolean> updateTenantInfo(@Valid @RequestBody TenantInfo info) {
-
-        return succeed(tenantInfoService.updateTenantInfo(info));
-    }
-
-    /**
-     * 查看详情
+     * 插入数据
      */
-    @PostMapping("/detail")
-    @ApiOperation(value = "查看详情", notes = "查看详情")
-    //@PreAuthorize("@pcs.hasPermissions('tenantInfo/detail')")
-    public HttpResponseResult<TenantInfoWrapper.TenantInfo > detail(@Valid @RequestBody TenantInfo info) {
-        Long id = info.getId();
-        return succeed(tenantInfoService.Infodetail(id));
+    @PostMapping("/add")
+    @ApiOperation(value = "更新", notes = "传入TenantInfo")
+    @PreAuthorize("@pcs.hasPermissions('tenantInfo/add')")
+    public HttpResponseResult<Boolean> add(@Validated @RequestBody TenantInfoVo.TenantInfo info) {
+        return succeed(tenantInfoService.add(JSON.parseObject(info.jsonString(), TenantInfo.class)));
     }
 
-
-
     /**
-     * 插入数据
+     * 修改数据
      */
-    @PostMapping("/insert")
-    @ApiOperation(value = "更新", notes = "传入TenantInfo")
-    //@PreAuthorize("@pcs.hasPermissions('tenantInfo/insert')")
-    public HttpResponseResult<Boolean> insertTenantInfo( @RequestBody TenantInfo info) {
-
-
-
-        return succeed(tenantInfoService.add(info));
+    @PostMapping("/update")
+    @ApiOperation(value = "修改", notes = "传入TenantInfo")
+    @PreAuthorize("@pcs.hasPermissions('tenantInfo/update')")
+    public HttpResponseResult<Boolean> update(@Valid @RequestBody TenantInfoVo.TenantInfo info) {
+        return succeed(tenantInfoService.update(JSON.parseObject(info.jsonString(), TenantInfo.class)));
     }
 
-
     /**
      * 冻结
      */
-    @PostMapping("/state")
+    @PostMapping("/updateStatus")
     @ApiOperation(value = "冻结", notes = "传入id和布尔类型")
-    @PreAuthorize("@pcs.hasPermissions('tenantInfo/state')")
-    public HttpResponseResult<Boolean> state(@RequestBody TenantInfoWrapper.TenantInfoQuery query) {
-        if (StringUtil.isEmpty(query.getId())) {
-            return failed("参数不能为空");
-        }
-        return status(tenantInfoService.state(query));
+    @PreAuthorize("@pcs.hasPermissions('tenantInfo/updateStatus')")
+    public HttpResponseResult<Boolean> updateStatus(@RequestBody TenantInfoWrapper.UpdateStatus updateStatus) {
+        tenantInfoService.updateStatus(updateStatus);
+        return succeed();
     }
 
 
@@ -108,8 +87,9 @@ public class TenantInfoController extends BaseController {
     //@PreAuthorize("@pcs.hasPermissions('tenantInfo/applyPage')")
     public HttpResponseResult<PageInfo<TenantInfoWrapper.TenantInfo>> applyPage(@RequestBody TenantInfoWrapper.TenantInfoQuery query) {
 
-        IPage<TenantInfoWrapper.TenantInfo> pages = tenantInfoService.applyPage(PageUtil.getPage(query), query);
-        return succeed(PageUtil.pageInfo(pages));
+//        IPage<TenantInfoWrapper.TenantInfo> pages = tenantInfoService.applyPage(PageUtil.getPage(query), query);
+//        return succeed(PageUtil.pageInfo(pages));
+        return null;
     }
 
 
@@ -122,8 +102,9 @@ public class TenantInfoController extends BaseController {
     //@PreAuthorize("@pcs.hasPermissions('tenantInfo/historyPage')")
     public HttpResponseResult<PageInfo<TenantInfoWrapper.TenantInfo>> historyPage(@RequestBody TenantInfoWrapper.TenantInfoQuery query) {
 
-        IPage<TenantInfoWrapper.TenantInfo> pages = tenantInfoService.historyPage(PageUtil.getPage(query), query);
-        return succeed(PageUtil.pageInfo(pages));
+//        IPage<TenantInfoWrapper.TenantInfo> pages = tenantInfoService.historyPage(PageUtil.getPage(query), query);
+//        return succeed(PageUtil.pageInfo(pages));
+        return null;
     }
 
 
@@ -152,5 +133,4 @@ public class TenantInfoController extends BaseController {
     }
 
 
-
 }

+ 69 - 0
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/io/request/TenantInfoVo.java

@@ -0,0 +1,69 @@
+package com.yonge.cooleshow.admin.io.request;
+
+import com.alibaba.fastjson.JSON;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Date;
+
+import lombok.Data;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+
+/**
+ * 机构表
+ * 2023-08-01 11:19:12
+ */
+@ApiModel(value = "TenantInfoVo对象", description = "机构表查询视图对象")
+public class TenantInfoVo {
+
+    @Data
+    @ApiModel(" TenantInfo-机构表")
+    public static class TenantInfo {
+
+        @ApiModelProperty("主键ID")
+        private Long id;
+
+        @ApiModelProperty("名称")
+        @NotNull
+        private String name;
+
+        @ApiModelProperty("logo")
+        private String logo;
+
+        @ApiModelProperty("简介")
+        private String briefIntroduction;
+
+        @ApiModelProperty("省份编码")
+        @NotNull
+        private Integer provinceCode;
+
+        @ApiModelProperty("城市编码")
+        @NotNull
+        private Integer cityCode;
+
+        @ApiModelProperty("地区/街道")
+        @NotNull
+        private Integer regionCode;
+
+        @ApiModelProperty("联系人")
+        @Length(min = 1, max = 8, message = "联系人字符最大8位")
+        private String username;
+
+        @ApiModelProperty("手机号")
+        @NotNull
+        @Pattern(regexp = "^1\\d{10}$", message = "手机号码格式错误")
+        private String phone;
+
+        public String jsonString() {
+            return JSON.toJSONString(this);
+        }
+
+        public static TenantInfo from(String json) {
+            return JSON.parseObject(json, TenantInfo.class);
+        }
+    }
+
+}

+ 3 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/StudentDao.java

@@ -11,6 +11,7 @@ import com.yonge.cooleshow.biz.dal.entity.Student;
 import com.yonge.cooleshow.biz.dal.entity.Subject;
 import com.yonge.cooleshow.biz.dal.vo.MyFollow;
 import com.yonge.cooleshow.biz.dal.vo.StudentVo;
+import com.yonge.cooleshow.biz.dal.wrapper.TenantInfoWrapper;
 import org.apache.ibatis.annotations.Param;
 
 public interface StudentDao extends BaseMapper<Student> {
@@ -74,4 +75,6 @@ public interface StudentDao extends BaseMapper<Student> {
     List<Map<Integer, String>> getStudentSubjectMapList(List<Long> studentIds);
 
     int countStudentsWithTenant(Map<String, Object> params);
+
+    List<TenantInfoWrapper.UserCount> countTeacherByTenantIds(@Param("tenantIdList") List<Long> tenantIdList);
 }

+ 11 - 5
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/TeacherDao.java

@@ -15,6 +15,7 @@ import com.yonge.cooleshow.biz.dal.vo.MyFens;
 import com.yonge.cooleshow.biz.dal.vo.TeacherVo;
 
 import com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper;
+import com.yonge.cooleshow.biz.dal.wrapper.TenantInfoWrapper;
 import org.apache.ibatis.annotations.Param;
 
 public interface TeacherDao extends BaseMapper<Teacher> {
@@ -33,18 +34,18 @@ public interface TeacherDao extends BaseMapper<Teacher> {
     List<TeacherVo> selectPage(@Param("page") IPage page, @Param("param") TeacherSearch teacher);
 
     /**
-     * @description: 获取用户基本信息
      * @param userId
      * @return com.yonge.cooleshow.biz.dal.dto.BasicUserInfo
+     * @description: 获取用户基本信息
      * @author zx
      * @date 2022/3/22 13:52
      */
     BasicUserInfo getBasicUserInfo(@Param("userId") Long userId);
 
     /**
-     * @description: 获取用户基本信息
      * @param studentIds
      * @return com.yonge.cooleshow.biz.dal.dto.BasicUserInfo
+     * @description: 获取用户基本信息
      * @author zx
      * @date 2022/3/22 13:52
      */
@@ -85,26 +86,31 @@ public interface TeacherDao extends BaseMapper<Teacher> {
      * @updateTime 2022/5/9 10:17
      * @return: java.util.List<com.yonge.cooleshow.biz.dal.entity.Subject>
      */
-    List<Subject> querySubjectItem(@Param("userId") Long userId, @Param("type")String type);
+    List<Subject> querySubjectItem(@Param("userId") Long userId, @Param("type") String type);
 
     /**
      * 查询我的粉丝
-     * @param page IPage<MyFens>
+     *
+     * @param page  IPage<MyFens>
      * @param query TeacherQueryInfo.FansQuery
      * @return List<MyFens>
      */
     List<MyFens> queryMyFans(@Param("page") IPage<MyFens> page, @Param("record") TeacherQueryInfo.FansQuery query);
-    
+
     /**
      * 查询热门老师
+     *
      * @return
      */
     List<HotTeacherVo> queryHotTeacherList(Long subjectId);
 
     /**
      * 老师学生人数统计
+     *
      * @param teacherIds 老师ID
      * @return List<StatGroupWrapper>
      */
     List<StatGroupWrapper> selectTeacherStudentNumberStatInfo(@Param("teacherIds") List<Long> teacherIds);
+
+    List<TenantInfoWrapper.UserCount> countTeacherByTenantIds(@Param("tenantIdList") List<Long> tenantIdList);
 }

+ 2 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/TenantInfoMapper.java

@@ -45,9 +45,9 @@ public interface TenantInfoMapper extends BaseMapper<TenantInfo> {
 
 	Boolean insertInfo(@Param("param") TenantInfo tenantInfo);
 
-	TeacherCounts queryTeacherCounts(@Param("id") Long Id);
+	TeacherCounts queryTeacherCounts(@Param("id") Long id);
 
-	StudentCounts queryStudentCounts(@Param("id") long Id);
+	StudentCounts queryStudentCounts(@Param("id") Long id);
 
 	List<TenantInfoWrapper.TenantInfo> selectApplyPage(@Param("page") IPage<TenantInfoWrapper.TenantInfo> page, @Param("param") TenantInfoWrapper.TenantInfoQuery query);
 

+ 4 - 5
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/TenantInfoService.java

@@ -24,11 +24,10 @@ public interface TenantInfoService extends IService<TenantInfo>  {
 
     /**
      * 分页查询
-     * @param page IPage<TenantInfo>
      * @param query TenantInfoWrapper.TenantInfoQuery
      * @return IPage<TenantInfo>
      */
-    IPage<TenantInfoWrapper.TenantInfo> selectPage(IPage<TenantInfoWrapper.TenantInfo> page, TenantInfoWrapper.TenantInfoQuery query);
+    IPage<TenantInfoWrapper.TenantInfo> selectPage(TenantInfoWrapper.TenantInfoQuery query);
 	
     /**
      * 添加
@@ -42,7 +41,7 @@ public interface TenantInfoService extends IService<TenantInfo>  {
      * @param info TenantInfoWrapper.TenantInfo
      * @return Boolean
      */
-    Boolean updateTenantInfo(TenantInfo info);
+    Boolean update(TenantInfo info);
 
     /**
      * 机构信息
@@ -55,10 +54,10 @@ public interface TenantInfoService extends IService<TenantInfo>  {
 
     /**
      * 冻结
-     * @param query
+     * @param updateStatus
      * @return
      */
-    Boolean state(TenantInfoWrapper.TenantInfoQuery query);
+    Boolean updateStatus(TenantInfoWrapper.UpdateStatus updateStatus);
 
 
 

+ 155 - 131
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantInfoServiceImpl.java

@@ -1,11 +1,17 @@
 package com.yonge.cooleshow.biz.dal.service.impl;
 
-import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.yonge.cooleshow.biz.dal.entity.*;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import com.yonge.cooleshow.biz.dal.dao.StudentDao;
+import com.yonge.cooleshow.biz.dal.dao.TeacherDao;
+import com.yonge.cooleshow.biz.dal.entity.SysArea;
+import com.yonge.cooleshow.biz.dal.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.entity.Teacher;
+import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
+import com.yonge.cooleshow.biz.dal.entity.TenantStaff;
 import com.yonge.cooleshow.biz.dal.mapper.SysUserMapper;
 import com.yonge.cooleshow.biz.dal.mapper.TenantApplyRecordMapper;
 import com.yonge.cooleshow.biz.dal.mapper.TenantEntryRecordMapper;
@@ -14,7 +20,6 @@ import com.yonge.cooleshow.biz.dal.mapper.TenantStaffMapper;
 import com.yonge.cooleshow.biz.dal.service.SysAreaService;
 import com.yonge.cooleshow.biz.dal.service.SysConfigService;
 import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
-import com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumWrapper;
 import com.yonge.cooleshow.biz.dal.wrapper.TenantInfoWrapper;
 import com.yonge.cooleshow.common.constant.SysConfigConstant;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
@@ -68,6 +73,11 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
     @Autowired
     TenantApplyRecordMapper tenantApplyRecordMapper;
 
+    @Autowired
+    private TeacherDao teacherDao;
+
+    @Autowired
+    private StudentDao studentDao;
 
 
     /**
@@ -88,32 +98,38 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
     /**
      * 分页查询
      *
-     * @param page  IPage<TenantInfo>
      * @param query TenantInfoWrapper.TenantInfoQuery
      * @return IPage<TenantInfo>
      */
     @Override
-    public IPage<TenantInfoWrapper.TenantInfo> selectPage(IPage<TenantInfoWrapper.TenantInfo> page,
-                                                          TenantInfoWrapper.TenantInfoQuery query) {
+    public IPage<TenantInfoWrapper.TenantInfo> selectPage(TenantInfoWrapper.TenantInfoQuery query) {
 
         //分页查询
+        IPage<TenantInfoWrapper.TenantInfo> page = QueryInfo.getPage(query);
         List<TenantInfoWrapper.TenantInfo> tenantInfos = baseMapper.selectPage(page, query);
-        //获取id
+        if (tenantInfos.isEmpty()) {
+            return page.setRecords(new ArrayList<>());
+        }
 
-        //查询对应机构的老师学生数量
-        TeacherCounts  teacherCounts= new TeacherCounts();
-        StudentCounts  studentCounts= new StudentCounts();
+        List<Long> tenantIdList =
+                tenantInfos.stream().map(TenantInfoWrapper.TenantInfo::getId).collect(Collectors.toList());
 
-        for (int i = 0; i < tenantInfos.size(); i++) {
-            TenantInfoWrapper.TenantInfo info = tenantInfos.get(i);
-            long id = info.getId();
-            teacherCounts = tenantInfoMapper.queryTeacherCounts(id);
-            studentCounts = tenantInfoMapper.queryStudentCounts(id);
-            info.setTeacherCounts(teacherCounts.getTeacherCounts().toString());
-            info.setStudentCounts(studentCounts.getStudentCounts().toString());
+        List<TenantInfoWrapper.UserCount> teacherByTenantIds = teacherDao.countTeacherByTenantIds(tenantIdList);
+        List<TenantInfoWrapper.UserCount> studentByTenantIds = studentDao.countTeacherByTenantIds(tenantIdList);
 
-        }
+        Map<Long, Integer> teacherIdCountMap = teacherByTenantIds.stream()
+                .collect(Collectors.toMap(TenantInfoWrapper.UserCount::getTenantId,
+                        TenantInfoWrapper.UserCount::getCount));
 
+        Map<Long, Integer> studentIdCountMap = studentByTenantIds.stream()
+                .collect(Collectors.toMap(TenantInfoWrapper.UserCount::getTenantId,
+                        TenantInfoWrapper.UserCount::getCount));
+
+
+        for (TenantInfoWrapper.TenantInfo info : tenantInfos) {
+            info.setTeacherCounts(teacherIdCountMap.getOrDefault(info.getId(), 0));
+            info.setTeacherCounts(studentIdCountMap.getOrDefault(info.getId(), 0));
+        }
 
         //获取省市区信息
         List<TenantInfoWrapper.TenantInfo> tenantList = queryArea(tenantInfos);
@@ -127,9 +143,15 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
      * @param tenantInfo TenantInfoWrapper.TenantInfo
      * @return Boolean
      */
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public Boolean add(TenantInfo tenantInfo) {
-        SysUser sysUser = getOrCreateAccount(tenantInfo);
+        SysUser sysUser = getOrCreateAccount(tenantInfo, null);
+        tenantInfo.setEnableFlag(true);
+        if (StringUtils.isEmpty(tenantInfo.getLogo())) {
+            // todo 设置默认logo
+            tenantInfo.setLogo("");
+        }
         tenantInfo.setEnableFlag(true);
         tenantInfo.setUserId(sysUser.getId());
         tenantInfoMapper.insert(tenantInfo);
@@ -140,13 +162,12 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
         tenantStaff.setAvatar(sysUser.getAvatar());
         tenantStaff.setNickname(tenantInfo.getUsername());
         tenantStaff.setStatus(UserLockFlag.NORMAL);
+        tenantStaff.setManageAdmin(true);
         tenantStaffMapper.insert(tenantStaff);
-
-
         return true;
     }
 
-    private SysUser getOrCreateAccount(TenantInfo tenantInfo) {
+    private SysUser getOrCreateAccount(TenantInfo tenantInfo, TenantInfo oldTenantInfo) {
         QueryWrapper<SysUser> sysUserQueryWrapper = new QueryWrapper<>();
         sysUserQueryWrapper.lambda().eq(SysUser::getPhone, tenantInfo.getPhone());
         List<SysUser> sysUsers = sysUserMapper.selectList(sysUserQueryWrapper);
@@ -155,7 +176,8 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
         if (!sysUsers.isEmpty()) {
             sysUser = sysUsers.get(0);
             TenantStaff tenantStaff = tenantStaffMapper.selectById(sysUser.getId());
-            if (tenantStaff != null) {
+            if (tenantStaff != null && oldTenantInfo != null &&
+                    !tenantStaff.getUserId().equals(oldTenantInfo.getUserId())) {
                 throw new BizException("手机号已经注册机构账号");
             }
             //获取当前账户的用户类型
@@ -225,41 +247,35 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
     }
 
     /**
-     * 冻结
+     * 修改状态
      *
-     * @param query TenantInfoWrapper.TenantInfo
-     * @return Boolean
+     * @param updateStatus updateStatus
+     * @return true
      */
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public Boolean state(TenantInfoWrapper.TenantInfoQuery query) {
-        Boolean flag;
-        long id = query.getId();
-        TenantInfo info = detail(id);
+    public Boolean updateStatus(TenantInfoWrapper.UpdateStatus updateStatus) {
 
-        //TenantInfo info = this.getById(id);
-        if (Objects.isNull(info)) {
+        boolean update = this.lambdaUpdate()
+                .set(TenantInfo::getEnableFlag, updateStatus.getEnableFlag())
+                .eq(TenantInfo::getId, updateStatus.getId())
+                .update();
+        if (!update) {
             throw new BizException("机构信息不存在");
         }
-        //获取是否冻结
-        if (query.getIfFreeze() == 1) {
-            if (!info.getEnableFlag()) {
-                return false;
-            }
-            //修改机构账号冻结状态
-            flag = tenantInfoMapper.updateFlag(id);
-            //修改机构staff状态
-            tenantStaffMapper.updateById();
-            //是否更改结算方式
-            if (query.getIfMethod() == 1) {
-                tenantInfoMapper.updateMethod(id);
-            } else {
-                return true;
-            }
-        } else {
-            return false;
+
+        if (!updateStatus.getEnableFlag()) {
+            tenantStaffMapper.update(null, Wrappers.<TenantStaff>lambdaUpdate()
+                    .set(TenantStaff::getStatus, UserLockFlag.LOCKED)
+                    .eq(TenantStaff::getTenantId, updateStatus.getId()));
+        }
+
+        if (updateStatus.getSettlement() != null) {
+            teacherDao.update(null, Wrappers.<Teacher>lambdaUpdate()
+                    .set(Teacher::getSettlementFrom, updateStatus.getSettlement())
+                    .eq(Teacher::getTenantId, updateStatus.getId()));
         }
-        return flag;
+        return true;
     }
 
 
@@ -270,17 +286,22 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
      * @return Boolean
      */
     @Override
-    public Boolean updateTenantInfo(TenantInfo info) {
+    public Boolean update(TenantInfo info) {
+        // todo  机构冻结状态是否允许修改
         //更新或创建sysUser
-        SysUser sysUser = getOrCreateAccount(info);
-
         TenantInfo oldTenantInfo = this.getById(info.getId());
+        SysUser sysUser = getOrCreateAccount(info, oldTenantInfo);
+
         tenantStaffMapper.update(null, Wrappers.<TenantStaff>lambdaUpdate()
                 .set(TenantStaff::getUserId, sysUser.getId())
                 .set(TenantStaff::getNickname, info.getUsername())
                 .eq(TenantStaff::getUserId, oldTenantInfo.getUserId())
         );
 
+        if (StringUtils.isEmpty(info.getLogo())) {
+            // todo 设置默认logo
+            info.setLogo("");
+        }
         tenantInfoMapper.update(null, Wrappers.<TenantInfo>lambdaUpdate()
                 .set(TenantInfo::getName, info.getName())
                 .set(TenantInfo::getLogo, info.getLogo())
@@ -288,8 +309,9 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
                 .set(TenantInfo::getProvinceCode, info.getProvinceCode())
                 .set(TenantInfo::getCityCode, info.getCityCode())
                 .set(TenantInfo::getRegionCode, info.getRegionCode())
-                .set(TenantInfo::getPhone,  info.getPhone())
+                .set(TenantInfo::getPhone, info.getPhone())
                 .set(TenantInfo::getUsername, info.getUsername())
+                .set(TenantInfo::getUserId, sysUser.getId())
                 .eq(TenantInfo::getId, info.getId())
         );
         return true;
@@ -321,13 +343,14 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
     @Override
     public IPage<TenantInfoWrapper.TenantInfo> historyPage(IPage<TenantInfoWrapper.TenantInfo> page,
                                                            TenantInfoWrapper.TenantInfoQuery query) {
-        long id = query.getId();
-        //分页查询
-        List<TenantInfoWrapper.TenantInfo> tenantInfos = baseMapper.selectHistoryPage(page, id);
-        //查询对应省市区
-        List<TenantInfoWrapper.TenantInfo> infos = queryArea(tenantInfos);
-
-        return page.setRecords(infos);
+//        long id = query.getId();
+//        //分页查询
+//        List<TenantInfoWrapper.TenantInfo> tenantInfos = baseMapper.selectHistoryPage(page, id);
+//        //查询对应省市区
+//        List<TenantInfoWrapper.TenantInfo> infos = queryArea(tenantInfos);
+//
+//        return page.setRecords(infos);
+        return null;
     }
 
     /**
@@ -365,80 +388,81 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoMapper, TenantI
 
     @Override
     public Boolean entry(TenantInfoWrapper.TenantInfoQuery query) {
-        Integer pass = query.getIfPass();
-        //审核通过
-        if (pass == 1) {
-            //查询本次提交记录,并插入审核表
-            TenantInfoWrapper.TenantInfo info = queryNow(query);
-            TenantEntryRecord entryRecord = new TenantEntryRecord();
-            entryRecord.setId(info.getId());
-            entryRecord.setName(info.getName());
-            entryRecord.setLogo(info.getLogo());
-            entryRecord.setProvinceCode(info.getProvinceCode());
-            entryRecord.setCityCode(info.getCityCode());
-            entryRecord.setRegionCode(info.getRegionCode());
-            entryRecord.setUsername(info.getUserName());
-            entryRecord.setPhone(info.getPhone());
-            entryRecord.setStatus("PASS");
-            entryRecord.setVerifyUserId(info.getVerifyUserId());
-            entryRecord.setReason(info.getReason());
-            entryRecord.setCreateTime(info.getCreateTime());
-            tenantEntryRecordMapper.insert(entryRecord);
-            //更改当前记录的审核状态
-            long id = info.getId();
-            tenantInfoMapper.updateStatusById(id);
-
-            //机构账户新增逻辑
-            TenantInfo tenantInfo = new TenantInfo();
-            tenantInfo.setId(info.getId());
-            tenantInfo.setLogo(info.getLogo());
-            tenantInfo.setName(info.getName());
-            tenantInfo.setProvinceCode(info.getProvinceCode());
-            tenantInfo.setCityCode(info.getCityCode());
-            tenantInfo.setRegionCode(info.getRegionCode());
-            tenantInfo.setUsername(info.getUserName());
-            tenantInfo.setPhone(info.getPhone());
-            tenantInfo.setEnableFlag(true);
-            tenantInfo.setBriefIntroduction(info.getBriefIntroduction());
-            tenantInfo.setUpdateTime(info.getUpdateTime());
-            tenantInfo.setCreateTime(info.getCreateTime());
-            add(tenantInfo);
-
-
-        } else {
-            //查询本次提交记录,并插入审核表
-            TenantInfoWrapper.TenantInfo info = queryNow(query);
-            TenantEntryRecord entryRecord = new TenantEntryRecord();
-            entryRecord.setId(info.getId());
-            entryRecord.setName(info.getName());
-            entryRecord.setLogo(info.getLogo());
-            entryRecord.setProvinceCode(info.getProvinceCode());
-            entryRecord.setCityCode(info.getCityCode());
-            entryRecord.setRegionCode(info.getRegionCode());
-            entryRecord.setUsername(info.getUserName());
-            entryRecord.setPhone(info.getPhone());
-            entryRecord.setStatus("UNPASS");
-            entryRecord.setVerifyUserId(info.getVerifyUserId());
-            entryRecord.setReason(info.getReason());
-            entryRecord.setCreateTime(info.getCreateTime());
-            tenantEntryRecordMapper.insert(entryRecord);
-            //更改当前记录的审核状态
-            long id = info.getId();
-            tenantInfoMapper.updateUnpassStatusById(id);
-        }
-        return  true;
+//        Integer pass = query.getIfPass();
+//        //审核通过
+//        if (pass == 1) {
+//            //查询本次提交记录,并插入审核表
+//            TenantInfoWrapper.TenantInfo info = queryNow(query);
+//            TenantEntryRecord entryRecord = new TenantEntryRecord();
+//            entryRecord.setId(info.getId());
+//            entryRecord.setName(info.getName());
+//            entryRecord.setLogo(info.getLogo());
+//            entryRecord.setProvinceCode(info.getProvinceCode());
+//            entryRecord.setCityCode(info.getCityCode());
+//            entryRecord.setRegionCode(info.getRegionCode());
+//            entryRecord.setUsername(info.getUserName());
+//            entryRecord.setPhone(info.getPhone());
+//            entryRecord.setStatus("PASS");
+//            entryRecord.setVerifyUserId(info.getVerifyUserId());
+//            entryRecord.setReason(info.getReason());
+//            entryRecord.setCreateTime(info.getCreateTime());
+//            tenantEntryRecordMapper.insert(entryRecord);
+//            //更改当前记录的审核状态
+//            long id = info.getId();
+//            tenantInfoMapper.updateStatusById(id);
+//
+//            //机构账户新增逻辑
+//            TenantInfo tenantInfo = new TenantInfo();
+//            tenantInfo.setId(info.getId());
+//            tenantInfo.setLogo(info.getLogo());
+//            tenantInfo.setName(info.getName());
+//            tenantInfo.setProvinceCode(info.getProvinceCode());
+//            tenantInfo.setCityCode(info.getCityCode());
+//            tenantInfo.setRegionCode(info.getRegionCode());
+//            tenantInfo.setUsername(info.getUserName());
+//            tenantInfo.setPhone(info.getPhone());
+//            tenantInfo.setEnableFlag(true);
+//            tenantInfo.setBriefIntroduction(info.getBriefIntroduction());
+//            tenantInfo.setUpdateTime(info.getUpdateTime());
+//            tenantInfo.setCreateTime(info.getCreateTime());
+//            add(tenantInfo);
+//
+//
+//        } else {
+//            //查询本次提交记录,并插入审核表
+//            TenantInfoWrapper.TenantInfo info = queryNow(query);
+//            TenantEntryRecord entryRecord = new TenantEntryRecord();
+//            entryRecord.setId(info.getId());
+//            entryRecord.setName(info.getName());
+//            entryRecord.setLogo(info.getLogo());
+//            entryRecord.setProvinceCode(info.getProvinceCode());
+//            entryRecord.setCityCode(info.getCityCode());
+//            entryRecord.setRegionCode(info.getRegionCode());
+//            entryRecord.setUsername(info.getUserName());
+//            entryRecord.setPhone(info.getPhone());
+//            entryRecord.setStatus("UNPASS");
+//            entryRecord.setVerifyUserId(info.getVerifyUserId());
+//            entryRecord.setReason(info.getReason());
+//            entryRecord.setCreateTime(info.getCreateTime());
+//            tenantEntryRecordMapper.insert(entryRecord);
+//            //更改当前记录的审核状态
+//            long id = info.getId();
+//            tenantInfoMapper.updateUnpassStatusById(id);
+//        }
+        return true;
     }
 
     @Override
     public TenantInfoWrapper.TenantInfo Infodetail(Long id) {
-        if (id == null || id == -1) {
-            return null;
-        }
-        TenantInfoWrapper.TenantInfo info = tenantInfoMapper.selectInfoById(id);
-
-        info.setStudentCounts(tenantInfoMapper.queryStudentCount(id));
-        info.setTeacherCounts(tenantInfoMapper.queryTeacherCount(id));
-        return info;
+//        if (id == null || id == -1) {
+//            return null;
+//        }
+//        TenantInfoWrapper.TenantInfo info = tenantInfoMapper.selectInfoById(id);
+//
+//        info.setStudentCounts(tenantInfoMapper.queryStudentCount(id));
+//        info.setTeacherCounts(tenantInfoMapper.queryTeacherCount(id));
+//        return info;
+        return null;
     }
 
 

+ 38 - 26
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantInfoWrapper.java

@@ -2,8 +2,9 @@ package com.yonge.cooleshow.biz.dal.wrapper;
 
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
-import com.yonge.toolset.base.page.QueryInfo;
+import com.yonge.cooleshow.common.enums.ESettlementFrom;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -24,28 +25,20 @@ import org.apache.commons.lang3.StringUtils;
 public class TenantInfoWrapper {
 
     @Data
-	@Builder
+    @Builder
     @NoArgsConstructor
     @AllArgsConstructor
     @ApiModel(" TenantInfoQuery-机构表")
-    public static class TenantInfoQuery  extends QueryInfo {
-        @ApiModelProperty("id")
-        private long id;
+    public static class TenantInfoQuery implements QueryInfo {
 
-        @ApiModelProperty("是否冻结")
-        private Integer ifFreeze;
+        @ApiModelProperty("当前页")
+        private Integer page;
 
-        @ApiModelProperty("是否更改结算方式")
-        private Integer ifMethod;
-    
-    	@ApiModelProperty("当前页")
-        private int page;
-        
         @ApiModelProperty("分页行数")
-        private int rows;
-        
+        private Integer rows;
+
         @ApiModelProperty("关键字匹配")
-		private String keyword;
+        private String keyword;
 
         @ApiModelProperty("省份编码")
         private Integer provinceCode;
@@ -56,14 +49,10 @@ public class TenantInfoWrapper {
         @ApiModelProperty("地区街道编码")
         private Integer regionCode;
 
-        @ApiModelProperty("审核是否通过")
-        private Integer ifPass;
-
-        
         public String getKeyword() {
             return Optional.ofNullable(keyword).filter(StringUtils::isNotBlank).orElse(null);
         }
-        
+
         public String jsonString() {
             return JSON.toJSONString(this);
         }
@@ -71,7 +60,7 @@ public class TenantInfoWrapper {
         public static TenantInfoQuery from(String json) {
             return JSON.parseObject(json, TenantInfoQuery.class);
         }
-    }  
+    }
 
 
     @Data
@@ -102,10 +91,10 @@ public class TenantInfoWrapper {
         private String phone;
 
         @ApiModelProperty("教师数量")
-        private String teacherCounts;
+        private Integer teacherCounts;
 
         @ApiModelProperty("学生数量")
-        private String studentCounts;
+        private Integer studentCounts;
 
         @ApiModelProperty("省份编码")
         private Integer provinceCode;
@@ -146,7 +135,7 @@ public class TenantInfoWrapper {
 
         @ApiModelProperty("启用/冻结")
         private Boolean enableFlag;
-        
+
         public String jsonString() {
             return JSON.toJSONString(this);
         }
@@ -154,6 +143,29 @@ public class TenantInfoWrapper {
         public static TenantInfo from(String json) {
             return JSON.parseObject(json, TenantInfo.class);
         }
-	}
+    }
+
+    @ApiModel("启用/冻结")
+    @Data
+    public static class UpdateStatus {
+
+        @ApiModelProperty("id")
+        private Long id;
+
+        @ApiModelProperty("true:启用/false:冻结")
+        private Boolean enableFlag;
+
+        @ApiModelProperty("结算方式")
+        private ESettlementFrom settlement;
+    }
+
+    @Data
+    public static class UserCount {
+
+        private Long tenantId;
+
+        private Integer count;
+
+    }
 
 }

+ 11 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/StudentMapper.xml

@@ -315,4 +315,15 @@
             AND (su.username_ LIKE CONCAT('%', #{search}, '%') OR su.phone_ LIKE CONCAT('%', #{search}, '%'))
         </if>
     </select>
+
+    <select id="countTeacherByTenantIds" resultType="com.yonge.cooleshow.biz.dal.wrapper.TenantInfoWrapper$UserCount">
+        select tenant_id_ tenantId, count(tenant_id_) count
+        from student
+        where tenant_id_ in
+        <foreach collection="tenantIdList" item="item" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        group by tenant_id_
+
+    </select>
 </mapper>

+ 192 - 161
cooleshow-user/user-biz/src/main/resources/config/mybatis/TeacherMapper.xml

@@ -2,56 +2,56 @@
 <!DOCTYPE  mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="com.yonge.cooleshow.biz.dal.dao.TeacherDao">
     <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.Teacher">
-        <result column="user_id_" property="userId" />
-        <result column="education_background_" property="educationBackground" />
-        <result column="graduate_school_" property="graduateSchool" />
-        <result column="technical_titles_" property="technicalTitles" />
-        <result column="work_unit_" property="workUnit" />
-        <result column="subject_id_" property="subjectId" />
-        <result column="default_subject_" property="defaultSubject" />
-        <result column="introduction_" property="introduction" />
-        <result column="subject_" property="subject" />
-        <result column="grad_certificate_" property="gradCertificate" />
-        <result column="degree_certificate_" property="degreeCertificate" />
-        <result column="teacher_certificate_" property="teacherCertificate" />
-        <result column="entry_flag_" property="entryFlag" />
-        <result column="entry_auth_date_" property="entryAuthDate" />
-        <result column="musician_flag_" property="musicianFlag" />
-        <result column="musician_date_" property="musicianDate" />
+        <result column="user_id_" property="userId"/>
+        <result column="education_background_" property="educationBackground"/>
+        <result column="graduate_school_" property="graduateSchool"/>
+        <result column="technical_titles_" property="technicalTitles"/>
+        <result column="work_unit_" property="workUnit"/>
+        <result column="subject_id_" property="subjectId"/>
+        <result column="default_subject_" property="defaultSubject"/>
+        <result column="introduction_" property="introduction"/>
+        <result column="subject_" property="subject"/>
+        <result column="grad_certificate_" property="gradCertificate"/>
+        <result column="degree_certificate_" property="degreeCertificate"/>
+        <result column="teacher_certificate_" property="teacherCertificate"/>
+        <result column="entry_flag_" property="entryFlag"/>
+        <result column="entry_auth_date_" property="entryAuthDate"/>
+        <result column="musician_flag_" property="musicianFlag"/>
+        <result column="musician_date_" property="musicianDate"/>
         <result column="member_rank_setting_id_" property="memberRankSettingId"/>
         <result column="membership_start_time_" property="membershipStartTime"/>
         <result column="membership_end_time_" property="membershipEndTime"/>
-        <result column="live_flag_" property="liveFlag" />
-        <result column="live_date_" property="liveDate" />
-        <result column="music_date_" property="musicDate" />
-        <result column="video_date_" property="videoDate" />
-        <result column="style_date_" property="styleDate" />
-        <result column="degree_date_" property="degreeDate" />
-        <result column="teacher_date_" property="teacherDate" />
-        <result column="degree_flag_" property="degreeFlag" />
-        <result column="teacher_flag_" property="teacherFlag" />
-        <result column="browse_" property="browse" />
-        <result column="memo_" property="memo" />
-        <result column="lock_flag_" property="lockFlag" />
-        <result column="is_settlement_" property="isSettlement" />
-        <result column="is_test_user_" property="isTestUser" />
-        <result column="tenant_id_" property="tenantId" />
-        <result column="settlement_from_" property="settlementFrom" />
-        <result column="create_time_" property="createTime" />
-        <result column="update_time_" property="updateTime" />
+        <result column="live_flag_" property="liveFlag"/>
+        <result column="live_date_" property="liveDate"/>
+        <result column="music_date_" property="musicDate"/>
+        <result column="video_date_" property="videoDate"/>
+        <result column="style_date_" property="styleDate"/>
+        <result column="degree_date_" property="degreeDate"/>
+        <result column="teacher_date_" property="teacherDate"/>
+        <result column="degree_flag_" property="degreeFlag"/>
+        <result column="teacher_flag_" property="teacherFlag"/>
+        <result column="browse_" property="browse"/>
+        <result column="memo_" property="memo"/>
+        <result column="lock_flag_" property="lockFlag"/>
+        <result column="is_settlement_" property="isSettlement"/>
+        <result column="is_test_user_" property="isTestUser"/>
+        <result column="tenant_id_" property="tenantId"/>
+        <result column="settlement_from_" property="settlementFrom"/>
+        <result column="create_time_" property="createTime"/>
+        <result column="update_time_" property="updateTime"/>
     </resultMap>
-    
+
     <resultMap id="HotTeacherVoMap" type="com.yonge.cooleshow.biz.dal.vo.HotTeacherVo">
-        <result column="user_id_" property="userId" />
-        <result column="avatar_" property="avatar" />
-        <result column="graduate_school_" property="graduateSchool" />
-        <result column="username_" property="username" />
-        <result column="isLiving_" property="isLiving" />
+        <result column="user_id_" property="userId"/>
+        <result column="avatar_" property="avatar"/>
+        <result column="graduate_school_" property="graduateSchool"/>
+        <result column="username_" property="username"/>
+        <result column="isLiving_" property="isLiving"/>
     </resultMap>
 
     <!-- 表字段 -->
     <sql id="baseColumns">
-         t.user_id_ as "userId"
+        t.user_id_ as "userId"
         , t.education_background_ as "educationBackground"
         , t.graduate_school_ as "graduateSchool"
         , t.technical_titles_ as "technicalTitles"
@@ -89,29 +89,29 @@
         , t.evaluate_time_ as evaluateTime
         , t.tenant_id_ as tenantId
         , t.settlement_from_ as settlementFrom
-        </sql>
+    </sql>
 
     <!-- 分页查询 -->
-    <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherVo" >
+    <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherVo">
         SELECT
-            <include refid="baseColumns"/>,
-            if(u.lock_flag_ = 0 and t.lock_flag_ = 0,0,1) as lockFlag,
-            u.username_ as username,
-            u.phone_ as phone,
-            u.real_name_ as realName,
-            u.avatar_ as avatar,
-            u.birthdate_ as birthdate,
-            u.gender_ as gender,
-            (case when t.membership_end_time_ &gt;= now() then 1 else 0 end) isVip,
-<!--            t.tag_ tag,-->
-            u.del_flag_ as delFlag,
-            (case when isnull(u.id_card_no_) then 0 else 1 end) as isReal,
-            (case when isnull(b.user_id_) then 0 else 1 end) as isBank,
-            (case when t.tenant_id_ = -1 then '平台老师' else ti.name_ end) as tenantName
+        <include refid="baseColumns"/>,
+        if(u.lock_flag_ = 0 and t.lock_flag_ = 0,0,1) as lockFlag,
+        u.username_ as username,
+        u.phone_ as phone,
+        u.real_name_ as realName,
+        u.avatar_ as avatar,
+        u.birthdate_ as birthdate,
+        u.gender_ as gender,
+        (case when t.membership_end_time_ &gt;= now() then 1 else 0 end) isVip,
+        <!--            t.tag_ tag,-->
+        u.del_flag_ as delFlag,
+        (case when isnull(u.id_card_no_) then 0 else 1 end) as isReal,
+        (case when isnull(b.user_id_) then 0 else 1 end) as isBank,
+        (case when t.tenant_id_ = -1 then '平台老师' else ti.name_ end) as tenantName
         FROM teacher t
         left join sys_user u on t.user_id_ = u.id_
         left join (
-            select distinct user_id_ from user_bank_card where del_flag_ = 0
+        select distinct user_id_ from user_bank_card where del_flag_ = 0
         ) b on t.user_id_ = b.user_id_
         left join tenant_info ti on t.tenant_id_ = ti.id_
         <where>
@@ -125,28 +125,28 @@
             </if>
             <if test="null != param.teacherType and '' != param.teacherType">
                 and (
-                    1=0
-                    <if test='param.teacherType.contains("TOURIST")'>
-                        or (t.entry_flag_ = 0 and t.musician_flag_ = 0)
-                    </if>
-                    <if test='param.teacherType.contains("ENTRY")'>
-                        or t.entry_flag_ = 1
-                    </if>
-                    <if test='param.teacherType.contains("MUSICIAN")'>
-                        or t.musician_flag_ = 1
-                    </if>
+                1=0
+                <if test='param.teacherType.contains("TOURIST")'>
+                    or (t.entry_flag_ = 0 and t.musician_flag_ = 0)
+                </if>
+                <if test='param.teacherType.contains("ENTRY")'>
+                    or t.entry_flag_ = 1
+                </if>
+                <if test='param.teacherType.contains("MUSICIAN")'>
+                    or t.musician_flag_ = 1
+                </if>
                 )
             </if>
             <if test="param.isVip != null">
-            	<if test="param.isVip == 0">
-            		and (t.membership_end_time_ is null or t.membership_end_time_ &lt; now())
-            	</if>
-            	<if test="param.isVip == 1">
-            		and t.membership_end_time_ &gt;= now()
-            	</if>
+                <if test="param.isVip == 0">
+                    and (t.membership_end_time_ is null or t.membership_end_time_ &lt; now())
+                </if>
+                <if test="param.isVip == 1">
+                    and t.membership_end_time_ &gt;= now()
+                </if>
             </if>
             <if test="param.tag != null">
-            	and find_in_set(#{param.tag},t.tag_)
+                and find_in_set(#{param.tag},t.tag_)
             </if>
             <if test="null != param.lockFlag">
                 and t.lock_flag_ = #{param.lockFlag}
@@ -155,13 +155,13 @@
                 and u.del_flag_ = #{param.delFlag}
             </if>
             <if test="param.subjectId != null">
-            	and find_in_set(#{param.subjectId},t.subject_id_)
+                and find_in_set(#{param.subjectId},t.subject_id_)
             </if>
             <if test="param.isSettlement != null">
-            	and t.is_settlement_ = #{param.isSettlement}
+                and t.is_settlement_ = #{param.isSettlement}
             </if>
             <if test="param.isTestUser != null">
-            	and t.is_test_user_ = #{param.isTestUser}
+                and t.is_test_user_ = #{param.isTestUser}
             </if>
             <if test="null != param.vipEndTime">
                 and t.membership_end_time_ &lt;= #{param.vipEndTime}
@@ -195,111 +195,125 @@
         </choose>
     </select>
 
-	<resultMap id="BasicUserInfo" type="com.yonge.cooleshow.biz.dal.dto.BasicUserInfo">
-		<result property="userId" column="user_id_"/>
-		<result property="username" column="username_"/>
-		<result property="realName" column="real_name_"/>
-		<result property="avatar" column="avatar_"/>
-	</resultMap>
-	<select id="getBasicUserInfo" resultMap="BasicUserInfo">
-		SELECT id_ user_id_,username_,real_name_,avatar_ FROM sys_user
-		WHERE del_flag_ = 0 and id_ = #{userId} LIMIT 1
-	</select>
+    <resultMap id="BasicUserInfo" type="com.yonge.cooleshow.biz.dal.dto.BasicUserInfo">
+        <result property="userId" column="user_id_"/>
+        <result property="username" column="username_"/>
+        <result property="realName" column="real_name_"/>
+        <result property="avatar" column="avatar_"/>
+    </resultMap>
+    <select id="getBasicUserInfo" resultMap="BasicUserInfo">
+        SELECT id_ user_id_, username_, real_name_, avatar_
+        FROM sys_user
+        WHERE del_flag_ = 0
+          and id_ = #{userId}
+        LIMIT 1
+    </select>
 
-	<select id="findBasicUserInfo" resultMap="BasicUserInfo">
-		SELECT id_ user_id_,username_,real_name_,avatar_ FROM sys_user
-		WHERE del_flag_ = 0 and id_ IN
-		<foreach collection="studentIds" open="(" close=")" separator="," item="userId">
-			#{userId}
-		</foreach>
-	</select>
+    <select id="findBasicUserInfo" resultMap="BasicUserInfo">
+        SELECT id_ user_id_,username_,real_name_,avatar_ FROM sys_user
+        WHERE del_flag_ = 0 and id_ IN
+        <foreach collection="studentIds" open="(" close=")" separator="," item="userId">
+            #{userId}
+        </foreach>
+    </select>
 
     <select id="detail" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherVo">
         SELECT
-            <include refid="baseColumns"/>,
-            if(u.lock_flag_ = 0 and t.lock_flag_ = 0,0,1) as lockFlag,
-            u.avatar_ as avatar,
-            u.username_ as username,
-            u.gender_ as `gender`,
-            u.birthdate_ as birthdate,
-            u.phone_ as phone,
-            (case when isnull(u.id_card_no_) then 0 else 1 end) as isReal,
-            (!isnull(membership_end_time_) and membership_end_time_ > now()) as isVip,
-            u.real_name_ as realName,
-            u.id_card_no_ as idCardNo,
-            (case when isnull(b.user_id_) then 0 else 1 end) as isBank,
-            (
-                SELECT GROUP_CONCAT(name_ ORDER by locate(id_,t.subject_id_)) FROM subject WHERE FIND_IN_SET(id_,t.subject_id_)
-            ) as subjectName,
-            u.user_type_ as userType
+        <include refid="baseColumns"/>,
+        if(u.lock_flag_ = 0 and t.lock_flag_ = 0,0,1) as lockFlag,
+        u.avatar_ as avatar,
+        u.username_ as username,
+        u.gender_ as `gender`,
+        u.birthdate_ as birthdate,
+        u.phone_ as phone,
+        (case when isnull(u.id_card_no_) then 0 else 1 end) as isReal,
+        (!isnull(membership_end_time_) and membership_end_time_ > now()) as isVip,
+        u.real_name_ as realName,
+        u.id_card_no_ as idCardNo,
+        (case when isnull(b.user_id_) then 0 else 1 end) as isBank,
+        (
+        SELECT GROUP_CONCAT(name_ ORDER by locate(id_,t.subject_id_)) FROM subject WHERE FIND_IN_SET(id_,t.subject_id_)
+        ) as subjectName,
+        u.user_type_ as userType
         FROM teacher t
         left join sys_user u on t.user_id_ = u.id_
         left join (
-            select distinct user_id_ from user_bank_card where del_flag_ = 0 and user_id_ = #{userId}
+        select distinct user_id_ from user_bank_card where del_flag_ = 0 and user_id_ = #{userId}
         ) b on t.user_id_ = b.user_id_
         where u.del_flag_ = 0 and t.user_id_ = #{userId}
     </select>
 
     <select id="querySubject" resultMap="com.yonge.cooleshow.biz.dal.dao.SubjectDao.Subject">
-        SELECT s.* FROM `subject` s
-        LEFT JOIN teacher t ON FIND_IN_SET(s.id_,t.subject_id_)
+        SELECT s.*
+        FROM `subject` s
+                 LEFT JOIN teacher t ON FIND_IN_SET(s.id_, t.subject_id_)
         WHERE t.user_id_ = #{userId}
     </select>
 
     <update id="setSubject">
-        update teacher set subject_id_ = #{subjectIds},update_time_ = now() where user_id_ = #{id}
+        update teacher
+        set subject_id_  = #{subjectIds},
+            update_time_ = now()
+        where user_id_ = #{id}
     </update>
 
     <update id="addHomeBrowse">
-        update teacher set browse_ = browse_ + 1 where user_id_ = #{userId}
+        update teacher
+        set browse_ = browse_ + 1
+        where user_id_ = #{userId}
     </update>
 
     <select id="querySubjectItem" resultType="com.yonge.cooleshow.biz.dal.entity.Subject">
         select t.* from subject t
         join (
-            select a.subject_id_ from (
-                <trim prefixOverrides="union all">
-                    <if test="type == null or type =='MUSIC'">union all
-                        (select music_subject_ as subject_id_ from music_sheet where user_id_ = #{userId} GROUP BY
-                        music_subject_)
-                    </if>
-                    <if test="type == null or type =='VIDEO'">
-                        union all
-                        (select lesson_subject_ as subject_id_ from video_lesson_group where teacher_id_ = #{userId} GROUP BY lesson_subject_)
-                    </if>
-                    <if test="type == null or type =='PIANO_ROOM'">
-                        union all
-                        (select subject_id_ as subject_id_ from course_group where type_ = 'PIANO_ROOM_CLASS' and teacher_id_ = #{userId} GROUP BY subject_id_)
-                    </if>
-                    <if test="type == null or type =='PRACTICE'">
-                        union all
-                        (select subject_id_ as subject_id_ from course_group where type_ = 'PRACTICE' and teacher_id_ = #{userId} GROUP BY subject_id_)
-                    </if>
-                    <if test="type == null or type =='LIVE'">
-                        union all
-                        (select subject_id_ as subject_id_ from course_group where type_ = 'LIVE' and teacher_id_ = #{userId} GROUP BY subject_id_)
-                    </if>
-                </trim>
-            ) a group by a.subject_id_
+        select a.subject_id_ from (
+        <trim prefixOverrides="union all">
+            <if test="type == null or type =='MUSIC'">
+                union all
+                (select music_subject_ as subject_id_ from music_sheet where user_id_ = #{userId} GROUP BY
+                music_subject_)
+            </if>
+            <if test="type == null or type =='VIDEO'">
+                union all
+                (select lesson_subject_ as subject_id_ from video_lesson_group where teacher_id_ = #{userId} GROUP BY
+                lesson_subject_)
+            </if>
+            <if test="type == null or type =='PIANO_ROOM'">
+                union all
+                (select subject_id_ as subject_id_ from course_group where type_ = 'PIANO_ROOM_CLASS' and teacher_id_ =
+                #{userId} GROUP BY subject_id_)
+            </if>
+            <if test="type == null or type =='PRACTICE'">
+                union all
+                (select subject_id_ as subject_id_ from course_group where type_ = 'PRACTICE' and teacher_id_ =
+                #{userId} GROUP BY subject_id_)
+            </if>
+            <if test="type == null or type =='LIVE'">
+                union all
+                (select subject_id_ as subject_id_ from course_group where type_ = 'LIVE' and teacher_id_ = #{userId}
+                GROUP BY subject_id_)
+            </if>
+        </trim>
+        ) a group by a.subject_id_
         ) a on t.id_ = a.subject_id_
         where t.parent_subject_id_ != 0
         and not exists(
-            select 1 from teacher s where s.user_id_ = #{userId} and find_in_set(t.id_,s.subject_id_)
+        select 1 from teacher s where s.user_id_ = #{userId} and find_in_set(t.id_,s.subject_id_)
         )
     </select>
 
     <select id="queryMyFans" resultType="com.yonge.cooleshow.biz.dal.vo.MyFens">
         SELECT
-            s.student_id_ AS userId,
-            s.create_time_ AS starTime,
-            u.avatar_ AS avatar,
-            u.username_ AS userName,
-            u.real_name_ AS realName,
-            u.gender_ AS gender,
-            u.phone_ AS phone,
-            u.birthdate_ AS birthdate,
-            (SELECT group_concat(name_) FROM `subject` WHERE find_in_set(id_,sr.subject_id_)) AS subjectName,
-            if(sr.membership_start_time_ &lt;= now() and sr.membership_end_time_ &gt;= now(),1,0) AS isVip
+        s.student_id_ AS userId,
+        s.create_time_ AS starTime,
+        u.avatar_ AS avatar,
+        u.username_ AS userName,
+        u.real_name_ AS realName,
+        u.gender_ AS gender,
+        u.phone_ AS phone,
+        u.birthdate_ AS birthdate,
+        (SELECT group_concat(name_) FROM `subject` WHERE find_in_set(id_,sr.subject_id_)) AS subjectName,
+        if(sr.membership_start_time_ &lt;= now() and sr.membership_end_time_ &gt;= now(),1,0) AS isVip
         FROM student_star s
         LEFT JOIN sys_user u ON s.student_id_ = u.id_
         LEFT JOIN student sr ON s.student_id_ = sr.user_id_
@@ -322,15 +336,21 @@
             </if>
         </where>
     </select>
-    
+
     <select id="queryHotTeacherList" resultMap="HotTeacherVoMap">
-		select t.user_id_,t.graduate_school_,u.username_,u.avatar_,ifnull(a.speaker_id_,0) isLiving_
-		from teacher t 
-		left join sys_user u on t.user_id_ = u.id_   
-		left join teacher_total tt on tt.user_id_ = t.user_id_
-		left join (SELECT lr.speaker_id_ from live_room lr WHERE live_state_ = 1 and type_ = 'temp' group by lr.speaker_id_) a on a.speaker_id_ = t.user_id_
-		where t.entry_flag_ = 1 and t.is_test_user_ = 0 and find_in_set(#{subjectId},t.subject_id_)
-		order by tt.fans_num_ desc limit 10
+        select t.user_id_, t.graduate_school_, u.username_, u.avatar_, ifnull(a.speaker_id_, 0) isLiving_
+        from teacher t
+                 left join sys_user u on t.user_id_ = u.id_
+                 left join teacher_total tt on tt.user_id_ = t.user_id_
+                 left join (SELECT lr.speaker_id_
+                            from live_room lr
+                            WHERE live_state_ = 1 and type_ = 'temp'
+                            group by lr.speaker_id_) a on a.speaker_id_ = t.user_id_
+        where t.entry_flag_ = 1
+          and t.is_test_user_ = 0
+          and find_in_set(#{subjectId}, t.subject_id_)
+        order by tt.fans_num_ desc
+        limit 10
     </select>
 
     <!--老师学生人数统计-->
@@ -339,11 +359,22 @@
         SELECT t1.teacher_id_ AS id, COUNT(DISTINCT t1.id_) AS total FROM user_binding_teacher t1
         <where>
             <if test="teacherIds != null">
-                AND t1.teacher_id_ IN (<foreach collection="teacherIds" separator="," item="item">#{item}</foreach>)
+                AND t1.teacher_id_ IN (<foreach collection="teacherIds" separator="," item="item">
+                #{item}
+            </foreach>)
             </if>
         </where>
         GROUP BY t1.teacher_id_
     </select>
-    <!--老师学生人数统计-->
 
+    <select id="countTeacherByTenantIds" resultType="com.yonge.cooleshow.biz.dal.wrapper.TenantInfoWrapper$UserCount">
+        select tenant_id_ tenantId, count(tenant_id_) count
+        from teacher
+        where tenant_id_ in
+        <foreach collection="tenantIdList" item="item" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        group by tenant_id_
+    </select>
+    <!--老师学生人数统计-->
 </mapper>

+ 1 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantInfoMapper.xml

@@ -134,7 +134,7 @@
         status_ AS status
         FROM tenant_apply_record t
         where 1=1
-        <if test="param.keyword != null and param.keyword  != ''">
+        <if test="param.keyword != null and param.keyword.trim()  != ''">
             and (
             t.name_ like concat('%',#{param.keyword},'%')
             or t.username_ like concat('%',#{param.keyword},'%')