This commit is contained in:
PQZ 2024-09-12 18:38:03 +08:00
parent 3516465c9d
commit a5eef57edb
9 changed files with 177 additions and 204 deletions

View File

@ -1,16 +1,14 @@
package cn.iocoder.yudao.module.project.controller.admin; 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.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.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.entity.RepairProject;
import cn.iocoder.yudao.module.project.service.RepairProjectService; import cn.iocoder.yudao.module.project.service.RepairProjectService;
import cn.iocoder.yudao.module.project.vo.RepairProjectPageReqVO; import cn.iocoder.yudao.module.project.vo.RepairProjectPageReqVO;
import cn.iocoder.yudao.module.project.vo.RepairProjectRespVO; import cn.iocoder.yudao.module.project.vo.RepairProjectRespVO;
import cn.iocoder.yudao.module.project.vo.RepairProjectSaveReqVO; import cn.iocoder.yudao.module.project.vo.RepairProjectSaveReqVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@ -19,12 +17,8 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; 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; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 维修项目") @Tag(name = "管理后台 - 维修项目")
@ -36,21 +30,46 @@ public class RepairProjectController {
@Resource @Resource
private RepairProjectService repairProjectService; private RepairProjectService repairProjectService;
/**
* 创建维修项目
*
* @param createReqVO RepairProjectSaveReqVO实体
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.Boolean>
* @author PQZ
* @date 14:56 2024/9/12
**/
@PostMapping("/create") @PostMapping("/create")
@Operation(summary = "创建维修项目") @Operation(summary = "创建维修项目")
@PreAuthorize("@ss.hasPermission('repair:project:create')") @PreAuthorize("@ss.hasPermission('repair:project:create')")
public CommonResult<String> createRepairProject(@Valid @RequestBody RepairProjectSaveReqVO createReqVO) { public CommonResult<Boolean> createRepairProject(@Valid @RequestBody RepairProjectSaveReqVO createReqVO) {
return success(repairProjectService.createRepairProject(createReqVO)); repairProjectService.saveRepairProject(createReqVO);
return success(true);
} }
/**
* 更新维修项目
*
* @param updateReqVO RepairProjectSaveReqVO实体
* @return cn.iocoder.yudao.framewor.k.common.pojo.CommonResult<java.lang.Boolean>
* @author PQZ
* @date 14:56 2024/9/12
**/
@PutMapping("/update") @PutMapping("/update")
@Operation(summary = "更新维修项目") @Operation(summary = "更新维修项目")
@PreAuthorize("@ss.hasPermission('repair:project:update')") @PreAuthorize("@ss.hasPermission('repair:project:update')")
public CommonResult<Boolean> updateRepairProject(@Valid @RequestBody RepairProjectSaveReqVO updateReqVO) { public CommonResult<Boolean> updateRepairProject(@Valid @RequestBody RepairProjectSaveReqVO updateReqVO) {
repairProjectService.updateRepairProject(updateReqVO); repairProjectService.saveRepairProject(updateReqVO);
return success(true); return success(true);
} }
/**
* 删除维修项目
*
* @param id 维修项目id
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.Boolean>
* @author PQZ
* @date 14:59 2024/9/12
**/
@DeleteMapping("/delete") @DeleteMapping("/delete")
@Operation(summary = "删除维修项目") @Operation(summary = "删除维修项目")
@Parameter(name = "id", description = "编号", required = true) @Parameter(name = "id", description = "编号", required = true)
@ -60,6 +79,14 @@ public class RepairProjectController {
return success(true); return success(true);
} }
/**
* 根据维修项目id获取维修项目
*
* @param id 维修项目id
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<cn.iocoder.yudao.module.project.vo.RepairProjectRespVO>
* @author PQZ
* @date 14:59 2024/9/12
**/
@GetMapping("/get") @GetMapping("/get")
@Operation(summary = "获得维修项目") @Operation(summary = "获得维修项目")
@Parameter(name = "id", description = "编号", required = true, example = "1024") @Parameter(name = "id", description = "编号", required = true, example = "1024")
@ -69,25 +96,25 @@ public class RepairProjectController {
return success(BeanUtils.toBean(repairProject, RepairProjectRespVO.class)); return success(BeanUtils.toBean(repairProject, RepairProjectRespVO.class));
} }
/**
* 分页获取维修项目分页
*
* @param pageReqVO RepairProjectPageReqVO
* @param pageNo 分页参数
* @param pageSize 分页参数
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<cn.iocoder.yudao.framework.common.pojo.PageResult < cn.iocoder.yudao.module.project.vo.RepairProjectRespVO>>
* @author PQZ
* @date 15:04 2024/9/12
**/
@GetMapping("/page") @GetMapping("/page")
@Operation(summary = "获得维修项目分页") @Operation(summary = "获得维修项目分页")
@PreAuthorize("@ss.hasPermission('repair:project:query')") @PreAuthorize("@ss.hasPermission('repair:project:query')")
public CommonResult<PageResult<RepairProjectRespVO>> getRepairProjectPage(@Valid RepairProjectPageReqVO pageReqVO) { public CommonResult<IPage<?>> getRepairProjectPage(RepairProjectPageReqVO pageReqVO,
PageResult<RepairProject> pageResult = repairProjectService.getRepairProjectPage(pageReqVO); @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
return success(BeanUtils.toBean(pageResult, RepairProjectRespVO.class)); @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
} Page<RepairProjectRespVO> page = new Page<>(pageNo, pageSize);
return success(repairProjectService.queryListPage(pageReqVO,page));
@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

@ -58,6 +58,8 @@ public class RepairProject extends TenantBaseDO {
* 工时 * 工时
*/ */
private String manHour; private String manHour;
/**供应商*/
private String corpId;
/** /**
* 是否自助0否1是 * 是否自助0否1是
*/ */

View File

@ -1,8 +1,13 @@
package cn.iocoder.yudao.module.project.mapper; package cn.iocoder.yudao.module.project.mapper;
import cn.iocoder.yudao.module.project.entity.RepairProject; import cn.iocoder.yudao.module.project.entity.RepairProject;
import cn.iocoder.yudao.module.project.vo.RepairProjectPageReqVO;
import cn.iocoder.yudao.module.project.vo.RepairProjectRespVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/** /**
* 维修项目 Mapper * 维修项目 Mapper
@ -12,4 +17,15 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface RepairProjectMapper extends BaseMapper<RepairProject> { public interface RepairProjectMapper extends BaseMapper<RepairProject> {
/**
* 分页查询维修项目信息
*
* @param pageReqVO RepairProjectPageReqVO实体
* @param page 分页参数故
* @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.project.vo.RepairProjectRespVO>
* @author PQZ
* @date 15:13 2024/9/12
**/
IPage<RepairProjectRespVO> selectListPage(@Param("entity") RepairProjectPageReqVO pageReqVO, Page<RepairProjectRespVO> page);
} }

