【优化】添加多语言支持
This commit is contained in:
parent
7b0aa46e25
commit
358bd93a6a
|
|
@ -51,7 +51,6 @@ public class PositionController extends ControllerBase {
|
|||
|
||||
/**
|
||||
* 获取职位列表
|
||||
*
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -59,13 +58,11 @@ public class PositionController extends ControllerBase {
|
|||
@ApiMark(moduleName = "职位管理", apiName = "获取职位列表")
|
||||
public ApiResult<PageData<TBasePosition>> getList(@RequestBody PositionQuery query) {
|
||||
Page<TBasePosition> result = positionService.getList(new Page<>(query.getPage(), query.getPageSize()), query);
|
||||
|
||||
return ApiResult.success(result.getRecords(), query, result.getTotal());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取明细
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -74,7 +71,6 @@ public class PositionController extends ControllerBase {
|
|||
public ApiResult<PositionDetailVO> getPositionDetail(@RequestParam("id") Integer id) {
|
||||
TBasePosition ent = positionService.getById(id);
|
||||
VUtils.trueThrow(null == ent).throwMessage(STATE.ParamErr, "职位不存在");
|
||||
|
||||
PositionDetailVO result = Convert.convert(PositionDetailVO.class, ent);
|
||||
List<Language> allLanguage = languageService.lambdaQuery().eq(Language::getEnable, true).list();
|
||||
Map<String, String> positionLanguageMp=new HashMap<>();
|
||||
|
|
@ -101,11 +97,9 @@ public class PositionController extends ControllerBase {
|
|||
@ApiMark(moduleName = "职位管理", apiName = "获取语言列表-新增时调用")
|
||||
public ApiResult<List<PositionLanguageVO> > getLanguage() {
|
||||
List<Language> allLanguage = languageService.lambdaQuery().eq(Language::getEnable, true).list();
|
||||
|
||||
return ApiResult.success(Convert.toList(PositionLanguageVO.class,allLanguage));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("add")
|
||||
@MethodInfoMark(value = "新增", menuName = "职位管理")
|
||||
@ApiMark(moduleName = "职位管理", apiName = "新增")
|
||||
|
|
|
|||
|
|
@ -25,4 +25,6 @@ public interface ITBasePositionService extends IService<TBasePosition> {
|
|||
void delByIds(@Param("ids") List<Integer> ids);
|
||||
|
||||
List<TitleSimpleVO> getSimpleTitles(Integer type);
|
||||
|
||||
TBasePosition getWithLanguage(Integer titleId, String language);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ import java.util.stream.Collectors;
|
|||
* <p>
|
||||
* 后台-用户 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 曹鹏飞
|
||||
* @since 2025-01-03
|
||||
*/
|
||||
|
|
@ -347,7 +346,7 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
|||
@Override
|
||||
public AdminUserVO getInfo(Integer userId) {
|
||||
AdminUser user = getById(userId);
|
||||
TBasePosition title = positionService.getById(user.getTitleId());
|
||||
TBasePosition title = positionService.getWithLanguage(user.getTitleId(), MultilingualUtil.getLanguage());
|
||||
return new AdminUserVO()
|
||||
.setId(user.getId())
|
||||
.setAvatar(user.getAvatar())
|
||||
|
|
|
|||
|
|
@ -11,10 +11,7 @@ import com.nflg.mobilebroken.common.exception.NflgException;
|
|||
import com.nflg.mobilebroken.common.pojo.PageData;
|
||||
import com.nflg.mobilebroken.common.pojo.request.*;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.*;
|
||||
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||
import com.nflg.mobilebroken.common.util.AppUserUtil;
|
||||
import com.nflg.mobilebroken.common.util.PageUtil;
|
||||
import com.nflg.mobilebroken.common.util.VUtils;
|
||||
import com.nflg.mobilebroken.common.util.*;
|
||||
import com.nflg.mobilebroken.repository.entity.*;
|
||||
import com.nflg.mobilebroken.repository.mapper.AppUserMapper;
|
||||
import com.nflg.mobilebroken.repository.service.*;
|
||||
|
|
@ -132,7 +129,12 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
|||
|
||||
@Override
|
||||
public AppUserVO getInfo(Integer userId) {
|
||||
return baseMapper.getInfo(userId);
|
||||
AppUserVO vo = baseMapper.getInfo(userId);
|
||||
if (Objects.nonNull(vo.getTitleId())) {
|
||||
TBasePosition title = positionService.getWithLanguage(vo.getTitleId(), MultilingualUtil.getLanguage());
|
||||
vo.setTitle(title.getPositionName());
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,23 +1,28 @@
|
|||
package com.nflg.mobilebroken.repository.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.mobilebroken.common.constant.Constant;
|
||||
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.PositionLanguageVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.TitleSimpleVO;
|
||||
import com.nflg.mobilebroken.repository.entity.TBasePosition;
|
||||
import com.nflg.mobilebroken.repository.mapper.TBasePositionMapper;
|
||||
import com.nflg.mobilebroken.repository.service.ITBasePositionService;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.boot.autoconfigure.amqp.RabbitProperties;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 职位管理 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2025
|
||||
*/
|
||||
|
|
@ -25,13 +30,13 @@ import java.util.stream.Collectors;
|
|||
public class TBasePositionServiceImpl extends ServiceImpl<TBasePositionMapper, TBasePosition> implements ITBasePositionService {
|
||||
|
||||
|
||||
public Page<TBasePosition> getList(@Param("page")Page<PageBaseQuery> page, @Param("query") PageBaseQuery query){
|
||||
return this.getBaseMapper().getList(page,query);
|
||||
}
|
||||
public Page<TBasePosition> getList(@Param("page") Page<PageBaseQuery> page, @Param("query") PageBaseQuery query) {
|
||||
return this.getBaseMapper().getList(page, query);
|
||||
}
|
||||
|
||||
public void delByIds(@Param("ids") List<Integer> ids){
|
||||
this.getBaseMapper().delByIds(ids);
|
||||
}
|
||||
public void delByIds(@Param("ids") List<Integer> ids) {
|
||||
this.getBaseMapper().delByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TitleSimpleVO> getSimpleTitles(Integer type) {
|
||||
|
|
@ -43,4 +48,23 @@ public class TBasePositionServiceImpl extends ServiceImpl<TBasePositionMapper, T
|
|||
.map(d -> new TitleSimpleVO().setId(d.getId()).setName(d.getPositionName()).setPositionLanguage(d.getPositionLanguage()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TBasePosition getWithLanguage(Integer titleId, String language) {
|
||||
TBasePosition position = getById(titleId);
|
||||
if (Objects.isNull(position)) {
|
||||
return null;
|
||||
}
|
||||
if (!StrUtil.equals(Constant.DEFAULT_LANGUAGE_CODE, language)) {
|
||||
List<PositionLanguageVO> languageVOS = JSONUtil.toList(position.getPositionLanguage(), PositionLanguageVO.class);
|
||||
position.setPositionName(
|
||||
languageVOS.stream()
|
||||
.filter(l -> StrUtil.equals(l.getCode(), language))
|
||||
.findFirst()
|
||||
.map(PositionLanguageVO::getLanguageValue)
|
||||
.orElse("")
|
||||
);
|
||||
}
|
||||
return position;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue