diff --git a/imt-server/imt-module-system/imt-module-system-api/src/main/java/com/inspur/module/system/enums/ErrorCodeConstants.java b/imt-server/imt-module-system/imt-module-system-api/src/main/java/com/inspur/module/system/enums/ErrorCodeConstants.java index c607664..f84997e 100644 --- a/imt-server/imt-module-system/imt-module-system-api/src/main/java/com/inspur/module/system/enums/ErrorCodeConstants.java +++ b/imt-server/imt-module-system/imt-module-system-api/src/main/java/com/inspur/module/system/enums/ErrorCodeConstants.java @@ -162,4 +162,7 @@ public interface ErrorCodeConstants { // ========== 站内信发送 1-002-028-000 ========== ErrorCode NOTIFY_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_028_000, "模板参数({})缺失"); + // ========== 基础信息模块 ========== + ErrorCode MODEL_INFO_NOT_EXISTS = new ErrorCode(1_002_028_000, "未获取到机床型号信息"); + } diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/baseData/ModelInfoController.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/baseData/ModelInfoController.java new file mode 100644 index 0000000..9fecf8a --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/baseData/ModelInfoController.java @@ -0,0 +1,98 @@ +package com.inspur.module.system.controller.baseData; + +import com.inspur.module.system.controller.baseData.vo.ModelInfoPageReqVO; +import com.inspur.module.system.controller.baseData.vo.ModelInfoRespVO; +import com.inspur.module.system.controller.baseData.vo.ModelInfoSaveReqVO; +import com.inspur.module.system.dal.dataobject.baseData.ModelInfoDO; +import com.inspur.module.system.service.baseData.ModelInfoService; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import com.inspur.framework.common.pojo.PageParam; +import com.inspur.framework.common.pojo.PageResult; +import com.inspur.framework.common.pojo.CommonResult; +import com.inspur.framework.common.util.object.BeanUtils; + +import static com.inspur.framework.common.pojo.CommonResult.success; + +import com.inspur.framework.excel.core.util.ExcelUtils; + +import com.inspur.framework.apilog.core.annotation.ApiAccessLog; + +import static com.inspur.framework.apilog.core.enums.OperateTypeEnum.*; + + +@Tag(name = "管理后台 - 机床型号信息") +@RestController +@RequestMapping("/admin-api/baseData/modelInfo") +@Validated +public class ModelInfoController { + + @Resource + private ModelInfoService modelInfoService; + + @PostMapping("/create") + @Operation(summary = "创建机床型号信息") + @PreAuthorize("@ss.hasPermission('imt:model-info:create')") + public CommonResult createModelInfo(@Valid @RequestBody ModelInfoSaveReqVO createReqVO) { + return success(modelInfoService.createModelInfo(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新机床型号信息") + @PreAuthorize("@ss.hasPermission('imt:model-info:update')") + public CommonResult updateModelInfo(@Valid @RequestBody ModelInfoSaveReqVO updateReqVO) { + modelInfoService.updateModelInfo(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除机床型号信息") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('imt:model-info:delete')") + public CommonResult deleteModelInfo(@RequestParam("id") String id) { + modelInfoService.deleteModelInfo(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得机床型号信息") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('imt:model-info:query')") + public CommonResult getModelInfo(@RequestParam("id") String id) { + ModelInfoDO modelInfo = modelInfoService.getModelInfo(id); + return success(BeanUtils.toBean(modelInfo, ModelInfoRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得机床型号信息分页") + @PreAuthorize("@ss.hasPermission('imt:model-info:query')") + public CommonResult> getModelInfoPage(@Valid ModelInfoPageReqVO pageReqVO) { + PageResult pageResult = modelInfoService.getModelInfoPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, ModelInfoRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出机床型号信息 Excel") + @PreAuthorize("@ss.hasPermission('imt:model-info:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportModelInfoExcel(@Valid ModelInfoPageReqVO pageReqVO, HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = modelInfoService.getModelInfoPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "机床型号信息.xls", "数据", ModelInfoRespVO.class, BeanUtils.toBean(list, ModelInfoRespVO.class)); + } + +} \ No newline at end of file diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/baseData/vo/ModelInfoPageReqVO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/baseData/vo/ModelInfoPageReqVO.java new file mode 100644 index 0000000..7fae735 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/baseData/vo/ModelInfoPageReqVO.java @@ -0,0 +1,19 @@ +package com.inspur.module.system.controller.baseData.vo; + +import lombok.*; +import io.swagger.v3.oas.annotations.media.Schema; +import com.inspur.framework.common.pojo.PageParam; + +@Schema(description = "管理后台 - 机床型号信息分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ModelInfoPageReqVO extends PageParam { + + @Schema(description = "机床型号名称") + private String modelName; + + @Schema(description = "机床类型(0:立式,1:卧式,2:龙门,3:立车,4:其他)") + private Integer machineType; + +} \ No newline at end of file diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/baseData/vo/ModelInfoRespVO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/baseData/vo/ModelInfoRespVO.java new file mode 100644 index 0000000..c01eba9 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/baseData/vo/ModelInfoRespVO.java @@ -0,0 +1,44 @@ +package com.inspur.module.system.controller.baseData.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import com.alibaba.excel.annotation.*; +import com.inspur.framework.excel.core.annotations.DictFormat; +import com.inspur.framework.excel.core.convert.DictConvert; + +@Schema(description = "管理后台 - 机床型号信息 Response VO") +@Data +@ExcelIgnoreUnannotated +public class ModelInfoRespVO { + + @Schema(description = "机床型号id", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("机床型号id") + private String modelId; + + @Schema(description = "机床型号名称", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("机床型号名称") + private String modelName; + + @Schema(description = "机床类型(0:立式,1:卧式,2:龙门,3:立车,4:其他)", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty(value = "机床类型", converter = DictConvert.class) + @DictFormat("machine_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer machineType; + + @Schema(description = "规格参数") + @ExcelProperty("规格参数") + private String modelSpn; + + @Schema(description = "状态(0:开启,1:关闭)") + @ExcelProperty(value = "状态", converter = DictConvert.class) + @DictFormat("common_status") + private Integer status; + + @Schema(description = "备注") + @ExcelProperty("备注") + private String remark; + + @Schema(description = "型号图片路径") + private String modelPicPath; + +} \ No newline at end of file diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/baseData/vo/ModelInfoSaveReqVO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/baseData/vo/ModelInfoSaveReqVO.java new file mode 100644 index 0000000..469bbb3 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/baseData/vo/ModelInfoSaveReqVO.java @@ -0,0 +1,39 @@ +package com.inspur.module.system.controller.baseData.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 机床型号信息新增/修改 Request VO") +@Data +public class ModelInfoSaveReqVO { + + @Schema(description = "机床型号id", requiredMode = Schema.RequiredMode.REQUIRED) + private String modelId; + + @Schema(description = "机床型号名称", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "机床型号名称不能为空") + @Size(message = "机床型号最大不允许超过20个字符", max = 20) + private String modelName; + + @Schema(description = "机床类型(0:立式,1:卧式,2:龙门,3:立车,4:其他)", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "机床类型(0:立式,1:卧式,2:龙门,3:立车,4:其他)不能为空") + private Integer machineType; + + @Schema(description = "规格参数") + @Size(message = "规格参数最大不允许超过255个字符", max = 255) + private String modelSpn; + + @Schema(description = "状态(0:开启,1:关闭)") + private Integer status; + + @Schema(description = "备注") + @Size(message = "备注最大不允许超过500个字符", max = 500) + private String remark; + + @Schema(description = "型号图片路径") + private String modelPicPath; + +} \ No newline at end of file diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/baseData/ModelInfoDO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/baseData/ModelInfoDO.java new file mode 100644 index 0000000..8d4fb88 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/baseData/ModelInfoDO.java @@ -0,0 +1,54 @@ +package com.inspur.module.system.dal.dataobject.baseData; + +import lombok.*; +import java.util.*; +import com.baomidou.mybatisplus.annotation.*; +import com.inspur.framework.mybatis.core.dataobject.BaseDO; + +/** + * 机床型号信息 DO + * + * @author 芋道源码 + */ +@TableName("imt_model_info") +@KeySequence("imt_model_info_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ModelInfoDO extends BaseDO { + + /** + * 机床型号id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String modelId; + /** + * 机床型号名称 + */ + private String modelName; + /** + * 机床类型(0:立式,1:卧式,2:龙门,3:立车,4:其他) + * + */ + private Integer machineType; + /** + * 规格参数 + */ + private String modelSpn; + /** + * 状态(0:开启,1:关闭) + */ + private Integer status; + /** + * 备注 + */ + private String remark; + /** + * 型号图片路径 + */ + private String modelPicPath; + +} \ No newline at end of file diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/mysql/baseData/ModelInfoMapper.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/mysql/baseData/ModelInfoMapper.java new file mode 100644 index 0000000..a1730e9 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/mysql/baseData/ModelInfoMapper.java @@ -0,0 +1,25 @@ +package com.inspur.module.system.dal.mysql.baseData; + +import com.inspur.framework.common.pojo.PageResult; +import com.inspur.framework.mybatis.core.mapper.BaseMapperX; +import com.inspur.framework.mybatis.core.query.LambdaQueryWrapperX; +import com.inspur.module.system.controller.baseData.vo.ModelInfoPageReqVO; +import com.inspur.module.system.dal.dataobject.baseData.ModelInfoDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 机床型号信息 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface ModelInfoMapper extends BaseMapperX { + + default PageResult selectPage(ModelInfoPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(ModelInfoDO::getModelName, reqVO.getModelName()) + .eqIfPresent(ModelInfoDO::getMachineType, reqVO.getMachineType()) + .orderByDesc(ModelInfoDO::getModelId)); + } + +} \ No newline at end of file diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/baseData/ModelInfoService.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/baseData/ModelInfoService.java new file mode 100644 index 0000000..04fca13 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/baseData/ModelInfoService.java @@ -0,0 +1,55 @@ +package com.inspur.module.system.service.baseData; + +import com.inspur.framework.common.pojo.PageResult; +import com.inspur.module.system.controller.baseData.vo.ModelInfoPageReqVO; +import com.inspur.module.system.controller.baseData.vo.ModelInfoSaveReqVO; +import com.inspur.module.system.dal.dataobject.baseData.ModelInfoDO; + +import javax.validation.*; + +/** + * 机床型号信息 Service 接口 + * + * @author 芋道源码 + */ +public interface ModelInfoService { + + /** + * 创建机床型号信息 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + String createModelInfo(@Valid ModelInfoSaveReqVO createReqVO); + + /** + * 更新机床型号信息 + * + * @param updateReqVO 更新信息 + */ + void updateModelInfo(@Valid ModelInfoSaveReqVO updateReqVO); + + /** + * 删除机床型号信息 + * + * @param id 编号 + */ + void deleteModelInfo(String id); + + /** + * 获得机床型号信息 + * + * @param id 编号 + * @return 机床型号信息 + */ + ModelInfoDO getModelInfo(String id); + + /** + * 获得机床型号信息分页 + * + * @param pageReqVO 分页查询 + * @return 机床型号信息分页 + */ + PageResult getModelInfoPage(ModelInfoPageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/baseData/ModelInfoServiceImpl.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/baseData/ModelInfoServiceImpl.java new file mode 100644 index 0000000..a988649 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/baseData/ModelInfoServiceImpl.java @@ -0,0 +1,70 @@ +package com.inspur.module.system.service.baseData; + +import com.inspur.framework.common.pojo.PageResult; +import com.inspur.module.system.controller.baseData.vo.ModelInfoPageReqVO; +import com.inspur.module.system.controller.baseData.vo.ModelInfoSaveReqVO; +import com.inspur.module.system.dal.dataobject.baseData.ModelInfoDO; +import com.inspur.module.system.dal.mysql.baseData.ModelInfoMapper; +import com.inspur.module.system.enums.ErrorCodeConstants; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import com.inspur.framework.common.util.object.BeanUtils; + +import static com.inspur.framework.common.exception.util.ServiceExceptionUtil.exception; + +/** + * 机床型号信息 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class ModelInfoServiceImpl implements ModelInfoService { + + @Resource + private ModelInfoMapper modelInfoMapper; + + @Override + public String createModelInfo(ModelInfoSaveReqVO createReqVO) { + // 插入 + ModelInfoDO modelInfo = BeanUtils.toBean(createReqVO, ModelInfoDO.class); + modelInfoMapper.insert(modelInfo); + // 返回 + return modelInfo.getModelId(); + } + + @Override + public void updateModelInfo(ModelInfoSaveReqVO updateReqVO) { + // 校验存在 + validateModelInfoExists(updateReqVO.getModelId()); + // 更新 + ModelInfoDO updateObj = BeanUtils.toBean(updateReqVO, ModelInfoDO.class); + modelInfoMapper.updateById(updateObj); + } + + @Override + public void deleteModelInfo(String id) { + // 校验存在 + validateModelInfoExists(id); + // 删除 + modelInfoMapper.deleteById(id); + } + + private void validateModelInfoExists(String id) { + if (modelInfoMapper.selectById(id) == null) { + throw exception(ErrorCodeConstants.MODEL_INFO_NOT_EXISTS); + } + } + + @Override + public ModelInfoDO getModelInfo(String id) { + return modelInfoMapper.selectById(id); + } + + @Override + public PageResult getModelInfoPage(ModelInfoPageReqVO pageReqVO) { + return modelInfoMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file diff --git a/imt-ui/src/api/system/baseData/modelinfo.js b/imt-ui/src/api/system/baseData/modelinfo.js new file mode 100644 index 0000000..16f55a4 --- /dev/null +++ b/imt-ui/src/api/system/baseData/modelinfo.js @@ -0,0 +1,53 @@ +import request from '@/utils/request' + +// 创建机床型号信息 +export function createModelInfo(data) { + return request({ + url: '/baseData/modelInfo/create', + method: 'post', + data: data + }) +} + +// 更新机床型号信息 +export function updateModelInfo(data) { + return request({ + url: '/baseData/modelInfo/update', + method: 'put', + data: data + }) +} + +// 删除机床型号信息 +export function deleteModelInfo(id) { + return request({ + url: '/baseData/modelInfo/delete?id=' + id, + method: 'delete' + }) +} + +// 获得机床型号信息 +export function getModelInfo(id) { + return request({ + url: '/baseData/modelInfo/get?id=' + id, + method: 'get' + }) +} + +// 获得机床型号信息分页 +export function getModelInfoPage(params) { + return request({ + url: '/baseData/modelInfo/page', + method: 'get', + params + }) +} +// 导出机床型号信息 Excel +export function exportModelInfoExcel(params) { + return request({ + url: '/baseData/modelInfo/export-excel', + method: 'get', + params, + responseType: 'blob' + }) +} diff --git a/imt-ui/src/utils/dict.js b/imt-ui/src/utils/dict.js index 29b05f7..f236338 100644 --- a/imt-ui/src/utils/dict.js +++ b/imt-ui/src/utils/dict.js @@ -10,6 +10,9 @@ export const DICT_TYPE = { COMMON_STATUS: 'common_status', TERMINAL: 'terminal', + //========== imt 模块 ========== + MACHINE_TYPE: 'machine_type', + // ========== SYSTEM 模块 ========== SYSTEM_USER_SEX: 'system_user_sex', SYSTEM_MENU_TYPE: 'system_menu_type', diff --git a/imt-ui/src/views/system/baseData/modelinfo/ModelInfoForm.vue b/imt-ui/src/views/system/baseData/modelinfo/ModelInfoForm.vue new file mode 100644 index 0000000..0e0653d --- /dev/null +++ b/imt-ui/src/views/system/baseData/modelinfo/ModelInfoForm.vue @@ -0,0 +1,136 @@ + + + diff --git a/imt-ui/src/views/system/baseData/modelinfo/index.vue b/imt-ui/src/views/system/baseData/modelinfo/index.vue new file mode 100644 index 0000000..a65d92f --- /dev/null +++ b/imt-ui/src/views/system/baseData/modelinfo/index.vue @@ -0,0 +1,169 @@ + + +