//例如:日志表增删改查(表名jms_jc_apc_cancel_log)
1、domain文件夹新建 class → JmsJcApcCancelLog
对应表结构get/set
@TableName(value = "jms_jc_apc_cancel_log")
public class JmsJcApcCancelLog {
@TableId(value = "id",type = IdType.ASSIGN_ID) //主键
private Long id; //id bigint primary key,
private String patient_id; //patient_id varchar(12),
private Integer times; //times int,
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getPatient_id() {
return patient_id;
}
public void setPatient_id(String patient_id) {
this.patient_id = patient_id;
}
public Integer getTimes() {
return times;
}
public void setTimes(Integer times) {
this.times = times;
}
}
2、mapper文件夹新建 interface → JmsJcApcCancelLogMapper
@Component
@Mapper
public interface JmsJcApcCancelLogMapper extends BaseMapper<JmsJcApcCancelLog> {
}
3、执行sql语句查询
查询函数:mapper文件夹新建 interface → ChisCustMapper
@Component
@Mapper
public interface ChisCustMapper {
@Select("EXEC jms_getJcApcCancelList #{begin_time},#{end_time},#{apply_type},#{mz_zy_flag}")
List<VoJcApcCancel> jms_getJcApcCancelList(@Param("begin_time")String begin_time, @Param("end_time")String end_time, @Param("apply_type")String apply_type, @Param("mz_zy_flag")String mz_zy_flag);
}
执行查询
List<VoJcApcCancel> cancelList =
chisCustMapper.jms_getJcApcCancelList(begin_time,end_time,apply_type,mz_zy_flag);
4、插入
//【插入】
JmsJcApcCancelLog log= new JmsJcApcCancelLog();//new一个日志表对象
log.setOrder_sn(orderSn);
log.setChannel(channel);
log.setApply_type(applyType);
log.setCharge_no(chargeNo);
log.setExam_serial(examSerial);
log.setPatient_id(patientId);
log.setTimes(times);
log.setMz_zy_flag(mzZyFlag);
log.setCancel_result("0");
jmsJcApcCancelLogMapper.insert(log);
5、更新
//【更新】
//方法1
//该方法更新全表
log.setCancel_result(cancelResult);
log.setIn_log(inputXML);
log.setOut_log(outputXml);
jmsJcApcCancelLogMapper.updateById(log);
//方法2
//该方法只更新需要更新的字段
LambdaUpdateWrapper<JmsJcApcCancelLog> updateWrapper = Wrappers.lambdaUpdate();
updateWrapper.set(JmsJcApcCancelLog::getCancel_result,cancelResult); //成功失败标识
updateWrapper.set(JmsJcApcCancelLog::getIn_log,inputXML); //入参
updateWrapper.set(JmsJcApcCancelLog::getOut_log,outputXml); //出参
updateWrapper.eq(JmsJcApcCancelLog::getId,log.getId());
jmsJcApcCancelLogMapper.update(null,updateWrapper);
6、删除
//【删除】
//方法1
//单一条件主键删除
jmsJcApcCancelLogMapper.deleteById("此处写需要删除的id值即可");
//方法2
//多条件删除或联合主键删除
LambdaQueryWrapper<JmsJcApcCancelLog> queryWrapper = Wrappers.lambdaQuery();
updateWrapper.eq(JmsJcApcCancelLog::getId,"此处写需要删除的id值");
updateWrapper.eq(JmsJcApcCancelLog::getPatient_id,"此处写需要删除的patient_id值");
jmsJcApcCancelLogMapper.delete(queryWrapper);