|
@@ -1,21 +1,32 @@
|
|
|
package cn.com.ty.lift.system.user.service.impl;
|
|
|
|
|
|
import cn.com.ty.lift.common.constants.ApiConstants;
|
|
|
+import cn.com.ty.lift.common.utils.ProjectUtils;
|
|
|
import cn.com.ty.lift.system.user.dao.entity.Expert;
|
|
|
import cn.com.ty.lift.system.user.dao.entity.UserAccount;
|
|
|
import cn.com.ty.lift.system.user.dao.entity.UserInfo;
|
|
|
import cn.com.ty.lift.system.user.dao.entity.model.ExpertRequest;
|
|
|
+import cn.com.ty.lift.system.user.dao.entity.model.ExpertResponse;
|
|
|
+import cn.com.ty.lift.system.user.dao.entity.model.UserResponse;
|
|
|
import cn.com.ty.lift.system.user.dao.mapper.ExpertMapper;
|
|
|
import cn.com.ty.lift.system.user.service.IExpertService;
|
|
|
import cn.com.ty.lift.system.user.service.IUserAccountService;
|
|
|
import cn.com.ty.lift.system.user.service.IUserInfoService;
|
|
|
+import cn.com.ty.lift.system.user.service.IUserService;
|
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -34,6 +45,45 @@ public class ExpertServiceImpl extends ServiceImpl<ExpertMapper, Expert> impleme
|
|
|
@Autowired
|
|
|
private IUserInfoService userInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IUserService userService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RestResponse expertList(ExpertRequest expertRequest) {
|
|
|
+ IPage expertPage = new Page(expertRequest.getPageNum(), expertRequest.getPageSize());
|
|
|
+ expertPage = this.page(expertPage, new QueryWrapper<Expert>()
|
|
|
+ .like(StringUtils.isNotBlank(expertRequest.getName()), "name", expertRequest.getName())
|
|
|
+ .eq("delete_flag", ApiConstants.DELETE_NO)
|
|
|
+ );
|
|
|
+
|
|
|
+ List<Expert> expertList = expertPage.getRecords();
|
|
|
+ //封装专家信息
|
|
|
+ if (expertList != null && expertList.size() > 0) {
|
|
|
+ List<ExpertResponse> expertResponseList = new ArrayList<>();
|
|
|
+ List<Long> userIdList = ProjectUtils.getAttrList(expertList, "userId", null);
|
|
|
+ Map<Long, UserResponse> userIdToUserResponseList = userService.getUserResponseByUserIdList(userIdList);
|
|
|
+ for (Expert expert : expertList) {
|
|
|
+ ExpertResponse expertResponse = new ExpertResponse();
|
|
|
+ //设置专家信息
|
|
|
+ expertResponse.setId(expert.getId());
|
|
|
+ expertResponse.setName(expert.getName());
|
|
|
+ expertResponse.setDescription(expert.getDescription());
|
|
|
+ expertResponse.setUserId(expert.getUserId());
|
|
|
+ //设置用户信息
|
|
|
+ UserResponse userResponse = userIdToUserResponseList.get(expert.getUserId());
|
|
|
+ if(userResponse != null){
|
|
|
+ expertResponse.setAvatarUrl(userResponse.getAvatarUrl());
|
|
|
+ expertResponse.setMobile(userResponse.getMobile());
|
|
|
+ }
|
|
|
+ expertResponseList.add(expertResponse);
|
|
|
+ }
|
|
|
+ expertPage.setRecords(expertResponseList);
|
|
|
+ return RestResponse.success(expertPage, ApiConstants.RESULT_SUCCESS, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ return RestResponse.success();
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public RestResponse add(ExpertRequest expertRequest) {
|
|
@@ -44,7 +94,7 @@ public class ExpertServiceImpl extends ServiceImpl<ExpertMapper, Expert> impleme
|
|
|
userAccount.setType(ApiConstants.UserConstants.TYPE_USER);
|
|
|
userAccountService.save(userAccount);
|
|
|
//设置专家基础信息
|
|
|
- UserInfo userInfo = new UserInfo();
|
|
|
+ UserInfo userInfo = new UserInfo();
|
|
|
userInfo.setMobile(expertRequest.getMobile());
|
|
|
userInfo.setUserId(userAccount.getUserId());
|
|
|
userInfoService.save(userInfo);
|
|
@@ -57,4 +107,5 @@ public class ExpertServiceImpl extends ServiceImpl<ExpertMapper, Expert> impleme
|
|
|
this.save(expert);
|
|
|
return RestResponse.success(null, ApiConstants.RESULT_SUCCESS, "保存专家信息成功");
|
|
|
}
|
|
|
+
|
|
|
}
|