From e65003ddb31817bd3cd079e340e05f2999b071d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Thu, 16 Oct 2025 20:34:06 +0800 Subject: [PATCH] =?UTF-8?q?feat(generator):=E4=B8=BA=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=AD=97=E6=AE=B5=E6=B7=BB=E5=8A=A0=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E6=A0=BC=E5=BC=8F=E5=8C=96=E6=B3=A8=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在实体类模板中为LocalDateTime、LocalDate、LocalTime和Date类型字段添加@JsonFormat注解 - 设置默认日期格式为"yyyy-MM-dd HH:mm:ss"- 确保生成的实体类能正确序列化和反序列化时间字段 --- .../ClinicAppointmentController.java | 128 ------------------ .../clinic/entity/ClinicAppointment.java | 60 -------- .../mapper/ClinicAppointmentMapper.java | 37 ----- .../mapper/xml/ClinicAppointmentMapper.xml | 60 -------- .../clinic/param/ClinicAppointmentParam.java | 58 -------- .../service/ClinicAppointmentService.java | 42 ------ .../impl/ClinicAppointmentServiceImpl.java | 47 ------- .../generator/templates/entity.java.btl | 10 +- 8 files changed, 9 insertions(+), 433 deletions(-) delete mode 100644 src/main/java/com/gxwebsoft/clinic/controller/ClinicAppointmentController.java delete mode 100644 src/main/java/com/gxwebsoft/clinic/entity/ClinicAppointment.java delete mode 100644 src/main/java/com/gxwebsoft/clinic/mapper/ClinicAppointmentMapper.java delete mode 100644 src/main/java/com/gxwebsoft/clinic/mapper/xml/ClinicAppointmentMapper.xml delete mode 100644 src/main/java/com/gxwebsoft/clinic/param/ClinicAppointmentParam.java delete mode 100644 src/main/java/com/gxwebsoft/clinic/service/ClinicAppointmentService.java delete mode 100644 src/main/java/com/gxwebsoft/clinic/service/impl/ClinicAppointmentServiceImpl.java diff --git a/src/main/java/com/gxwebsoft/clinic/controller/ClinicAppointmentController.java b/src/main/java/com/gxwebsoft/clinic/controller/ClinicAppointmentController.java deleted file mode 100644 index 4612446..0000000 --- a/src/main/java/com/gxwebsoft/clinic/controller/ClinicAppointmentController.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.gxwebsoft.clinic.controller; - -import com.gxwebsoft.common.core.web.BaseController; -import com.gxwebsoft.clinic.service.ClinicAppointmentService; -import com.gxwebsoft.clinic.entity.ClinicAppointment; -import com.gxwebsoft.clinic.param.ClinicAppointmentParam; -import com.gxwebsoft.common.core.web.ApiResult; -import com.gxwebsoft.common.core.web.PageResult; -import com.gxwebsoft.common.core.web.PageParam; -import com.gxwebsoft.common.core.web.BatchParam; -import com.gxwebsoft.common.core.annotation.OperationLog; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.List; - -/** - * 挂号控制器 - * - * @author 科技小王子 - * @since 2025-10-16 20:26:59 - */ -@Tag(name = "挂号管理") -@RestController -@RequestMapping("/api/clinic/clinic-appointment") -public class ClinicAppointmentController extends BaseController { - @Resource - private ClinicAppointmentService clinicAppointmentService; - - @PreAuthorize("hasAuthority('clinic:clinicAppointment:list')") - @Operation(summary = "分页查询挂号") - @GetMapping("/page") - public ApiResult> page(ClinicAppointmentParam param) { - // 使用关联查询 - return success(clinicAppointmentService.pageRel(param)); - } - - @PreAuthorize("hasAuthority('clinic:clinicAppointment:list')") - @Operation(summary = "查询全部挂号") - @GetMapping() - public ApiResult> list(ClinicAppointmentParam param) { - // 使用关联查询 - return success(clinicAppointmentService.listRel(param)); - } - - @PreAuthorize("hasAuthority('clinic:clinicAppointment:list')") - @Operation(summary = "根据id查询挂号") - @GetMapping("/{id}") - public ApiResult get(@PathVariable("id") Long id) { - // 使用关联查询 - return success(clinicAppointmentService.getByIdRel(id)); - } - - @PreAuthorize("hasAuthority('clinic:clinicAppointment:save')") - @OperationLog - @Operation(summary = "添加挂号") - @PostMapping() - public ApiResult save(@RequestBody ClinicAppointment clinicAppointment) { - // 记录当前登录用户id - // User loginUser = getLoginUser(); - // if (loginUser != null) { - // clinicAppointment.setUserId(loginUser.getUserId()); - // } - if (clinicAppointmentService.save(clinicAppointment)) { - return success("添加成功"); - } - return fail("添加失败"); - } - - @PreAuthorize("hasAuthority('clinic:clinicAppointment:update')") - @OperationLog - @Operation(summary = "修改挂号") - @PutMapping() - public ApiResult update(@RequestBody ClinicAppointment clinicAppointment) { - if (clinicAppointmentService.updateById(clinicAppointment)) { - return success("修改成功"); - } - return fail("修改失败"); - } - - @PreAuthorize("hasAuthority('clinic:clinicAppointment:remove')") - @OperationLog - @Operation(summary = "删除挂号") - @DeleteMapping("/{id}") - public ApiResult remove(@PathVariable("id") Integer id) { - if (clinicAppointmentService.removeById(id)) { - return success("删除成功"); - } - return fail("删除失败"); - } - - @PreAuthorize("hasAuthority('clinic:clinicAppointment:save')") - @OperationLog - @Operation(summary = "批量添加挂号") - @PostMapping("/batch") - public ApiResult saveBatch(@RequestBody List list) { - if (clinicAppointmentService.saveBatch(list)) { - return success("添加成功"); - } - return fail("添加失败"); - } - - @PreAuthorize("hasAuthority('clinic:clinicAppointment:update')") - @OperationLog - @Operation(summary = "批量修改挂号") - @PutMapping("/batch") - public ApiResult removeBatch(@RequestBody BatchParam batchParam) { - if (batchParam.update(clinicAppointmentService, "id")) { - return success("修改成功"); - } - return fail("修改失败"); - } - - @PreAuthorize("hasAuthority('clinic:clinicAppointment:remove')") - @OperationLog - @Operation(summary = "批量删除挂号") - @DeleteMapping("/batch") - public ApiResult removeBatch(@RequestBody List ids) { - if (clinicAppointmentService.removeByIds(ids)) { - return success("删除成功"); - } - return fail("删除失败"); - } - -} diff --git a/src/main/java/com/gxwebsoft/clinic/entity/ClinicAppointment.java b/src/main/java/com/gxwebsoft/clinic/entity/ClinicAppointment.java deleted file mode 100644 index 0588200..0000000 --- a/src/main/java/com/gxwebsoft/clinic/entity/ClinicAppointment.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.gxwebsoft.clinic.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import java.time.LocalDateTime; -import java.io.Serializable; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - * 挂号 - * - * @author 科技小王子 - * @since 2025-10-16 20:26:59 - */ -@Data -@EqualsAndHashCode(callSuper = false) -@Schema(name = "ClinicAppointment对象", description = "挂号") -public class ClinicAppointment implements Serializable { - private static final long serialVersionUID = 1L; - - @Schema(description = "主键ID") - @TableId(value = "id", type = IdType.AUTO) - private Long id; - - @Schema(description = "类型") - private Integer type; - - @Schema(description = "就诊原因") - private String reason; - - @Schema(description = "挂号时间") - private LocalDateTime evaluateTime; - - @Schema(description = "医生") - private Integer doctorId; - - @Schema(description = "患者") - private Integer userId; - - @Schema(description = "备注") - private String comments; - - @Schema(description = "排序号") - private Integer sortNumber; - - @Schema(description = "是否删除") - private Integer isDelete; - - @Schema(description = "租户id") - private Integer tenantId; - - @Schema(description = "创建时间") - private LocalDateTime createTime; - - @Schema(description = "修改时间") - private LocalDateTime updateTime; - -} diff --git a/src/main/java/com/gxwebsoft/clinic/mapper/ClinicAppointmentMapper.java b/src/main/java/com/gxwebsoft/clinic/mapper/ClinicAppointmentMapper.java deleted file mode 100644 index 34eea12..0000000 --- a/src/main/java/com/gxwebsoft/clinic/mapper/ClinicAppointmentMapper.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.gxwebsoft.clinic.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.gxwebsoft.clinic.entity.ClinicAppointment; -import com.gxwebsoft.clinic.param.ClinicAppointmentParam; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * 挂号Mapper - * - * @author 科技小王子 - * @since 2025-10-16 20:26:59 - */ -public interface ClinicAppointmentMapper extends BaseMapper { - - /** - * 分页查询 - * - * @param page 分页对象 - * @param param 查询参数 - * @return List - */ - List selectPageRel(@Param("page") IPage page, - @Param("param") ClinicAppointmentParam param); - - /** - * 查询全部 - * - * @param param 查询参数 - * @return List - */ - List selectListRel(@Param("param") ClinicAppointmentParam param); - -} diff --git a/src/main/java/com/gxwebsoft/clinic/mapper/xml/ClinicAppointmentMapper.xml b/src/main/java/com/gxwebsoft/clinic/mapper/xml/ClinicAppointmentMapper.xml deleted file mode 100644 index 3825e91..0000000 --- a/src/main/java/com/gxwebsoft/clinic/mapper/xml/ClinicAppointmentMapper.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - SELECT a.* - FROM clinic_appointment a - - - AND a.id = #{param.id} - - - AND a.type = #{param.type} - - - AND a.reason LIKE CONCAT('%', #{param.reason}, '%') - - - AND a.evaluate_time LIKE CONCAT('%', #{param.evaluateTime}, '%') - - - AND a.doctor_id = #{param.doctorId} - - - AND a.user_id = #{param.userId} - - - AND a.comments LIKE CONCAT('%', #{param.comments}, '%') - - - AND a.sort_number = #{param.sortNumber} - - - AND a.is_delete = #{param.isDelete} - - - AND a.create_time >= #{param.createTimeStart} - - - AND a.create_time <= #{param.createTimeEnd} - - - AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') - ) - - - - - - - - - - - diff --git a/src/main/java/com/gxwebsoft/clinic/param/ClinicAppointmentParam.java b/src/main/java/com/gxwebsoft/clinic/param/ClinicAppointmentParam.java deleted file mode 100644 index 8caebe1..0000000 --- a/src/main/java/com/gxwebsoft/clinic/param/ClinicAppointmentParam.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.gxwebsoft.clinic.param; - -import java.math.BigDecimal; -import com.gxwebsoft.common.core.annotation.QueryField; -import com.gxwebsoft.common.core.annotation.QueryType; -import com.gxwebsoft.common.core.web.BaseParam; -import com.fasterxml.jackson.annotation.JsonInclude; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - * 挂号查询参数 - * - * @author 科技小王子 - * @since 2025-10-16 20:26:59 - */ -@Data -@EqualsAndHashCode(callSuper = false) -@JsonInclude(JsonInclude.Include.NON_NULL) -@Schema(name = "ClinicAppointmentParam对象", description = "挂号查询参数") -public class ClinicAppointmentParam extends BaseParam { - private static final long serialVersionUID = 1L; - - @Schema(description = "主键ID") - @QueryField(type = QueryType.EQ) - private Long id; - - @Schema(description = "类型") - @QueryField(type = QueryType.EQ) - private Integer type; - - @Schema(description = "就诊原因") - private String reason; - - @Schema(description = "挂号时间") - private String evaluateTime; - - @Schema(description = "医生") - @QueryField(type = QueryType.EQ) - private Integer doctorId; - - @Schema(description = "患者") - @QueryField(type = QueryType.EQ) - private Integer userId; - - @Schema(description = "备注") - private String comments; - - @Schema(description = "排序号") - @QueryField(type = QueryType.EQ) - private Integer sortNumber; - - @Schema(description = "是否删除") - @QueryField(type = QueryType.EQ) - private Integer isDelete; - -} diff --git a/src/main/java/com/gxwebsoft/clinic/service/ClinicAppointmentService.java b/src/main/java/com/gxwebsoft/clinic/service/ClinicAppointmentService.java deleted file mode 100644 index 83156dc..0000000 --- a/src/main/java/com/gxwebsoft/clinic/service/ClinicAppointmentService.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.gxwebsoft.clinic.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.gxwebsoft.common.core.web.PageResult; -import com.gxwebsoft.clinic.entity.ClinicAppointment; -import com.gxwebsoft.clinic.param.ClinicAppointmentParam; - -import java.util.List; - -/** - * 挂号Service - * - * @author 科技小王子 - * @since 2025-10-16 20:26:59 - */ -public interface ClinicAppointmentService extends IService { - - /** - * 分页关联查询 - * - * @param param 查询参数 - * @return PageResult - */ - PageResult pageRel(ClinicAppointmentParam param); - - /** - * 关联查询全部 - * - * @param param 查询参数 - * @return List - */ - List listRel(ClinicAppointmentParam param); - - /** - * 根据id查询 - * - * @param id 主键ID - * @return ClinicAppointment - */ - ClinicAppointment getByIdRel(Long id); - -} diff --git a/src/main/java/com/gxwebsoft/clinic/service/impl/ClinicAppointmentServiceImpl.java b/src/main/java/com/gxwebsoft/clinic/service/impl/ClinicAppointmentServiceImpl.java deleted file mode 100644 index fb79e40..0000000 --- a/src/main/java/com/gxwebsoft/clinic/service/impl/ClinicAppointmentServiceImpl.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.gxwebsoft.clinic.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.gxwebsoft.clinic.mapper.ClinicAppointmentMapper; -import com.gxwebsoft.clinic.service.ClinicAppointmentService; -import com.gxwebsoft.clinic.entity.ClinicAppointment; -import com.gxwebsoft.clinic.param.ClinicAppointmentParam; -import com.gxwebsoft.common.core.web.PageParam; -import com.gxwebsoft.common.core.web.PageResult; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * 挂号Service实现 - * - * @author 科技小王子 - * @since 2025-10-16 20:26:59 - */ -@Service -public class ClinicAppointmentServiceImpl extends ServiceImpl implements ClinicAppointmentService { - - @Override - public PageResult pageRel(ClinicAppointmentParam param) { - PageParam page = new PageParam<>(param); - page.setDefaultOrder("sort_number asc, create_time desc"); - List list = baseMapper.selectPageRel(page, param); - return new PageResult<>(list, page.getTotal()); - } - - @Override - public List listRel(ClinicAppointmentParam param) { - List list = baseMapper.selectListRel(param); - // 排序 - PageParam page = new PageParam<>(); - page.setDefaultOrder("sort_number asc, create_time desc"); - return page.sortRecords(list); - } - - @Override - public ClinicAppointment getByIdRel(Long id) { - ClinicAppointmentParam param = new ClinicAppointmentParam(); - param.setId(id); - return param.getOne(baseMapper.selectListRel(param)); - } - -} diff --git a/src/test/java/com/gxwebsoft/generator/templates/entity.java.btl b/src/test/java/com/gxwebsoft/generator/templates/entity.java.btl index e98a1d3..0838977 100644 --- a/src/test/java/com/gxwebsoft/generator/templates/entity.java.btl +++ b/src/test/java/com/gxwebsoft/generator/templates/entity.java.btl @@ -13,6 +13,8 @@ import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; <% } %> <% } %> +<% /* 为时间类型字段添加日期格式化注解的导入 */ %> +import com.fasterxml.jackson.annotation.JsonFormat; /** * ${table.comment!} @@ -65,6 +67,12 @@ public class ${entity} implements Serializable { */ <% } %> <% } %> + + <% /* 为时间类型字段添加日期格式化注解 */ %> + <% if(field.propertyType == 'LocalDateTime' || field.propertyType == 'LocalDate' || field.propertyType == 'LocalTime' || field.propertyType == 'Date') { %> + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + <% } %> + <% /* 主键 */ %> <% if(field.keyFlag) { %> <% if(field.keyIdentityFlag) { %> @@ -154,4 +162,4 @@ public class ${entity} implements Serializable { "}"; } <% } %> -} +} \ No newline at end of file