Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -88,6 +88,14 @@ public class ElementController {
|
||||
return success(BeanUtils.toBean(pageResult, ElementRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/pageByEnable")
|
||||
@Operation(summary = "获得启用的金属元素分页")
|
||||
@PreAuthorize("@ss.hasPermission('base:element:query')")
|
||||
public CommonResult<PageResult<ElementRespVO>> getElementPageByEnable(@Valid ElementPageReqVO pageReqVO) {
|
||||
PageResult<ElementDO> pageResult = elementService.getElementPageByEnable(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ElementRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出金属元素 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('base:element:export')")
|
||||
|
||||
@@ -23,6 +23,7 @@ public interface ElementMapper extends BaseMapperX<ElementDO> {
|
||||
.likeIfPresent(ElementDO::getAbbreviation, reqVO.getAbbreviation())
|
||||
.likeIfPresent(ElementDO::getName, reqVO.getName())
|
||||
.eqIfPresent(ElementDO::getDecimalValue, reqVO.getDecimalValue())
|
||||
.eqIfPresent(ElementDO::getIsEnable, reqVO.getIsEnable())
|
||||
.likeIfPresent(ElementDO::getCoding, reqVO.getCoding())
|
||||
.eqIfPresent(ElementDO::getGradeUnit, reqVO.getGradeUnit())
|
||||
.betweenIfPresent(ElementDO::getCreateTime, reqVO.getCreateTime())
|
||||
@@ -36,4 +37,9 @@ public interface ElementMapper extends BaseMapperX<ElementDO> {
|
||||
.eq(ElementDO::getIsEnable, 1)
|
||||
.orderByDesc(ElementDO::getSort));
|
||||
}
|
||||
|
||||
default ElementDO getElementName(String code){
|
||||
return selectOne(new LambdaQueryWrapperX<ElementDO>()
|
||||
.eq(ElementDO::getAbbreviation, code));
|
||||
};
|
||||
}
|
||||
@@ -65,4 +65,6 @@ public interface ElementService {
|
||||
void enableElementList(List<ElementRespVO> saveReqVOS);
|
||||
|
||||
List<ElementDO> getElementNoPage();
|
||||
|
||||
PageResult<ElementDO> getElementPageByEnable(ElementPageReqVO pageReqVO);
|
||||
}
|
||||
@@ -35,6 +35,8 @@ public class ElementServiceImpl implements ElementService {
|
||||
public ElementRespVO createElement(ElementSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
ElementDO element = BeanUtils.toBean(createReqVO, ElementDO.class);
|
||||
// 校验存在
|
||||
validateElementCodeExists(createReqVO.getAbbreviation());
|
||||
//金属编码自动生成,格式 JSYS-00001,依次新增
|
||||
String maxCode = elementMapper.selectMaxCode();
|
||||
if (maxCode == null) {
|
||||
@@ -55,6 +57,8 @@ public class ElementServiceImpl implements ElementService {
|
||||
public void updateElement(ElementSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateElementExists(updateReqVO.getId());
|
||||
// 校验存在
|
||||
validateElementCodeExists(updateReqVO.getAbbreviation());
|
||||
// 更新
|
||||
ElementDO updateObj = BeanUtils.toBean(updateReqVO, ElementDO.class);
|
||||
elementMapper.updateById(updateObj);
|
||||
@@ -69,12 +73,12 @@ public class ElementServiceImpl implements ElementService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteElementListByIds(List<Long> ids) {
|
||||
public void deleteElementListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateElementExists(ids);
|
||||
// 删除
|
||||
elementMapper.deleteByIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateElementExists(List<Long> ids) {
|
||||
List<ElementDO> list = elementMapper.selectByIds(ids);
|
||||
@@ -89,6 +93,13 @@ public class ElementServiceImpl implements ElementService {
|
||||
}
|
||||
}
|
||||
|
||||
private void validateElementCodeExists(String code) {
|
||||
ElementDO elementDO = elementMapper.getElementName(code);
|
||||
if (elementDO == null) {
|
||||
throw exception(ELEMENT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElementDO getElement(Long id) {
|
||||
return elementMapper.selectById(id);
|
||||
@@ -102,7 +113,7 @@ public class ElementServiceImpl implements ElementService {
|
||||
@Override
|
||||
public void enableElementList(List<ElementRespVO> saveReqVOS) {
|
||||
List<ElementDO> updateObj = BeanUtils.toBean(saveReqVOS, ElementDO.class);
|
||||
List<BatchResult> count = elementMapper.updateById(updateObj);
|
||||
List<BatchResult> count = elementMapper.updateById(updateObj);
|
||||
if (CollUtil.isEmpty(count)) {
|
||||
throw exception(ELEMENT_NOT_EXISTS);
|
||||
}
|
||||
@@ -113,4 +124,12 @@ public class ElementServiceImpl implements ElementService {
|
||||
return elementMapper.getElementNoPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ElementDO> getElementPageByEnable(ElementPageReqVO pageReqVO) {
|
||||
if (pageReqVO!=null&&pageReqVO.getIsEnable()==null){
|
||||
pageReqVO.setIsEnable("1");
|
||||
}
|
||||
return elementMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user