diff --git a/element-vue/src/pages/manager/home.vue b/element-vue/src/components/manager/home.vue similarity index 54% rename from element-vue/src/pages/manager/home.vue rename to element-vue/src/components/manager/home.vue index 258d289..5030e98 100644 --- a/element-vue/src/pages/manager/home.vue +++ b/element-vue/src/components/manager/home.vue @@ -1,34 +1,41 @@ diff --git a/element-vue/src/components/manager/index.vue b/element-vue/src/components/manager/index.vue new file mode 100644 index 0000000..54fcbd6 --- /dev/null +++ b/element-vue/src/components/manager/index.vue @@ -0,0 +1,19 @@ + + + + + diff --git a/element-vue/src/components/manager/navBar.vue b/element-vue/src/components/manager/navBar.vue index 7f90119..2ddd34f 100644 --- a/element-vue/src/components/manager/navBar.vue +++ b/element-vue/src/components/manager/navBar.vue @@ -7,11 +7,11 @@ @select="handleSelect" background-color="#1989fa" text-color="#ffffff" - active-text-color="#ffd04b"> - 首页 - - 审核 - 管理实验室 + active-text-color="#ffd04b" + router> + 首页 + 审核 + 实验室管理 @@ -41,7 +41,7 @@ }, 1000) }, goPersonal: function () { - this.$router.push('/manager/personal') + this.$router.push('/manager/index/personal') } }, components: { diff --git a/element-vue/src/components/supManager/addLab.vue b/element-vue/src/components/supManager/addLab.vue index 41aa9c1..edecffe 100644 --- a/element-vue/src/components/supManager/addLab.vue +++ b/element-vue/src/components/supManager/addLab.vue @@ -1,129 +1,98 @@ diff --git a/element-vue/src/components/supManager/home.vue b/element-vue/src/components/supManager/home.vue index 45850a2..eb0c545 100644 --- a/element-vue/src/components/supManager/home.vue +++ b/element-vue/src/components/supManager/home.vue @@ -24,7 +24,7 @@ homeParams: [ { name: '实验室管理', func: () => { - this.$router.push('/supManager/index/labManage') + this.$router.push('/supManager/index/labManager') } }, { diff --git a/element-vue/src/components/supManager/labManage.vue b/element-vue/src/components/supManager/labManage.vue index 36c901e..8376bd7 100644 --- a/element-vue/src/components/supManager/labManage.vue +++ b/element-vue/src/components/supManager/labManage.vue @@ -1,143 +1,121 @@ @@ -146,53 +124,101 @@ import addLab from "~/components/supManager/addLab" ; import {get, post} from "~/utils"; - import {showDialog, showFail, showSuccess} from "~/utils/dialog"; + import {closeLoading, showDialog, showDialogWithReject, showFail, showLoading, showSuccess} from "~/utils/dialog"; + import setLabTime from "~/components/supManager/setLabTime"; + export default { - components:{addLab}, - data(){ - return{ - edit:"", - form:{ - type:'0', - position:'0', - status:'0', - }, - time:{ - year:'0', - week:'0', - day1:"0", - day2:"16", - semester:'0' + components: {addLab, setLabTime}, + data() { + return { + edit: false, + setLabTimeDialog: false, + form: {}, + time: { + year: '2019', + semester: 2 }, - - search:'', - tableData:[ - { name:"aaaa" , address:"509"} - ], + search: '', + tableData: [], } }, - methods:{ - showAddLab(){ + methods: { + async load() { + this.tableData = await get('/lb/lab/getLabList') + }, + // 编辑 + async editLab(item) { + // 判断是否为编辑模式 + this.edit = !!item + this.$refs.addLab.form = item ? item : { + position: '', + name: '', + capacity: '', + manager_id: '' + } + this.$refs.addLab.addLabDialog = true console.log(this.$refs.addLab) - this.$refs.addLab.addLabDialog=true - this.$router.push('/supManager/index/labManager') - + // 弹出编辑框 + this.dialogFormVisible = true }, - // 编辑用户 - // async editLab(item) { - // // 判断是否为编辑模式 - // this.edit = !!item - // this.userForm = item ? item : { - // nickname: "", - // tel: "", - // email: "", - // username: "", - // office: "", - // position: '' - // } - // // 弹出编辑框 - // this.dialogFormVisible = true + async submit() { + this.$refs.addLab.form.capacity = parseInt(this.$refs.addLab.form.capacity) + this.$refs.addLab.form.managerId = this.$refs.addLab.form.manager_id + if (this.$refs.addLab.form.lab_id) { + // 编辑 + await showDialog('确认要编辑吗?',this) + this.$refs.addLab.form.labId = this.$refs.addLab.form.lab_id + await post('lb/lab/updateLab', this.$refs.addLab.form).then(async () => { + await this.load() + showSuccess('编辑成功', this) + }).catch(() => { + showFail('编辑失败', this) + }) + + } else { + // 新增 + await showDialog('确认要新增吗?',this) + await showDialogWithReject('是否需要为该实验室添加'+parseInt(this.time.year)+'-'+(parseInt(this.time.year)+1)+'学年第'+this.time.semester+'学期16周的所有时间段?',this).then(async()=>{ + this.$refs.addLab.form.fastInsert = true + this.$refs.addLab.form.year = this.time.year + this.$refs.addLab.form.semester = this.time.semester + console.log(this.$refs.addLab.form) + await this.addLab() + }).catch(async()=>{ + this.$refs.addLab.form.fastInsert = false + await this.addLab() + }) + } + this.$refs.addLab.addLabDialog = false + }, + async addLab(){ + const loading = showLoading('正在新增...', this) + const newLab = await post('lb/lab/addLab', this.$refs.addLab.form).then(async () => { + await this.load() + showSuccess('新增成功', this) + closeLoading(loading) + }).catch(() => { + closeLoading(loading) + showFail('新增失败', this) + }) + }, + // async deleteLab(labId) { + // await showDialog("确定要删除吗?", this) + // await post('lb/lab/deleteLab', {labId}).then(async () => { + // await this.load() + // await showSuccess('删除成功', this) + // }).catch(err => { + // showFail('删除失败,实验室含有时间段时无法删除', this) + // }) // }, + async schedulePreview() { + await showFail('尚未开发', this) + }, + async editSchedule(item) { + this.$refs.setLabTime.lab = item + this.$refs.setLabTime.form.labId = item.lab_id + this.$refs.setLabTime.setLabTimeDialog = true + } }, computed: { // tableDataComputed() { @@ -207,7 +233,8 @@ }, - mounted() { + async mounted() { + await this.load() // this.tableData=get('/url') } } diff --git a/element-vue/src/components/supManager/setLabTime.vue b/element-vue/src/components/supManager/setLabTime.vue index 83790d0..4bdf5b0 100644 --- a/element-vue/src/components/supManager/setLabTime.vue +++ b/element-vue/src/components/supManager/setLabTime.vue @@ -1,8 +1,9 @@ @@ -49,33 +51,43 @@ import tb_course from "~/components/tb_course"; import {get, post, stop} from "~/utils"; import {showDialog, showFail, showSuccess} from "~/utils/dialog"; + export default { - name: "setLabTime", - components:{weekSelection,tb_course}, - data(){ - return{ - form:{ - year:2019, - semester:2, - time:"", + components: {weekSelection, tb_course}, + data() { + return { + lab: { + name: '', + position: '' + }, + form: { + year: '2019', + semester: 2 }, - allWeeksValue:[], - aWeekValue:[], - courseDialog:false, - tableAlive:false, //用于重载表格 - weekDialog:false, + setLabTimeDialog: false, + ableList: [], + weekDisable: [], + allWeeksValue: [], + aWeekValue: [], + courseDialog: false, + tableAlive: false, //用于重载表格 + weekDialog: false, selectOptions1: [ { - value: 2017, + value: '2017', label: '2017-2018年' }, { - value: 2018, + value: '2018', label: '2018-2019年' }, { - value: 2019, + value: '2019', label: '2019-2020年' + }, + { + value: '2020', + label: '2020-2021年' } ], selectOptions2: [ @@ -90,90 +102,108 @@ ], } }, - methods:{ + methods: { //设置周次与节次 - showCourseDialog(){ - console.log('嘿') - this.tableAlive=true - this.courseDialog=true + async showCourseDialog() { + this.tableAlive = true + this.courseDialog = true }, //表格中每个格子的风格 - cellStyle:function({row, column, rowIndex, columnIndex}){ - if (column.label!=''){ + cellStyle: function ({row, column, rowIndex, columnIndex}) { + if (column.label != '') { return 'cursor:pointer' } }, //点击格子促发的函数 - cellClick(row, column, cell, event) { - console.log(row.index) - if (column.label!='') { - this.weekDialog=true - this.perTargetValue=event.target //用target对表格进行定位并保存致target对象 - console.log(this.aWeekValue,this.allWeeksValue) - this.aWeekValue.push(row.index,column.index) - } + async cellClick(row, column, cell, event) { + this.form.weeks = null + this.form.day = column.index + this.form.time = row.index + this.form.uc_id = 0 + console.log(this.form) + const weekAll = await get('lb/labTime/getWeeks', this.form) + const weekAble = await get("lb/labTime/getWeeksAbleBook", this.form) + this.weekDisable = weekAll.filter(elem => !(weekAble.indexOf(elem) > -1)) + this.ableList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18].filter(elem => !(this.weekDisable.indexOf(elem) > -1)) + this.weekDialog = true + // if (column.label != '') { + // this.weekDialog = true + // this.perTargetValue = event.target //用target对表格进行定位并保存致target对象 + // // console.log(this.aWeekValue, this.allWeeksValue) + // this.aWeekValue.push(row.index, column.index) + // } }, //添加已选择的的周数 async addWeek() { - this.weekDialog=false + console.log(this.form) + this.weekDialog = false var targetValue = this.$refs.weekSelection.checkedValue - if(targetValue.length!==0){ - this.perTargetValue.textContent='【'+targetValue+'】周' - this.aWeekValue.push(targetValue) //单个节数时间段添加完成,包括[rowIndex,column,targetValue] - this.allWeeksValue.push(this.aWeekValue) //把单个格子选择的时间段添加到allWeeksValue中 - this.perTargetValue.style.backgroundColor='lightyellow' - for (let i=0;i +
+ {{arr1}} -> {{constrict(arr1)}}
+ {{arr2}}->{{seg(arr2,4)}} +
+ + + + + diff --git a/element-vue/src/components/weekSelection.vue b/element-vue/src/components/weekSelection.vue index a4373fa..b7cea8f 100644 --- a/element-vue/src/components/weekSelection.vue +++ b/element-vue/src/components/weekSelection.vue @@ -10,7 +10,7 @@ - + 确定 @@ -22,6 +22,9 @@ diff --git a/element-vue/src/pages/teacher/applyLab.vue b/element-vue/src/pages/teacher/applyLab.vue index 24463d7..791a5ac 100644 --- a/element-vue/src/pages/teacher/applyLab.vue +++ b/element-vue/src/pages/teacher/applyLab.vue @@ -2,97 +2,94 @@
- + - + - +
- + + + 我的申请记录
- - - - - - - - - - + + + + + + > + + >
- + - - - + + + - + - - - + + + - + - + - + - + -
填写申请时间段 取消
- - + + - - 取 消 - 确 定 - - - - + + +
-
@@ -103,218 +100,227 @@ import timeSelect from "~/components/timeSelect"; import {get, post, stop} from "~/utils"; import {showDialog, showFail, showSuccess} from "~/utils/dialog"; + export default { name: "applyLab", - components:{ - tb_course, - navBar, - weekSelection, - timeSelect + components: { + tb_course, navBar, weekSelection, timeSelect }, - data(){ - return{ - user:{}, - lab:{}, - - tableAlive:false, //用于重载表格 - tableData:[{}], - checkOption :[], + data() { + return { + user: {}, + lab: {}, + ableList: [], + tableAlive: false, //用于重载表格 + tableData: [{}], + checkOption: [], - formDialog:false, - courseDialog:false, - weekDialog:false, + formDialog: false, + courseDialog: false, + weekDialog: false, - perTargetValue:'', - aWeekValue:[], - allWeeksValue:[], + perTargetValue: '', + aWeekValue: [], + allWeeksValue: [], - form:{ - position:'', - name:'', - date: '', - nickname:'', - tel:'', - course_name:'', - class:'', - population:'', - schedule:'', - remind:'无' - }, - courseOption:[] - } + form: { + position: '', + name: '', + date: '', + nickname: '', + tel: '', + course_name: '', + class: '', + population: '', + schedule: '', + remind: '无' + }, + courseOption: [] + } }, - methods:{ + methods: { //表格中每个格子的风格 - cellStyle({row, column, rowIndex, columnIndex}){ - if (column.label!=''){ + cellStyle({row, column, rowIndex, columnIndex}) { + if (column.label != '') { return 'cursor:pointer' } }, //点击格子促发的函数 async cellClick(row, column, cell, event) { - console.log(row.index) + this.form.weeks = null + this.form.day = column.index + this.form.time = row.index + this.form.year = this.$refs.timeSelection.year + this.form.semester = this.$refs.timeSelection.semester + this.ableList = await get("lb/labTime/getWeeksAbleBook", this.form) + this.aWeekValue.push(row.index, column.index) + //(待写)检索该格子的周数申请信息,被申请的周数使其样式变为disable + // let position = this.lab.position + // let rowIndex = row.index + // let columIndex = column.index + // var weeks=get('',{position,rowIndex,columIndex}) //发送给实验室的地址,rowIndex,columIndex返回该格子的周数信息:数组 + // var weeks=[6,7,8] //(待写)检索该格子的周数申请信息,被申请的周数使其样式变为disablevar + if (column.label != '') { + this.perTargetValue = event.target //用target对表格进行定位并保存致target对象 + this.aWeekValue.push(row.index, column.index) - - if (column.label!='') { - this.perTargetValue=event.target //用target对表格进行定位并保存致target对象 - this.aWeekValue.push(row.index,column.index) - - new Promise((resolve,reject)=> { //使weekDialog打开和调用按顺序执行 - this.weekDialog=true + new Promise((resolve, reject) => { //使weekDialog打开和调用按顺序执行 + this.weekDialog = true resolve('打开了weekDialog') - }).then((res)=>{ + }).then((res) => { // console.log(this.$refs.weekSelection) - var position = this.form.position - var rowIndex = row.index - var columnIndex = column.index - var selectedWeeks=get('',{position,rowIndex,columnIndex}) //发送给实验室的地址,rowIndex,columIndex返回该格子的周数信息:数组 - selectedWeeks=[1,2,3] - this.$refs.weekSelection.disableList=selectedWeeks - this.$refs.weekSelection.singleVal=this.$refs.weekSelection.singleVal.filter(x=>!selectedWeeks.includes(x)) - this.$refs.weekSelection.doubleVal=this.$refs.weekSelection.doubleVal.filter(x=>!selectedWeeks.includes(x)) - this.$refs.weekSelection.allVal=this.$refs.weekSelection.allVal.filter(x=>!selectedWeeks.includes(x)) - console.log('aa',this.$refs.weekSelection.singleVal) + // var position = this.form.position + // var rowIndex = row.index + // var columnIndex = column.index + // var selectedWeeks = get('', {position, rowIndex, columnIndex}) //发送给实验室的地址,rowIndex,columIndex返回该格子的周数信息:数组 + // selectedWeeks = [1, 2, 3] + // this.$refs.weekSelection.disableList = selectedWeeks + // this.$refs.weekSelection.singleVal = this.$refs.weekSelection.singleVal.filter(x => !selectedWeeks.includes(x)) + // this.$refs.weekSelection.doubleVal = this.$refs.weekSelection.doubleVal.filter(x => !selectedWeeks.includes(x)) + // this.$refs.weekSelection.allVal = this.$refs.weekSelection.allVal.filter(x => !selectedWeeks.includes(x)) + // console.log('aa', this.$refs.weekSelection.singleVal) }) - } + } }, //点击表格操作栏申请按钮 - clickLabApply(row){ - this.lab=row - this.form={ - position:'', - name:'', - date: '', - nickname:'', - tel:'', - course_name:'', - class:'', - population:'', - schedule:'', - remind:'无' + clickLabApply(row) { + console.log(row) + this.lab = row + this.form = { + labId: row.lab_id, + position: row.position, + name: row.name, + nickname: this.user.nickname, + tel: this.user.tel, + class: '', + population: '', + remind: '无' } - this.formDialog=true - + this.formDialog = true }, //点击查看申请详情 - checkDetail(row){ - this.$router.push('/labApplyDetail/'+row.position) //发送该行的实验室地址作为参数,使得实验室申请详情可以获得此参数后请求并检索数据 + checkDetail(row) { + this.$router.push('/labApplyDetail/' + row.position) //发送该行的实验室地址作为参数,使得实验室申请详情可以获得此参数后请求并检索数据 }, //当选择的课程发生改变触发此函数 - selectChange(){ - console.log('aaaaaa') - // this.form.position= this.lab.position //实验室地点 - // this.form.name= this.lab.name //实验室名称 - // this.form.nickname= this.user.nickname //昵称 - // this.form.tel= this.user.tel //电话 - // this.form.class= this.courseOption.class //班级 - // this.form.population= this.courseOption.population //人数 + async selectChange(uc_id) { + let course = await get("lb/usercourse/findusercourse/" + uc_id) + this.form.class = course.classes + this.form.population = course.population + this.form.uc_id = uc_id }, //添加已选择的的周数 async addWeek() { + this.weekDialog = false + const targetValue = this.$refs.weekSelection.checkedValue + this.form.weeks = targetValue + //提交 + await showDialog("确认预约此时间段吗?", this) + await post('lb/labrecord/updateWeeks', this.form) + await showSuccess("预约成功,管理员正在审核",this) + this.form.weeks = [] - this.weekDialog=false - var targetValue = this.$refs.weekSelection.checkedValue - await showDialog("确认设置此时间段吗?",this) - if(targetValue.length!==0){ - this.perTargetValue.textContent='【'+targetValue+'】周' - this.aWeekValue.push(targetValue) //单个节数时间段添加完成,包括[rowIndex,column,targetValue] - this.allWeeksValue.push(this.aWeekValue) //把单个格子选择的时间段添加到allWeeksValue中 - this.perTargetValue.style.backgroundColor='lightyellow' - for (let i=0;i{ - // if (vailid){ - // this.courseDialog=true - // } - // }) - this.formDialog=false + // cancelSetWeeks: function () { + // this.allWeeksValue = [] + // this.form.schedule = "" + // this.courseDialog = false + // this.formDialog = true + // console.log(this.allWeeksValue) + // this.tableAlive = false //表格失活 + // }, + setTime: function () { + this.tableAlive = true + // alert('这里本来要验证的,为了方便查看表格,暂无设置,需要验证请把代码行注释解除掉') + // this.courseDialog = true + this.$refs.courseForm.validate((valid)=>{ + if (valid){ + this.courseDialog=true + this.formDialog = false + } + }) }, - cancelAppy:function () { - this.formDialog=false + cancelAppy: function () { + this.formDialog = false }, //周次选择器关闭前的回调 - beforeClose(){ - this.weekDialog=false - this.aWeekValue=[] + beforeClose() { + this.weekDialog = false + this.aWeekValue = [] }, //跳转到我的申请记录 - toMyRecord(){ - this.$router.push('/teacher/myApplyRecord/'+this.user.u_id) //这里的user.u_id作为是作为路径参数存在 + toMyRecord() { + this.$router.push('/teacher/myApplyRecord/' + this.user.u_id) //这里的user.u_id作为是作为路径参数存在 + }, + async loadCourse() { + this.courseOption = await get("lb/usercourse/findbyyearandsemester/" + this.$refs.timeSelection.year + "/" + this.$refs.timeSelection.semester) } }, //钩子函数,生命周期mouted async mounted() { - this.courseOption = get('',this.u_id) //发送教师id,返回该教师课程管理中所有的课程信息,是一个数组 + // this.courseOption = get('',this.u_id) //发送教师id,返回该教师课程管理中所有的课程信息,是一个数组 //测试数据 - this.courseOption=[{ + this.courseOption = [{ year: '1819', semester: '2', uc_id: '12345677', @@ -325,11 +331,9 @@ isHaveDocuments: '1', remind: '无', }] - // console.log(this.$refs.detailtb) - console.log('this is mouted') - console.log(this.$refs.weekSelection) - var d = new Date() this.tableData = await get('/lb/lab/getLabList') + this.user = await get('lb/user/getUserInfo') + await this.loadCourse() } } diff --git a/element-vue/src/pages/teacher/myApplyRecord.vue b/element-vue/src/pages/teacher/myApplyRecord.vue index 294a8fa..e6a316c 100644 --- a/element-vue/src/pages/teacher/myApplyRecord.vue +++ b/element-vue/src/pages/teacher/myApplyRecord.vue @@ -11,20 +11,28 @@ - - - - - - - - - - + + + + + + + - + + - @@ -40,25 +48,17 @@ import navBar from "~/components/teacher/navBar"; import {get} from "~/utils"; export default { - name: "myApplyRecord", - props:['u_id'], components: { tb_course, navBar }, data() { return { - tableData: [ - ] + tableData: [] } }, - computed:{ - - }, - mounted() { - get('/lb_teacher_myApplyRecord',this.u_id).then((res)=>{ - this.tableData=res.data - }) + async mounted() { + this.tableData = await get('/lb/labrecord/getRecordBySelf') } } diff --git a/element-vue/src/router.js b/element-vue/src/router.js index b8d1a96..37fae8a 100644 --- a/element-vue/src/router.js +++ b/element-vue/src/router.js @@ -18,12 +18,15 @@ import supHome from "~/components/supManager/home"; import supIndex from "~/components/supManager/index"; import globalPersonal from "~/components/personal"; import userManage from "~/components/supManager/userManage"; -import setLabTime from "~/components/supManager/setLabTime"; import labManager from "~/components/supManager/labManage"; -import check from "~/components/supManager/check"; +import tool from "~/components/tool"; //manager -import home from "~/pages/manager/home"; +import check from "~/components/supManager/check"; + +// manager +import managerHome from "~/components/manager/home" +import managerIndex from "~/components/manager/index"; // 要告诉 vue 使用 vueRouter Vue.use(VueRouter); @@ -58,13 +61,13 @@ const routes = [ component: applyLab }, { - path:'myApplyRecord/:u_id', - component:myApplyRecord, - props:true + path: 'myApplyRecord/:u_id', + component: myApplyRecord, + props: true }, { - path:'courseManagement', - component:courseManagement + path: 'courseManagement', + component: courseManagement }, { path: 'myApplyRecord', @@ -75,12 +78,22 @@ const routes = [ { path: '/manager', component: manager, - children: [ - { - path:'', - component:home - } + children: [{ + path: '', + component: managerHome + },{ + path: 'index', + component: managerIndex, + children: [ + { + path: 'personal', + component: globalPersonal + }, { + path: 'labApply', + component: globalPersonal + } ] + }] }, { path: '/supManager', @@ -97,21 +110,17 @@ const routes = [ { path: 'personal', component: globalPersonal - },{ - path: 'labManage', - component: globalPersonal + }, { + path: 'labManager', + component: labManager }, { path: 'userManage', component: userManage }, { - path:'labManager', - component:labManager - }, - { - path:'check', - component:check + path: 'check', + component: check } ] } @@ -129,11 +138,11 @@ const routes = [ { path: '/labApplyDetail/:id', component: labApplyDetail, - props:true + props: true }, { - path:'/setLabTime', - component: setLabTime + path: '/tool', + component: tool } ] diff --git a/element-vue/src/utils/dialog.js b/element-vue/src/utils/dialog.js index b8de8ee..a6cecf9 100644 --- a/element-vue/src/utils/dialog.js +++ b/element-vue/src/utils/dialog.js @@ -10,6 +10,19 @@ export async function showDialog(content,that){ }).catch(() => {}); }) } + +//询问框带reject +export async function showDialogWithReject(content,that){ + return new Promise((resolve, reject) => { + that.$confirm(content, '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + resolve() + }).catch(() => {reject()}); + }) +} // 显示操作成功 export function showSuccess(content,that) { that.$message({ diff --git a/element-vue/src/utils/index.js b/element-vue/src/utils/index.js index 95c3843..15df463 100644 --- a/element-vue/src/utils/index.js +++ b/element-vue/src/utils/index.js @@ -38,6 +38,8 @@ async function request(url, method, data, params, header = {}) { } else { reject(res.data) } + }).catch(err=>{ + reject(err) }) }) } diff --git a/java/pom.xml b/java/pom.xml index 364a3d9..4738488 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -68,7 +68,11 @@ easyexcel 1.1.2-beta5 - + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 1.3.1 + org.junit.jupiter junit-jupiter diff --git a/java/src/main/java/com/hzu/bookingsystem/bean/LabRecordBean.java b/java/src/main/java/com/hzu/bookingsystem/bean/LabRecordBean.java index 14c054f..6a6c74b 100644 --- a/java/src/main/java/com/hzu/bookingsystem/bean/LabRecordBean.java +++ b/java/src/main/java/com/hzu/bookingsystem/bean/LabRecordBean.java @@ -1,6 +1,7 @@ package com.hzu.bookingsystem.bean; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import javax.persistence.*; @@ -10,6 +11,7 @@ import java.util.Date; @NoArgsConstructor @AllArgsConstructor @Entity +@Builder @Table(name = "tb_lab_record") public class LabRecordBean { @Id diff --git a/java/src/main/java/com/hzu/bookingsystem/controller/LabController.java b/java/src/main/java/com/hzu/bookingsystem/controller/LabController.java index d7bb6d3..3071711 100644 --- a/java/src/main/java/com/hzu/bookingsystem/controller/LabController.java +++ b/java/src/main/java/com/hzu/bookingsystem/controller/LabController.java @@ -2,14 +2,17 @@ package com.hzu.bookingsystem.controller; import com.hzu.bookingsystem.VO.ResultVO; import com.hzu.bookingsystem.bean.LabBean; +import com.hzu.bookingsystem.bean.LabTimeBean; import com.hzu.bookingsystem.converter.Map2Object; import com.hzu.bookingsystem.dto.LabDTO; import com.hzu.bookingsystem.service.LabService; +import com.hzu.bookingsystem.service.LabTimeService; import com.hzu.bookingsystem.utils.ResultVOUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; +import java.util.Date; import java.util.List; import java.util.Map; @@ -19,28 +22,45 @@ import java.util.Map; public class LabController { @Autowired private LabService labService; + @Autowired + private LabTimeService labTimeService; + @Autowired + private UserController userController; //创建实验室 - @PostMapping(value = "/addLab" , consumes = "application/json") - public ResultVO addLab(@RequestBody Map map){ + @PostMapping(value = "/addLab", consumes = "application/json") + public ResultVO addLab(@RequestBody Map map, HttpServletRequest request) { //转换对象 - LabBean lab1 = (LabBean) Map2Object.map2Object(map,LabBean.class); - System.out.println(lab1); - //查重 - if(labService.findByName(lab1.getName()) != null) - { - return ResultVOUtil.error(-1,"该实验室已存在"); + System.out.println(map); + LabBean lab1 = (LabBean) Map2Object.map2Object(map, LabBean.class); + //判断是否 + LabBean newLab = labService.add(lab1); + // 插入16周所有可选时间段 + if ((Boolean) map.get("fastInsert")) { + LabTimeBean labTime1 = (LabTimeBean) Map2Object.map2Object(map, LabTimeBean.class); + for (int i = 1; i <= 7; i++) { + for (int j = 1; j <= 5; j++) { + for (int k = 1; k <= 16; k++) { + labTimeService.add(LabTimeBean.builder() + .labId(newLab.getLabId()) + .year(labTime1.getYear()).semester(labTime1.getSemester()).week(k).day(i).time(j) + .creatorId(userController.getUIdByCookie(request)) + .status(0) + .createTime(new Date()) + .build()); + } + } + } } - labService.add(lab1); return ResultVOUtil.success(); } //通过LabId删除实验室 - @PostMapping(value = "/deleteLab" , consumes = "application/json") - public ResultVO deleteLab(@RequestBody LabBean lab){ + @PostMapping(value = "/deleteLab", consumes = "application/json") + public ResultVO deleteLab(@RequestBody LabBean lab) { //查找实验室是否存在 LabBean lab1 = labService.findByLabId(lab.getLabId()); - if(lab1 == null) { + if (lab1 == null) { return ResultVOUtil.error(-1, "该实验室不存在"); } else { labService.deleteByLabId(lab1.getLabId()); @@ -49,12 +69,12 @@ public class LabController { } //修改实验室信息 - @PostMapping(value = "/updateLab" , consumes = "application/json") - public ResultVO updateLab(@RequestBody Map map , HttpServletRequest request){ + @PostMapping(value = "/updateLab", consumes = "application/json") + public ResultVO updateLab(@RequestBody Map map, HttpServletRequest request) { //转换对象 - LabBean lab1 = (LabBean) Map2Object.map2Object(map,LabBean.class); - if(lab1.getLabId() == null){ - return ResultVOUtil.error(-1,"该实验室不存在,无法修改"); + LabBean lab1 = (LabBean) Map2Object.map2Object(map, LabBean.class); + if (lab1.getLabId() == null) { + return ResultVOUtil.error(-1, "该实验室不存在,无法修改"); } else { labService.update(lab1); } @@ -62,8 +82,8 @@ public class LabController { } //查找实验室 - @GetMapping(value = "/findByLabId" , consumes = "application/json") - public ResultVO> findByLabId(@RequestParam("LabId") Integer labId){ + @GetMapping(value = "/findByLabId", consumes = "application/json") + public ResultVO> findByLabId(@RequestParam("LabId") Integer labId) { LabBean lab1 = labService.findByLabId(labId); System.out.println(lab1); return ResultVOUtil.success(lab1); @@ -71,7 +91,7 @@ public class LabController { //查找所有实验室列表 @GetMapping(value = "/getLabList") - public ResultVO getLabList(){ + public ResultVO getLabList() { List labList = labService.findAllLabInfo(); return ResultVOUtil.success(labList); } diff --git a/java/src/main/java/com/hzu/bookingsystem/controller/LabRecordController.java b/java/src/main/java/com/hzu/bookingsystem/controller/LabRecordController.java index baac990..8d2172b 100644 --- a/java/src/main/java/com/hzu/bookingsystem/controller/LabRecordController.java +++ b/java/src/main/java/com/hzu/bookingsystem/controller/LabRecordController.java @@ -3,13 +3,17 @@ package com.hzu.bookingsystem.controller; import com.hzu.bookingsystem.VO.ResultVO; import com.hzu.bookingsystem.bean.LabRecordBean; +import com.hzu.bookingsystem.bean.LabTimeBean; import com.hzu.bookingsystem.converter.Map2Object; +import com.hzu.bookingsystem.dto.LabRecordDTO; import com.hzu.bookingsystem.service.LabRecordService; +import com.hzu.bookingsystem.service.LabTimeService; import com.hzu.bookingsystem.utils.ResultVOUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; +import java.util.Date; import java.util.List; import java.util.Map; @@ -21,16 +25,22 @@ public class LabRecordController { @Autowired private LabRecordService labrecordService; -// 根据id查看实验室记录 + @Autowired + private LabTimeService labTimeService; + + @Autowired + private UserController userController; + + // 根据id查看实验室记录 @GetMapping(value = "/findlabrecord/{lr_id}") public ResultVO> FindLabRecordId(@PathVariable("lr_id") Integer lr_id) { - LabRecordBean labrecord = labrecordService.findById( lr_id) ; + LabRecordBean labrecord = labrecordService.findById(lr_id); return ResultVOUtil.success(labrecord); } // 查找所有记录列表 @GetMapping(value = "/getlabrecordlist") - public ResultVO getLabRecordList(){ + public ResultVO getLabRecordList() { List labrecordList = labrecordService.findAll(); return ResultVOUtil.success(labrecordList); @@ -46,31 +56,91 @@ public class LabRecordController { // 增加申请记录 @PostMapping(value = "/addlabrecord", consumes = "application/json") - public ResultVO addLabRecord(@RequestBody Map map) { - LabRecordBean labrecord = (LabRecordBean) Map2Object.map2Object(map,LabRecordBean.class); + public ResultVO addLabRecord(@RequestBody Map map) { + LabRecordBean labrecord = (LabRecordBean) Map2Object.map2Object(map, LabRecordBean.class); labrecordService.add(labrecord); return ResultVOUtil.success(); } //更新记录 @PostMapping(value = "/updatelabrecord", consumes = "application/json") - public ResultVO updateLabRecord(@RequestBody Map map, HttpServletRequest request){ - LabRecordBean labrecord = (LabRecordBean) Map2Object.map2Object(map,LabRecordBean.class); - LabRecordBean labrecordnew = labrecordService.update(labrecord) ; + public ResultVO updateLabRecord(@RequestBody Map map, HttpServletRequest request) { + LabRecordBean labrecord = (LabRecordBean) Map2Object.map2Object(map, LabRecordBean.class); + LabRecordBean labrecordnew = labrecordService.update(labrecord); return ResultVOUtil.success(labrecordnew); } // 通过lr_id删除记录 @PostMapping(value = "/deletelabrecord/{lr_id}", consumes = "application/json") - public ResultVO deleteLabRecord(@PathVariable("lr_id") Integer lr_id){ + public ResultVO deleteLabRecord(@PathVariable("lr_id") Integer lr_id) { // 查找该用户看是否存在 LabRecordBean labrecord = labrecordService.findById(lr_id); - if (labrecord == null){ - return ResultVOUtil.error(-1,"记录不存在"); + if (labrecord == null) { + return ResultVOUtil.error(-1, "记录不存在"); } // 删除记录 labrecordService.deleteById(lr_id); return ResultVOUtil.success(); } -} + /** + * author 吴志岳 + * 通过uid查询预约记录 + */ + @GetMapping("/getRecordBySelf") + public ResultVO getRecordBySelf(HttpServletRequest request) { + List labRecordDTOList = labrecordService.findRecordListByUId(userController.getUIdByCookie(request)); + return ResultVOUtil.success(labRecordDTOList); + } + + /** + * 更改选课时间段 + */ + @PostMapping(value = "/updateWeeks", consumes = "application/json") + public ResultVO updateWeeks(@RequestBody Map map, HttpServletRequest request) { + //1. 转换对象 + LabTimeBean labTime = (LabTimeBean) Map2Object.map2Object(map, LabTimeBean.class); + Integer uc_id = (Integer)map.get("uc_id"); + List weeks = (List)map.get("weeks"); + System.out.println(labTime); + System.out.println(uc_id); + System.out.println(weeks); + //2. 定义对象 + LabRecordBean labRecordBean = new LabRecordBean(); + labRecordBean.setStatus(0); + labRecordBean.setUcId(uc_id); + + //3. DAO + List weekAble = labTimeService.findWeeksAble(labTime.getLabId(),labTime.getYear(),labTime.getSemester(),labTime.getDay(),labTime.getTime(),uc_id); + //判断是否选择不可选周数 + for (Integer i :weeks){ + if (!weekAble.contains(i)) + return ResultVOUtil.error(-1,"选择了不可选的周数"); + } + + List labTimeBeanList = labTimeService.findTimes(labTime.getLabId(),labTime.getYear(),labTime.getSemester(),labTime.getDay(),labTime.getTime()); + //过滤不可选取 + for (LabTimeBean labTimeBean: labTimeBeanList){ + if (!weekAble.contains(labTimeBean.getWeek())) + labTimeBeanList.remove(labTime); + } + + //4. 删除record + for (LabTimeBean labTimeBean: labTimeBeanList){ + labrecordService.deleteByLtIdAndUcId(labTimeBean.getLtId(),uc_id); + } + + //5. 插入record + for (LabTimeBean labTimeBean: labTimeBeanList){ + if (weeks.contains(labTimeBean.getWeek())){ + LabRecordBean labRecordBean1 = new LabRecordBean().builder() + .ltId(labTimeBean.getLtId()) + .ucId(uc_id) + .status(0) + .build(); + labrecordService.add(labRecordBean1); + } + } + return ResultVOUtil.success(); + } +} \ No newline at end of file diff --git a/java/src/main/java/com/hzu/bookingsystem/controller/LabTimeController.java b/java/src/main/java/com/hzu/bookingsystem/controller/LabTimeController.java index 10ee57b..66f9d61 100644 --- a/java/src/main/java/com/hzu/bookingsystem/controller/LabTimeController.java +++ b/java/src/main/java/com/hzu/bookingsystem/controller/LabTimeController.java @@ -92,8 +92,9 @@ public class LabTimeController { @RequestParam("year") String year, @RequestParam("semester") Integer semester, @RequestParam("day") Integer day, - @RequestParam("time") Integer time) { - List weeks = labTimeService.findWeeksAble(lab_id, year, semester, day, time); + @RequestParam("time") Integer time, + @RequestParam("uc_id") Integer uc_id) { + List weeks = labTimeService.findWeeksAble(lab_id, year, semester, day, time, uc_id); return ResultVOUtil.success(weeks); } @@ -106,18 +107,18 @@ public class LabTimeController { labTime.setCreateTime(new Date()); labTime.setStatus(0); // 用户发起的修改请求 - List weeks = (List)map.get("weeks"); + List weeks = (List) map.get("weeks"); // 实验室预约时间段 - List weeksAll = labTimeService.findWeeks(labTime.getLabId(),labTime.getYear(),labTime.getSemester(),labTime.getDay(),labTime.getTime()); + List weeksAll = labTimeService.findWeeks(labTime.getLabId(), labTime.getYear(), labTime.getSemester(), labTime.getDay(), labTime.getTime()); // 实验室可预约时间段 - List weeksAble = labTimeService.findWeeksAble(labTime.getLabId(),labTime.getYear(),labTime.getSemester(),labTime.getDay(),labTime.getTime()); + List weeksAble = labTimeService.findWeeksAble(labTime.getLabId(), labTime.getYear(), labTime.getSemester(), labTime.getDay(), labTime.getTime()); // 实验室不可变换或不可选取的时间段 List weeksDisable = new ArrayList<>(weeksAll); weeksDisable.removeAll(weeksAble); // 如果请求weeks中不包含不可选取的时间段,报错 - if (!weeks.containsAll(weeksDisable)){ - return ResultVOUtil.error(-1,"已被预约的时间段无法去除"); + if (!weeks.containsAll(weeksDisable)) { + return ResultVOUtil.error(-1, "已被预约的时间段无法去除"); } // 2. 数据处理 @@ -126,18 +127,18 @@ public class LabTimeController { weekInsert.removeAll(weeksAll); // 需要delete的weeks - List weekDelete = new ArrayList<>(weeksAll); + List weekDelete = new ArrayList<>(weeksAll); weekDelete.removeAll(weeks); // 3.批量删除 - List labTimeBeans = labTimeService.findTimes(labTime.getLabId(),labTime.getYear(),labTime.getSemester(),labTime.getDay(),labTime.getTime()); + List labTimeBeans = labTimeService.findTimes(labTime.getLabId(), labTime.getYear(), labTime.getSemester(), labTime.getDay(), labTime.getTime()); labTimeBeans.removeIf(labTimeBean -> !weekDelete.contains(labTimeBean.getWeek())); - for (LabTimeBean labTimeBean : labTimeBeans){ + for (LabTimeBean labTimeBean : labTimeBeans) { labTimeService.deleteByLtId(labTimeBean.getLtId()); } // 4.批量插入 - for (int i : weekInsert){ + for (int i : weekInsert) { LabTimeBean temp = LabTimeBean.builder().labId(labTime.getLabId()) .year(labTime.getYear()) .semester(labTime.getSemester()) @@ -151,11 +152,36 @@ public class LabTimeController { labTimeService.add(temp); } - System.out.println("用户请求"+weeks); - System.out.println("原来有的"+weeksAll); - System.out.println("要插入的"+weekInsert); - System.out.println("要删除的"+weekDelete); - return ResultVOUtil.success(labTimeService.findWeeks(labTime.getLabId(),labTime.getYear(),labTime.getSemester(),labTime.getDay(),labTime.getTime())); + System.out.println("用户请求" + weeks); + System.out.println("原来有的" + weeksAll); + System.out.println("要插入的" + weekInsert); + System.out.println("要删除的" + weekDelete); + return ResultVOUtil.success(labTimeService.findWeeks(labTime.getLabId(), labTime.getYear(), labTime.getSemester(), labTime.getDay(), labTime.getTime())); } + +// /** +// * author 吴志岳 +// * 一键插入该学年学期 16周所有可选时间段 +// */ +// @PostMapping(value = "/fastInsert", consumes = "application/json") +// public ResultVO fastInsert(@RequestBody Map map, HttpServletRequest request) { +// //转换对象 +// LabTimeBean labTime1 = (LabTimeBean) Map2Object.map2Object(map, LabTimeBean.class); +// // 插入16周所有可选时间段 +// for (int i = 1; i <= 7; i++) { +// for (int j = 1; j <= 5; j++) { +// for (int k = 1; k <= 16; k++){ +// labTimeService.add(LabTimeBean.builder() +// .labId((Integer)map.get("labId")) +// .year(labTime1.getYear()).semester(labTime1.getSemester()).week(k).day(i).time(j) +// .creatorId(userController.getUIdByCookie(request)) +// .status(0) +// .createTime(new Date()) +// .build()); +// } +// } +// } +// return ResultVOUtil.success(); +// } } diff --git a/java/src/main/java/com/hzu/bookingsystem/dto/LabRecordDTO.java b/java/src/main/java/com/hzu/bookingsystem/dto/LabRecordDTO.java new file mode 100644 index 0000000..88278cc --- /dev/null +++ b/java/src/main/java/com/hzu/bookingsystem/dto/LabRecordDTO.java @@ -0,0 +1,38 @@ +package com.hzu.bookingsystem.dto; + + +import lombok.Data; + +import javax.persistence.Entity; +import javax.persistence.Id; + +@Data +public class LabRecordDTO { + // 学年 + private String year; + + // 学期 + private Integer semester; + + // 几周 + private Integer week; + + // 周几 + private Integer day; + + // 第几节课 + private Integer time; + + private Integer status; + + //UC + private String course_name; + private Integer population; + private String classes; + + //LAB + private String lab_name; + + private String position; + +} diff --git a/java/src/main/java/com/hzu/bookingsystem/repository/LabRecordDTOMapper.java b/java/src/main/java/com/hzu/bookingsystem/repository/LabRecordDTOMapper.java new file mode 100644 index 0000000..b190b0d --- /dev/null +++ b/java/src/main/java/com/hzu/bookingsystem/repository/LabRecordDTOMapper.java @@ -0,0 +1,46 @@ +package com.hzu.bookingsystem.repository; + +import com.hzu.bookingsystem.dto.LabRecordDTO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +@Mapper +public interface LabRecordDTOMapper { + @Select("SELECT " + + " tb_lab_time.`year`, " + + " tb_lab_time.semester, " + + "COUNT(tb_lab_time.`week`) AS `week`,"+ + " tb_lab_time.`day`, " + + " tb_lab_time.time, " + + " tb_lab_record.`status`, " + + " tb_user_course.`name` AS course_name, " + + " tb_user_course.population, " + + " tb_user_course.classes, " + + " tb_lab.`name` AS lab_name, " + + " tb_lab.position " + + "FROM " + + " tb_lab_time " + + " INNER JOIN " + + " tb_lab_record " + + " ON " + + " tb_lab_time.lt_id = tb_lab_record.lt_id " + + " INNER JOIN " + + " tb_lab " + + " ON " + + " tb_lab_time.lab_id = tb_lab.lab_id, " + + " tb_user_course " + + "WHERE " + + " tb_lab_time.lt_id = tb_lab_record.lt_id AND " + + " tb_lab_record.uc_id = tb_user_course.uc_id AND " + + " tb_lab_time.lab_id = tb_lab.lab_id AND " + + " tb_user_course.u_id = #{uId} " + + "GROUP BY " + + " tb_lab_time.`year`, " + + " tb_lab_time.semester, " + + " tb_lab_time.`day`, " + + " tb_lab_time.time, " + + " tb_lab_record.`status`") + List getRecordListByUId(Integer uId); +} diff --git a/java/src/main/java/com/hzu/bookingsystem/repository/LabRecordRepository.java b/java/src/main/java/com/hzu/bookingsystem/repository/LabRecordRepository.java index 1595fbf..b57abf8 100644 --- a/java/src/main/java/com/hzu/bookingsystem/repository/LabRecordRepository.java +++ b/java/src/main/java/com/hzu/bookingsystem/repository/LabRecordRepository.java @@ -26,6 +26,8 @@ public interface LabRecordRepository extends JpaRepository List findByUcIdAndStatus(Integer uc_id , Integer status); + void deleteByLtIdAndUcId(Integer lt_id,Integer uc_id); + } diff --git a/java/src/main/java/com/hzu/bookingsystem/repository/LabTimeRepository.java b/java/src/main/java/com/hzu/bookingsystem/repository/LabTimeRepository.java index 2227902..0fec494 100644 --- a/java/src/main/java/com/hzu/bookingsystem/repository/LabTimeRepository.java +++ b/java/src/main/java/com/hzu/bookingsystem/repository/LabTimeRepository.java @@ -85,4 +85,24 @@ public interface LabTimeRepository extends JpaRepository { " tb_lab_time.lt_id not in (select lt_id from tb_lab_record where status is not null)" , nativeQuery = true) List findWeeksAbleBook(Integer lab_id, String year, Integer semester, Integer day, Integer time) ; + @Query(value = "SELECT " + + " tb_lab_time.* " + + "FROM " + + "tb_lab_time LEFT JOIN tb_lab_record ON tb_lab_time.lt_id=tb_lab_record.lt_id " + + "WHERE " + + " tb_lab_time.lab_id = ?1 AND " + + " tb_lab_time.`year` = ?2 AND " + + " tb_lab_time.semester = ?3 AND " + + " tb_lab_time.`day` = ?4 AND " + + " tb_lab_time.time = ?5 AND " + + " tb_lab_time.lt_id not in (select lt_id from tb_lab_record where status is not null)" + + "OR " + + " tb_lab_time.lab_id = ?1 AND " + + " tb_lab_time.`year` = ?2 AND " + + " tb_lab_time.semester = ?3 AND " + + " tb_lab_time.`day` = ?4 AND " + + " tb_lab_time.time = ?5 AND " + + "tb_lab_record.uc_id = ?6" , nativeQuery = true) + List findWeeksAbleBook(Integer lab_id, String year, Integer semester, Integer day, Integer time,Integer uc_id) ; + } diff --git a/java/src/main/java/com/hzu/bookingsystem/service/LabRecordService.java b/java/src/main/java/com/hzu/bookingsystem/service/LabRecordService.java index 43a11b1..cb6463d 100644 --- a/java/src/main/java/com/hzu/bookingsystem/service/LabRecordService.java +++ b/java/src/main/java/com/hzu/bookingsystem/service/LabRecordService.java @@ -2,6 +2,7 @@ package com.hzu.bookingsystem.service; import com.hzu.bookingsystem.bean.LabRecordBean; +import com.hzu.bookingsystem.dto.LabRecordDTO; import java.util.List; @@ -65,6 +66,17 @@ public interface LabRecordService { String[][] getcourseByuser(Integer u_id , String year ,Integer semester ) ; + /** + * author 吴志岳 + * 查看自己的审核记录 + */ + List findRecordListByUId(Integer uId); + + /** + * author 吴志岳 + * 根据LTid与UCid删除LR + */ + void deleteByLtIdAndUcId(Integer LtId,Integer UcId); diff --git a/java/src/main/java/com/hzu/bookingsystem/service/LabTimeService.java b/java/src/main/java/com/hzu/bookingsystem/service/LabTimeService.java index f73348e..75c906c 100644 --- a/java/src/main/java/com/hzu/bookingsystem/service/LabTimeService.java +++ b/java/src/main/java/com/hzu/bookingsystem/service/LabTimeService.java @@ -83,6 +83,14 @@ public interface LabTimeService { */ List findWeeksAble(Integer lab_id,String year,Integer semester, Integer day,Integer time) ; + /** + * 通过学期、周、星期、上课时间、ucid查找实验室可预约时间段周次 + *author 吴志岳 + * @param lab_id、year、semester + * @return List + */ + List findWeeksAble(Integer lab_id,String year,Integer semester, Integer day,Integer time,Integer uc_id) ; + /** * 通过学年、学期、星期、上课时间查找实验室预约时间段 */ diff --git a/java/src/main/java/com/hzu/bookingsystem/service/impl/LabRecordServiceImpl.java b/java/src/main/java/com/hzu/bookingsystem/service/impl/LabRecordServiceImpl.java index 6ee5a38..f8ba77b 100644 --- a/java/src/main/java/com/hzu/bookingsystem/service/impl/LabRecordServiceImpl.java +++ b/java/src/main/java/com/hzu/bookingsystem/service/impl/LabRecordServiceImpl.java @@ -4,15 +4,23 @@ import com.hzu.bookingsystem.bean.LabRecordBean; import com.hzu.bookingsystem.bean.LabTimeBean; import com.hzu.bookingsystem.bean.UserBean; import com.hzu.bookingsystem.bean.UserCourseBean; +import com.hzu.bookingsystem.dto.LabRecordDTO; +import com.hzu.bookingsystem.dto.LabTimeDTO; +import com.hzu.bookingsystem.repository.LabRecordDTOMapper; import com.hzu.bookingsystem.repository.LabRecordRepository; import com.hzu.bookingsystem.service.LabRecordService; import com.hzu.bookingsystem.service.LabTimeService; import com.hzu.bookingsystem.service.UserCourseService; import com.hzu.bookingsystem.service.UserService; +import org.hibernate.SQLQuery; +import org.hibernate.transform.Transformers; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; import javax.transaction.Transactional; import java.util.List; @@ -27,6 +35,11 @@ public class LabRecordServiceImpl implements LabRecordService{ @Resource private UserService userservice ; + @Resource + private LabRecordDTOMapper labRecordDTOMapper; + + @PersistenceContext + private EntityManager entityManager; @Override public LabRecordBean add(LabRecordBean labrcecord) { labrcecord.setLrId(null); @@ -147,4 +160,22 @@ public class LabRecordServiceImpl implements LabRecordService{ } return value_name ; } + + /** + * 通过uid查询审核记录 + * author 吴志岳 + */ + + @Override + public List findRecordListByUId(Integer uId) { + return labRecordDTOMapper.getRecordListByUId(13); + } + + @Transactional + @Override + public void deleteByLtIdAndUcId(Integer ltId, Integer ucId) { + labrecordRepository.deleteByLtIdAndUcId(ltId,ucId); + } + + } diff --git a/java/src/main/java/com/hzu/bookingsystem/service/impl/LabTimeServiceImpl.java b/java/src/main/java/com/hzu/bookingsystem/service/impl/LabTimeServiceImpl.java index a829d52..f8551c2 100644 --- a/java/src/main/java/com/hzu/bookingsystem/service/impl/LabTimeServiceImpl.java +++ b/java/src/main/java/com/hzu/bookingsystem/service/impl/LabTimeServiceImpl.java @@ -119,6 +119,24 @@ public class LabTimeServiceImpl implements LabTimeService { return weeks; } + /** + * author 吴志岳 + * + * @param lab_id、year、semester + * @param year + * @param semester + * @return + */ + @Override + public List findWeeksAble(Integer lab_id, String year, Integer semester, Integer day, Integer time,Integer uc_id) { + List list = labTimeRepository.findWeeksAbleBook(lab_id, year, semester, day, time, uc_id); + List weeks = new ArrayList<>(); + for (LabTimeBean labtime : list) { + weeks.add(labtime.getWeek()); + } + return weeks; + } + @Override public List findTimes(Integer lab_id, String year, Integer semester, Integer day, Integer time) { return labTimeRepository.findByLabIdAndYearAndSemesterAndDayAndTime(lab_id, year, semester, day, time); diff --git a/java/src/main/resources/application.yml b/java/src/main/resources/application.yml index 62da168..99e9ee3 100644 --- a/java/src/main/resources/application.yml +++ b/java/src/main/resources/application.yml @@ -23,4 +23,6 @@ spring: useGlobalDataourceStat: true connectionProperties: druid.stat.mergeSql=true:druid.stat.slowSqlMillis=500 - +mybatis: + # 指定sql映射文件位置 + mapper-locations: classpath:mybatis/mapper/*.xml