提交 77dca853 authored 作者: zhu's avatar zhu

1.develop

2.fix bug
上级 fccee4d8
/**
* 项目:互联网医疗
* 模型分组:服务管理
* 模型名称:医生报告查看关系表
* @Author: xiongwei
* @Date: 2023-09-05 09:42:00
*/
package com.xwd.hospital.server.domain;
import java.io.Serializable;
import com.xwd.hospital.server.rest.res.ApiCode;
import lombok.*;
import java.util.List;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.format.annotation.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.xwd.hospital.server.base.BaseDomain;
import com.xwd.hospital.server.domain.MedicalReport;
import com.xwd.hospital.server.domain.DoctorInfo;
@Data
@Builder(builderMethodName = "newBuilder")
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
@TableName("`pms_medical_report_doctor`")
@Schema(name = "MedicalReportDoctor", description = "医生报告查看关系表")
public class MedicalReportDoctor extends BaseDomain {
/**
* Id
*/
@TableId(value = "id", type = IdType.AUTO)
@Schema(description = "Id", nullable = false)
private Long id;
/**
* 报告id
*/
@TableField(value = "report_id")
@Schema(description = "报告id", nullable = false)
private Long reportId;
/**
* 报告id
*/
@Schema(description = "报告id")
@TableField(exist = false)
private MedicalReport report;
/**
* 医生id
*/
@TableField(value = "doctor_id")
@Schema(description = "医生id", nullable = false)
private Long doctorId;
/**
* 医生id
*/
@Schema(description = "医生id")
@TableField(exist = false)
private DoctorInfo doctor;
/**
* 操作人Id
*/
@TableField(value = "editor_id")
@Schema(description = "操作人Id", nullable = false)
private Long editorId;
/**
* 操作人
*/
@TableField(value = "editor_name")
@Schema(description = "操作人", nullable = false)
private String editorName;
/**
* 创建时间
*/
@TableField(value = "create_time", fill = FieldFill.INSERT)
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建时间", nullable = false)
private java.util.Date createTime;
/**
* 更新时间
*/
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "更新时间", nullable = false)
private java.util.Date updateTime;
/**
* 设置默认值
*/
@Override
public MedicalReportDoctor setDefault() {
if (this.getEditorId() == null) {
this.setEditorId(1L);
}
if (this.getEditorName() == null) {
this.setEditorName("admin");
}
if (this.getCreateTime() == null) {
this.setCreateTime(new java.util.Date());
}
if (this.getUpdateTime() == null) {
this.setUpdateTime(new java.util.Date());
}
return this;
}
/**
* 数据验证
*/
@Override
public boolean validate(boolean throwException) {
if (this.getReportId() == null) {
if (throwException) {
throw new ApiCode.ApiException(-1, "报告id不能为空!");
}
return false;
}
if (this.getDoctorId() == null) {
if (throwException) {
throw new ApiCode.ApiException(-1, "医生id不能为空!");
}
return false;
}
if (this.getEditorId() == null) {
if (throwException) {
throw new ApiCode.ApiException(-1, "操作人Id不能为空!");
}
return false;
}
if (this.getEditorName() == null) {
if (throwException) {
throw new ApiCode.ApiException(-1, "操作人不能为空!");
}
return false;
}
return true;
}
/**
* 数据验证
*/
@Override
public boolean validate() {
return this.validate(false);
}
}
/**
* 项目:互联网医疗
* 模型分组:服务管理
* 模型名称:医生报告查看关系表
* @Author: xiongwei
* @Date: 2023-09-05 09:42:00
*/
package com.xwd.hospital.server.repository;
import java.io.Serializable;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.springframework.stereotype.Repository;
import org.apache.ibatis.annotations.Param;
import com.xwd.hospital.server.domain.MedicalReportDoctor;
import com.xwd.hospital.server.repository.base.MedicalReportDoctorBaseMapper;
@Repository
public interface MedicalReportDoctorMapper extends MedicalReportDoctorBaseMapper {
}
/**
* 项目:互联网医疗
* 模型分组:服务管理
* 模型名称:医生报告查看关系表
* @Author: xiongwei
* @Date: 2023-09-05 09:42:00
*/
package com.xwd.hospital.server.repository.base;
import java.io.Serializable;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.springframework.stereotype.Repository;
import org.apache.ibatis.annotations.Param;
import com.xwd.hospital.server.domain.MedicalReportDoctor;
@Repository
public interface MedicalReportDoctorBaseMapper extends BaseMapper<MedicalReportDoctor> {
/**
* 根据 ID 更新所有字段
*
* @param entity 实体对象
*/
int updateAllFieldsById(@Param(Constants.ENTITY) MedicalReportDoctor entity);
/**
* 批量插入
*
* @param records 实体对象列表
*/
int batchInsert(@Param("records") List<MedicalReportDoctor> records);
}
/**
* 项目:互联网医疗
* 模型分组:服务管理
* 模型名称:医生报告查看关系表
* @Author: xiongwei
* @Date: 2023-09-05 09:42:00
*/
package com.xwd.hospital.server.rest;
import java.util.List;
import java.util.Arrays;
import cn.dev33.satoken.stp.SaLoginModel;
import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xwd.hospital.server.annotation.ApiCommon;
import com.xwd.hospital.server.annotation.AuthUser;
import com.xwd.hospital.server.base.BaseController;
import com.xwd.hospital.server.domain.User;
import com.xwd.hospital.server.rest.res.ApiCode;
import com.xwd.hospital.server.domain.MedicalReportDoctor;
import com.xwd.hospital.server.rest.req.MedicalReportDoctorParam;
import com.xwd.hospital.server.rest.res.ApiResponse;
import com.xwd.hospital.server.service.MedicalReportDoctorService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@RestController
@Tag(name = "MedicalReportDoctorController", description = "医生报告查看关系表管理")
@RequestMapping("/v1/pms/medical-report-doctor")
public class MedicalReportDoctorController extends BaseController<MedicalReportDoctorService, MedicalReportDoctor, MedicalReportDoctorParam> {
@Resource
public void setService(MedicalReportDoctorService service) {
this.service = service;
}
/**
* 新增
*
* @param entity 要新增的对象
* @return 新增的对象
*/
@PostMapping("/")
@Operation(summary = "新增")
@Override
public ApiResponse<MedicalReportDoctor> add(@RequestBody MedicalReportDoctor entity, @AuthUser User user) {
entity.setEditorId(user.getId());
entity.setEditorName(user.getUsername());
entity.setDefault().validate(true);
this.service.save(entity);
return ApiResponse.ok(this.service.getById(entity.getId()));
}
/**
* 批量新增
*
* @param entityList 要新增的对象
* @return boolean 成功或失败
*/
@PostMapping("/batch-save")
@Operation(summary = "批量新增")
@Override
public ApiResponse<Boolean> batchSave(@RequestBody List<MedicalReportDoctor> entityList, @AuthUser User user) {
entityList.forEach(entity -> {
entity.setEditorId(user.getId());
entity.setEditorName(user.getUsername());
entity.setDefault().validate(true);
});
return ApiResponse.ok(this.service.saveBatch(entityList));
}
}
/**
* 项目:互联网医疗
* 模型分组:服务管理
* 模型名称:医生报告查看关系表
* @Author: xiongwei
* @Date: 2023-09-05 09:42:00
*/
package com.xwd.hospital.server.rest.req;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;
import com.xwd.hospital.server.base.BaseParam;
import com.xwd.hospital.server.domain.MedicalReportDoctor;
@Data
@EqualsAndHashCode(callSuper = true)
@Builder(builderMethodName = "newBuilder")
@NoArgsConstructor
@AllArgsConstructor
public class MedicalReportDoctorParam extends BaseParam<MedicalReportDoctor> {
/**
* Id
*/
@Parameter(description = "Id")
private Long id;
/**
* Id IN值List
*/
@Parameter(description = "Id IN值List")
private List<Long> idList;
/**
* 报告id
*/
@Parameter(description = "报告id")
private Long reportId;
/**
* 医生id
*/
@Parameter(description = "医生id")
private Long doctorId;
/**
* 操作人Id
*/
@Parameter(description = "操作人Id")
private Long editorId;
/**
* 操作人
*/
@Parameter(description = "操作人")
private String editorName;
/**
* 创建时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Parameter(description = "创建时间")
private java.util.Date createTime;
/**
* 创建时间 下限值(大于等于)
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Parameter(description = "创建时间 下限值(大于等于)")
private java.util.Date createTimeFrom;
/**
* 创建时间 上限值(小于)
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Parameter(description = "创建时间 上限值(小于)")
private java.util.Date createTimeTo;
/**
* 更新时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Parameter(description = "更新时间")
private java.util.Date updateTime;
/**
* 更新时间 下限值(大于等于)
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Parameter(description = "更新时间 下限值(大于等于)")
private java.util.Date updateTimeFrom;
/**
* 更新时间 上限值(小于)
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Parameter(description = "更新时间 上限值(小于)")
private java.util.Date updateTimeTo;
/**
* 将查询参数转化为查询Wrapper
*/
@Override
public QueryWrapper<MedicalReportDoctor> toQueryWrapper() {
return this.toQueryWrapper("");
}
/**
* 将查询参数转化为查询Wrapper
*/
@Override
public QueryWrapper<MedicalReportDoctor> toQueryWrapper(String columnPrefix) {
QueryWrapper<MedicalReportDoctor> wrapper = Wrappers.<MedicalReportDoctor>query();
wrapper.eq(this.getId() != null, columnPrefix + "id", this.getId());
wrapper.in(this.getIdList() != null && this.getIdList().size() > 0, columnPrefix + "id", this.getIdList());
wrapper.eq(this.getReportId() != null, columnPrefix + "report_id", this.getReportId());
wrapper.eq(this.getDoctorId() != null, columnPrefix + "doctor_id", this.getDoctorId());
wrapper.eq(this.getEditorId() != null, columnPrefix + "editor_id", this.getEditorId());
if (this.getEditorName() != null) {
if (this.getEditorName().startsWith("%") && this.getEditorName().endsWith("%")) {
wrapper.like(columnPrefix + "editor_name", this.getEditorName().substring(1, this.getEditorName().length() - 1));
} else if (this.getEditorName().startsWith("%") && !this.getEditorName().endsWith("%")) {
wrapper.likeLeft(columnPrefix + "editor_name", this.getEditorName().substring(1));
} else if (this.getEditorName().endsWith("%")) {
wrapper.likeRight(columnPrefix + "editor_name", this.getEditorName().substring(0, this.getEditorName().length() - 1));
} else {
wrapper.eq(columnPrefix + "editor_name", this.getEditorName());
}
}
wrapper.eq(this.getCreateTime() != null, columnPrefix + "create_time", this.getCreateTime());
wrapper.ge(this.getCreateTimeFrom() != null, columnPrefix + "create_time", this.getCreateTimeFrom());
wrapper.lt(this.getCreateTimeTo() != null, columnPrefix + "create_time", this.getCreateTimeTo());
wrapper.eq(this.getUpdateTime() != null, columnPrefix + "update_time", this.getUpdateTime());
wrapper.ge(this.getUpdateTimeFrom() != null, columnPrefix + "update_time", this.getUpdateTimeFrom());
wrapper.lt(this.getUpdateTimeTo() != null, columnPrefix + "update_time", this.getUpdateTimeTo());
return wrapper;
}
}
/**
* 项目:互联网医疗
* 模型分组:服务管理
* 模型名称:医生报告查看关系表
* @Author: xiongwei
* @Date: 2023-09-05 09:42:00
*/
package com.xwd.hospital.server.service;
import java.util.List;
import com.xwd.hospital.server.base.BaseService;
import com.xwd.hospital.server.domain.MedicalReportDoctor;
import com.xwd.hospital.server.rest.req.MedicalReportDoctorParam;
public interface MedicalReportDoctorService extends BaseService<MedicalReportDoctor> {
}
/**
* 项目:互联网医疗
* 模型分组:服务管理
* 模型名称:医生报告查看关系表
* @Author: xiongwei
* @Date: 2023-09-05 09:42:00
*/
package com.xwd.hospital.server.service.impl;
import java.io.Serializable;
import java.util.List;
import java.util.ArrayList;
import java.util.Collection;
import jakarta.annotation.Resource;
import com.baomidou.mybatisplus.core.enums.SqlMethod;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.xwd.hospital.server.service.MedicalReportDoctorService;
import com.xwd.hospital.server.repository.MedicalReportDoctorMapper;
import com.xwd.hospital.server.repository.base.MedicalReportDoctorBaseMapper;
import com.xwd.hospital.server.domain.MedicalReportDoctor;
import com.xwd.hospital.server.rest.req.MedicalReportDoctorParam;
@Service
public class MedicalReportDoctorServiceImpl extends ServiceImpl<MedicalReportDoctorMapper, MedicalReportDoctor> implements MedicalReportDoctorService {
@Override
public int updateAllFieldsById(MedicalReportDoctor entity) {
return this.getBaseMapper().updateAllFieldsById(entity);
}
/**
* 批量插入
*
* @param entityList ignore
* @param batchSize ignore
* @return ignore
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean saveBatch(Collection<MedicalReportDoctor> entityList, int batchSize) {
String sqlStatement = SqlHelper.getSqlStatement(MedicalReportDoctorBaseMapper.class, SqlMethod.INSERT_ONE);
return executeBatch(entityList, batchSize, (sqlSession, entity) -> sqlSession.insert(sqlStatement, entity));
}
}
<?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="com.xwd.hospital.server.repository.MedicalReportDoctorMapper">
<resultMap id="ResultMap" type="com.xwd.hospital.server.domain.MedicalReportDoctor" extends="com.xwd.hospital.server.repository.base.MedicalReportDoctorBaseMapper.ResultMap">
</resultMap>
<resultMap id="ListResultMap" type="com.xwd.hospital.server.domain.MedicalReportDoctor" extends="com.xwd.hospital.server.repository.base.MedicalReportDoctorBaseMapper.BaseResultMap">
</resultMap>
<!-- 根据主键查询 -->
<select id="selectById" parameterType="java.io.Serializable" resultMap="ResultMap">
select
<include refid="com.xwd.hospital.server.repository.base.MedicalReportDoctorBaseMapper.Base_Column_List" />
from pms_medical_report_doctor
where id = #{id}
</select>
<!-- 根据Wrapper查询 -->
<select id="selectOne" resultMap="ResultMap">
select
<include refid="com.xwd.hospital.server.repository.base.MedicalReportDoctorBaseMapper.Base_Column_List" />
from pms_medical_report_doctor
${ew.customSqlSegment}
LIMIT 1
</select>
<!-- 根据Wrapper查询 -->
<select id="selectPage" resultMap="ListResultMap">
select
<include refid="com.xwd.hospital.server.repository.base.MedicalReportDoctorBaseMapper.Base_Column_List" />
from pms_medical_report_doctor
${ew.customSqlSegment}
</select>
<!-- 根据Wrapper查询 -->
<select id="selectList" resultMap="ResultMap">
select
<include refid="com.xwd.hospital.server.repository.base.MedicalReportDoctorBaseMapper.Base_Column_List" />
from pms_medical_report_doctor
${ew.customSqlSegment}
</select>
</mapper>
<?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="com.xwd.hospital.server.repository.base.MedicalReportDoctorBaseMapper">
<resultMap id="BaseResultMap" type="com.xwd.hospital.server.domain.MedicalReportDoctor">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="report_id" jdbcType="BIGINT" property="reportId" />
<result column="doctor_id" jdbcType="BIGINT" property="doctorId" />
<result column="editor_id" jdbcType="BIGINT" property="editorId" />
<result column="editor_name" jdbcType="VARCHAR" property="editorName" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<resultMap id="ResultMap" type="com.xwd.hospital.server.domain.MedicalReportDoctor" extends="BaseResultMap">
<association column="report_id" property="report" javaType="com.xwd.hospital.server.domain.MedicalReport"
select="com.xwd.hospital.server.repository.MedicalReportMapper.selectById" />
<association column="doctor_id" property="doctor" javaType="com.xwd.hospital.server.domain.DoctorInfo"
select="com.xwd.hospital.server.repository.DoctorInfoMapper.selectById" />
</resultMap>
<sql id="Base_Column_List">
`id`, `report_id`, `doctor_id`, `editor_id`, `editor_name`, `create_time`, `update_time`
</sql>
<sql id="Base_Column_List_With_Prefix">
t.`id`, t.`report_id`, t.`doctor_id`, t.`editor_id`, t.`editor_name`, t.`create_time`, t.`update_time`
</sql>
<insert id="batchInsert">
insert into pms_medical_report_doctor (
`report_id`, `doctor_id`, `editor_id`, `editor_name`
)
values
<foreach collection="records" item="record" separator=",">
(
#{record.reportId, jdbcType=BIGINT}, #{record.doctorId, jdbcType=BIGINT}, #{record.editorId, jdbcType=BIGINT}, #{record.editorName, jdbcType=VARCHAR}
)
</foreach>
</insert>
<update id="updateAllFieldsById" parameterType="com.xwd.hospital.server.domain.MedicalReportDoctor">
update pms_medical_report_doctor set
<trim suffixOverrides=",">
report_id = #{et.reportId, jdbcType=BIGINT},
doctor_id = #{et.doctorId, jdbcType=BIGINT},
editor_id = #{et.editorId, jdbcType=BIGINT},
editor_name = #{et.editorName, jdbcType=VARCHAR},
</trim>
where id = #{et.id}
</update>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论