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