This commit is contained in:
PQZ 2024-09-09 18:28:53 +08:00
parent 49dd8c8515
commit 197440a8bb
11 changed files with 531 additions and 0 deletions

35
dl-module-repair/pom.xml Normal file
View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>yudao</artifactId>
<groupId>cn.iocoder.boot</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dl-module-repair</artifactId>
<dependencies>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>dl-module-base</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>dl-module-company</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-system-biz</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
</project>

View File

@ -0,0 +1,93 @@
package cn.iocoder.yudao.module.project.controller.admin;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.project.entity.RepairProject;
import cn.iocoder.yudao.module.project.service.RepairProjectService;
import cn.iocoder.yudao.module.project.vo.RepairProjectPageReqVO;
import cn.iocoder.yudao.module.project.vo.RepairProjectRespVO;
import cn.iocoder.yudao.module.project.vo.RepairProjectSaveReqVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 维修项目")
@RestController
@RequestMapping("/repair/project")
@Validated
public class RepairProjectController {
@Resource
private RepairProjectService repairProjectService;
@PostMapping("/create")
@Operation(summary = "创建维修项目")
@PreAuthorize("@ss.hasPermission('repair:project:create')")
public CommonResult<String> createRepairProject(@Valid @RequestBody RepairProjectSaveReqVO createReqVO) {
return success(repairProjectService.createRepairProject(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新维修项目")
@PreAuthorize("@ss.hasPermission('repair:project:update')")
public CommonResult<Boolean> updateRepairProject(@Valid @RequestBody RepairProjectSaveReqVO updateReqVO) {
repairProjectService.updateRepairProject(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除维修项目")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('repair:project:delete')")
public CommonResult<Boolean> deleteRepairProject(@RequestParam("id") String id) {
repairProjectService.deleteRepairProject(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得维修项目")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('repair:project:query')")
public CommonResult<RepairProjectRespVO> getRepairProject(@RequestParam("id") String id) {
RepairProject repairProject = repairProjectService.getRepairProject(id);
return success(BeanUtils.toBean(repairProject, RepairProjectRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得维修项目分页")
@PreAuthorize("@ss.hasPermission('repair:project:query')")
public CommonResult<PageResult<RepairProjectRespVO>> getRepairProjectPage(@Valid RepairProjectPageReqVO pageReqVO) {
PageResult<RepairProject> pageResult = repairProjectService.getRepairProjectPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, RepairProjectRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出维修项目 Excel")
@PreAuthorize("@ss.hasPermission('repair:project:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportRepairProjectExcel(@Valid RepairProjectPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<RepairProject> list = repairProjectService.getRepairProjectPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "维修项目.xls", "数据", RepairProjectRespVO.class,
BeanUtils.toBean(list, RepairProjectRespVO.class));
}
}

View File

@ -0,0 +1,75 @@
package cn.iocoder.yudao.module.project.entity;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import java.math.BigDecimal;
/**
* 维修项目 DO
*
* @author pqz
*/
@TableName("dl_repair_project")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class RepairProject extends TenantBaseDO {
/**
* 主键标识
*/
@TableId(type = IdType.ASSIGN_UUID)
private String id;
/**
* 名称
*/
private String name;
/**
* 成本
*/
private Long cost;
/**
* 规格
*/
private String spec;
/**
* 售价
*/
private BigDecimal price;
/**
* 编码
*/
private String code;
/**
* 单位
*/
private String unit;
/**
* 分类
*/
private String type;
/**
* 工时
*/
private String manHour;
/**
* 是否自助0否1是
*/
private String isSelf;
/**
* 是否允许分店公用此产品0否1是
*/
private String isPublic;
/**
* 备注
*/
private String remark;
}

View File

@ -0,0 +1,15 @@
package cn.iocoder.yudao.module.project.mapper;
import cn.iocoder.yudao.module.project.entity.RepairProject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 维修项目 Mapper
*
* @author pqz
*/
@Mapper
public interface RepairProjectMapper extends BaseMapper<RepairProject> {
}

View File

@ -0,0 +1,57 @@
package cn.iocoder.yudao.module.project.service;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.project.entity.RepairProject;
import cn.iocoder.yudao.module.project.vo.RepairProjectPageReqVO;
import cn.iocoder.yudao.module.project.vo.RepairProjectSaveReqVO;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.validation.Valid;
/**
* 维修项目 Service 接口
*
* @author pqz
*/
public interface RepairProjectService extends IService<RepairProject> {
/**
* 创建维修项目
*
* @param createReqVO 创建信息
* @return 编号
*/
String createRepairProject(@Valid RepairProjectSaveReqVO createReqVO);
/**
* 更新维修项目
*
* @param updateReqVO 更新信息
*/
void updateRepairProject(@Valid RepairProjectSaveReqVO updateReqVO);
/**
* 删除维修项目
*
* @param id 编号
*/
void deleteRepairProject(String id);
/**
* 获得维修项目
*
* @param id 编号
* @return 维修项目
*/
RepairProject getRepairProject(String id);
/**
* 获得维修项目分页
*
* @param pageReqVO 分页查询
* @return 维修项目分页
*/
PageResult<RepairProject> getRepairProjectPage(RepairProjectPageReqVO pageReqVO);
}

View File

@ -0,0 +1,70 @@
package cn.iocoder.yudao.module.project.service.impl;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.project.entity.RepairProject;
import cn.iocoder.yudao.module.project.mapper.RepairProjectMapper;
import cn.iocoder.yudao.module.project.service.RepairProjectService;
import cn.iocoder.yudao.module.project.vo.RepairProjectPageReqVO;
import cn.iocoder.yudao.module.project.vo.RepairProjectSaveReqVO;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
/**
* 维修项目 Service 实现类
*
* @author pqz
*/
@Service
@Validated
public class RepairProjectServiceImpl extends ServiceImpl<RepairProjectMapper, RepairProject> implements RepairProjectService {
@Resource
private RepairProjectMapper repairProjectMapper;
@Override
public String createRepairProject(RepairProjectSaveReqVO createReqVO) {
// 插入
RepairProject repairProject = BeanUtils.toBean(createReqVO, RepairProject.class);
repairProjectMapper.insert(repairProject);
// 返回
return repairProject.getId();
}
@Override
public void updateRepairProject(RepairProjectSaveReqVO updateReqVO) {
// 校验存在
validateRepairProjectExists(updateReqVO.getId());
// 更新
RepairProject updateObj = BeanUtils.toBean(updateReqVO, RepairProject.class);
repairProjectMapper.updateById(updateObj);
}
@Override
public void deleteRepairProject(String id) {
// 校验存在
validateRepairProjectExists(id);
// 删除
repairProjectMapper.deleteById(id);
}
private void validateRepairProjectExists(String id) {
if (repairProjectMapper.selectById(id) == null) {
// throw exception();
}
}
@Override
public RepairProject getRepairProject(String id) {
return repairProjectMapper.selectById(id);
}
@Override
public PageResult<RepairProject> getRepairProjectPage(RepairProjectPageReqVO pageReqVO) {
return null;
}
}

View File

@ -0,0 +1,56 @@
package cn.iocoder.yudao.module.project.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.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 RepairProjectPageReqVO extends PageParam {
@Schema(description = "名称", example = "王五")
private String name;
@Schema(description = "成本")
private Long cost;
@Schema(description = "规格")
private String spec;
@Schema(description = "售价", example = "16985")
private BigDecimal price;
@Schema(description = "编码")
private String code;
@Schema(description = "单位")
private String unit;
@Schema(description = "分类", example = "1")
private String type;
@Schema(description = "工时")
private String manHour;
@Schema(description = "是否自助0否1是")
private String isSelf;
@Schema(description = "是否允许分店公用此产品0否1是")
private String isPublic;
@Schema(description = "备注", example = "你说的对")
private String remark;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,68 @@
package cn.iocoder.yudao.module.project.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 维修项目 Response VO")
@Data
@ExcelIgnoreUnannotated
public class RepairProjectRespVO {
@Schema(description = "主键标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "2050")
@ExcelProperty("主键标识")
private String id;
@Schema(description = "名称", example = "王五")
@ExcelProperty("名称")
private String name;
@Schema(description = "成本")
@ExcelProperty("成本")
private Long cost;
@Schema(description = "规格")
@ExcelProperty("规格")
private String spec;
@Schema(description = "售价", example = "16985")
@ExcelProperty("售价")
private BigDecimal price;
@Schema(description = "编码")
@ExcelProperty("编码")
private String code;
@Schema(description = "单位")
@ExcelProperty("单位")
private String unit;
@Schema(description = "分类", example = "1")
@ExcelProperty("分类")
private String type;
@Schema(description = "工时")
@ExcelProperty("工时")
private String manHour;
@Schema(description = "是否自助0否1是")
@ExcelProperty("是否自助0否1是")
private String isSelf;
@Schema(description = "是否允许分店公用此产品0否1是")
@ExcelProperty("是否允许分店公用此产品0否1是")
private String isPublic;
@Schema(description = "备注", example = "你说的对")
@ExcelProperty("备注")
private String remark;
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,49 @@
package cn.iocoder.yudao.module.project.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
import java.math.BigDecimal;
@Schema(description = "管理后台 - 维修项目新增/修改 Request VO")
@Data
public class RepairProjectSaveReqVO {
@Schema(description = "主键标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "2050")
private String id;
@Schema(description = "名称", example = "王五")
private String name;
@Schema(description = "成本")
private Long cost;
@Schema(description = "规格")
private String spec;
@Schema(description = "售价", example = "16985")
private BigDecimal price;
@Schema(description = "编码")
private String code;
@Schema(description = "单位")
private String unit;
@Schema(description = "分类", example = "1")
private String type;
@Schema(description = "工时")
private String manHour;
@Schema(description = "是否自助0否1是")
private String isSelf;
@Schema(description = "是否允许分店公用此产品0否1是")
private String isPublic;
@Schema(description = "备注", example = "你说的对")
private String remark;
}

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.project.mapper.RepairProjectMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

View File

@ -25,6 +25,7 @@
<module>dl-module-company</module> <module>dl-module-company</module>
<module>dl-module-knowledge</module> <module>dl-module-knowledge</module>
<module>dl-module-rescue</module> <module>dl-module-rescue</module>
<module>dl-module-repair</module>
<module>dl-module-jx</module> <module>dl-module-jx</module>
<!-- Server 主项目 --> <!-- Server 主项目 -->
<module>yudao-server</module> <module>yudao-server</module>