|
@@ -1,29 +1,32 @@
|
|
|
package com.yonge.cooleshow.admin.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.microsvc.toolkit.common.response.paging.PageInfo;
|
|
|
import com.microsvc.toolkit.common.response.paging.QueryInfo;
|
|
|
-import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
|
-import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.EmployeeService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.TenantUnbindRecordService;
|
|
|
-import com.yonge.cooleshow.biz.dal.vo.EmployeeVo;
|
|
|
-import com.yonge.cooleshow.biz.dal.wrapper.TenantUnbindRecordWrapper;
|
|
|
+import com.microsvc.toolkit.common.response.template.R;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.SysUser;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.TenantUnbindHistory;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.SysUserService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.TenantUnbindHistoryService;
|
|
|
+import com.yonge.cooleshow.biz.dal.wrapper.TenantUnbindHistoryWrapper;
|
|
|
import com.yonge.cooleshow.common.controller.BaseController;
|
|
|
-import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
-import com.yonge.cooleshow.common.enums.UserLockFlag;
|
|
|
-import com.yonge.toolset.base.exception.BizException;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
|
@Validated
|
|
@@ -33,38 +36,46 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
public class TenantUnbindHistoryController extends BaseController{
|
|
|
|
|
|
@Autowired
|
|
|
- private TenantUnbindRecordService tenantUnbindRecordService;
|
|
|
+ private TenantUnbindHistoryService tenantUnbindHistoryService;
|
|
|
|
|
|
@Autowired
|
|
|
- private SysUserFeignService sysUserFeignService;
|
|
|
+ private SysUserService sysUserService;
|
|
|
|
|
|
@Autowired
|
|
|
- private EmployeeService employeeService;
|
|
|
+ private TenantInfoService tenantInfoService;
|
|
|
|
|
|
- @ApiOperation(value = "查询分页", notes = "机构解绑申请记录- 传入 TenantUnbindRecordVo.TenantUnbindRecordQuery")
|
|
|
- @PreAuthorize("@pcs.hasPermissions('tenantUnbindRecord/page')")
|
|
|
+ @ApiOperation(value = "查询分页", notes = "机构解绑历史表- 传入 TenantUnbindHistoryWrapper.TenantUnbindHistoryQuery")
|
|
|
@PostMapping("/page")
|
|
|
- public HttpResponseResult<PageInfo<TenantUnbindRecordWrapper.TenantUnbindRecord>>
|
|
|
- page(@RequestBody TenantUnbindRecordWrapper.TenantUnbindRecordQuery query) {
|
|
|
- // 查询数据
|
|
|
- IPage<TenantUnbindRecordWrapper.TenantUnbindRecord> pages =
|
|
|
- tenantUnbindRecordService.selectPage(QueryInfo.getPage(query), query);
|
|
|
- return succeed(QueryInfo.pageInfo(pages, pages.getRecords()));
|
|
|
- }
|
|
|
+ public R<PageInfo<TenantUnbindHistoryWrapper.TenantUnbindHistory>> page(@RequestBody TenantUnbindHistoryWrapper.TenantUnbindHistoryQuery query) {
|
|
|
|
|
|
- @ApiOperation(value = "审核")
|
|
|
- @PostMapping("/audit")
|
|
|
- @PreAuthorize("@pcs.hasPermissions('tenantUnbindRecord/audit')")
|
|
|
- public HttpResponseResult<Boolean> audit(@RequestBody TenantUnbindRecordWrapper.Audio audio) {
|
|
|
- SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
- if (sysUser == null) {
|
|
|
- throw new BizException("请登录");
|
|
|
- }
|
|
|
- EmployeeVo employeeVo = employeeService.detail(sysUserFeignService.queryUserInfo().getId());
|
|
|
- if (employeeVo == null || UserLockFlag.LOCKED.equals(employeeVo.getLockFlag())) {
|
|
|
- throw new BizException("权限不足");
|
|
|
+ IPage<TenantUnbindHistory> pages = tenantUnbindHistoryService.selectPage(QueryInfo.getPage(query), query);
|
|
|
+
|
|
|
+ List<TenantUnbindHistory> records = pages.getRecords();
|
|
|
+ if (records.isEmpty()) {
|
|
|
+ return R.from(QueryInfo.pageInfo(pages, new ArrayList<>()));
|
|
|
}
|
|
|
- tenantUnbindRecordService.tenantUserUnbindAudit(audio, sysUser.getId(),true);
|
|
|
- return succeed();
|
|
|
+ List<Long> userIds =
|
|
|
+ pages.getRecords().stream().map(TenantUnbindHistory::getVerifyUserId).distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ Map<Long, SysUser> mapByIds = sysUserService.getMapByIds(userIds);
|
|
|
+
|
|
|
+ List<Long> tenantIds =
|
|
|
+ pages.getRecords().stream().map(TenantUnbindHistory::getTenantId).distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ Map<Long, TenantInfo> tenantInfoMap = tenantInfoService.getMapByIds(tenantIds);
|
|
|
+ List<TenantUnbindHistoryWrapper.TenantUnbindHistory> histories = records.stream().map(next -> {
|
|
|
+ TenantUnbindHistoryWrapper.TenantUnbindHistory tenantUnbindHistory =
|
|
|
+ JSON.parseObject(JSON.toJSONString(next), TenantUnbindHistoryWrapper.TenantUnbindHistory.class);
|
|
|
+ SysUser orDefault = mapByIds.getOrDefault(next.getVerifyUserId(), new SysUser());
|
|
|
+ tenantUnbindHistory.setVerifyUserName(orDefault.getUsername());
|
|
|
+ if(tenantInfoMap.containsKey(next.getTenantId())){
|
|
|
+ TenantInfo tenantInfo = tenantInfoMap.get(next.getTenantId());
|
|
|
+ tenantUnbindHistory.setTenantUserName(tenantInfo.getUsername());
|
|
|
+ tenantUnbindHistory.setTenantPhone(tenantInfo.getPhone());
|
|
|
+ }
|
|
|
+ return tenantUnbindHistory;
|
|
|
+
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return R.from(QueryInfo.pageInfo(pages, histories));
|
|
|
}
|
|
|
}
|