View File

@ -1,14 +1,14 @@
package cn.iocoder.yudao.module.project.service; 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.entity.RepairProject;
import cn.iocoder.yudao.module.project.vo.RepairProjectPageReqVO; 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 cn.iocoder.yudao.module.project.vo.RepairProjectSaveReqVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import javax.validation.Valid;
/** /**
* 维修项目 Service 接口 * 维修项目 Service 接口
* *
@ -17,41 +17,43 @@ import javax.validation.Valid;
public interface RepairProjectService extends IService<RepairProject> { public interface RepairProjectService extends IService<RepairProject> {
/** /**
* 创建维修项目 * 保存维修项目
* *
* @param createReqVO 创建信息 * @param saveReqVO RepairProjectSaveReqVO实体
* @return 编号 * @author PQZ
*/ * @date 14:51 2024/9/12
String createRepairProject(@Valid RepairProjectSaveReqVO createReqVO); **/
void saveRepairProject(RepairProjectSaveReqVO saveReqVO);
/**
* 更新维修项目
*
* @param updateReqVO 更新信息
*/
void updateRepairProject(@Valid RepairProjectSaveReqVO updateReqVO);
/** /**
* 删除维修项目 * 删除维修项目
* *
* @param id 编号 * @param id 维修项目id
*/ * @author PQZ
* @date 15:08 2024/9/12
**/
void deleteRepairProject(String id); void deleteRepairProject(String id);
/** /**
* 获得维修项目 * 根据id获取维修项目
* *
* @param id 编号 * @param id 维修项目id
* @return 维修项目 * @return cn.iocoder.yudao.module.project.entity.RepairProject
*/ * @author PQZ
* @date 15:08 2024/9/12
**/
RepairProject getRepairProject(String id); RepairProject getRepairProject(String id);
/** /**
* 获得维修项目分页 * 分页查询维修项目
* *
* @param pageReqVO 分页查询 * @param pageReqVO RepairProjectPageReqVO实体
* @return 维修项目分页 * @param page 分页参数
*/ * @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.project.vo.RepairProjectRespVO>
PageResult<RepairProject> getRepairProjectPage(RepairProjectPageReqVO pageReqVO); * @author PQZ
* @date 15:08 2024/9/12
**/
IPage<RepairProjectRespVO> queryListPage(RepairProjectPageReqVO pageReqVO, Page<RepairProjectRespVO> page);
} }

View File

