This commit is contained in:
PQZ 2024-08-04 12:12:20 +08:00
parent e5e48c7f2c
commit d28e02f8c8
9 changed files with 468 additions and 0 deletions

View File

@ -0,0 +1,94 @@
package cn.iocoder.yudao.module.label.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.label.entity.Label;
import cn.iocoder.yudao.module.label.service.LabelService;
import cn.iocoder.yudao.module.label.vo.LabelPageReqVO;
import cn.iocoder.yudao.module.label.vo.LabelRespVO;
import cn.iocoder.yudao.module.label.vo.LabelSaveReqVO;
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("/base/label")
@Validated
public class LabelController {
@Resource
private LabelService labelService;
@PostMapping("/create")
@Operation(summary = "创建标签库")
@PreAuthorize("@ss.hasPermission('base:label:create')")
public CommonResult<String> createLabel(@Valid @RequestBody LabelSaveReqVO createReqVO) {
return success(labelService.createLabel(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新标签库")
@PreAuthorize("@ss.hasPermission('base:label:update')")
public CommonResult<Boolean> updateLabel(@Valid @RequestBody LabelSaveReqVO updateReqVO) {
labelService.updateLabel(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除标签库")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('base:label:delete')")
public CommonResult<Boolean> deleteLabel(@RequestParam("id") String id) {
labelService.deleteLabel(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得标签库")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('base:label:query')")
public CommonResult<LabelRespVO> getLabel(@RequestParam("id") String id) {
Label label = labelService.getLabel(id);
return success(BeanUtils.toBean(label, LabelRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得标签库分页")
@PreAuthorize("@ss.hasPermission('base:label:query')")
public CommonResult<PageResult<LabelRespVO>> getLabelPage(@Valid LabelPageReqVO pageReqVO) {
PageResult<Label> pageResult = labelService.getLabelPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, LabelRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出标签库 Excel")
@PreAuthorize("@ss.hasPermission('base:label:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportLabelExcel(@Valid LabelPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<Label> list = labelService.getLabelPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "标签库.xls", "数据", LabelRespVO.class,
BeanUtils.toBean(list, LabelRespVO.class));
}
}

View File

@ -0,0 +1,39 @@
package cn.iocoder.yudao.module.label.entity;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import lombok.*;
import com.baomidou.mybatisplus.annotation.*;
/**
* 标签库 DO
*
* @author 后台管理员
*/
@TableName("base_label")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Label extends TenantBaseDO {
/**
* 主键标识
*/
@TableId(type = IdType.INPUT)
private String id;
/**
* 标签名称
*/
private String labelName;
/**
* 标签描述
*/
private String labelDesc;
/**
* 系统标识
*/
private String systemCode;
}

View File

@ -0,0 +1,16 @@
package cn.iocoder.yudao.module.label.mapper;
import cn.iocoder.yudao.module.label.entity.Label;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 客户管理扩展Mapper
*
* @author pqz
*/
@Mapper
public interface LabelMapper extends BaseMapper<Label> {
}

View File

@ -0,0 +1,55 @@
package cn.iocoder.yudao.module.label.service;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.label.entity.Label;
import cn.iocoder.yudao.module.label.vo.LabelPageReqVO;
import cn.iocoder.yudao.module.label.vo.LabelSaveReqVO;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.validation.Valid;
/**
* 标签库 Service 接口
*
* @author 后台管理员
*/
public interface LabelService extends IService<Label> {
/**
* 创建标签库
*
* @param createReqVO 创建信息
* @return 编号
*/
String createLabel(@Valid LabelSaveReqVO createReqVO);
/**
* 更新标签库
*
* @param updateReqVO 更新信息
*/
void updateLabel(@Valid LabelSaveReqVO updateReqVO);
/**
* 删除标签库
*
* @param id 编号
*/
void deleteLabel(String id);
/**
* 获得标签库
*
* @param id 编号
* @return 标签库
*/
Label getLabel(String id);
/**
* 获得标签库分页
*
* @param pageReqVO 分页查询
* @return 标签库分页
*/
PageResult<Label> getLabelPage(LabelPageReqVO pageReqVO);
}

View File

@ -0,0 +1,70 @@
package cn.iocoder.yudao.module.label.service.impl;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.label.entity.Label;
import cn.iocoder.yudao.module.label.mapper.LabelMapper;
import cn.iocoder.yudao.module.label.service.LabelService;
import cn.iocoder.yudao.module.label.vo.LabelPageReqVO;
import cn.iocoder.yudao.module.label.vo.LabelSaveReqVO;
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 后台管理员
*/
@Service
@Validated
public class LabelServiceImpl extends ServiceImpl<LabelMapper, Label> implements LabelService {
@Resource
private LabelMapper labelMapper;
@Override
public String createLabel(LabelSaveReqVO createReqVO) {
// 插入
Label label = BeanUtils.toBean(createReqVO, Label.class);
labelMapper.insert(label);
// 返回
return label.getId();
}
@Override
public void updateLabel(LabelSaveReqVO updateReqVO) {
// 校验存在
validateLabelExists(updateReqVO.getId());
// 更新
Label updateObj = BeanUtils.toBean(updateReqVO, Label.class);
labelMapper.updateById(updateObj);
}
@Override
public void deleteLabel(String id) {
// 校验存在
validateLabelExists(id);
// 删除
labelMapper.deleteById(id);
}
private void validateLabelExists(String id) {
if (labelMapper.selectById(id) == null) {
// throw exception(LABEL_NOT_EXISTS);
}
}
@Override
public Label getLabel(String id) {
return labelMapper.selectById(id);
}
@Override
public PageResult<Label> getLabelPage(LabelPageReqVO pageReqVO) {
return null;
}
}

View File

@ -0,0 +1,31 @@
package cn.iocoder.yudao.module.label.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
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 LabelPageReqVO extends PageParam {
@Schema(description = "标签名称", example = "芋艿")
private String lableName;
@Schema(description = "标签描述")
private String lableDesc;
@Schema(description = "系统标识")
private String systemCode;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,35 @@
package cn.iocoder.yudao.module.label.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 标签库 Response VO")
@Data
@ExcelIgnoreUnannotated
public class LabelRespVO {
@Schema(description = "主键标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "1802")
@ExcelProperty("主键标识")
private String id;
@Schema(description = "标签名称", example = "芋艿")
@ExcelProperty("标签名称")
private String lableName;
@Schema(description = "标签描述")
@ExcelProperty("标签描述")
private String lableDesc;
@Schema(description = "系统标识")
@ExcelProperty("系统标识")
private String systemCode;
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.label.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 LabelSaveReqVO {
@Schema(description = "主键标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "1802")
private String id;
@Schema(description = "标签名称", example = "芋艿")
private String lableName;
@Schema(description = "标签描述")
private String lableDesc;
@Schema(description = "系统标识")
private String systemCode;
}

View File

@ -0,0 +1,104 @@
<?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.label.mapper.LabelMapper">
<sql id="baseCarMainColumn">
tbcm.id,
tbcm.engine_number,
tbcm.vin,
tbcm.license_number,
tbcm.car_model,
tbcm.maintenance_date,
tbcm.maintenance_mileage,
tbcm.inspection_date,
tbcm.insurance_date,
tbcm.check_date,
tbcm.next_maintenance_date,
tbcm.next_maintenance_mileage,
tbcm.next_inspection_date,
tbcm.insurance_expiry_date,
tbcm.next_check_date,
tbcm.car_brand,
tbcm.car_nature,
tbcm.car_category,
tbcm.car_register_date,
tbcm.car_license_img,
tbcm.recently_handled_business,
tbcm.recently_handle_business_time,
tbcm.deleted,
tbcm.creator,
tbcm.create_time,
tbcm.updater,
tbcm.update_time
</sql>
<select id="findPage" resultType="cn.iocoder.yudao.module.custom.vo.CarMainRespVO">
SELECT
<include refid="baseCarMainColumn"></include>
FROM `base_car_main` tbcm
WHERE
tbcm.deleted = 0
<if test="dto.licenseNumber != null and dto.licenseNumber != ''">
AND tbcm.license_number LIKE CONCAT('%',#{dto.licenseNumber},'%')
</if>
<if test="dto.carBrand != null and dto.carBrand != ''">
AND tbcm.car_brand = #{dto.carBrand}
</if>
<if test="dto.carCategory != null and dto.carCategory != ''">
AND tbcm.car_category = #{dto.carCategory}
</if>
<if test="dto.recentlyHandledBusiness != null and dto.recentlyHandledBusiness != ''">
AND tbcm.recently_handled_business = #{dto.recentlyHandledBusiness}
</if>
<if test="dto.recentlyHandleBusinessTime != null">
AND tbcm.recently_handle_business_time = #{dto.recentlyHandleBusinessTime}
</if>
<if test="dto.vin != null and dto.vin != ''">
AND tbcm.vin LIKE CONCAT('%',#{dto.vin},'%')
</if>
<if test="dto.recentlyHandledBusiness != null and dto.recentlyHandledBusiness != ''">
AND tbcm.tenant_id = #{dto.tenant}
</if>
<if test="dto.carModel != null and dto.carModel != ''">
AND tbcm.car_model = #{dto.carModel}
</if>
<if test="dto.carNature != null and dto.carNature != ''">
AND tbcm.car_nature = #{dto.carNature}
</if>
<if test="dto.engineNumber != null and dto.engineNumber != ''">
AND tbcm.engine_number LIKE CONCAT('%',#{dto.engineNumber},'%')
</if>
ORDER BY
tbcm.car_register_date DESC
</select>
<select id="isDataKeyValueRepeat" resultType="cn.iocoder.yudao.module.custom.entity.CarMain">
SELECT
tbcm.id
FROM `base_car_main` tbcm
WHERE
tbcm.deleted = 0
<if test="dto.licenseNumber != null and dto.licenseNumber != ''">
AND tbcm.license_number = #{dto.licenseNumber}
</if>
<if test="dto.vin != null and dto.vin != ''">
AND tbcm.vin = #{dto.vin}
</if>
<if test="dto.engineNumber != null and dto.engineNumber != ''">
AND tbcm.engine_number = #{dto.engineNumber}
</if>
</select>
<select id="selectListByCusId" resultType="cn.iocoder.yudao.module.custom.vo.CarMainRespVO">
SELECT
<include refid="baseCarMainColumn"></include>,main.is_owner AS isOwner
FROM
base_customer_car main
LEFT JOIN base_car_main tbcm ON main.car_id = tbcm.id AND tbcm.deleted = 0
WHERE
main.deleted = 0
AND main.cus_id = #{cusId}
ORDER BY main.create_time DESC
</select>
</mapper>