mirror of
https://gitee.com/beecue/fastbee.git
synced 2026-05-06 15:54:42 +08:00
feat(国际化): 新增国际化
This commit is contained in:
@@ -59,7 +59,7 @@ public interface ISocialLoginService {
|
||||
* @param loginId 登录id
|
||||
* @return
|
||||
*/
|
||||
AjaxResult socialLogin(String loginId);
|
||||
AjaxResult socialLogin(String loginId, String language);
|
||||
|
||||
/**
|
||||
* 绑定登录api
|
||||
@@ -67,7 +67,7 @@ public interface ISocialLoginService {
|
||||
* @param bindLoginBody 绑定账户参数
|
||||
* @return
|
||||
*/
|
||||
AjaxResult bindLogin(BindLoginBody bindLoginBody);
|
||||
AjaxResult bindLogin(BindLoginBody bindLoginBody, String language);
|
||||
|
||||
/**
|
||||
* 注册绑定api
|
||||
@@ -75,7 +75,7 @@ public interface ISocialLoginService {
|
||||
* @param bindRegisterBody
|
||||
* @return
|
||||
*/
|
||||
AjaxResult bindRegister(BindRegisterBody bindRegisterBody);
|
||||
AjaxResult bindRegister(BindRegisterBody bindRegisterBody, String language);
|
||||
|
||||
String genBindId(AuthUser authUser);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.common.core.domain.entity.SysRole;
|
||||
import com.fastbee.common.core.domain.entity.SysUser;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.common.utils.MessageUtils;
|
||||
import com.fastbee.iot.domain.Category;
|
||||
import com.fastbee.iot.mapper.CategoryMapper;
|
||||
import com.fastbee.iot.model.IdAndName;
|
||||
@@ -124,12 +125,12 @@ public class CategoryServiceImpl implements ICategoryService
|
||||
{
|
||||
int productCount=categoryMapper.productCountInCategorys(categoryIds);
|
||||
if(productCount>0){
|
||||
return AjaxResult.error("删除失败,请先删除对应分类下的产品");
|
||||
return AjaxResult.error(MessageUtils.message("delete.fail.please.delete.category.product"));
|
||||
}
|
||||
if(categoryMapper.deleteCategoryByCategoryIds(categoryIds)>0){
|
||||
return AjaxResult.success("删除成功");
|
||||
return AjaxResult.success(MessageUtils.message("delete.success"));
|
||||
}
|
||||
return AjaxResult.error("删除失败");
|
||||
return AjaxResult.error(MessageUtils.message("delete.fail"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.fastbee.common.enums.DeviceStatus;
|
||||
import com.fastbee.common.enums.ThingsModelType;
|
||||
import com.fastbee.common.exception.ServiceException;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.common.utils.MessageUtils;
|
||||
import com.fastbee.common.utils.StringUtils;
|
||||
import com.fastbee.common.utils.http.HttpUtils;
|
||||
import com.fastbee.common.utils.ip.IpUtils;
|
||||
@@ -678,8 +679,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
// 设备编号唯一检查
|
||||
Device existDevice = deviceMapper.selectDeviceBySerialNumber(device.getSerialNumber());
|
||||
if (existDevice != null) {
|
||||
log.error("设备编号:" + device.getSerialNumber() + "已经存在了,新增设备失败");
|
||||
throw new ServiceException("设备编号:" + device.getSerialNumber() + " 已经存在,新增失败");
|
||||
throw new ServiceException(MessageUtils.message("device.insert.fail.device.number.already.exist", device.getSerialNumber()));
|
||||
}
|
||||
SysUser sysUser = getLoginUser().getUser();
|
||||
//添加设备
|
||||
@@ -747,7 +747,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
Device existDevice = deviceMapper.selectDeviceBySerialNumber(deviceRelateUserInput.getDeviceNumberAndProductIds().get(i).getDeviceNumber());
|
||||
if (existDevice != null) {
|
||||
if (existDevice.getUserId().longValue() == deviceRelateUserInput.getUserId().longValue()) {
|
||||
return AjaxResult.error("用户已经拥有设备:" + existDevice.getDeviceName() + ", 设备编号:" + existDevice.getSerialNumber());
|
||||
return AjaxResult.error(MessageUtils.message("now.user.belong.device.can.not.repeat.share", existDevice.getSerialNumber()));
|
||||
}
|
||||
// 先删除设备的所有用户
|
||||
deviceUserMapper.deleteDeviceUserByDeviceId(new UserIdDeviceIdModel(null, existDevice.getDeviceId()));
|
||||
@@ -774,11 +774,11 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
deviceRelateUserInput.getUserId(),
|
||||
deviceRelateUserInput.getDeviceNumberAndProductIds().get(i).getProductId());
|
||||
if (result == 0) {
|
||||
return AjaxResult.error("设备不存在,自动添加设备时失败,请检查产品编号是否正确");
|
||||
return AjaxResult.error(MessageUtils.message("device.not.exist.add.fail.please.check.product.id.is.correct"));
|
||||
}
|
||||
}
|
||||
}
|
||||
return AjaxResult.success("添加设备成功");
|
||||
return AjaxResult.success(MessageUtils.message("device.add.success"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1240,7 +1240,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
DeviceMqttConnectVO connectVO = new DeviceMqttConnectVO();
|
||||
DeviceMqttVO deviceMqttVO = deviceMapper.selectMqttConnectData(deviceId);
|
||||
if (deviceMqttVO == null) {
|
||||
throw new ServiceException("获取设备MQTT连接参数失败");
|
||||
throw new ServiceException(MessageUtils.message("device.get.mqtt.connection.param.fail"));
|
||||
}
|
||||
// 不管认证方式,目前就只返回简单认证方式
|
||||
String password;
|
||||
@@ -1248,7 +1248,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
// 查询产品授权码
|
||||
List<ProductAuthorize> productAuthorizeList = productAuthorizeService.listByProductId(deviceMqttVO.getProductId());
|
||||
if (CollectionUtils.isEmpty(productAuthorizeList)) {
|
||||
throw new ServiceException("产品已启用授权,获取设备授权码失败,请先配置授权码");
|
||||
throw new ServiceException(MessageUtils.message("device.get.authorization.fail.please.config"));
|
||||
}
|
||||
List<ProductAuthorize> collect = productAuthorizeList.stream().filter(p -> p.getProductId().equals(deviceMqttVO.getDeviceId())).collect(Collectors.toList());
|
||||
ProductAuthorize productAuthorize = CollectionUtils.isEmpty(collect) ? productAuthorizeList.get(0) : collect.get(0);
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.common.utils.MessageUtils;
|
||||
import com.fastbee.iot.model.IdAndName;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -95,12 +96,12 @@ public class NewsCategoryServiceImpl implements INewsCategoryService
|
||||
{
|
||||
int productCount=newsCategoryMapper.newsCountInCategorys(categoryIds);
|
||||
if(productCount>0){
|
||||
return AjaxResult.error("删除失败,请先删除对应分类下的新闻资讯");
|
||||
return AjaxResult.error(MessageUtils.message("newsCategory.delete.fail.please.delete.category.info"));
|
||||
}
|
||||
if(newsCategoryMapper.deleteNewsCategoryByCategoryIds(categoryIds)>0){
|
||||
return AjaxResult.success("删除成功");
|
||||
return AjaxResult.success(MessageUtils.message("delete.success"));
|
||||
}
|
||||
return AjaxResult.error("删除失败");
|
||||
return AjaxResult.error(MessageUtils.message("delete.fail"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.fastbee.common.core.domain.entity.SysUser;
|
||||
import com.fastbee.common.core.redis.RedisCache;
|
||||
import com.fastbee.common.core.redis.RedisKeyBuilder;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.common.utils.MessageUtils;
|
||||
import com.fastbee.iot.domain.Product;
|
||||
import com.fastbee.iot.domain.ThingsModelTemplate;
|
||||
import com.fastbee.iot.mapper.DeviceMapper;
|
||||
@@ -196,7 +197,7 @@ public class ProductServiceImpl implements IProductService
|
||||
public AjaxResult changeProductStatus(ChangeProductStatusModel model)
|
||||
{
|
||||
if(model.getStatus()!=1 && model.getStatus()!=2){
|
||||
return AjaxResult.error("状态更新失败,状态值有误");
|
||||
return AjaxResult.error(MessageUtils.message("product.status.update.fail.value.fail"));
|
||||
}
|
||||
if(model.getStatus()==2){
|
||||
// 产品下必须包含物模型
|
||||
@@ -214,9 +215,9 @@ public class ProductServiceImpl implements IProductService
|
||||
//}
|
||||
}
|
||||
if(productMapper.changeProductStatus(model)>0){
|
||||
return AjaxResult.success("操作成功");
|
||||
return AjaxResult.success(MessageUtils.message("operate.success"));
|
||||
}
|
||||
return AjaxResult.error("状态更新失败");
|
||||
return AjaxResult.error(MessageUtils.message("product.status.update.fail"));
|
||||
}
|
||||
|
||||
/***
|
||||
@@ -250,7 +251,7 @@ public class ProductServiceImpl implements IProductService
|
||||
// 产品下不能有设备
|
||||
int deviceCount=productMapper.deviceCountInProducts(productIds);
|
||||
if(deviceCount>0){
|
||||
return AjaxResult.error("删除失败,请先删除对应产品下的设备");
|
||||
return AjaxResult.error(MessageUtils.message("delete.fail.please.delete.product.device"));
|
||||
}
|
||||
// 删除产品物模型
|
||||
productMapper.deleteProductThingsModelByProductIds(productIds);
|
||||
@@ -258,9 +259,9 @@ public class ProductServiceImpl implements IProductService
|
||||
productAuthorizeMapper.deleteProductAuthorizeByProductIds(productIds);
|
||||
// 删除产品
|
||||
if(productMapper.deleteProductByProductIds(productIds)>0){
|
||||
return AjaxResult.success("删除成功");
|
||||
return AjaxResult.success(MessageUtils.message("delete.success"));
|
||||
}
|
||||
return AjaxResult.error("删除失败");
|
||||
return AjaxResult.error(MessageUtils.message("delete.fail"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.fastbee.common.core.domain.model.LoginUser;
|
||||
import com.fastbee.common.core.redis.RedisCache;
|
||||
import com.fastbee.common.exception.ServiceException;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.common.utils.MessageUtils;
|
||||
import com.fastbee.common.utils.SecurityUtils;
|
||||
import com.fastbee.common.utils.StringUtils;
|
||||
import com.fastbee.common.utils.sign.Md5Utils;
|
||||
@@ -220,13 +221,13 @@ public class SocialLoginServiceImpl implements ISocialLoginService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult socialLogin(String loginId) {
|
||||
public AjaxResult socialLogin(String loginId, String language) {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
String loginKey = LOGIN_SOCIAL_REDIS_KEY + loginId;
|
||||
LoginIdValue loginIdValue = redisCache.getCacheObject(loginKey);
|
||||
if (loginIdValue != null) {
|
||||
//login
|
||||
String token = sysLoginService.redirectLogin(loginIdValue.getUsername(), loginIdValue.getPassword());
|
||||
String token = sysLoginService.redirectLogin(loginIdValue.getUsername(), loginIdValue.getPassword(), language);
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
} else {
|
||||
log.info("loginId:{} ", loginId);
|
||||
@@ -236,7 +237,7 @@ public class SocialLoginServiceImpl implements ISocialLoginService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult bindLogin(BindLoginBody bindLoginBody) {
|
||||
public AjaxResult bindLogin(BindLoginBody bindLoginBody, String language) {
|
||||
BindIdValue bindValue = redisCache.getCacheObject(BIND_REDIS_KEY + bindLoginBody.getBindId());
|
||||
SocialUser socialUser = findSocialUser(bindValue.getUuid(), bindValue.getSource());
|
||||
AjaxResult checkAjax = checkSocialUser(socialUser, bindLoginBody.getBindId());
|
||||
@@ -248,19 +249,19 @@ public class SocialLoginServiceImpl implements ISocialLoginService {
|
||||
SysUser sysUser = iSysUserService.selectUserByUserName(bindLoginBody.getUsername());
|
||||
if (sysUser == null) {
|
||||
// 单独返回code用户不存在,给前端处理
|
||||
return AjaxResult.error(HttpStatus.USER_NO_EXIST, "用户不存在");
|
||||
return AjaxResult.error(HttpStatus.USER_NO_EXIST, MessageUtils.message("socialLogin.user.not.exist"));
|
||||
}
|
||||
// 自定义一下密码错误的提示
|
||||
if(!SecurityUtils.matchesPassword(bindLoginBody.getPassword(), sysUser.getPassword())){
|
||||
throw new ServiceException("密码错误");
|
||||
throw new ServiceException(MessageUtils.message("password.fail"));
|
||||
}
|
||||
List<SocialUser> socialUserList = iSocialUserService.selectBySysUserId(sysUser.getUserId());
|
||||
if (CollectionUtils.isNotEmpty(socialUserList)) {
|
||||
throw new ServiceException("该账号已经绑定其他微信,请先解绑后重试!");
|
||||
throw new ServiceException(MessageUtils.message("socialLogin.account.already.bind.other.wechat.please.unbind"));
|
||||
}
|
||||
// 生成令牌
|
||||
String token = sysLoginService.login(bindLoginBody.getUsername(), bindLoginBody.getPassword(), bindLoginBody.getCode(),
|
||||
bindLoginBody.getUuid());
|
||||
bindLoginBody.getUuid(), language);
|
||||
LoginUser loginUser = tokenService.getLoginUserByToken(token);
|
||||
//绑定和更新
|
||||
SocialUser updateSocialUser = new SocialUser();
|
||||
@@ -274,7 +275,7 @@ public class SocialLoginServiceImpl implements ISocialLoginService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult bindRegister(BindRegisterBody bindRegisterBody) {
|
||||
public AjaxResult bindRegister(BindRegisterBody bindRegisterBody, String language) {
|
||||
if (!("true".equals(iSysConfigService.selectConfigByKey("sys.account.registerUser")))) {
|
||||
return error("当前系统没有开启注册功能!");
|
||||
}
|
||||
@@ -301,7 +302,7 @@ public class SocialLoginServiceImpl implements ISocialLoginService {
|
||||
iSocialUserService.updateSocialUser(updateSocialUser);
|
||||
redisCache.deleteObject(BIND_REDIS_KEY + bindRegisterBody.getBindId());
|
||||
// 生成令牌
|
||||
String token = sysLoginService.redirectLogin(sysUser.getUserName(), sysUser.getPassword());
|
||||
String token = sysLoginService.redirectLogin(sysUser.getUserName(), sysUser.getPassword(), language);
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
return ajax;
|
||||
}
|
||||
@@ -410,7 +411,7 @@ public class SocialLoginServiceImpl implements ISocialLoginService {
|
||||
public AjaxResult checkSocialUser(SocialUser socialUser, String bindId) {
|
||||
if (socialUser == null) {
|
||||
log.info("bindId不存在, bindId: {}", bindId);
|
||||
return error("绑定账户不存在");
|
||||
return error(MessageUtils.message("bind.account.not.exist"));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.fastbee.common.core.redis.RedisKeyBuilder;
|
||||
import com.fastbee.common.enums.ThingsModelType;
|
||||
import com.fastbee.common.exception.ServiceException;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.common.utils.MessageUtils;
|
||||
import com.fastbee.common.utils.StringUtils;
|
||||
import com.fastbee.iot.domain.Product;
|
||||
import com.fastbee.iot.domain.ThingsModel;
|
||||
@@ -427,7 +428,7 @@ public class ThingsModelServiceImpl implements IThingsModelService {
|
||||
*/
|
||||
public String importData(List<ThingsModel> lists, Integer tempSlaveId) {
|
||||
if (null == tempSlaveId || CollectionUtils.isEmpty(lists)) {
|
||||
throw new ServiceException("导入数据异常");
|
||||
throw new ServiceException(MessageUtils.message("things.model.import.data.exception"));
|
||||
}
|
||||
int success = 0;
|
||||
int failure = 0;
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.fastbee.common.core.domain.entity.SysUser;
|
||||
import com.fastbee.common.core.domain.model.LoginUser;
|
||||
import com.fastbee.common.exception.ServiceException;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.common.utils.MessageUtils;
|
||||
import com.fastbee.common.utils.StringUtils;
|
||||
import com.fastbee.iot.domain.ThingsModel;
|
||||
import com.fastbee.iot.model.varTemp.EnumClass;
|
||||
@@ -107,7 +108,7 @@ public class ThingsModelTemplateServiceImpl implements IThingsModelTemplateServi
|
||||
return thingsModelTemplateMapper.insertThingsModelTemplate(template);
|
||||
}catch (Exception e){
|
||||
if (e.getMessage().contains("iot_things_modes_slaveId_reg")){
|
||||
throw new ServiceException("同一个采集点模板下,寄存器地址重复,请检查导入变量寄存器地址");
|
||||
throw new ServiceException(MessageUtils.message("things.model.register.address.repeat"));
|
||||
}else {
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
@@ -196,7 +197,7 @@ public class ThingsModelTemplateServiceImpl implements IThingsModelTemplateServi
|
||||
*/
|
||||
public String importData(List<ThingsModelTemplate> lists, String tempSlaveId) {
|
||||
if (null == tempSlaveId || CollectionUtils.isEmpty(lists)) {
|
||||
throw new ServiceException("导入数据异常");
|
||||
throw new ServiceException(MessageUtils.message("things.model.import.data.exception"));
|
||||
}
|
||||
int success = 0;
|
||||
int failure = 0;
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.fastbee.common.constant.HttpStatus;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.common.core.redis.RedisCache;
|
||||
import com.fastbee.common.enums.SocialPlatformType;
|
||||
import com.fastbee.common.utils.MessageUtils;
|
||||
import com.fastbee.iot.domain.SocialUser;
|
||||
import com.fastbee.iot.domain.UserSocialProfile;
|
||||
import com.fastbee.iot.model.login.BindIdValue;
|
||||
@@ -65,7 +66,7 @@ public class UserSocialProfileServiceImpl implements IUserSocialProfileService {
|
||||
updateSocialUser.setSysUserId(sysUserId);
|
||||
iSocialUserService.updateSocialUser(updateSocialUser);
|
||||
redisCache.deleteObject(BIND_REDIS_KEY + bindId);
|
||||
return AjaxResult.success("绑定成功!");
|
||||
return AjaxResult.success(MessageUtils.message("bind.success"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,7 +74,7 @@ public class UserSocialProfileServiceImpl implements IUserSocialProfileService {
|
||||
try {
|
||||
SocialPlatformType.valueOf(platform);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("错误平台类型");
|
||||
return AjaxResult.error(MessageUtils.message("socialLogin.platform.type.fail"));
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
@@ -82,15 +83,15 @@ public class UserSocialProfileServiceImpl implements IUserSocialProfileService {
|
||||
public AjaxResult unbindSocialAccount(Long socialUserId, Long sysUserId) {
|
||||
SocialUser socialUser = iSocialUserService.selectSocialUserBySocialUserId(socialUserId);
|
||||
if (socialUser == null) {
|
||||
return AjaxResult.error("绑定账户不存在!");
|
||||
return AjaxResult.error(MessageUtils.message("bind.account.not.exist"));
|
||||
} else if (!socialUser.getSysUserId().equals(socialUserId)) {
|
||||
return AjaxResult.error("用户账户和绑定账户不匹配!");
|
||||
return AjaxResult.error(MessageUtils.message("user.account.and.bind.account.not.match"));
|
||||
} else {
|
||||
SocialUser updateSocialUser = new SocialUser();
|
||||
updateSocialUser.setSocialUserId(socialUserId);
|
||||
updateSocialUser.setSysUserId(-1L);
|
||||
iSocialUserService.updateSocialUser(updateSocialUser);
|
||||
return AjaxResult.success("解除绑定成功!");
|
||||
return AjaxResult.success(MessageUtils.message("unbind.success"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,14 +21,14 @@ public interface WeChatService {
|
||||
* @param weChatLoginBody 微信登录参数
|
||||
* @return String
|
||||
*/
|
||||
WeChatLoginResult mobileLogin(WeChatLoginBody weChatLoginBody);
|
||||
WeChatLoginResult mobileLogin(WeChatLoginBody weChatLoginBody, String language);
|
||||
|
||||
/**
|
||||
* 小程序微信登录
|
||||
* @param weChatLoginBody 微信登录参数
|
||||
* @return 登录结果
|
||||
*/
|
||||
WeChatLoginResult miniLogin(WeChatLoginBody weChatLoginBody);
|
||||
WeChatLoginResult miniLogin(WeChatLoginBody weChatLoginBody, String language);
|
||||
|
||||
/**
|
||||
* 取消所有相关微信绑定
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.fastbee.common.enums.SocialPlatformType;
|
||||
import com.fastbee.common.enums.VerifyTypeEnum;
|
||||
import com.fastbee.common.exception.ServiceException;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.common.utils.MessageUtils;
|
||||
import com.fastbee.common.utils.StringUtils;
|
||||
import com.fastbee.common.utils.bean.BeanUtils;
|
||||
import com.fastbee.common.utils.http.HttpUtils;
|
||||
@@ -107,19 +108,19 @@ public class WeChatServiceImpl implements WeChatService {
|
||||
* @param weChatLoginBody 微信登录参数
|
||||
* @return String
|
||||
*/
|
||||
public WeChatLoginResult mobileLogin(WeChatLoginBody weChatLoginBody) {
|
||||
public WeChatLoginResult mobileLogin(WeChatLoginBody weChatLoginBody, String language) {
|
||||
WeChatLoginResult weChatLoginResult = new WeChatLoginResult();
|
||||
SocialPlatformType socialPlatformType = SocialPlatformType.WECHAT_OPEN_MOBILE;
|
||||
// 查询微信平台信息
|
||||
SocialPlatform socialPlatform = socialPlatformService.selectSocialPlatformByPlatform(socialPlatformType.getSourceClient());
|
||||
if (socialPlatform == null) {
|
||||
throw new ServiceException("请先配置微信开放平台移动应用信息");
|
||||
throw new ServiceException(MessageUtils.message("wechat.please.config.open.platform"));
|
||||
}
|
||||
// 用户凭证code只能消费一次,前端调的uni.login有时会消费,然后直接就把获取到的信息传过来,不会消费的话就这里通过code拿
|
||||
if (StringUtils.isEmpty(weChatLoginBody.getAccessToken()) || StringUtils.isEmpty(weChatLoginBody.getOpenId()) || StringUtils.isEmpty(weChatLoginBody.getUnionId())) {
|
||||
WeChatAppResult weChatResult = this.getAccessTokenOpenId(weChatLoginBody.getCode(), socialPlatform);
|
||||
if (weChatResult == null || weChatResult.getErrCode() != null) {
|
||||
throw new ServiceException("用户凭证获取失败,请重新登录!");
|
||||
throw new ServiceException(MessageUtils.message("wechat.user.certificate.gain.fail"));
|
||||
}
|
||||
weChatLoginBody.setAccessToken(weChatResult.getAccessToken()).setRefreshToken(weChatResult.getRefreshToken()).setExpiresIn(weChatResult.getExpiresIn()).setOpenId(weChatResult.getOpenId()).setUnionId(weChatResult.getUnionId()).setScope(weChatResult.getScope());
|
||||
}
|
||||
@@ -165,9 +166,9 @@ public class WeChatServiceImpl implements WeChatService {
|
||||
} else {
|
||||
SysUser sysUser = sysUserService.selectUserById(bindSysUserId);
|
||||
if (sysUser == null) {
|
||||
throw new ServiceException("用户不存在");
|
||||
throw new ServiceException(MessageUtils.message("user.not.exist"));
|
||||
}
|
||||
String token = sysLoginService.redirectLogin(sysUser.getUserName(), sysUser.getPassword());
|
||||
String token = sysLoginService.redirectLogin(sysUser.getUserName(), sysUser.getPassword(), language);
|
||||
weChatLoginResult.setToken(token);
|
||||
}
|
||||
return weChatLoginResult;
|
||||
@@ -179,26 +180,26 @@ public class WeChatServiceImpl implements WeChatService {
|
||||
* @return 登录结果
|
||||
*/
|
||||
@Override
|
||||
public WeChatLoginResult miniLogin(WeChatLoginBody weChatLoginBody) {
|
||||
public WeChatLoginResult miniLogin(WeChatLoginBody weChatLoginBody, String language) {
|
||||
// 使用微信手机号去登录不绑定微信,没有用户则用手机号自动注册一个登录,密码是手机号
|
||||
SocialPlatformType socialPlatformType = SocialPlatformType.WECHAT_OPEN_MINI_PROGRAM;
|
||||
// 查询微信平台信息
|
||||
SocialPlatform socialPlatform = socialPlatformService.selectSocialPlatformByPlatform(socialPlatformType.getSourceClient());
|
||||
if (socialPlatform == null) {
|
||||
throw new ServiceException("请先配置微信公众平台小程序信息!");
|
||||
throw new ServiceException(MessageUtils.message("wechat.please.config.open.platform.mini"));
|
||||
}
|
||||
if (StringUtils.isEmpty(weChatLoginBody.getPhoneCode())) {
|
||||
throw new ServiceException("用户手机号凭证获取失败,请重新登录!");
|
||||
throw new ServiceException(MessageUtils.message("wechat.user.phone.certificate.gain.fail"));
|
||||
}
|
||||
// 先获取token
|
||||
WeChatAppResult result = getAccessToken(socialPlatform);
|
||||
if (result == null || StringUtils.isEmpty(result.getAccessToken())) {
|
||||
throw new ServiceException("获取用户调用凭据失败,请重新登录!");
|
||||
throw new ServiceException(MessageUtils.message("wechat.user.certificate.gain.fail"));
|
||||
}
|
||||
// 根据phoneCode获取用户手机号
|
||||
WeChatPhoneInfo userPhoneInfo = getWechatUserPhoneInfo(weChatLoginBody.getPhoneCode(), result.getAccessToken());
|
||||
if (userPhoneInfo == null || !userPhoneInfo.getErrCode().equals("0")) {
|
||||
throw new ServiceException("获取用户手机号失败,请重新登录!");
|
||||
throw new ServiceException(MessageUtils.message("wechat.user.phone.certificate.gain.fail"));
|
||||
}
|
||||
String phoneNumber = userPhoneInfo.getPhoneInfo().getPhoneNumber();
|
||||
SysUser sysUser = sysUserService.selectUserByPhoneNumber(phoneNumber);
|
||||
@@ -214,9 +215,9 @@ public class WeChatServiceImpl implements WeChatService {
|
||||
if (StringUtils.isNotEmpty(registerUserOutput.getMsg())) {
|
||||
throw new ServiceException(registerUserOutput.getMsg());
|
||||
}
|
||||
token = sysLoginService.redirectLogin(phoneNumber, phoneNumber);
|
||||
token = sysLoginService.redirectLogin(phoneNumber, phoneNumber, language);
|
||||
} else {
|
||||
token = sysLoginService.redirectLogin(sysUser.getUserName(), sysUser.getPassword());
|
||||
token = sysLoginService.redirectLogin(sysUser.getUserName(), sysUser.getPassword(), language);
|
||||
}
|
||||
weChatLoginResult.setToken(token);
|
||||
return weChatLoginResult;
|
||||
@@ -252,21 +253,21 @@ public class WeChatServiceImpl implements WeChatService {
|
||||
public AjaxResult cancelBind(WxCancelBindReqVO wxCancelBindReqVO) {
|
||||
LoginUser loginUser = getLoginUser();
|
||||
if (loginUser == null || loginUser.getUserId() == null) {
|
||||
throw new ServiceException("请先登录后重试");
|
||||
throw new ServiceException(MessageUtils.message("wechat.please.login"));
|
||||
}
|
||||
// 密码验证
|
||||
if (VerifyTypeEnum.PASSWORD.getVerifyType().equals(wxCancelBindReqVO.getVerifyType())) {
|
||||
if (StringUtils.isEmpty(wxCancelBindReqVO.getPassword())) {
|
||||
throw new ServiceException("请传入用户密码");
|
||||
throw new ServiceException(MessageUtils.message("wechat.please.enter.user.password"));
|
||||
}
|
||||
Boolean validateResult = sysUserService.validatePassword(loginUser.getUser().getPassword(), wxCancelBindReqVO.getPassword());
|
||||
if (Boolean.FALSE.equals(validateResult)) {
|
||||
throw new ServiceException("密码错误,请重新输入");
|
||||
throw new ServiceException(MessageUtils.message("wechat.cancelBind.password.fail"));
|
||||
}
|
||||
}
|
||||
// 解绑所有微信应用
|
||||
int cancelBind = socialUserService.cancelBind(loginUser.getUserId(), SocialPlatformType.listWechatPlatform);
|
||||
return cancelBind >= 1 ? success("解绑成功") : AjaxResult.error("解绑失败");
|
||||
return cancelBind >= 1 ? success(MessageUtils.message("unbind.success")) : AjaxResult.error(MessageUtils.message("unbind.fail"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -278,30 +279,30 @@ public class WeChatServiceImpl implements WeChatService {
|
||||
public AjaxResult bind(WxBindReqVO wxBindReqVO) {
|
||||
Long sysUserId = getUserId();
|
||||
if (sysUserId == null) {
|
||||
throw new ServiceException("请登录后重试");
|
||||
throw new ServiceException(MessageUtils.message("wechat.please.login"));
|
||||
}
|
||||
String openId = "";
|
||||
String unionId = "";
|
||||
// 区分小程序绑定还是移动应用绑定
|
||||
if (SocialPlatformType.WECHAT_OPEN_MOBILE.sourceClient.equals(wxBindReqVO.getSourceClient())) {
|
||||
if (StringUtils.isEmpty(wxBindReqVO.getOpenId()) || StringUtils.isEmpty(wxBindReqVO.getUnionId())) {
|
||||
throw new ServiceException("请传入微信用户信息");
|
||||
throw new ServiceException(MessageUtils.message("wechat.please.enter.wechat.user.info"));
|
||||
}
|
||||
openId = wxBindReqVO.getOpenId();
|
||||
unionId = wxBindReqVO.getUnionId();
|
||||
} else if (SocialPlatformType.WECHAT_OPEN_MINI_PROGRAM.sourceClient.equals(wxBindReqVO.getSourceClient())) {
|
||||
if (StringUtils.isEmpty(wxBindReqVO.getCode())) {
|
||||
throw new ServiceException("请传入用户凭证");
|
||||
throw new ServiceException(MessageUtils.message("wechat.please.enter.user.certificate"));
|
||||
}
|
||||
// 查询微信平台信息
|
||||
SocialPlatform socialPlatform = socialPlatformService.selectSocialPlatformByPlatform(SocialPlatformType.WECHAT_OPEN_MINI_PROGRAM.sourceClient);
|
||||
if (socialPlatform == null) {
|
||||
throw new ServiceException("请先配置微信开放平台小程序信息!");
|
||||
throw new ServiceException(MessageUtils.message("wechat.please.config.open.platform.mini"));
|
||||
}
|
||||
WeChatMiniProgramResult weChatMiniProgramResult = this.codeToSession(wxBindReqVO.getCode(), socialPlatform);
|
||||
if (weChatMiniProgramResult == null
|
||||
|| (StringUtils.isEmpty(weChatMiniProgramResult.getOpenId()) && StringUtils.isEmpty(weChatMiniProgramResult.getUnionId()))) {
|
||||
throw new ServiceException("获取微信信息失败,请重试!");
|
||||
throw new ServiceException(MessageUtils.message("wechat.gain.wechat.info.fail"));
|
||||
}
|
||||
openId = weChatMiniProgramResult.getOpenId();
|
||||
unionId = weChatMiniProgramResult.getUnionId();
|
||||
@@ -311,11 +312,11 @@ public class WeChatServiceImpl implements WeChatService {
|
||||
int bindResult;
|
||||
List<SocialUser> socialUserList = socialUserService.selectBySysUserId(sysUserId);
|
||||
if (CollectionUtils.isNotEmpty(socialUserList)) {
|
||||
return success("绑定成功!");
|
||||
return success(MessageUtils.message("bind.success"));
|
||||
}
|
||||
if (socialUser != null) {
|
||||
if (socialUser.getSysUserId() != null && !sysUserId.equals(socialUser.getSysUserId())) {
|
||||
throw new ServiceException("该微信已绑定其他账号,请先使用微信登录解绑后重试!");
|
||||
throw new ServiceException(MessageUtils.message("wechat.this.wechat.already.bind.other.account"));
|
||||
}
|
||||
SocialUser updateSocialUser = new SocialUser();
|
||||
updateSocialUser.setSocialUserId(socialUser.getSocialUserId());
|
||||
@@ -334,19 +335,19 @@ public class WeChatServiceImpl implements WeChatService {
|
||||
bindResult = socialUserService.insertSocialUser(insertSocialUser);
|
||||
}
|
||||
// 绑定
|
||||
return bindResult >= 1 ? success("绑定成功!") : AjaxResult.error("绑定失败");
|
||||
return bindResult >= 1 ? success(MessageUtils.message("bind.success")) : AjaxResult.error(MessageUtils.message("bind.fail"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getWxBindQr(HttpServletRequest httpServletRequest) {
|
||||
Long sysUserId = getUserId();
|
||||
if (sysUserId == null) {
|
||||
throw new ServiceException("请先登录后重试!");
|
||||
throw new ServiceException(MessageUtils.message("wechat.please.login"));
|
||||
}
|
||||
WeChatLoginQrRes weChatLoginQrRes = new WeChatLoginQrRes();
|
||||
SocialPlatform socialPlatform = socialPlatformService.selectSocialPlatformByPlatform(SocialPlatformType.WECHAT_OPEN_WEB_BIND.sourceClient);
|
||||
if (socialPlatform == null) {
|
||||
throw new ServiceException("请先配置微信开放平台网站应用个人中心绑定信息");
|
||||
throw new ServiceException(MessageUtils.message("wechat.please.config.open.platform.web.application.personal.bind.info"));
|
||||
}
|
||||
weChatLoginQrRes.setAppid(socialPlatform.getClientId());
|
||||
weChatLoginQrRes.setScope("snsapi_login");
|
||||
@@ -362,36 +363,36 @@ public class WeChatServiceImpl implements WeChatService {
|
||||
SocialPlatform socialPlatform = socialPlatformService.selectSocialPlatformByPlatform(SocialPlatformType.WECHAT_OPEN_WEB_BIND.sourceClient);
|
||||
if (socialPlatform == null) {
|
||||
String serverName = httpServletRequest.getServerName();
|
||||
String msgId = socialLoginService.genErrorId("请先配置微信开放平台网站应用个人中心绑定信息");
|
||||
String msgId = socialLoginService.genErrorId(MessageUtils.message("wechat.please.config.open.platform.web.application.personal.bind.info"));
|
||||
return "https://" + serverName + "/user/profile?wxBindMsgId=" + msgId;
|
||||
}
|
||||
String url = socialPlatform.getRedirectLoginUri();
|
||||
//获取临时票据 code
|
||||
log.info("code:{}", code);
|
||||
if (StringUtils.isEmpty(code)) {
|
||||
String msgId = socialLoginService.genErrorId("您已取消授权或未获取到授权信息");
|
||||
String msgId = socialLoginService.genErrorId(MessageUtils.message("wechat.you.cancel.or.not.gain.authorization.info"));
|
||||
return url + msgId;
|
||||
}
|
||||
Long sysUserId = redisCache.getCacheObject(WX_BIND_REDIS_KEY + wxBindId);
|
||||
if (sysUserId == null) {
|
||||
String msgId = socialLoginService.genErrorId("二维码已失效,请重新点击绑定");
|
||||
String msgId = socialLoginService.genErrorId(MessageUtils.message("wechat.the.qr.code.has.expired"));
|
||||
return url + msgId;
|
||||
}
|
||||
List<SocialUser> socialUserList = socialUserService.selectBySysUserId(sysUserId);
|
||||
if (CollectionUtils.isNotEmpty(socialUserList)) {
|
||||
String msgId = socialLoginService.genErrorId("您的账号已绑定微信,请先解绑");
|
||||
String msgId = socialLoginService.genErrorId(MessageUtils.message("wechat.your.account.already.bind.wechat"));
|
||||
return url + msgId;
|
||||
}
|
||||
// 组装获取accessToken的url
|
||||
WeChatAppResult weChatAppResult = this.getAccessTokenOpenId(code, socialPlatform);
|
||||
if (weChatAppResult == null || StringUtils.isEmpty(weChatAppResult.getAccessToken())
|
||||
|| StringUtils.isEmpty(weChatAppResult.getOpenId()) || StringUtils.isEmpty(weChatAppResult.getUnionId())) {
|
||||
String msgId = socialLoginService.genErrorId("获取微信信息失败,请重试");
|
||||
String msgId = socialLoginService.genErrorId(MessageUtils.message("wechat.gain.wechat.info.fail"));
|
||||
return url + msgId;
|
||||
}
|
||||
Long bindUserId = socialUserService.selectSysUserIdByUnionId(weChatAppResult.getUnionId());
|
||||
if (bindUserId != null && !bindUserId.equals(sysUserId)) {
|
||||
String msgId = socialLoginService.genErrorId("您的微信已绑定其他账号,请先使用微信登录解绑后重试!");
|
||||
String msgId = socialLoginService.genErrorId(MessageUtils.message("wechat.your.wechat.already.bind.other.account"));
|
||||
return url + msgId;
|
||||
}
|
||||
SocialUser socialUser = socialUserService.selectOneByOpenIdAndUnionId(weChatAppResult.getOpenId(), weChatAppResult.getUnionId());
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.fastbee.system.convert;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fastbee.system.domain.AppLanguage;
|
||||
import com.fastbee.system.domain.vo.AppLanguageVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* app语言Convert转换类
|
||||
*
|
||||
* @author zhuangpeng.li
|
||||
* @date 2024-11-25
|
||||
*/
|
||||
@Mapper
|
||||
public interface AppLanguageConvert
|
||||
{
|
||||
|
||||
AppLanguageConvert INSTANCE = Mappers.getMapper(AppLanguageConvert.class);
|
||||
|
||||
/**
|
||||
* 实体类转换为VO类
|
||||
*
|
||||
* @param appLanguage
|
||||
* @return app语言集合
|
||||
*/
|
||||
AppLanguageVO convertAppLanguageVO(AppLanguage appLanguage);
|
||||
|
||||
/**
|
||||
* VO类转换为实体类集合
|
||||
*
|
||||
* @param appLanguageVO
|
||||
* @return app语言集合
|
||||
*/
|
||||
AppLanguage convertAppLanguage(AppLanguageVO appLanguageVO);
|
||||
|
||||
/**
|
||||
* 实体类转换为VO类集合
|
||||
*
|
||||
* @param appLanguageList
|
||||
* @return app语言集合
|
||||
*/
|
||||
List<AppLanguageVO> convertAppLanguageVOList(List<AppLanguage> appLanguageList);
|
||||
|
||||
/**
|
||||
* VO类转换为实体类
|
||||
*
|
||||
* @param appLanguageVOList
|
||||
* @return app语言集合
|
||||
*/
|
||||
List<AppLanguage> convertAppLanguageList(List<AppLanguageVO> appLanguageVOList);
|
||||
|
||||
/**
|
||||
* 实体类转换为VO类分页
|
||||
*
|
||||
* @param appLanguagePage
|
||||
* @return app语言分页
|
||||
*/
|
||||
Page<AppLanguageVO> convertAppLanguageVOPage(Page<AppLanguage> appLanguagePage);
|
||||
|
||||
/**
|
||||
* VO类转换为实体类
|
||||
*
|
||||
* @param appLanguageVOPage
|
||||
* @return app语言分页
|
||||
*/
|
||||
Page<AppLanguage> convertAppLanguagePage(Page<AppLanguageVO> appLanguageVOPage);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.fastbee.system.convert;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fastbee.system.domain.AppPreferences;
|
||||
import com.fastbee.system.domain.vo.AppPreferencesVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* APP用户偏好设置Convert转换类
|
||||
*
|
||||
* @author fastbee
|
||||
* @date 2024-12-03
|
||||
*/
|
||||
@Mapper
|
||||
public interface AppPreferencesConvert
|
||||
{
|
||||
|
||||
AppPreferencesConvert INSTANCE = Mappers.getMapper(AppPreferencesConvert.class);
|
||||
|
||||
/**
|
||||
* 实体类转换为VO类
|
||||
*
|
||||
* @param appPreferences
|
||||
* @return APP用户偏好设置集合
|
||||
*/
|
||||
AppPreferencesVO convertAppPreferencesVO(AppPreferences appPreferences);
|
||||
|
||||
/**
|
||||
* VO类转换为实体类集合
|
||||
*
|
||||
* @param appPreferencesVO
|
||||
* @return APP用户偏好设置集合
|
||||
*/
|
||||
AppPreferences convertAppPreferences(AppPreferencesVO appPreferencesVO);
|
||||
|
||||
/**
|
||||
* 实体类转换为VO类集合
|
||||
*
|
||||
* @param appPreferencesList
|
||||
* @return APP用户偏好设置集合
|
||||
*/
|
||||
List<AppPreferencesVO> convertAppPreferencesVOList(List<AppPreferences> appPreferencesList);
|
||||
|
||||
/**
|
||||
* VO类转换为实体类
|
||||
*
|
||||
* @param appPreferencesVOList
|
||||
* @return APP用户偏好设置集合
|
||||
*/
|
||||
List<AppPreferences> convertAppPreferencesList(List<AppPreferencesVO> appPreferencesVOList);
|
||||
|
||||
/**
|
||||
* 实体类转换为VO类分页
|
||||
*
|
||||
* @param appPreferencesPage
|
||||
* @return APP用户偏好设置分页
|
||||
*/
|
||||
Page<AppPreferencesVO> convertAppPreferencesVOPage(Page<AppPreferences> appPreferencesPage);
|
||||
|
||||
/**
|
||||
* VO类转换为实体类
|
||||
*
|
||||
* @param appPreferencesVOPage
|
||||
* @return APP用户偏好设置分页
|
||||
*/
|
||||
Page<AppPreferences> convertAppPreferencesPage(Page<AppPreferencesVO> appPreferencesVOPage);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.fastbee.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fastbee.common.core.domain.PageEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* app语言对象 app_language
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "AppLanguage", description = "app语言 app_language")
|
||||
@Data
|
||||
@TableName("app_language" )
|
||||
public class AppLanguage extends PageEntity implements Serializable {
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/** 主键ID */
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty("主键ID")
|
||||
private Long id;
|
||||
|
||||
/** 语言 */
|
||||
@ApiModelProperty("语言")
|
||||
private String language;
|
||||
|
||||
/** 国家 */
|
||||
@ApiModelProperty("国家")
|
||||
private String country;
|
||||
|
||||
/** 时区 */
|
||||
@ApiModelProperty("时区")
|
||||
private String timeZone;
|
||||
|
||||
/** 创建者 */
|
||||
@ApiModelProperty("创建者")
|
||||
private String createBy;
|
||||
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
/** 语言名称 */
|
||||
@ApiModelProperty("语言名称")
|
||||
private String langName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.fastbee.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fastbee.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* APP用户偏好设置对象 app_preferences
|
||||
*
|
||||
* @author fastbee
|
||||
* @date 2024-12-03
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "AppPreferences", description = "APP用户偏好设置 app_preferences")
|
||||
@Data
|
||||
@TableName("app_preferences" )
|
||||
public class AppPreferences extends BaseEntity implements Serializable{
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/** 主键id */
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty("主键id")
|
||||
private Long id;
|
||||
|
||||
/** 用户 */
|
||||
@ApiModelProperty("用户")
|
||||
private Long userId;
|
||||
|
||||
/** 语言 */
|
||||
@ApiModelProperty("语言")
|
||||
private String language;
|
||||
|
||||
/** 时区 */
|
||||
@ApiModelProperty("时区")
|
||||
private String timeZone;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.fastbee.system.domain;
|
||||
|
||||
import com.fastbee.common.annotation.Excel;
|
||||
import com.fastbee.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 翻译对象 sys_translate
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Data
|
||||
public class SysTranslate extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
@Excel(name = "ID")
|
||||
private Long id;
|
||||
|
||||
/** zh_CN */
|
||||
@Excel(name = "zh-CN")
|
||||
private String zh_CN;
|
||||
|
||||
/** en_US */
|
||||
@Excel(name = "en-US")
|
||||
private String en_US;
|
||||
|
||||
/** 物模型翻译表使用 */
|
||||
private Long productId;
|
||||
|
||||
private String tableName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.fastbee.system.domain.vo;
|
||||
|
||||
import com.fastbee.common.annotation.Excel;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* app语言对象 app_language
|
||||
*
|
||||
* @author zhuangpeng.li
|
||||
* @date 2024-11-25
|
||||
*/
|
||||
|
||||
@ApiModel(value = "AppLanguageVO", description = "app语言 app_language")
|
||||
@Data
|
||||
public class AppLanguageVO {
|
||||
|
||||
/** 主键ID */
|
||||
@Excel(name = "主键ID")
|
||||
@ApiModelProperty("主键ID")
|
||||
private Long id;
|
||||
|
||||
/** 语言 */
|
||||
@Excel(name = "语言")
|
||||
@ApiModelProperty("语言")
|
||||
private String language;
|
||||
|
||||
/** 国家 */
|
||||
@Excel(name = "国家")
|
||||
@ApiModelProperty("国家")
|
||||
private String country;
|
||||
|
||||
/** 时区 */
|
||||
@Excel(name = "时区")
|
||||
@ApiModelProperty("时区")
|
||||
private String timeZone;
|
||||
|
||||
/** 创建者 */
|
||||
@Excel(name = "创建者")
|
||||
@ApiModelProperty("创建者")
|
||||
private String createBy;
|
||||
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("创建时间")
|
||||
@Excel(name = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
/** 语言名称 */
|
||||
@Excel(name = "语言名称")
|
||||
@ApiModelProperty("语言名称")
|
||||
private String langName;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.fastbee.system.domain.vo;
|
||||
|
||||
import com.fastbee.common.annotation.Excel;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* APP用户偏好设置对象 app_preferences
|
||||
*
|
||||
* @author fastbee
|
||||
* @date 2024-12-03
|
||||
*/
|
||||
|
||||
@ApiModel(value = "AppPreferencesVO", description = "APP用户偏好设置 app_preferences")
|
||||
@Data
|
||||
public class AppPreferencesVO {
|
||||
|
||||
/** 主键id */
|
||||
@Excel(name = "主键id")
|
||||
@ApiModelProperty("主键id")
|
||||
private Long id;
|
||||
|
||||
/** 用户 */
|
||||
@Excel(name = "用户")
|
||||
@ApiModelProperty("用户")
|
||||
private Long userId;
|
||||
|
||||
/** 语言 */
|
||||
@Excel(name = "语言")
|
||||
@ApiModelProperty("语言")
|
||||
private String language;
|
||||
|
||||
/** 时区 */
|
||||
@Excel(name = "时区")
|
||||
@ApiModelProperty("时区")
|
||||
private String timeZone;
|
||||
|
||||
/** 创建者 */
|
||||
@Excel(name = "创建者")
|
||||
@ApiModelProperty("创建者")
|
||||
private String createBy;
|
||||
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("创建时间")
|
||||
@Excel(name = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
/** 更新者 */
|
||||
@Excel(name = "更新者")
|
||||
@ApiModelProperty("更新者")
|
||||
private String updateBy;
|
||||
|
||||
/** 更新时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("更新时间")
|
||||
@Excel(name = "更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
/** 备注 */
|
||||
@Excel(name = "备注")
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.fastbee.system.mapper;
|
||||
|
||||
|
||||
import com.fastbee.common.mybatis.mapper.BaseMapperX;
|
||||
import com.fastbee.system.domain.AppLanguage;
|
||||
|
||||
/**
|
||||
* app语言Mapper接口
|
||||
*/
|
||||
public interface AppLanguageMapper extends BaseMapperX<AppLanguage>
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.fastbee.system.mapper;
|
||||
|
||||
|
||||
import com.fastbee.common.mybatis.mapper.BaseMapperX;
|
||||
import com.fastbee.system.domain.AppPreferences;
|
||||
|
||||
/**
|
||||
* APP用户偏好设置Mapper接口
|
||||
*/
|
||||
public interface AppPreferencesMapper extends BaseMapperX<AppPreferences>
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
@@ -42,7 +42,15 @@ public interface SysDictDataMapper
|
||||
* @param dictCode 字典数据ID
|
||||
* @return 字典数据
|
||||
*/
|
||||
public SysDictData selectDictDataById(Long dictCode);
|
||||
public SysDictData selectDictDataById(@Param("dictCode") Long dictCode, @Param("language") String language);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询字典数据--返回所有语言
|
||||
*
|
||||
* @param dictData 字典数据信息
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
public List<SysDictData> selectDictDataListAll(SysDictData dictData);
|
||||
|
||||
/**
|
||||
* 查询字典数据
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.fastbee.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fastbee.common.core.domain.entity.SysDictData;
|
||||
import com.fastbee.common.core.domain.entity.SysDictType;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 字典表 数据层
|
||||
@@ -23,7 +26,7 @@ public interface SysDictTypeMapper
|
||||
*
|
||||
* @return 字典类型集合信息
|
||||
*/
|
||||
public List<SysDictType> selectDictTypeAll();
|
||||
public List<SysDictType> selectDictTypeAll(@Param("language") String language);
|
||||
|
||||
/**
|
||||
* 根据字典类型ID查询信息
|
||||
@@ -31,7 +34,7 @@ public interface SysDictTypeMapper
|
||||
* @param dictId 字典类型ID
|
||||
* @return 字典类型
|
||||
*/
|
||||
public SysDictType selectDictTypeById(Long dictId);
|
||||
public SysDictType selectDictTypeById(@Param("dictId") Long dictId, @Param("language") String language);
|
||||
|
||||
/**
|
||||
* 根据字典类型查询信息
|
||||
@@ -39,7 +42,7 @@ public interface SysDictTypeMapper
|
||||
* @param dictType 字典类型
|
||||
* @return 字典类型
|
||||
*/
|
||||
public SysDictType selectDictTypeByType(String dictType);
|
||||
public SysDictType selectDictTypeByType(@Param("dictType") String dictType, @Param("language") String language);
|
||||
|
||||
/**
|
||||
* 通过字典ID删除字典信息
|
||||
@@ -79,5 +82,5 @@ public interface SysDictTypeMapper
|
||||
* @param dictType 字典类型
|
||||
* @return 结果
|
||||
*/
|
||||
public SysDictType checkDictTypeUnique(String dictType);
|
||||
public List<SysDictType> checkDictTypeUnique(@Param("dictType") String dictType, @Param("language") String language);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public interface SysMenuMapper
|
||||
*
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<SysMenu> selectMenuTreeAll();
|
||||
public List<SysMenu> selectMenuTreeAll(@Param("language") String language);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询菜单
|
||||
@@ -63,7 +63,7 @@ public interface SysMenuMapper
|
||||
* @param userId 用户ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<SysMenu> selectMenuTreeByUserId(Long userId);
|
||||
public List<SysMenu> selectMenuTreeByUserId(@Param("userId") Long userId, @Param("language") String language);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询菜单树信息
|
||||
@@ -80,7 +80,7 @@ public interface SysMenuMapper
|
||||
* @param menuId 菜单ID
|
||||
* @return 菜单信息
|
||||
*/
|
||||
public SysMenu selectMenuById(Long menuId);
|
||||
public SysMenu selectMenuById(@Param("menuId") Long menuId, @Param("language") String language);
|
||||
|
||||
/**
|
||||
* 是否存在菜单子节点
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.fastbee.system.mapper;
|
||||
|
||||
import com.fastbee.common.mybatis.mapper.BaseMapperX;
|
||||
import com.fastbee.system.domain.SysTranslate;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 翻译Mapper接口
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-05-29
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysTranslateMapper extends BaseMapperX<SysTranslate>
|
||||
{
|
||||
|
||||
/**
|
||||
* 新增或修改翻译
|
||||
*
|
||||
* @param sysTranslate 翻译
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysTranslate(SysTranslate sysTranslate);
|
||||
|
||||
/**
|
||||
* 查询翻译列表
|
||||
*
|
||||
* @param sysTranslate 翻译
|
||||
* @return 翻译集合
|
||||
*/
|
||||
public List<SysTranslate> selectSysTranslateList(SysTranslate sysTranslate);
|
||||
|
||||
/**
|
||||
* 查询原表数据列表
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @param idColumn id列名
|
||||
* @param nameColumn 名称列名
|
||||
* @return 翻译集合
|
||||
*/
|
||||
public List<SysTranslate> selectSourceList(@Param("tableName") String tableName, @Param("idColumn") String idColumn, @Param("nameColumn") String nameColumn, @Param("productId") Long productId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.fastbee.system.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fastbee.system.domain.AppLanguage;
|
||||
import com.fastbee.system.domain.vo.AppLanguageVO;
|
||||
|
||||
/**
|
||||
* app语言Service接口
|
||||
*/
|
||||
public interface IAppLanguageService extends IService<AppLanguage>
|
||||
{
|
||||
/**
|
||||
* 查询app语言
|
||||
*
|
||||
* @param id app语言主键
|
||||
* @return app语言
|
||||
*/
|
||||
public AppLanguage selectAppLanguageById(Long id);
|
||||
|
||||
/**
|
||||
* 查询app语言列表
|
||||
*
|
||||
* @param appLanguage app语言
|
||||
* @return app语言分页集合
|
||||
*/
|
||||
Page<AppLanguageVO> pageAppLanguageVO(AppLanguage appLanguage);
|
||||
|
||||
/**
|
||||
* 新增app语言
|
||||
*
|
||||
* @param appLanguage app语言
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertAppLanguage(AppLanguage appLanguage);
|
||||
|
||||
/**
|
||||
* 修改app语言
|
||||
*
|
||||
* @param appLanguage app语言
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateAppLanguage(AppLanguage appLanguage);
|
||||
|
||||
/**
|
||||
* 批量删除app语言
|
||||
*
|
||||
* @param ids 需要删除的app语言主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAppLanguageByIds(Long[] ids);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.fastbee.system.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fastbee.system.domain.AppPreferences;
|
||||
import com.fastbee.system.domain.vo.AppPreferencesVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* APP用户偏好设置Service接口
|
||||
*/
|
||||
public interface IAppPreferencesService extends IService<AppPreferences>
|
||||
{
|
||||
|
||||
/**
|
||||
* 查询APP用户偏好设置列表
|
||||
*
|
||||
* @param appPreferences APP用户偏好设置
|
||||
* @return APP用户偏好设置分页集合
|
||||
*/
|
||||
Page<AppPreferencesVO> pageAppPreferencesVO(AppPreferences appPreferences);
|
||||
|
||||
/**
|
||||
* 查询APP用户偏好设置
|
||||
*
|
||||
* @param userId APP用户偏好设置主键
|
||||
* @return APP用户偏好设置
|
||||
*/
|
||||
public AppPreferences selectAppPreferencesByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 查询APP用户偏好设置列表
|
||||
*
|
||||
* @param appPreferences APP用户偏好设置
|
||||
* @return APP用户偏好设置集合
|
||||
*/
|
||||
List<AppPreferencesVO> listAppPreferencesVO(AppPreferences appPreferences);
|
||||
|
||||
/**
|
||||
* 新增APP用户偏好设置
|
||||
*
|
||||
* @param appPreferences APP用户偏好设置
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertAppPreferences(AppPreferences appPreferences);
|
||||
|
||||
/**
|
||||
* 修改APP用户偏好设置
|
||||
*
|
||||
* @param appPreferences APP用户偏好设置
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateAppPreferences(AppPreferences appPreferences);
|
||||
|
||||
/**
|
||||
* 批量删除APP用户偏好设置
|
||||
*
|
||||
* @param userIds 需要删除的APP用户偏好设置主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAppPreferencesByUserIds(Long[] userIds);
|
||||
|
||||
/**
|
||||
* 删除APP用户偏好设置信息
|
||||
*
|
||||
* @param userId APP用户偏好设置主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAppPreferencesByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 新增或者更新用户偏好设置
|
||||
* @param appPreferences
|
||||
* @return
|
||||
*/
|
||||
public int addOrUpdate(AppPreferences appPreferences);
|
||||
|
||||
/**
|
||||
* 获取用户偏好语言
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
public String getLanguage(Long userId);
|
||||
}
|
||||
@@ -50,9 +50,10 @@ public interface ISysMenuService
|
||||
* 根据用户ID查询菜单树信息
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param language 语言
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<SysMenu> selectMenuTreeByUserId(Long userId);
|
||||
public List<SysMenu> selectMenuTreeByUserId(Long userId, String language);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询菜单树信息
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.fastbee.system.service;
|
||||
|
||||
|
||||
import com.fastbee.system.domain.SysTranslate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 翻译Service接口
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-05-29
|
||||
*/
|
||||
public interface ISysTranslateService
|
||||
{
|
||||
/**
|
||||
* 导入翻译列表
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public void importSysTranslate(List<SysTranslate> list, String type, Long productId);
|
||||
|
||||
/**
|
||||
* 查询翻译列表
|
||||
* @param sysTranslate 翻译类
|
||||
* @return 翻译列表
|
||||
*/
|
||||
public List<SysTranslate> selectSysTranslateList(SysTranslate sysTranslate, String type);
|
||||
|
||||
/**
|
||||
* 查询原表数据列表
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public List<SysTranslate> selectSourceList(String type, Long productId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.fastbee.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fastbee.common.utils.StringUtils;
|
||||
import com.fastbee.system.convert.AppLanguageConvert;
|
||||
import com.fastbee.system.domain.AppLanguage;
|
||||
import com.fastbee.system.domain.vo.AppLanguageVO;
|
||||
import com.fastbee.system.mapper.AppLanguageMapper;
|
||||
import com.fastbee.system.service.IAppLanguageService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* app语言Service业务层处理
|
||||
*/
|
||||
@Service
|
||||
public class AppLanguageServiceImpl extends ServiceImpl<AppLanguageMapper,AppLanguage> implements IAppLanguageService
|
||||
{
|
||||
@Resource
|
||||
private AppLanguageMapper appLanguageMapper;
|
||||
|
||||
/**
|
||||
* 查询app语言
|
||||
*
|
||||
* @param id app语言主键
|
||||
* @return app语言
|
||||
*/
|
||||
@Override
|
||||
public AppLanguage selectAppLanguageById(Long id)
|
||||
{
|
||||
return appLanguageMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询app语言分页列表
|
||||
*
|
||||
* @param appLanguage app语言
|
||||
* @return app语言
|
||||
*/
|
||||
@Override
|
||||
public Page<AppLanguageVO> pageAppLanguageVO(AppLanguage appLanguage) {
|
||||
LambdaQueryWrapper<AppLanguage> lqw = buildQueryWrapper(appLanguage);
|
||||
Page<AppLanguage> appLanguagePage = baseMapper.selectPage(new Page<>(appLanguage.getPageNum(), appLanguage.getPageSize()), lqw);
|
||||
return AppLanguageConvert.INSTANCE.convertAppLanguageVOPage(appLanguagePage);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<AppLanguage> buildQueryWrapper(AppLanguage query) {
|
||||
Map<String, Object> params = query.getParams();
|
||||
LambdaQueryWrapper<AppLanguage> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(StringUtils.isNotBlank(query.getLanguage()), AppLanguage::getLanguage, query.getLanguage());
|
||||
lqw.eq(StringUtils.isNotBlank(query.getCountry()), AppLanguage::getCountry, query.getCountry());
|
||||
lqw.eq(StringUtils.isNotBlank(query.getTimeZone()), AppLanguage::getTimeZone, query.getTimeZone());
|
||||
lqw.like(StringUtils.isNotBlank(query.getLangName()), AppLanguage::getLangName, query.getLangName());
|
||||
|
||||
if (!Objects.isNull(params.get("beginTime")) &&
|
||||
!Objects.isNull(params.get("endTime"))) {
|
||||
lqw.between(AppLanguage::getCreateTime, params.get("beginTime"), params.get("endTime"));
|
||||
}
|
||||
return lqw;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增app语言
|
||||
*
|
||||
* @param appLanguage app语言
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertAppLanguage(AppLanguage appLanguage)
|
||||
{
|
||||
return appLanguageMapper.insert(appLanguage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改app语言
|
||||
*
|
||||
* @param appLanguage app语言
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateAppLanguage(AppLanguage appLanguage)
|
||||
{
|
||||
return appLanguageMapper.updateById(appLanguage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除app语言
|
||||
*
|
||||
* @param ids 需要删除的app语言主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAppLanguageByIds(Long[] ids)
|
||||
{
|
||||
return appLanguageMapper.deleteBatchIds(Arrays.asList(ids));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
package com.fastbee.system.service.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fastbee.common.enums.Language;
|
||||
import com.fastbee.common.utils.SecurityUtils;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.common.utils.StringUtils;
|
||||
import com.fastbee.system.convert.AppPreferencesConvert;
|
||||
import com.fastbee.system.domain.AppPreferences;
|
||||
import com.fastbee.system.domain.vo.AppPreferencesVO;
|
||||
import com.fastbee.system.mapper.AppPreferencesMapper;
|
||||
import com.fastbee.system.service.IAppPreferencesService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**
|
||||
* APP用户偏好设置Service业务层处理
|
||||
*/
|
||||
@Service
|
||||
public class AppPreferencesServiceImpl extends ServiceImpl<AppPreferencesMapper,AppPreferences> implements IAppPreferencesService
|
||||
{
|
||||
|
||||
/**
|
||||
* 查询APP用户偏好设置分页列表
|
||||
*
|
||||
* @param appPreferences APP用户偏好设置
|
||||
* @return APP用户偏好设置
|
||||
*/
|
||||
@Override
|
||||
public Page<AppPreferencesVO> pageAppPreferencesVO(AppPreferences appPreferences) {
|
||||
LambdaQueryWrapper<AppPreferences> lqw = buildQueryWrapper(appPreferences);
|
||||
Page<AppPreferences> appPreferencesPage = baseMapper.selectPage(new Page<>(appPreferences.getPageNum(), appPreferences.getPageSize()), lqw);
|
||||
return AppPreferencesConvert.INSTANCE.convertAppPreferencesVOPage(appPreferencesPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询APP用户偏好设置
|
||||
*
|
||||
* @param userId APP用户偏好设置主键
|
||||
* @return APP用户偏好设置
|
||||
*/
|
||||
@Override
|
||||
public AppPreferences selectAppPreferencesByUserId(Long userId)
|
||||
{
|
||||
LambdaQueryWrapper<AppPreferences> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AppPreferences::getUserId, userId);
|
||||
AppPreferences appPreferences = baseMapper.selectOne(queryWrapper);
|
||||
if (appPreferences == null){
|
||||
appPreferences = new AppPreferences();
|
||||
}
|
||||
// 设置默认语言
|
||||
if (StringUtils.isEmpty(appPreferences.getLanguage())) {
|
||||
appPreferences.setLanguage(Language.DEFAULT.getValue());
|
||||
}
|
||||
return appPreferences;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询APP用户偏好设置列表
|
||||
*
|
||||
* @param appPreferences APP用户偏好设置
|
||||
* @return APP用户偏好设置
|
||||
*/
|
||||
@Override
|
||||
public List<AppPreferencesVO> listAppPreferencesVO(AppPreferences appPreferences) {
|
||||
LambdaQueryWrapper<AppPreferences> lqw = buildQueryWrapper(appPreferences);
|
||||
List<AppPreferences> appPreferencesList = baseMapper.selectList(lqw);
|
||||
return AppPreferencesConvert.INSTANCE.convertAppPreferencesVOList(appPreferencesList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增APP用户偏好设置
|
||||
*
|
||||
* @param appPreferences APP用户偏好设置
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertAppPreferences(AppPreferences appPreferences)
|
||||
{
|
||||
appPreferences.setCreateTime(DateUtils.getNowDate());
|
||||
return baseMapper.insert(appPreferences);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改APP用户偏好设置
|
||||
*
|
||||
* @param appPreferences APP用户偏好设置
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateAppPreferences(AppPreferences appPreferences)
|
||||
{
|
||||
appPreferences.setUpdateTime(DateUtils.getNowDate());
|
||||
return baseMapper.updateById(appPreferences);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除APP用户偏好设置
|
||||
*
|
||||
* @param userIds 需要删除的APP用户偏好设置主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAppPreferencesByUserIds(Long[] userIds)
|
||||
{
|
||||
LambdaUpdateWrapper<AppPreferences> query = new LambdaUpdateWrapper<>();
|
||||
query.in(AppPreferences::getUserId, Arrays.asList(userIds));
|
||||
return baseMapper.delete(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除APP用户偏好设置信息
|
||||
*
|
||||
* @param userId APP用户偏好设置主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAppPreferencesByUserId(Long userId)
|
||||
{
|
||||
LambdaUpdateWrapper<AppPreferences> query = new LambdaUpdateWrapper<>();
|
||||
query.eq(AppPreferences::getUserId, userId);
|
||||
return baseMapper.delete(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或者更新用户偏好设置
|
||||
* @param appPreferences
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int addOrUpdate(AppPreferences appPreferences)
|
||||
{
|
||||
if (Objects.isNull(appPreferences.getId())){
|
||||
appPreferences.setUserId(SecurityUtils.getUserId());
|
||||
}
|
||||
AppPreferences preferences = this.selectAppPreferencesByUserId(SecurityUtils.getUserId());
|
||||
if (!Objects.isNull(preferences)){
|
||||
return baseMapper.updateById(appPreferences);
|
||||
} else {
|
||||
return baseMapper.insert(appPreferences);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户偏好语言
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getLanguage(Long userId) {
|
||||
AppPreferences appPreferences = selectAppPreferencesByUserId(userId);
|
||||
return appPreferences.getLanguage();
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<AppPreferences> buildQueryWrapper(AppPreferences query) {
|
||||
Map<String, Object> params = query.getParams();
|
||||
LambdaQueryWrapper<AppPreferences> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(query.getUserId() != null, AppPreferences::getUserId, query.getUserId());
|
||||
lqw.eq(StringUtils.isNotBlank(query.getLanguage()), AppPreferences::getLanguage, query.getLanguage());
|
||||
lqw.eq(StringUtils.isNotBlank(query.getTimeZone()), AppPreferences::getTimeZone, query.getTimeZone());
|
||||
|
||||
if (!Objects.isNull(params.get("beginTime")) &&
|
||||
!Objects.isNull(params.get("endTime"))) {
|
||||
lqw.between(AppPreferences::getCreateTime, params.get("beginTime"), params.get("endTime"));
|
||||
}
|
||||
return lqw;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.fastbee.system.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fastbee.common.utils.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.fastbee.common.core.domain.entity.SysDictData;
|
||||
@@ -28,6 +30,7 @@ public class SysDictDataServiceImpl implements ISysDictDataService
|
||||
@Override
|
||||
public List<SysDictData> selectDictDataList(SysDictData dictData)
|
||||
{
|
||||
dictData.setLanguage(SecurityUtils.getLanguage());
|
||||
return dictDataMapper.selectDictDataList(dictData);
|
||||
}
|
||||
|
||||
@@ -53,7 +56,7 @@ public class SysDictDataServiceImpl implements ISysDictDataService
|
||||
@Override
|
||||
public SysDictData selectDictDataById(Long dictCode)
|
||||
{
|
||||
return dictDataMapper.selectDictDataById(dictCode);
|
||||
return dictDataMapper.selectDictDataById(dictCode, SecurityUtils.getLanguage());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,13 +12,16 @@ import com.fastbee.system.service.ISysDictTypeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.fastbee.common.utils.SecurityUtils;
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.fastbee.common.constant.Constants.EN_US;
|
||||
import static com.fastbee.common.constant.Constants.ZH_CN;
|
||||
|
||||
/**
|
||||
* 字典 业务层处理
|
||||
*
|
||||
@@ -51,6 +54,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
@Override
|
||||
public List<SysDictType> selectDictTypeList(SysDictType dictType)
|
||||
{
|
||||
dictType.setLanguage(SecurityUtils.getLanguage());
|
||||
return dictTypeMapper.selectDictTypeList(dictType);
|
||||
}
|
||||
|
||||
@@ -62,7 +66,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
@Override
|
||||
public List<SysDictType> selectDictTypeAll()
|
||||
{
|
||||
return dictTypeMapper.selectDictTypeAll();
|
||||
return dictTypeMapper.selectDictTypeAll(SecurityUtils.getLanguage());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,12 +81,14 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
List<SysDictData> dictDatas = DictUtils.getDictCache(dictType);
|
||||
if (StringUtils.isNotEmpty(dictDatas))
|
||||
{
|
||||
convertDictLabel(dictDatas, SecurityUtils.getLanguage());
|
||||
return dictDatas;
|
||||
}
|
||||
dictDatas = dictDataMapper.selectDictDataByType(dictType);
|
||||
if (StringUtils.isNotEmpty(dictDatas))
|
||||
{
|
||||
DictUtils.setDictCache(dictType, dictDatas);
|
||||
convertDictLabel(dictDatas, SecurityUtils.getLanguage());
|
||||
return dictDatas;
|
||||
}
|
||||
return null;
|
||||
@@ -97,7 +103,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
@Override
|
||||
public SysDictType selectDictTypeById(Long dictId)
|
||||
{
|
||||
return dictTypeMapper.selectDictTypeById(dictId);
|
||||
return dictTypeMapper.selectDictTypeById(dictId, SecurityUtils.getLanguage());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,7 +115,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
@Override
|
||||
public SysDictType selectDictTypeByType(String dictType)
|
||||
{
|
||||
return dictTypeMapper.selectDictTypeByType(dictType);
|
||||
return dictTypeMapper.selectDictTypeByType(dictType, SecurityUtils.getLanguage());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,7 +146,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
{
|
||||
SysDictData dictData = new SysDictData();
|
||||
dictData.setStatus("0");
|
||||
Map<String, List<SysDictData>> dictDataMap = dictDataMapper.selectDictDataList(dictData).stream().collect(Collectors.groupingBy(SysDictData::getDictType));
|
||||
Map<String, List<SysDictData>> dictDataMap = dictDataMapper.selectDictDataListAll(dictData).stream().collect(Collectors.groupingBy(SysDictData::getDictType));
|
||||
for (Map.Entry<String, List<SysDictData>> entry : dictDataMap.entrySet())
|
||||
{
|
||||
DictUtils.setDictCache(entry.getKey(), entry.getValue().stream().sorted(Comparator.comparing(SysDictData::getDictSort)).collect(Collectors.toList()));
|
||||
@@ -193,7 +199,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
@Transactional
|
||||
public int updateDictType(SysDictType dict)
|
||||
{
|
||||
SysDictType oldDict = dictTypeMapper.selectDictTypeById(dict.getDictId());
|
||||
SysDictType oldDict = dictTypeMapper.selectDictTypeById(dict.getDictId(), SecurityUtils.getLanguage());
|
||||
dictDataMapper.updateDictDataType(oldDict.getDictType(), dict.getDictType());
|
||||
int row = dictTypeMapper.updateDictType(dict);
|
||||
if (row > 0)
|
||||
@@ -214,11 +220,32 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
public boolean checkDictTypeUnique(SysDictType dict)
|
||||
{
|
||||
Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId();
|
||||
SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType());
|
||||
if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue())
|
||||
List<SysDictType> dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType(), SecurityUtils.getLanguage());
|
||||
if (!dictType.isEmpty() && dictType.get(0).getDictId().longValue() != dictId.longValue())
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多语言转换
|
||||
* @param list
|
||||
* @param language
|
||||
* @return
|
||||
*/
|
||||
public static void convertDictLabel(List<SysDictData> list, String language) {
|
||||
switch (language) {
|
||||
case EN_US:
|
||||
for (SysDictData data : list) {
|
||||
data.setDictLabel(data.getDictLabel_en_US());
|
||||
}
|
||||
break;
|
||||
case ZH_CN:
|
||||
for (SysDictData data : list) {
|
||||
data.setDictLabel(data.getDictLabel_zh_CN());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
@Override
|
||||
public List<SysMenu> selectMenuList(SysMenu menu, Long userId)
|
||||
{
|
||||
menu.setLanguage(SecurityUtils.getLanguage());
|
||||
List<SysMenu> menuList = null;
|
||||
// 管理员显示所有菜单信息
|
||||
if (SysUser.isAdmin(userId))
|
||||
@@ -128,16 +129,16 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @return 菜单列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenu> selectMenuTreeByUserId(Long userId)
|
||||
public List<SysMenu> selectMenuTreeByUserId(Long userId, String language)
|
||||
{
|
||||
List<SysMenu> menus = null;
|
||||
if (SecurityUtils.isAdmin(userId))
|
||||
{
|
||||
menus = menuMapper.selectMenuTreeAll();
|
||||
menus = menuMapper.selectMenuTreeAll(language);
|
||||
}
|
||||
else
|
||||
{
|
||||
menus = menuMapper.selectMenuTreeByUserId(userId);
|
||||
menus = menuMapper.selectMenuTreeByUserId(userId, language);
|
||||
}
|
||||
return getChildPerms(menus, 0);
|
||||
}
|
||||
@@ -263,7 +264,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
@Override
|
||||
public SysMenu selectMenuById(Long menuId)
|
||||
{
|
||||
return menuMapper.selectMenuById(menuId);
|
||||
return menuMapper.selectMenuById(menuId, SecurityUtils.getLanguage());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.fastbee.system.service.impl;
|
||||
|
||||
import com.fastbee.common.enums.TranslateType;
|
||||
import com.fastbee.system.domain.SysTranslate;
|
||||
import com.fastbee.system.mapper.SysTranslateMapper;
|
||||
import com.fastbee.system.service.ISysTranslateService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static com.fastbee.common.constant.Constants.*;
|
||||
|
||||
/**
|
||||
* 翻译Service业务层处理
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2024-05-29
|
||||
*/
|
||||
@Service
|
||||
public class SysTranslateServiceImpl implements ISysTranslateService
|
||||
{
|
||||
@Resource
|
||||
private SysTranslateMapper sysTranslateMapper;
|
||||
|
||||
/**
|
||||
* 导入翻译列表
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public void importSysTranslate(List<SysTranslate> list, String type, Long productId) {
|
||||
TranslateType translateType = matchTranslateType(type);
|
||||
if (translateType == null) {
|
||||
return;
|
||||
}
|
||||
for (SysTranslate sysTranslate : list) {
|
||||
sysTranslate.setTableName(translateType.getTranslateTable());
|
||||
sysTranslate.setProductId(productId);
|
||||
sysTranslateMapper.insertSysTranslate(sysTranslate);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询翻译列表
|
||||
* @param sysTranslate 翻译类
|
||||
* @return 翻译列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysTranslate> selectSysTranslateList(SysTranslate sysTranslate, String type)
|
||||
{
|
||||
TranslateType translateType = matchTranslateType(type);
|
||||
if (translateType == null) {
|
||||
return null;
|
||||
}
|
||||
sysTranslate.setTableName(translateType.getTranslateTable());
|
||||
return sysTranslateMapper.selectSysTranslateList(sysTranslate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询原表数据列表
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<SysTranslate> selectSourceList(String type, Long productId) {
|
||||
TranslateType translateType = matchTranslateType(type);
|
||||
if (translateType == null) {
|
||||
return null;
|
||||
}
|
||||
return sysTranslateMapper.selectSourceList(translateType.getSourceTable(), translateType.getIdColumn(), translateType.getNameColumn(), productId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据type匹配对应的翻译类型
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public TranslateType matchTranslateType(String type) {
|
||||
switch (type) {
|
||||
case MENU:
|
||||
return TranslateType.MENU_TYPE;
|
||||
case DICT_DATA:
|
||||
return TranslateType.DICT_DATA_TYPE;
|
||||
case DICT_TYPE:
|
||||
return TranslateType.DICT_TYPE_TYPE;
|
||||
case THINGS_MODEL:
|
||||
return TranslateType.THINGS_MODEL_TYPE;
|
||||
case THINGS_MODEL_TEMPLATE:
|
||||
return TranslateType.THINGS_MODEL_TEMPLATE_TYPE;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fastbee.system.mapper.AppLanguageMapper">
|
||||
|
||||
<resultMap type="com.fastbee.system.domain.AppLanguage" id="AppLanguageResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="language" column="language" />
|
||||
<result property="country" column="country" />
|
||||
<result property="timeZone" column="time_zone" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="langName" column="lang_name" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAppLanguageVo">
|
||||
select id, language, country, time_zone, create_by, create_time, lang_name from app_language
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fastbee.system.mapper.AppPreferencesMapper">
|
||||
|
||||
<resultMap type="com.fastbee.system.domain.AppPreferences" id="AppPreferencesResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="language" column="language" />
|
||||
<result property="timeZone" column="time_zone" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAppPreferencesVo">
|
||||
select id, user_id, language, time_zone, create_by, create_time, update_by, update_time, remark from app_preferences
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
@@ -52,8 +52,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</select>
|
||||
|
||||
<select id="selectDictDataById" parameterType="Long" resultMap="SysDictDataResult">
|
||||
<include refid="selectDictDataVo"/>
|
||||
where dict_code = #{dictCode}
|
||||
select d.dict_code, d.dict_sort,
|
||||
case
|
||||
when #{language} = 'zh-CN' then d.dict_label
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else d.dict_label
|
||||
end as dict_label,
|
||||
d.dict_value, d.dict_type, d.css_class, d.list_class, d.is_default, d.status, d.create_by, d.create_time, d.remark
|
||||
from sys_dict_data d
|
||||
left join sys_dict_data_translate t on d.dict_code = t.id
|
||||
where d.dict_code = #{dictCode}
|
||||
</select>
|
||||
|
||||
<select id="selectDictDataListAll" parameterType="com.fastbee.common.core.domain.entity.SysDictData" resultMap="SysDictDataResult">
|
||||
select d.dict_code, d.dict_sort, d.dict_label, t.zh_cn as dict_label_zh_cn, t.en_us as dict_label_en_us,
|
||||
d.dict_value, d.dict_type, d.css_class, d.list_class, d.is_default, d.status, d.create_by, d.create_time, d.remark
|
||||
from sys_dict_data d
|
||||
left join sys_dict_data_translate t on d.dict_code = t.id
|
||||
<where>
|
||||
<if test="dictType != null and dictType != ''">
|
||||
AND d.dict_type = #{dictType}
|
||||
</if>
|
||||
<if test="dictLabel != null and dictLabel != ''">
|
||||
AND d.dict_label like concat('%', #{dictLabel}, '%')
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND d.status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
order by d.dict_sort asc
|
||||
</select>
|
||||
|
||||
<select id="countDictDataByType" resultType="Integer">
|
||||
|
||||
@@ -21,7 +21,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</sql>
|
||||
|
||||
<select id="selectDictTypeList" parameterType="SysDictType" resultMap="SysDictTypeResult">
|
||||
<include refid="selectDictTypeVo"/>
|
||||
select d.dict_id,
|
||||
case
|
||||
when #{language} = 'zh-CN' then d.dict_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else d.dict_name
|
||||
end as dict_name,
|
||||
d.dict_type, d.status, d.create_by, d.create_time, d.remark
|
||||
from sys_dict_type d
|
||||
left join sys_dict_type_translate t on d.dict_id = t.id
|
||||
<where>
|
||||
<if test="dictName != null and dictName != ''">
|
||||
AND dict_name like concat('%', #{dictName}, '%')
|
||||
@@ -42,22 +50,54 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</select>
|
||||
|
||||
<select id="selectDictTypeAll" resultMap="SysDictTypeResult">
|
||||
<include refid="selectDictTypeVo"/>
|
||||
select d.dict_id,
|
||||
case
|
||||
when #{language} = 'zh-CN' then d.dict_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else d.dict_name
|
||||
end as dict_name,
|
||||
d.dict_type, d.status, d.create_by, d.create_time, d.remark
|
||||
from sys_dict_type d
|
||||
left join sys_dict_type_translate t on d.dict_id = t.id
|
||||
</select>
|
||||
|
||||
<select id="selectDictTypeById" parameterType="Long" resultMap="SysDictTypeResult">
|
||||
<include refid="selectDictTypeVo"/>
|
||||
where dict_id = #{dictId}
|
||||
select d.dict_id,
|
||||
case
|
||||
when #{language} = 'zh-CN' then d.dict_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else d.dict_name
|
||||
end as dict_name,
|
||||
d.dict_type, d.status, d.create_by, d.create_time, d.remark
|
||||
from sys_dict_type d
|
||||
left join sys_dict_type_translate t on d.dict_id = t.id
|
||||
where d.dict_id = #{dictId}
|
||||
</select>
|
||||
|
||||
<select id="selectDictTypeByType" parameterType="String" resultMap="SysDictTypeResult">
|
||||
<include refid="selectDictTypeVo"/>
|
||||
where dict_type = #{dictType}
|
||||
select d.dict_id,
|
||||
case
|
||||
when #{language} = 'zh-CN' then d.dict_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else d.dict_name
|
||||
end as dict_name,
|
||||
d.dict_type, d.status, d.create_by, d.create_time, d.remark
|
||||
from sys_dict_type d
|
||||
left join sys_dict_type_translate t on d.dict_id = t.id
|
||||
where d.dict_type = #{dictType}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="checkDictTypeUnique" parameterType="String" resultMap="SysDictTypeResult">
|
||||
<include refid="selectDictTypeVo"/>
|
||||
where dict_type = #{dictType} limit 1
|
||||
select d.dict_id,
|
||||
case
|
||||
when #{language} = 'zh-CN' then d.dict_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else d.dict_name
|
||||
end as dict_name,
|
||||
d.dict_type, d.status, d.create_by, d.create_time, d.remark
|
||||
from sys_dict_type d
|
||||
left join sys_dict_type_translate t on d.dict_id = t.id
|
||||
where d.dict_type = #{dictType}
|
||||
</select>
|
||||
|
||||
<delete id="deleteDictTypeById" parameterType="Long">
|
||||
|
||||
@@ -33,7 +33,15 @@
|
||||
</sql>
|
||||
|
||||
<select id="selectMenuList" parameterType="SysMenu" resultMap="SysMenuResult">
|
||||
<include refid="selectMenuVo"/>
|
||||
select distinct m.menu_id,
|
||||
case
|
||||
when #{language} = 'zh-CN' then m.menu_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else m.menu_name
|
||||
end as menu_name,
|
||||
m.parent_id, m.order_num, m.path, m.component, m.query, m.is_frame, m.is_cache, m.menu_type, m.visible, m.status, ifnull(m.perms,'') as perms, m.icon, m.create_time
|
||||
from sys_menu m
|
||||
left join sys_menu_translate t on m.menu_id = t.id
|
||||
<where>
|
||||
<if test="menuName != null and menuName != ''">
|
||||
AND menu_name like concat('%', #{menuName}, '%')
|
||||
@@ -49,17 +57,33 @@
|
||||
</select>
|
||||
|
||||
<select id="selectMenuTreeAll" resultMap="SysMenuResult">
|
||||
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||
from sys_menu m where m.menu_type in ('M', 'C') and m.status = 0
|
||||
select distinct m.menu_id, m.parent_id,
|
||||
case
|
||||
when #{language} = 'zh-CN' then m.menu_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else m.menu_name
|
||||
end as menu_name,
|
||||
m.menu_name as zn_ch,t.en_us,
|
||||
m.path, m.component, m.query, m.visible, m.status, COALESCE(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||
from sys_menu m
|
||||
left join sys_menu_translate t on m.menu_id = t.id
|
||||
where m.menu_type in ('M', 'C') and m.status = 0
|
||||
order by m.parent_id, m.order_num
|
||||
</select>
|
||||
|
||||
<select id="selectMenuListByUserId" parameterType="SysMenu" resultMap="SysMenuResult">
|
||||
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||
select distinct m.menu_id, m.parent_id,
|
||||
case
|
||||
when #{language} = 'zh-CN' then m.menu_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else m.menu_name
|
||||
end as menu_name,
|
||||
m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||
left join sys_user_role ur on rm.role_id = ur.role_id
|
||||
left join sys_role ro on ur.role_id = ro.role_id
|
||||
left join sys_menu_translate t on m.menu_id = t.id
|
||||
where ur.user_id = #{params.userId}
|
||||
<if test="menuName != null and menuName != ''">
|
||||
AND m.menu_name like concat('%', #{menuName}, '%')
|
||||
@@ -74,12 +98,20 @@
|
||||
</select>
|
||||
|
||||
<select id="selectMenuTreeByUserId" parameterType="Long" resultMap="SysMenuResult">
|
||||
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||
select distinct m.menu_id, m.parent_id,
|
||||
case
|
||||
when #{language} = 'zh-CN' then m.menu_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else m.menu_name
|
||||
end as menu_name,
|
||||
m.menu_name as zn_ch,t.en_us,
|
||||
m.path, m.component, m.query, m.visible, m.status, COALESCE(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||
left join sys_user_role ur on rm.role_id = ur.role_id
|
||||
left join sys_role ro on ur.role_id = ro.role_id
|
||||
left join sys_user u on ur.user_id = u.user_id
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||
left join sys_user_role ur on rm.role_id = ur.role_id
|
||||
left join sys_role ro on ur.role_id = ro.role_id
|
||||
left join sys_user u on ur.user_id = u.user_id
|
||||
left join sys_menu_translate t on m.menu_id = t.id
|
||||
where u.user_id = #{userId} and m.menu_type in ('M', 'C') and m.status = 0 AND ro.status = 0
|
||||
order by m.parent_id, m.order_num
|
||||
</select>
|
||||
@@ -119,8 +151,17 @@
|
||||
</select>
|
||||
|
||||
<select id="selectMenuById" parameterType="Long" resultMap="SysMenuResult">
|
||||
<include refid="selectMenuVo"/>
|
||||
where menu_id = #{menuId}
|
||||
select distinct m.menu_id,
|
||||
case
|
||||
when #{language} = 'zh-CN' then m.menu_name
|
||||
when #{language} = 'en-US' then t.en_us
|
||||
else m.menu_name
|
||||
end as menu_name,
|
||||
m.menu_name as zn_ch,t.en_us,
|
||||
m.parent_id, m.order_num, m.path, m.component, m.query, m.is_frame, m.is_cache, m.menu_type, m.visible, m.status, COALESCE(m.perms, '') as perms, m.icon, m.create_time
|
||||
from sys_menu m
|
||||
left join sys_menu_translate t on m.menu_id = t.id
|
||||
where m.menu_id = #{menuId}
|
||||
</select>
|
||||
|
||||
<select id="hasChildByMenuId" resultType="Integer">
|
||||
@@ -128,7 +169,8 @@
|
||||
</select>
|
||||
|
||||
<select id="checkMenuNameUnique" parameterType="SysMenu" resultMap="SysMenuResult">
|
||||
<include refid="selectMenuVo"/>
|
||||
select distinct menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time
|
||||
from sys_menu
|
||||
where menu_name=#{menuName} and parent_id = #{parentId} limit 1
|
||||
</select>
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fastbee.system.mapper.SysTranslateMapper">
|
||||
|
||||
<resultMap type="com.fastbee.system.domain.SysTranslate" id="SysTranslateResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="zh_CN" column="zh_cn" />
|
||||
<result property="en_US" column="en_us" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insertSysTranslate" parameterType="com.fastbee.system.domain.SysTranslate">
|
||||
insert into ${tableName}
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="productId != null">product_id,</if>
|
||||
<if test="zh_CN != null">zh_cn,</if>
|
||||
<if test="en_US != null">en_us</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="productId != null">#{productId},</if>
|
||||
<if test="zh_CN != null">#{zh_CN},</if>
|
||||
<if test="en_US != null">#{en_US}</if>
|
||||
</trim>
|
||||
on duplicate key update
|
||||
<if test="productId != null">product_id = #{productId},</if>
|
||||
<if test="zh_CN != null">zh_cn = #{zh_CN},</if>
|
||||
<if test="en_US != null">en_us = #{en_US}</if>
|
||||
</insert>
|
||||
|
||||
<select id="selectSysTranslateList" parameterType="com.fastbee.system.domain.SysTranslate" resultMap="SysTranslateResult">
|
||||
select id, zh_cn, en_us from ${tableName}
|
||||
<where>
|
||||
<if test="zh_CN != null and zh_CN != ''"> and zh_cn = #{zh_CN}</if>
|
||||
<if test="en_US != null and en_US != ''"> and en_us = #{en_US}</if>
|
||||
<if test="productId != null and productId != ''"> and product_id = #{productId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSourceList" resultType="com.fastbee.system.domain.SysTranslate" resultMap="SysTranslateResult">
|
||||
select ${idColumn} as id, ${nameColumn} as zh_cn from ${tableName}
|
||||
<where>
|
||||
<if test="productId != null">product_id = #{productId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -23,6 +23,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="language" column="language"/>
|
||||
<result property="timeZone" column="time_zone"/>
|
||||
<association property="dept" javaType="SysDept" resultMap="deptResult" />
|
||||
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
|
||||
</resultMap>
|
||||
@@ -47,14 +49,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectUserVo">
|
||||
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
|
||||
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
|
||||
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
left join sys_user_role ur on u.user_id = ur.user_id
|
||||
left join sys_role r on r.role_id = ur.role_id
|
||||
</sql>
|
||||
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
|
||||
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
|
||||
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,
|
||||
ap.language,ap.time_zone
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
left join sys_user_role ur on u.user_id = ur.user_id
|
||||
left join sys_role r on r.role_id = ur.role_id
|
||||
left join app_preferences ap on u.user_id = ap.user_id
|
||||
</sql>
|
||||
|
||||
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
|
||||
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
|
||||
|
||||
Reference in New Issue
Block a user