1.创建请假单实体(com.imooc.oa.entity)LeaveForm.java
package com.imooc.oa.entity; import java.util.Date; public class LeaveForm { private Long formId; private Long employeeId; private Integer formType; private Date startTime; private Date endTime; private String reason; private Date createTime; private String state; @Override public String toString() { return "LeaveForm{" + "formId=" + formId + ", employeeId=" + employeeId + ", formType=" + formType + ", startTime=" + startTime + ", endTime=" + endTime + ", reason='" + reason + '\'' + ", createTime=" + createTime + ", state='" + state + '\'' + '}'; } public Long getFormId() { return formId; } public void setFormId(Long formId) { this.formId = formId; } public Long getEmployeeId() { return employeeId; } public void setEmployeeId(Long employeeId) { this.employeeId = employeeId; } public Integer getFormType() { return formType; } public void setFormType(Integer formType) { this.formType = formType; } public Date getStartTime() { return startTime; } public void setStartTime(Date startTime) { this.startTime = startTime; } public Date getEndTime() { return endTime; } public void setEndTime(Date endTime) { this.endTime = endTime; } public String getReason() { return reason; } public void setReason(String reason) { this.reason = reason; } public Date getCreateTime() { return createTime; } public void setCreateTime(Date createTime) { this.createTime = createTime; } public String getState() { return state; } public void setState(String state) { this.state = state; } }
2.创建新的接口用于处理数据库的交互(com.imooc.oa.mapper)LeaveFormMapper.java
package com.imooc.oa.mapper; import com.imooc.oa.entity.LeaveForm; public interface LeaveFormMapper { public void insert(LeaveForm form); }
3.创建mapper对应的xml(src/main/resources/mappers/leave_form.xml)leave_form.xml
<?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.imooc.oa.mapper.LeaveFormMapper"> <insert id="insert" parameterType="com.imooc.oa.entity.LeaveForm" useGeneratedKeys="true" keyProperty="formId" keyColumn="form_id"> INSERT INTO `imooc_oa`.`adm_leave_form`( `employee_id`, `form_type`, `start_time`, `end_time`, `reason`, `create_time`, `state`) VALUES ( #{employeeId}, #{formType}, #{startTime}, #{endTime}, #{reason}, #{createTime}, #{state}); </insert> </mapper>
4.在mybatis-config.xml进行注册
<mapper resource="mappers/leave_form.xml"/>
5.创建请假流程实体类(com.imooc.oa.entity)ProcessFlow.java
package com.imooc.oa.entity; import java.util.Date; public class ProcessFlow { private Long processId; private Long formId; private Long operatorId; private String action; private String result; private String reason; private Date createTime; private Date auditTime; private Integer orderNo; private String state; private Integer isLast; @Override public String toString() { return "ProcessFlow{" + "processId=" + processId + ", formId=" + formId + ", operatorId=" + operatorId + ", action='" + action + '\'' + ", result='" + result + '\'' + ", reason='" + reason + '\'' + ", createTime=" + createTime + ", auditTime=" + auditTime + ", orderNo=" + orderNo + ", state='" + state + '\'' + ", isLast=" + isLast + '}'; } public Long getProcessId() { return processId; } public void setProcessId(Long processId) { this.processId = processId; } public Long getFormId() { return formId; } public void setFormId(Long formId) { this.formId = formId; } public Long getOperatorId() { return operatorId; } public void setOperatorId(Long operatorId) { this.operatorId = operatorId; } public String getAction() { return action; } public void setAction(String action) { this.action = action; } public String getResult() { return result; } public void setResult(String result) { this.result = result; } public String getReason() { return reason; } public void setReason(String reason) { this.reason = reason; } public Date getCreateTime() { return createTime; } public void setCreateTime(Date createTime) { this.createTime = createTime; } public Date getAuditTime() { return auditTime; } public void setAuditTime(Date auditTime) { this.auditTime = auditTime; } public Integer getOrderNo() { return orderNo; } public void setOrderNo(Integer orderNo) { this.orderNo = orderNo; } public String getState() { return state; } public void setState(String state) { this.state = state; } public Integer getIsLast() { return isLast; } public void setIsLast(Integer isLast) { this.isLast = isLast; } }
6.创建新的接口用于处理数据库的交互(com.imooc.oa.mapper)ProcessFlowMapper.java
package com.imooc.oa.mapper; import com.imooc.oa.entity.ProcessFlow; public interface ProcessFlowMapper { public void insert(ProcessFlow processFlow); }
7.创建mapper对应的xml(src/main/resources/mappers/)process_flow.xml
<?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.imooc.oa.mapper.ProcessFlowMapper"> <insert id="insert" parameterType="com.imooc.oa.entity.ProcessFlow" useGeneratedKeys="true" keyProperty="processId" keyColumn="process_id"> INSERT INTO `imooc_oa`.`adm_process_flow`( `form_id`, `operator_id`, `action`, `result`, `reason`, `create_time`, `audit_time`, `order_no`, `state`, `is_last`) VALUES (#{formId}, #{operatorId}, #{action}, #{result}, #{reason}, #{createTime} , #{auditTime} , #{orderNo} , #{state} , #{isLast}); </insert> </mapper>
8.在mybatis-config.xml进行注册
<mapper resource="mappers/process_flow.xml"/>
9.创建系统通知实体类(com.imooc.oa.entity)Notice.java
package com.imooc.oa.entity; import java.util.Date; public class Notice { private Long noticeId; private Long receiverId; private String content; private Date createTime; public Notice(){ } public Notice(Long receiverId , String content){ this.receiverId = receiverId; this.content = content; this.createTime = new Date(); } @Override public String toString() { return "Notice{" + "noticeId=" + noticeId + ", receiverId=" + receiverId + ", content='" + content + '\'' + ", createTime=" + createTime + '}'; } public Long getNoticeId() { return noticeId; } public void setNoticeId(Long noticeId) { this.noticeId = noticeId; } public Long getReceiverId() { return receiverId; } public void setReceiverId(Long receiverId) { this.receiverId = receiverId; } public String getContent() { return content; } public void setContent(String content) { this.content = content; } public Date getCreateTime() { return createTime; } public void setCreateTime(Date createTime) { this.createTime = createTime; } }
10.创建新的接口用于处理数据库的交互(com.imooc.oa.mapper)NoticeMapper.java
package com.imooc.oa.mapper; import com.imooc.oa.entity.Notice; public interface NoticeMapper { public void insert(Notice notice); }
11.创建mapper对应的xml(src/main/resources/mappers/)notice.xml
<?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.imooc.oa.mapper.NoticeMapper"> <insert id="insert" parameterType="com.imooc.oa.entity.Notice" useGeneratedKeys="true" keyProperty="noticeId" keyColumn="notice_id"> INSERT INTO sys_notice( receiver_id, content, create_time) VALUES (#{receiverId}, #{content}, #{createTime}) </insert> </mapper>
12.在mybatis-config.xml进行注册
<mapper resource="mappers/notice.xml"/>
标签:请假,Mapper,return,String,void,private,createTime,017,public From: https://www.cnblogs.com/LLL0617/p/16977364.html