This commit is contained in:
PQZ 2024-08-04 15:35:08 +08:00
parent 767e6d9139
commit 55716462b9
10 changed files with 163 additions and 224 deletions

View File

@ -101,6 +101,8 @@ public class CustomerMainController {
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('base:customer-main:delete')")
public CommonResult<Boolean> deleteCustomerMain(@RequestParam("id") String id) {
// TODO: 2024/8/4 临时
customerMainService.removeById(id);
return success(true);
}
@ -144,7 +146,7 @@ public class CustomerMainController {
* @date 19:21 2024/8/3
**/
@PostMapping("/bindCustomerCar")
@Operation(summary = "创建客户管理")
@Operation(summary = "绑定车辆")
@PreAuthorize("@ss.hasPermission('base:customer-main:car')")
public CommonResult<Boolean> bindCustomerCar(@Valid @RequestBody CustomerMainSaveReqVO saveReqVO) {
customerMainService.bindCustomAndCar(saveReqVO);

View File

@ -1,17 +1,14 @@
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 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.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -20,12 +17,8 @@ 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 = "管理后台 - 标签库")
@ -37,23 +30,48 @@ public class LabelController {
@Resource
private LabelService labelService;
/**
* 新建标签
*
* @param createReqVO 标签扩展类
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.String>
* @author PQZ
* @date 14:18 2024/8/4
**/
@PostMapping("/create")
@Operation(summary = "创建标签库")
@PreAuthorize("@ss.hasPermission('base:label:create')")
public CommonResult<String> createLabel(@Valid @RequestBody LabelSaveReqVO createReqVO) {
return success(labelService.createLabel(createReqVO));
public CommonResult<Boolean> createLabel(@Valid @RequestBody LabelSaveReqVO createReqVO) {
labelService.saveLabel(createReqVO);
return success(true);
}
/**
* 更新标签库
*
* @param updateReqVO 标签扩展类
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.String>
* @author PQZ
* @date 14:18 2024/8/4
**/
@PutMapping("/update")
@Operation(summary = "更新标签库")
@PreAuthorize("@ss.hasPermission('base:label:update')")
public CommonResult<Boolean> updateLabel(@Valid @RequestBody LabelSaveReqVO updateReqVO) {
labelService.updateLabel(updateReqVO);
labelService.saveLabel(updateReqVO);
return success(true);
}
/**
* 删除标签
*
* @param id 标签id
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.Boolean>
* @author PQZ
* @date 14:33 2024/8/4
**/
@DeleteMapping("/delete")
@Operation(summary = "删除标签库")
@Operation(summary = "删除标签")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('base:label:delete')")
public CommonResult<Boolean> deleteLabel(@RequestParam("id") String id) {
@ -61,6 +79,14 @@ public class LabelController {
return success(true);
}
/**
* 通过id获取标签
*
* @param id 标签id
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<cn.iocoder.yudao.module.label.vo.LabelRespVO>
* @author PQZ
* @date 14:33 2024/8/4
**/
@GetMapping("/get")
@Operation(summary = "获得标签库")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@ -70,25 +96,25 @@ public class LabelController {
return success(BeanUtils.toBean(label, LabelRespVO.class));
}
/**
* 标签库分页查询
*
* @param pageReqVO LabelPageReqVO实体
* @param pageNo 分页参数
* @param pageSize 分页参数
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<com.baomidou.mybatisplus.core.metadata.IPage < ?>>
* @author PQZ
* @date 14:37 2024/8/4
**/
@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));
public CommonResult<IPage<?>> getLabelPage(LabelPageReqVO pageReqVO,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
Page<LabelRespVO> page = new Page<>(pageNo, pageSize);
return success(labelService.queryListPage(pageReqVO, page));
}
@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

@ -21,7 +21,7 @@ public class Label extends TenantBaseDO {
/**
* 主键标识
*/
@TableId(type = IdType.INPUT)
@TableId(type = IdType.ASSIGN_UUID)
private String id;
/**
* 标签名称
@ -35,5 +35,7 @@ public class Label extends TenantBaseDO {
* 系统标识
*/
private String systemCode;
/**标签样式*/
private String labelType;
}

View File

@ -1,8 +1,13 @@
package cn.iocoder.yudao.module.label.mapper;
import cn.iocoder.yudao.module.label.entity.Label;
import cn.iocoder.yudao.module.label.vo.LabelPageReqVO;
import cn.iocoder.yudao.module.label.vo.LabelRespVO;
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.Param;
/**
* 客户管理扩展Mapper
@ -12,5 +17,16 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface LabelMapper extends BaseMapper<Label> {
/**
* 分页查询标签页sql
*
* @param pageReqVO LabelPageReqVO
* @param page LabelRespVO
* @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.label.vo.LabelRespVO>
* @author PQZ
* @date 14:28 2024/8/4
**/
IPage<LabelRespVO> selectListPage(@Param("entity") LabelPageReqVO pageReqVO, Page<LabelRespVO> page);
}

View File

@ -1,55 +1,59 @@
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.LabelRespVO;
import cn.iocoder.yudao.module.label.vo.LabelSaveReqVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.validation.Valid;
/**
* 标签库 Service 接口
*
* @author 后台管理员
*/
public interface LabelService extends IService<Label> {
public interface LabelService extends IService<Label> {
/**
* 创建标签库
*
* @param createReqVO 创建信息
* @return 编号
*/
String createLabel(@Valid LabelSaveReqVO createReqVO);
* @param createReqVO LabelSaveReqVO
* @return java.lang.String
* @author PQZ
* @date 14:19 2024/8/4
**/
void saveLabel(LabelSaveReqVO createReqVO);
/**
* 更新标签库
* 删除标签
*
* @param updateReqVO 更新信息
*/
void updateLabel(@Valid LabelSaveReqVO updateReqVO);
/**
* 删除标签库
*
* @param id 编号
*/
* @param id 标签id
* @return void
* @author PQZ
* @date 14:22 2024/8/4
**/
void deleteLabel(String id);
/**
* 获得标签库
* 通过标签id获取标签信息
*
* @param id 编号
* @return 标签库
*/
* @param id 标签id
* @return cn.iocoder.yudao.module.label.entity.Label
* @author PQZ
* @date 14:23 2024/8/4
**/
Label getLabel(String id);
/**
* 获得标签库分页
* 分页查询标签库
*
* @param pageReqVO 分页查询
* @return 标签库分页
*/
PageResult<Label> getLabelPage(LabelPageReqVO pageReqVO);
* @param pageReqVO LabelPageReqVO
* @param page Page
* @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.label.vo.LabelRespVO>
* @author PQZ
* @date 14:25 2024/8/4
**/
IPage<LabelRespVO> queryListPage(LabelPageReqVO pageReqVO, Page<LabelRespVO> page);
}

View File

@ -1,12 +1,14 @@
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.LabelRespVO;
import cn.iocoder.yudao.module.label.vo.LabelSaveReqVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@ -25,46 +27,60 @@ public class LabelServiceImpl extends ServiceImpl<LabelMapper, Label> implements
@Resource
private LabelMapper labelMapper;
/**
* 创建标签库
*
* @param createReqVO LabelSaveReqVO
* @return java.lang.String
* @author PQZ
* @date 14:19 2024/8/4
**/
@Override
public String createLabel(LabelSaveReqVO createReqVO) {
public void saveLabel(LabelSaveReqVO createReqVO) {
// 插入
Label label = BeanUtils.toBean(createReqVO, Label.class);
labelMapper.insert(label);
// 返回
return label.getId();
this.saveOrUpdate(label);
}
@Override
public void updateLabel(LabelSaveReqVO updateReqVO) {
// 校验存在
validateLabelExists(updateReqVO.getId());
// 更新
Label updateObj = BeanUtils.toBean(updateReqVO, Label.class);
labelMapper.updateById(updateObj);
}
/**
* 删除标签
*
* @param id 标签id
* @author PQZ
* @date 14:22 2024/8/4
**/
@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);
}
this.removeById(id);
}
/**
* 通过标签id获取标签信息
*
* @param id 标签id
* @return cn.iocoder.yudao.module.label.entity.Label
* @author PQZ
* @date 14:23 2024/8/4
**/
@Override
public Label getLabel(String id) {
return labelMapper.selectById(id);
}
/**
* 分页查询标签库
*
* @param pageReqVO LabelPageReqVO
* @param page Page
* @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.label.vo.LabelRespVO>
* @author PQZ
* @date 14:25 2024/8/4
**/
@Override
public PageResult<Label> getLabelPage(LabelPageReqVO pageReqVO) {
return null;
public IPage<LabelRespVO> queryListPage(LabelPageReqVO pageReqVO, Page<LabelRespVO> page) {
return labelMapper.selectListPage(pageReqVO, page);
}
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.label.vo;
import cn.iocoder.yudao.module.label.entity.Label;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
@ -13,19 +14,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@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;
public class LabelPageReqVO extends Label {
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.label.vo;
import cn.iocoder.yudao.module.label.entity.Label;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
@ -10,26 +11,6 @@ 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;
public class LabelRespVO extends Label {
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.label.vo;
import cn.iocoder.yudao.module.label.entity.Label;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
@ -7,18 +8,8 @@ import javax.validation.constraints.*;
@Schema(description = "管理后台 - 标签库新增/修改 Request VO")
@Data
public class LabelSaveReqVO {
public class LabelSaveReqVO extends Label {
@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

@ -2,103 +2,16 @@
<!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 id="selectListPage" resultType="cn.iocoder.yudao.module.label.vo.LabelRespVO">
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
base_label
<where>
deleted = 0
<if test="entity.labelName != null and entity.cusName != ''">
AND label_name LIKE concat('%',#{entity.labelName},'%')
</if>
</where>
</select>
</mapper>