diff --git a/chenhai-admin/src/main/java/com/chenhai/web/controller/muhu/MuhuUserController.java b/chenhai-admin/src/main/java/com/chenhai/web/controller/muhu/MuhuUserController.java index 15ddf4c..fc3ade2 100644 --- a/chenhai-admin/src/main/java/com/chenhai/web/controller/muhu/MuhuUserController.java +++ b/chenhai-admin/src/main/java/com/chenhai/web/controller/muhu/MuhuUserController.java @@ -7,6 +7,8 @@ import java.util.Map; import com.chenhai.common.utils.DictUtils; import com.chenhai.common.utils.StringUtils; import com.chenhai.framework.web.service.TokenService; +import com.chenhai.vet.domain.VetPersonalInfo; +import com.chenhai.vet.service.IVetPersonalInfoService; import jakarta.servlet.http.HttpServletResponse; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; @@ -54,6 +56,9 @@ public class MuhuUserController extends BaseController @Autowired private TokenService tokenService; + @Autowired + private IVetPersonalInfoService vetPersonalInfoService; + /** * 查询牧户用户列表 */ @@ -292,6 +297,27 @@ public class MuhuUserController extends BaseController // 没有认证记录 result.put("authStatus", "未认证"); } + + // ========== 新增:查询兽医个人信息 ========== + // 判断用户类型,如果是兽医(01),则查询兽医信息表 + if ("01".equals(user.getUserType())) { + VetPersonalInfo vetInfo = vetPersonalInfoService.selectVetPersonalInfoByUserId(userId); + if (vetInfo != null) { + // 只提取需要的字段 + Map vetData = new HashMap<>(); + vetData.put("specialty", vetInfo.getSpecialty()); + vetData.put("workExperience", vetInfo.getWorkExperience()); + vetData.put("expertType", vetInfo.getExpertType()); + + // 可选:如果需要其他兽医字段也可以添加 + // vetData.put("title", vetInfo.getTitle()); + // vetData.put("hospital", vetInfo.getHospital()); + + result.put("vetInfo", vetData); + } + } + // ========== 新增结束 ========== + } else { result.put("authStatus", "未认证"); } @@ -307,8 +333,33 @@ public class MuhuUserController extends BaseController */ @PreAuthorize("@ss.hasRole('muhu') or @ss.hasRole('vet')") @PutMapping("/saveUserAreaCode/{areaCode}") - public AjaxResult getArea(@PathVariable("areaCode") String areaCode) { - Long userId = getUserId(); - return toAjax(sysUserService.updateUserAreaCode(userId, areaCode)); + public AjaxResult saveUserAreaCode(@PathVariable("areaCode") String areaCode) { + try { + Long userId = getUserId(); + + int result = sysUserService.updateUserAreaCode(userId, areaCode); + + if (result > 0) { + // 查询更新后的用户信息 + SysUser updatedUser = sysUserService.selectUserById(userId); + + // 更新缓存中的用户信息 + LoginUser loginUser = getLoginUser(); + loginUser.setUser(updatedUser); + tokenService.setLoginUser(loginUser); + + // 返回更新后的数据 + Map data = new HashMap<>(); + data.put("userId", userId); + data.put("areaCode", updatedUser.getAreaCode()); + data.put("userName", updatedUser.getUserName()); + + return success(data); + } else { + return error("保存失败"); + } + } catch (Exception e) { + return error("保存失败: " + e.getMessage()); + } } -} \ No newline at end of file +} diff --git a/chenhai-system/src/main/resources/mapper/system/SysUserMapper.xml b/chenhai-system/src/main/resources/mapper/system/SysUserMapper.xml index 92a2074..b5cde02 100644 --- a/chenhai-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/chenhai-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -258,6 +258,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" login_date = #{loginDate}, update_by = #{updateBy}, remark = #{remark}, + + area_code = #{areaCode}, update_time = sysdate() where user_id = #{userId} @@ -324,4 +326,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and del_flag = '0' - \ No newline at end of file +