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 f84997e..84a1a9e 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 @@ -164,5 +164,6 @@ public interface ErrorCodeConstants { // ========== 基础信息模块 ========== ErrorCode MODEL_INFO_NOT_EXISTS = new ErrorCode(1_002_028_000, "未获取到机床型号信息"); + ErrorCode CUSTOMER_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/CustomerInfoController.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/baseData/CustomerInfoController.java new file mode 100644 index 0000000..363d9da --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/baseData/CustomerInfoController.java @@ -0,0 +1,119 @@ +package com.inspur.module.system.controller.baseData; + +import cn.hutool.core.util.StrUtil; +import com.inspur.framework.common.pojo.PageResult; +import com.inspur.framework.ip.core.utils.AreaUtils; +import com.inspur.module.system.controller.baseData.vo.CustomerInfoPageReqVO; +import com.inspur.module.system.controller.baseData.vo.CustomerInfoRespVO; +import com.inspur.module.system.controller.baseData.vo.CustomerInfoSaveReqVO; +import com.inspur.module.system.dal.dataobject.baseData.CustomerInfoDO; +import com.inspur.module.system.service.baseData.CustomerInfoService; +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.io.IOException; +import java.util.List; +import java.util.Objects; + +import com.inspur.framework.common.pojo.PageParam; +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/customerInfo") +@Validated +public class CustomerInfoController { + + @Resource + private CustomerInfoService customerInfoService; + + @PostMapping("/create") + @Operation(summary = "创建机床客户信息") + @PreAuthorize("@ss.hasPermission('imt:customer-info:create')") + public CommonResult createCustomerInfo(@Valid @RequestBody CustomerInfoSaveReqVO createReqVO) { + return success(customerInfoService.createCustomerInfo(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新机床客户信息") + @PreAuthorize("@ss.hasPermission('imt:customer-info:update')") + public CommonResult updateCustomerInfo(@Valid @RequestBody CustomerInfoSaveReqVO updateReqVO) { + customerInfoService.updateCustomerInfo(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除机床客户信息") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('imt:customer-info:delete')") + public CommonResult deleteCustomerInfo(@RequestParam("id") String id) { + customerInfoService.deleteCustomerInfo(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得机床客户信息") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('imt:customer-info:query')") + public CommonResult getCustomerInfo(@RequestParam("id") String id) { + CustomerInfoDO customerInfo = customerInfoService.getCustomerInfo(id); + CustomerInfoRespVO bean = BeanUtils.toBean(customerInfo, CustomerInfoRespVO.class); + if (Objects.nonNull(bean.getDistrict())){ + Integer[] test = {bean.getProvinceCode(),bean.getCityCode(),bean.getDistrict()}; + bean.setDistrictArray(test); + } + return success(bean); + } + + @GetMapping("/page") + @Operation(summary = "获得机床客户信息分页") + @PreAuthorize("@ss.hasPermission('imt:customer-info:query')") + public CommonResult> getCustomerInfoPage(@Valid CustomerInfoPageReqVO pageReqVO) { + PageResult pageResult = customerInfoService.getCustomerInfoPage(pageReqVO); + PageResult bean = BeanUtils.toBean(pageResult, CustomerInfoRespVO.class); + List list = bean.getList(); + list.forEach(item->{ + if (Objects.nonNull(item.getDistrict())){ + String districtName = + AreaUtils.getArea(item.getProvinceCode()).getName() + "-" + + AreaUtils.getArea(item.getCityCode()).getName() + "-" + + AreaUtils.getArea(item.getDistrict()).getName(); + item.setDistrictName(districtName); + } + }); + bean.setList(list); + return success(bean); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出机床客户信息 Excel") + @PreAuthorize("@ss.hasPermission('imt:customer-info:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportCustomerInfoExcel(@Valid CustomerInfoPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = customerInfoService.getCustomerInfoPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "机床客户信息.xls", "数据", CustomerInfoRespVO.class, + BeanUtils.toBean(list, CustomerInfoRespVO.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/CustomerInfoPageReqVO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/baseData/vo/CustomerInfoPageReqVO.java new file mode 100644 index 0000000..ab15d79 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/baseData/vo/CustomerInfoPageReqVO.java @@ -0,0 +1,24 @@ +package com.inspur.module.system.controller.baseData.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import com.inspur.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static com.inspur.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 机床客户信息分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CustomerInfoPageReqVO extends PageParam { + + @Schema(description = "客户名称", example = "张三") + private String customerName; + + @Schema(description = "所属行业", example = "2") + private Integer industryType; + +} \ 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/CustomerInfoRespVO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/baseData/vo/CustomerInfoRespVO.java new file mode 100644 index 0000000..e7594de --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/baseData/vo/CustomerInfoRespVO.java @@ -0,0 +1,64 @@ +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 CustomerInfoRespVO { + + /** + * 机床客户信息id + */ + private String customerId; + + @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") + @ExcelProperty("客户名称") + private String customerName; + + @Schema(description = "省编号") + private Integer provinceCode; + + @Schema(description = "市编号") + private Integer cityCode; + + @Schema(description = "区县编号") + private Integer district; + + @ExcelProperty("地区") + private String districtName; + + private Integer[] districtArray; + + @Schema(description = "详细地址") + @ExcelProperty("详细地址") + private String address; + + @Schema(description = "所属行业", example = "2") + @ExcelProperty(value = "所属行业", converter = DictConvert.class) + @DictFormat("industry_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer industryType; + + @Schema(description = "联系人姓名") + @ExcelProperty("联系人姓名") + private String contactPerson; + + @Schema(description = "联系人电话") + @ExcelProperty("联系人电话") + private String contactPhone; + + @Schema(description = "状态", example = "1") + @ExcelProperty(value = "状态", converter = DictConvert.class) + @DictFormat("common_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private String status; + + @Schema(description = "备注", example = "你猜") + @ExcelProperty("备注") + private String remark; + +} \ 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/CustomerInfoSaveReqVO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/baseData/vo/CustomerInfoSaveReqVO.java new file mode 100644 index 0000000..217bec7 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/baseData/vo/CustomerInfoSaveReqVO.java @@ -0,0 +1,51 @@ +package com.inspur.module.system.controller.baseData.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 机床客户信息新增/修改 Request VO") +@Data +public class CustomerInfoSaveReqVO { + + @Schema(description = "机床客户信息id", requiredMode = Schema.RequiredMode.REQUIRED, example = "2573") + private String customerId; + + @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") + @NotBlank(message = "客户名称不能为空") + @Size(message = "客户名称最大不允许超过50个字符", max = 50) + private String customerName; + + @Schema(description = "省编号") + private Integer provinceCode; + + @Schema(description = "市编号") + private Integer cityCode; + + @Schema(description = "区县编号") + private Integer district; + + @Schema(description = "详细地址") + @Size(message = "详细地址最大不允许超过200个字符", max = 200) + private String address; + + @Schema(description = "所属行业", example = "2") + @NotNull(message = "所属行业不能为空") + private Integer industryType; + + @Schema(description = "联系人姓名") + @Size(message = "联系人姓名最大不允许超过20个字符", max = 20) + private String contactPerson; + + @Schema(description = "联系人电话") + @Size(message = "联系人电话最大不允许超过20个字符", max = 20) + private String contactPhone; + + @Schema(description = "状态", example = "1") + private String status; + + @Schema(description = "备注", example = "你猜") + @Size(message = "备注最大不允许超过500个字符", max = 500) + private String remark; + +} \ 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/CustomerInfoDO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/baseData/CustomerInfoDO.java new file mode 100644 index 0000000..51db015 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/baseData/CustomerInfoDO.java @@ -0,0 +1,74 @@ +package com.inspur.module.system.dal.dataobject.baseData; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import com.inspur.framework.mybatis.core.dataobject.BaseDO; + +/** + * 机床客户信息 DO + * + * @author xusd + */ +@TableName("imt_customer_info") +@KeySequence("imt_customer_info_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CustomerInfoDO extends BaseDO { + + /** + * 机床客户信息id + */ + @TableId(type = IdType.ASSIGN_UUID) + private String customerId; + /** + * 客户名称 + */ + private String customerName; + /** + * 省编号 + */ + private Integer provinceCode; + /** + * 市编号 + */ + private Integer cityCode; + /** + * 区县编号 + */ + private Integer district; + /** + * 详细地址 + */ + private String address; + /** + * 所属行业 + * + * 枚举 {@link TODO industry_type 对应的类} + */ + private Integer industryType; + /** + * 联系人姓名 + */ + private String contactPerson; + /** + * 联系人电话 + */ + private String contactPhone; + /** + * 状态 + * + */ + private String status; + /** + * 备注 + */ + private String remark; + +} \ 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/CustomerInfoMapper.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/mysql/baseData/CustomerInfoMapper.java new file mode 100644 index 0000000..0749a9a --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/mysql/baseData/CustomerInfoMapper.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.CustomerInfoPageReqVO; +import com.inspur.module.system.dal.dataobject.baseData.CustomerInfoDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 机床客户信息 Mapper + * + * @author xusd + */ +@Mapper +public interface CustomerInfoMapper extends BaseMapperX { + + default PageResult selectPage(CustomerInfoPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(CustomerInfoDO::getCustomerName, reqVO.getCustomerName()) + .eqIfPresent(CustomerInfoDO::getIndustryType, reqVO.getIndustryType()) + .orderByDesc(CustomerInfoDO::getCustomerId)); + } + +} \ 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/CustomerInfoService.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/baseData/CustomerInfoService.java new file mode 100644 index 0000000..3b1a0ae --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/baseData/CustomerInfoService.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.CustomerInfoPageReqVO; +import com.inspur.module.system.controller.baseData.vo.CustomerInfoSaveReqVO; +import com.inspur.module.system.dal.dataobject.baseData.CustomerInfoDO; + +import javax.validation.*; + +/** + * 机床客户信息 Service 接口 + * + * @author xusd + */ +public interface CustomerInfoService { + + /** + * 创建机床客户信息 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + String createCustomerInfo(@Valid CustomerInfoSaveReqVO createReqVO); + + /** + * 更新机床客户信息 + * + * @param updateReqVO 更新信息 + */ + void updateCustomerInfo(@Valid CustomerInfoSaveReqVO updateReqVO); + + /** + * 删除机床客户信息 + * + * @param id 编号 + */ + void deleteCustomerInfo(String id); + + /** + * 获得机床客户信息 + * + * @param id 编号 + * @return 机床客户信息 + */ + CustomerInfoDO getCustomerInfo(String id); + + /** + * 获得机床客户信息分页 + * + * @param pageReqVO 分页查询 + * @return 机床客户信息分页 + */ + PageResult getCustomerInfoPage(CustomerInfoPageReqVO 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/CustomerInfoServiceImpl.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/baseData/CustomerInfoServiceImpl.java new file mode 100644 index 0000000..dec03de --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/baseData/CustomerInfoServiceImpl.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.CustomerInfoPageReqVO; +import com.inspur.module.system.controller.baseData.vo.CustomerInfoSaveReqVO; +import com.inspur.module.system.dal.dataobject.baseData.CustomerInfoDO; +import com.inspur.module.system.dal.mysql.baseData.CustomerInfoMapper; +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; +import static com.inspur.module.system.enums.ErrorCodeConstants.CUSTOMER_INFO_NOT_EXISTS; + +/** + * 机床客户信息 Service 实现类 + * + * @author xusd + */ +@Service +@Validated +public class CustomerInfoServiceImpl implements CustomerInfoService { + + @Resource + private CustomerInfoMapper customerInfoMapper; + + @Override + public String createCustomerInfo(CustomerInfoSaveReqVO createReqVO) { + // 插入 + CustomerInfoDO customerInfo = BeanUtils.toBean(createReqVO, CustomerInfoDO.class); + customerInfoMapper.insert(customerInfo); + // 返回 + return customerInfo.getCustomerId(); + } + + @Override + public void updateCustomerInfo(CustomerInfoSaveReqVO updateReqVO) { + // 校验存在 + validateCustomerInfoExists(updateReqVO.getCustomerId()); + // 更新 + CustomerInfoDO updateObj = BeanUtils.toBean(updateReqVO, CustomerInfoDO.class); + customerInfoMapper.updateById(updateObj); + } + + @Override + public void deleteCustomerInfo(String id) { + // 校验存在 + validateCustomerInfoExists(id); + // 删除 + customerInfoMapper.deleteById(id); + } + + private void validateCustomerInfoExists(String id) { + if (customerInfoMapper.selectById(id) == null) { + throw exception(CUSTOMER_INFO_NOT_EXISTS); + } + } + + @Override + public CustomerInfoDO getCustomerInfo(String id) { + return customerInfoMapper.selectById(id); + } + + @Override + public PageResult getCustomerInfoPage(CustomerInfoPageReqVO pageReqVO) { + return customerInfoMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file diff --git a/imt-ui/src/api/system/baseData/customerInfo.js b/imt-ui/src/api/system/baseData/customerInfo.js new file mode 100644 index 0000000..3e853b1 --- /dev/null +++ b/imt-ui/src/api/system/baseData/customerInfo.js @@ -0,0 +1,53 @@ +import request from '@/utils/request' + +// 创建机床客户信息 +export function createCustomerInfo(data) { + return request({ + url: '/baseData/customerInfo/create', + method: 'post', + data: data + }) +} + +// 更新机床客户信息 +export function updateCustomerInfo(data) { + return request({ + url: '/baseData/customerInfo/update', + method: 'put', + data: data + }) +} + +// 删除机床客户信息 +export function deleteCustomerInfo(id) { + return request({ + url: '/baseData/customerInfo/delete?id=' + id, + method: 'delete' + }) +} + +// 获得机床客户信息 +export function getCustomerInfo(id) { + return request({ + url: '/baseData/customerInfo/get?id=' + id, + method: 'get' + }) +} + +// 获得机床客户信息分页 +export function getCustomerInfoPage(params) { + return request({ + url: '/baseData/customerInfo/page', + method: 'get', + params + }) +} +// 导出机床客户信息 Excel +export function exportCustomerInfoExcel(params) { + return request({ + url: '/baseData/customerInfo/export-excel', + method: 'get', + params, + responseType: 'blob' + }) +} diff --git a/imt-ui/src/utils/dict.js b/imt-ui/src/utils/dict.js index f236338..c1e1429 100644 --- a/imt-ui/src/utils/dict.js +++ b/imt-ui/src/utils/dict.js @@ -12,6 +12,7 @@ export const DICT_TYPE = { //========== imt 模块 ========== MACHINE_TYPE: 'machine_type', + INDUSTRY_TYPE: 'industry_type', // ========== SYSTEM 模块 ========== SYSTEM_USER_SEX: 'system_user_sex', diff --git a/imt-ui/src/views/system/baseData/customerInfo/CustomerInfoForm.vue b/imt-ui/src/views/system/baseData/customerInfo/CustomerInfoForm.vue new file mode 100644 index 0000000..46a3d00 --- /dev/null +++ b/imt-ui/src/views/system/baseData/customerInfo/CustomerInfoForm.vue @@ -0,0 +1,181 @@ + + + diff --git a/imt-ui/src/views/system/baseData/customerInfo/index.vue b/imt-ui/src/views/system/baseData/customerInfo/index.vue new file mode 100644 index 0000000..4b74cc3 --- /dev/null +++ b/imt-ui/src/views/system/baseData/customerInfo/index.vue @@ -0,0 +1,163 @@ + + +