@ -1,12 +1,14 @@
package cn.iocoder.yudao.module.project.service.impl; 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.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.project.entity.RepairProject; import cn.iocoder.yudao.module.project.entity.RepairProject;
import cn.iocoder.yudao.module.project.mapper.RepairProjectMapper; import cn.iocoder.yudao.module.project.mapper.RepairProjectMapper;
import cn.iocoder.yudao.module.project.service.RepairProjectService; import cn.iocoder.yudao.module.project.service.RepairProjectService;
import cn.iocoder.yudao.module.project.vo.RepairProjectPageReqVO; 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 cn.iocoder.yudao.module.project.vo.RepairProjectSaveReqVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -25,46 +27,59 @@ public class RepairProjectServiceImpl extends ServiceImpl<RepairProjectMapper, R
@Resource @Resource
private RepairProjectMapper repairProjectMapper; private RepairProjectMapper repairProjectMapper;
/**
* 保存维修项目
*
* @param saveReqVO RepairProjectSaveReqVO实体
* @author PQZ
* @date 14:51 2024/9/12
**/
@Override @Override
public String createRepairProject(RepairProjectSaveReqVO createReqVO) { public void saveRepairProject(RepairProjectSaveReqVO saveReqVO) {
// 插入 RepairProject repairProject = BeanUtils.toBean(saveReqVO, RepairProject.class);
RepairProject repairProject = BeanUtils.toBean(createReqVO, RepairProject.class); saveOrUpdate(repairProject);
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);
} }
/**
* 删除维修项目
*
* @param id 维修项目id
* @author PQZ
* @date 15:08 2024/9/12
**/
@Override @Override
public void deleteRepairProject(String id) { public void deleteRepairProject(String id) {
// 校验存在
validateRepairProjectExists(id);
// 删除 // 删除
repairProjectMapper.deleteById(id); repairProjectMapper.deleteById(id);
} }
private void validateRepairProjectExists(String id) { /**
if (repairProjectMapper.selectById(id) == null) { * 根据id获取维修项目
// throw exception(); *
} * @param id 维修项目id
} * @return cn.iocoder.yudao.module.project.entity.RepairProject
* @author PQZ
* @date 15:08 2024/9/12
**/
@Override @Override
public RepairProject getRepairProject(String id) { public RepairProject getRepairProject(String id) {
return repairProjectMapper.selectById(id); return repairProjectMapper.selectById(id);
} }
/**
* 分页查询维修项目
*
* @param pageReqVO RepairProjectPageReqVO实体
* @param page 分页参数
* @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.project.vo.RepairProjectRespVO>
* @author PQZ
* @date 15:08 2024/9/12
**/
@Override @Override
public PageResult<RepairProject> getRepairProjectPage(RepairProjectPageReqVO pageReqVO) { public IPage<RepairProjectRespVO> queryListPage(RepairProjectPageReqVO pageReqVO, Page<RepairProjectRespVO> page) {
return null; return repairProjectMapper.selectListPage(pageReqVO,page);
} }
} }

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.project.vo; package cn.iocoder.yudao.module.project.vo;
import cn.iocoder.yudao.module.project.entity.RepairProject;
import lombok.*; import lombok.*;
import java.util.*; import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
@ -14,43 +15,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class RepairProjectPageReqVO extends PageParam { public class RepairProjectPageReqVO extends RepairProject {
@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

@ -1,68 +1,23 @@
package cn.iocoder.yudao.module.project.vo; package cn.iocoder.yudao.module.project.vo;
import cn.iocoder.yudao.module.project.entity.RepairProject;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
import java.util.*; import java.util.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*; import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 维修项目 Response VO") @Schema(description = "管理后台 - 维修项目 Response VO")
@Data @Data
@ExcelIgnoreUnannotated @ExcelIgnoreUnannotated
public class RepairProjectRespVO { public class RepairProjectRespVO extends RepairProject {
@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;
/**所属分类*/
private String typeName;
} }

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.project.vo; package cn.iocoder.yudao.module.project.vo;
import cn.iocoder.yudao.module.project.entity.RepairProject;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
import java.util.*; import java.util.*;
@ -8,42 +9,8 @@ import java.math.BigDecimal;
@Schema(description = "管理后台 - 维修项目新增/修改 Request VO") @Schema(description = "管理后台 - 维修项目新增/修改 Request VO")
@Data @Data
public class RepairProjectSaveReqVO { public class RepairProjectSaveReqVO extends RepairProject {
@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

@ -9,4 +9,28 @@
文档可见https://www.iocoder.cn/MyBatis/x-plugins/ 文档可见https://www.iocoder.cn/MyBatis/x-plugins/
--> -->
<select id="selectListPage" resultType="cn.iocoder.yudao.module.project.vo.RepairProjectRespVO">
SELECT
drp.*,
dbt.NAME AS typeName
FROM
dl_repair_project drp
LEFT JOIN dl_base_type dbt ON drp.type = dbt.id
AND dbt.deleted = 0
<where>
drp.deleted = 0
<if test="entity.name != null and entity.name != ''">
and drp.name like concat('%', #{entity.name}, '%')
</if>
<if test="entity.type != null and entity.type != ''">
and drp.type = #{entity.type}
</if>
<if test="entity.corpId != null and entity.corpId != ''">
and drp.corp_id like concat('%', #{entity.corpId}, '%')
</if>
</where>
ORDER BY
drp.create_time DESC
</select>
</mapper> </mapper>