mirror of https://gitee.com/stylefeng/roses
【i18n】更新多语言删除语种
parent
0449999282
commit
f2e386ae01
|
@ -40,7 +40,7 @@ public class TranslationRequest extends BaseRequest {
|
||||||
/**
|
/**
|
||||||
* 语种字典
|
* 语种字典
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "tranLanguageCode不能为空", groups = {add.class, edit.class, changeUserLanguage.class})
|
@NotBlank(message = "tranLanguageCode不能为空", groups = {add.class, edit.class, changeUserLanguage.class, deleteTranLanguage.class})
|
||||||
private String tranLanguageCode;
|
private String tranLanguageCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,10 +49,22 @@ public class TranslationRequest extends BaseRequest {
|
||||||
@NotBlank(message = "tranValue不能为空", groups = {add.class, edit.class})
|
@NotBlank(message = "tranValue不能为空", groups = {add.class, edit.class})
|
||||||
private String tranValue;
|
private String tranValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典id,用在删除语种
|
||||||
|
*/
|
||||||
|
@NotNull(message = "字典id", groups = {deleteTranLanguage.class})
|
||||||
|
private Long dictId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 改变当前用户多语言
|
* 改变当前用户多语言
|
||||||
*/
|
*/
|
||||||
public @interface changeUserLanguage {
|
public @interface changeUserLanguage {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除语种
|
||||||
|
*/
|
||||||
|
public @interface deleteTranLanguage {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,18 @@ public class TranslationController {
|
||||||
return new SuccessResponseData();
|
return new SuccessResponseData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除某个语种
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2021/1/24 19:20
|
||||||
|
*/
|
||||||
|
@PostResource(name = "删除某个语种", path = "/i18n/deleteTranLanguage")
|
||||||
|
public ResponseData deleteTranLanguage(@RequestBody @Validated(TranslationRequest.deleteTranLanguage.class) TranslationRequest translationRequest) {
|
||||||
|
this.translationService.deleteTranLanguage(translationRequest);
|
||||||
|
return new SuccessResponseData();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查看多语言详情
|
* 查看多语言详情
|
||||||
*
|
*
|
||||||
|
|
|
@ -70,4 +70,13 @@ public interface TranslationService extends IService<Translation>, TranslationPe
|
||||||
*/
|
*/
|
||||||
PageResult<Translation> findPage(TranslationRequest translationRequest);
|
PageResult<Translation> findPage(TranslationRequest translationRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除语种
|
||||||
|
*
|
||||||
|
* @param translationRequest 参数对象
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2021/1/30 10:00
|
||||||
|
*/
|
||||||
|
void deleteTranLanguage(TranslationRequest translationRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||||
|
import cn.stylefeng.roses.kernel.dict.api.DictApi;
|
||||||
import cn.stylefeng.roses.kernel.i18n.api.context.TranslationContext;
|
import cn.stylefeng.roses.kernel.i18n.api.context.TranslationContext;
|
||||||
import cn.stylefeng.roses.kernel.i18n.api.exception.TranslationException;
|
import cn.stylefeng.roses.kernel.i18n.api.exception.TranslationException;
|
||||||
import cn.stylefeng.roses.kernel.i18n.api.exception.enums.TranslationExceptionEnum;
|
import cn.stylefeng.roses.kernel.i18n.api.exception.enums.TranslationExceptionEnum;
|
||||||
|
@ -15,10 +16,12 @@ import cn.stylefeng.roses.kernel.i18n.modular.factory.TranslationDictFactory;
|
||||||
import cn.stylefeng.roses.kernel.i18n.modular.mapper.TranslationMapper;
|
import cn.stylefeng.roses.kernel.i18n.modular.mapper.TranslationMapper;
|
||||||
import cn.stylefeng.roses.kernel.i18n.modular.service.TranslationService;
|
import cn.stylefeng.roses.kernel.i18n.modular.service.TranslationService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
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 org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -31,6 +34,9 @@ import java.util.List;
|
||||||
@Service
|
@Service
|
||||||
public class TranslationServiceImpl extends ServiceImpl<TranslationMapper, Translation> implements TranslationService {
|
public class TranslationServiceImpl extends ServiceImpl<TranslationMapper, Translation> implements TranslationService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DictApi dictApi;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(TranslationRequest translationRequest) {
|
public void add(TranslationRequest translationRequest) {
|
||||||
Translation translation = new Translation();
|
Translation translation = new Translation();
|
||||||
|
@ -79,6 +85,18 @@ public class TranslationServiceImpl extends ServiceImpl<TranslationMapper, Trans
|
||||||
return PageResultFactory.createPageResult(page);
|
return PageResultFactory.createPageResult(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteTranLanguage(TranslationRequest translationRequest) {
|
||||||
|
|
||||||
|
// 删除对应的字典信息
|
||||||
|
dictApi.deleteByDictId(translationRequest.getDictId());
|
||||||
|
|
||||||
|
// 删除该语言下的所有翻译项
|
||||||
|
LambdaUpdateWrapper<Translation> wrapper = new LambdaUpdateWrapper<>();
|
||||||
|
wrapper.eq(Translation::getTranLanguageCode, translationRequest.getTranLanguageCode());
|
||||||
|
this.remove(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TranslationDict> getAllTranslationDict() {
|
public List<TranslationDict> getAllTranslationDict() {
|
||||||
List<Translation> list = this.list();
|
List<Translation> list = this.list();
|
||||||
|
|
|
@ -41,4 +41,13 @@ public interface DictApi {
|
||||||
*/
|
*/
|
||||||
List<SimpleDict> getDictDetailsByDictTypeCode(String dictTypeCode);
|
List<SimpleDict> getDictDetailsByDictTypeCode(String dictTypeCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除字典,通过dictId
|
||||||
|
*
|
||||||
|
* @param dictId 字典id
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2021/1/30 10:03
|
||||||
|
*/
|
||||||
|
void deleteByDictId(Long dictId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,6 @@ public interface DictService extends IService<SysDict>, DictApi {
|
||||||
*/
|
*/
|
||||||
List<ZTreeNode> dictZTree(DictRequest dictRequest);
|
List<ZTreeNode> dictZTree(DictRequest dictRequest);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询
|
* 分页查询
|
||||||
*
|
*
|
||||||
|
|
|
@ -353,6 +353,11 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, SysDict> implements
|
||||||
return simpleDictList;
|
return simpleDictList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteByDictId(Long dictId) {
|
||||||
|
this.removeById(dictId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量修改pids的请求
|
* 批量修改pids的请求
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue