mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-14 13:42:07 +08:00
新增设计默认机台模板接口
This commit is contained in:
+1
@@ -193,6 +193,7 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode LABEL_NOT_EXISTS = new ErrorCode(1_002_300_001, "标签不存在");
|
ErrorCode LABEL_NOT_EXISTS = new ErrorCode(1_002_300_001, "标签不存在");
|
||||||
ErrorCode DEFAULT_LABEL_NOT_EXISTS = new ErrorCode(1_002_300_002, "该类型标签默认模板不存在");
|
ErrorCode DEFAULT_LABEL_NOT_EXISTS = new ErrorCode(1_002_300_002, "该类型标签默认模板不存在");
|
||||||
ErrorCode MACHINE_USE_LABEL = new ErrorCode(1_002_300_003, "无法删除已有机台使用标签");
|
ErrorCode MACHINE_USE_LABEL = new ErrorCode(1_002_300_003, "无法删除已有机台使用标签");
|
||||||
|
ErrorCode DEFAULT_NOT_DELETED = new ErrorCode(1_002_300_004, "默认标签模板无法删除");
|
||||||
|
|
||||||
// ========== 系统数据源 1_002_301_000 ==========
|
// ========== 系统数据源 1_002_301_000 ==========
|
||||||
ErrorCode DATA_SOURCE_NOT_EXISTS = new ErrorCode(1_002_301_000, "系统数据源不存在");
|
ErrorCode DATA_SOURCE_NOT_EXISTS = new ErrorCode(1_002_301_000, "系统数据源不存在");
|
||||||
|
|||||||
+8
@@ -93,6 +93,14 @@ public class LabelTemplateController {
|
|||||||
return success(labelTemplateService.getDefaultLabelTemplate(type));
|
return success(labelTemplateService.getDefaultLabelTemplate(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/setDefaultTemplate")
|
||||||
|
@Operation(summary = "设置默认标签模板")
|
||||||
|
@PreAuthorize("@ss.hasPermission('system:label-template:query')")
|
||||||
|
public CommonResult<Boolean> setDefaultTemplate(@RequestParam Long id) {
|
||||||
|
return success(labelTemplateService.setDefaultTemplate(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/export-excel")
|
@GetMapping("/export-excel")
|
||||||
@Operation(summary = "导出标签模板 Excel")
|
@Operation(summary = "导出标签模板 Excel")
|
||||||
@PreAuthorize("@ss.hasPermission('system:label-template:export')")
|
@PreAuthorize("@ss.hasPermission('system:label-template:export')")
|
||||||
|
|||||||
+2
@@ -63,4 +63,6 @@ public interface LabelTemplateService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
LabelTemplateRespVO getDefaultLabelTemplate(String type);
|
LabelTemplateRespVO getDefaultLabelTemplate(String type);
|
||||||
|
|
||||||
|
Boolean setDefaultTemplate(Long id);
|
||||||
}
|
}
|
||||||
+30
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
|||||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -54,6 +55,10 @@ public class LabelTemplateServiceImpl implements LabelTemplateService {
|
|||||||
if (labelTemplateDO == null) {
|
if (labelTemplateDO == null) {
|
||||||
throw exception(LABEL_TEMPLATE_NOT_EXISTS);
|
throw exception(LABEL_TEMPLATE_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
Boolean isDefault = labelTemplateDO.getIsDefault();
|
||||||
|
if(isDefault) {
|
||||||
|
throw exception(DEFAULT_NOT_DELETED);
|
||||||
|
}
|
||||||
labelTemplateMapper.deleteById(id);
|
labelTemplateMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,4 +105,29 @@ public class LabelTemplateServiceImpl implements LabelTemplateService {
|
|||||||
throw exception(DEFAULT_LABEL_NOT_EXISTS);
|
throw exception(DEFAULT_LABEL_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Boolean setDefaultTemplate(Long id) {
|
||||||
|
LabelTemplateDO labelTemplateDO = labelTemplateMapper.selectById(id);
|
||||||
|
if(Objects.isNull(labelTemplateDO)) {
|
||||||
|
throw exception(LABEL_TEMPLATE_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
List<LabelTemplateDO> labelTemplateDOS = labelTemplateMapper.selectList(new LambdaQueryWrapperX<LabelTemplateDO>()
|
||||||
|
.eq(LabelTemplateDO::getIsDefault, Boolean.TRUE)
|
||||||
|
.eq(LabelTemplateDO::getType, labelTemplateDO.getType())
|
||||||
|
);
|
||||||
|
if(CollectionUtil.isEmpty(labelTemplateDOS) || labelTemplateDOS.size()>1) {
|
||||||
|
throw exception(DEFAULT_TEMPLATE_COUNT);
|
||||||
|
}
|
||||||
|
LabelTemplateDO templateDO = new LabelTemplateDO();
|
||||||
|
templateDO.setId(labelTemplateDOS.get(0).getId());
|
||||||
|
templateDO.setIsDefault(Boolean.FALSE);
|
||||||
|
labelTemplateMapper.updateById(templateDO);
|
||||||
|
|
||||||
|
labelTemplateDO.setIsDefault(Boolean.TRUE);
|
||||||
|
labelTemplateMapper.updateById(labelTemplateDO);
|
||||||
|
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user