完成班级模块的所有接口
This commit is contained in:
parent
8dc7233645
commit
a3f430f02d
|
|
@ -63,4 +63,11 @@ export default {
|
|||
responseType: 'blob',
|
||||
params: config,
|
||||
}),
|
||||
getAssistantByClassIdPage: (data) => request.post('/adminusers/getAssistantByClassIdPage', data),
|
||||
deleteClassAssistant: (data) => request.post('/assistantClass/deleteClassAssistant', data),
|
||||
findAdminuserByAccount: (data) =>
|
||||
request.post('/adminusers/findAdminuserByAccount', data, { noNeedToken: true }),
|
||||
addClassAssistant: (data) => request.post('/assistantClass/addClassAssistant', data),
|
||||
getAssistantNotBelongClass: (data) =>
|
||||
request.post('/adminusers/getAssistantNotBelongClass', data),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,8 +46,10 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import ClassAssistantAdd from "./components/class-assistant-add.vue";
|
||||
|
||||
import {PROBLEM_TAB_NAMES} from "@/constant";
|
||||
import ClassAssistantSelect from "@/views/admin/class/components/class-assistant-select.vue";
|
||||
import { PROBLEM_TAB_NAMES } from '@/constant'
|
||||
import ClassAssistantSelect
|
||||
from '@/views/admin/class/components/class-assistant-select.vue'
|
||||
import ClassAssistantAdd
|
||||
from '@/views/admin/class/components/class-assistant-add.vue'
|
||||
</script>
|
||||
|
|
@ -62,9 +62,7 @@ const classInfoValue = ref({
|
|||
pageNum:paginationReactive.page,
|
||||
pageSize:paginationReactive.pageSize,
|
||||
});
|
||||
const onAdd = ()=>{
|
||||
router.push({name: 'ClassAssistantAdd',params:{clId}})
|
||||
}
|
||||
|
||||
const columns = [
|
||||
{
|
||||
key: 'no',
|
||||
|
|
@ -128,8 +126,11 @@ const onChangePage = (page) => {
|
|||
queryByPage()
|
||||
}
|
||||
}
|
||||
const onDetailedAssistant = async (classId)=>{
|
||||
const {id} = classId
|
||||
const onAdd = ()=>{
|
||||
router.push({name: 'ClassAssistantAdd',params:{clId}})
|
||||
}
|
||||
const onDetailedAssistant = async (assistantId)=>{
|
||||
const {id} = assistantId
|
||||
await router.push({name: 'ClassAssistantDetail', params: {clId: id}})
|
||||
}
|
||||
const onPasswordAssistant= async (classId)=>{
|
||||
|
|
@ -142,7 +143,7 @@ const onDeleteAssistant = async (classId)=>{
|
|||
const ids=classInfoValue.value.classId
|
||||
const idss=parseInt(ids)
|
||||
try {
|
||||
const res = await api.deleteClassAssistan({
|
||||
const res = await api.deleteClassAssistant({
|
||||
classId:idss,
|
||||
assistantId:id,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
<n-form-item v-if="
|
||||
userStore.getRole().length > 0 && (userStore.getRole().some((r) => r === 'admin'|| userStore.getRole().some((r) => r === 'teacher')))
|
||||
">
|
||||
<n-button type="primary" style="margin-right: 10px" @click="onAdd">添加课程班级</n-button>
|
||||
<n-button type="primary" style="margin-right: 10px" @click="onAdd">添加班级</n-button>
|
||||
</n-form-item>
|
||||
</div>
|
||||
</n-form>
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ const path=ref('')
|
|||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const userStore = useUserStore()
|
||||
const ids=userStore.getSchoolId()
|
||||
// const ids=userStore.getSchoolId()
|
||||
const loading = ref(true)
|
||||
const {clId}=route.params
|
||||
const assistantInfoValue = ref({
|
||||
|
|
@ -93,14 +93,14 @@ const Add=async ()=>{
|
|||
password:sha256(assistantInfoValue.value.password.trim()).toString(),
|
||||
sessionId: generateRandomString(64)+assistantInfoValue.value.password.trim(),
|
||||
no:assistantInfoValue.value.no,
|
||||
schoolId:ids
|
||||
// schoolId:ids
|
||||
})
|
||||
if (res.code==='400'){
|
||||
}else {
|
||||
if (res.data !== null) {
|
||||
const res1 = await api.findAdminuserByAccount({
|
||||
account: assistantInfoValue.value.account,
|
||||
schoolId: ids
|
||||
// schoolId: ids
|
||||
})
|
||||
await api.addClassAssistant({
|
||||
classId: clId,
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@
|
|||
|
||||
<script setup>
|
||||
import {onMounted, reactive, ref} from "vue";
|
||||
import ProblemActions from "@/views/admin/question/components/ProblemActions.vue";
|
||||
import api from "@/api/admin";
|
||||
import {useRoute, useRouter} from 'vue-router';
|
||||
import AssistantAction from "@/views/admin/class/components/assistant-action.vue";
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class HttpInterceptorConfig extends WebMvcConfigurationSupport {
|
|||
"/api/adminusers" +
|
||||
"/signTeacher",
|
||||
"/api/adminusers" +
|
||||
"/confirmQuestionAnswer","/api/adminusers/updatePasswordByAccount");
|
||||
"/confirmQuestionAnswer","/api/adminusers/updatePasswordByAccount","/api/adminusers/findAdminuserByAccount");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -273,6 +273,37 @@ public class AdminusersController {
|
|||
}
|
||||
|
||||
}
|
||||
@PostMapping("/findAdminuserByAccount")
|
||||
public RespBean findAdminuserByAccount(@RequestBody PMAdminusers pmadminusers) {
|
||||
PMAdminusers adminuser = adminusersServiceI
|
||||
.getAdminuserByAccount(pmadminusers.getAccount());
|
||||
if (adminuser != null) {
|
||||
return RespBean.ok("查询教师信息成功", adminuser);
|
||||
} else {
|
||||
return RespBean.ok("查询教师信息失败");
|
||||
}
|
||||
}
|
||||
@PostMapping("/getAssistantNotBelongClass")
|
||||
public RespBean getAssistantNotBelongClass(@RequestBody UAdminusers uAdminusers) // 查看不属于班级的助教
|
||||
{
|
||||
if(uAdminusers.getPageNum() < 1 || uAdminusers.getPageSize() < 1)
|
||||
return RespBean.error("参数错误");
|
||||
DataGrid dg = adminusersServiceI
|
||||
.getAssistantNotBelongClass(uAdminusers.getClassId(),
|
||||
uAdminusers.getAccount(), uAdminusers.getName(), uAdminusers.getEmail(), uAdminusers.getNo(), uAdminusers.getPageNum(), uAdminusers.getPageSize());
|
||||
return RespBean.ok("查看不属于班级的助教信息成功", dg);
|
||||
|
||||
}
|
||||
@PostMapping("/getAssistantByClassIdPage")
|
||||
public RespBean getAssistantByClassIdPage(@RequestBody UAdminusers uAdminusers) // 获取班级所属的助教
|
||||
{
|
||||
if(uAdminusers.getPageNum() < 1 || uAdminusers.getPageSize() < 1)
|
||||
return RespBean.error("参数错误");
|
||||
|
||||
DataGrid dg = adminusersServiceI
|
||||
.getAssistantByClassIdPage(uAdminusers.getClassId(), uAdminusers.getPageNum(), uAdminusers.getPageSize());
|
||||
return RespBean.ok("查看助教信息成功", dg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
package com.example.aes.user.controller;
|
||||
|
||||
|
||||
import com.example.aes.global.model.RespBean;
|
||||
import com.example.aes.user.dao.AssistantClassDaoI;
|
||||
import com.example.aes.user.model.UAssistant;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/assistantClass")
|
||||
@Transactional
|
||||
public class AssistantClassController {
|
||||
@Autowired
|
||||
AssistantClassDaoI assistantClassDao;
|
||||
|
||||
|
||||
|
||||
@PostMapping("/deleteClassAssistant")
|
||||
public RespBean deleteClassAssistant(@RequestBody UAssistant uAssistant) // 删除班级的助教
|
||||
{
|
||||
boolean result = assistantClassDao.delAssistantClass(uAssistant.getAssistantId(),
|
||||
uAssistant.getClassId());
|
||||
if (result) {
|
||||
return RespBean.ok("删除班级助教成功");
|
||||
} else {
|
||||
return RespBean.error("删除班级助教失败");
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/addClassAssistant")
|
||||
public RespBean addClassAssistant(@RequestBody UAssistant uAssistant) // 为班级添加助教
|
||||
{
|
||||
boolean result = assistantClassDao.addAssistantClass(uAssistant.getAssistantId(),
|
||||
uAssistant.getClassId());
|
||||
if (result) {
|
||||
return RespBean.ok("添加班级助教成功");
|
||||
} else {
|
||||
return RespBean.error("添加班级助教失败");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -26,4 +26,13 @@ public interface AdminusersDaoI extends BaseDaoI<Adminusers> {
|
|||
public boolean addAdminuser(PMAdminusers pmadminusers); // 添加教师
|
||||
public Map<String, String> findTeachersByteacherIdList(String teacherIdList);
|
||||
public List<Adminusers> getTeacher();
|
||||
public long getAssistantByClassIdNum(int classId);
|
||||
|
||||
public List<Adminusers> getAssistantByClassIdPage(int classId, int pageNum, int pageSize); // 获取班级所属的助教
|
||||
|
||||
public List<Adminusers> getAssistantNotBelongClass(int classId,
|
||||
String account, String name, String email, String no, int pageNum, int pageSize); // 查看不属于班级的助教
|
||||
|
||||
public long getAssistantNotBelongClassNum(int classId,
|
||||
String account, String name, String email, String no);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,5 +373,77 @@ public class AdminusersDaoImpl extends BaseDaoImpl<Adminusers> implements
|
|||
List<Adminusers> adminusersList = this.find(hql);
|
||||
return adminusersList;
|
||||
}
|
||||
@Override
|
||||
public long getAssistantByClassIdNum(int classId){
|
||||
String hql = "select count(distinct(a)) from Adminusers a,AssistantClass ac where a.id=ac.assistantId and ac.classId="
|
||||
+ classId;
|
||||
return this.count(hql).longValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Adminusers> getAssistantByClassIdPage(int classId, int pageNum, int pageSize){
|
||||
// TODO Auto-generated method stub
|
||||
String hql = "select distinct(a) from Adminusers a,AssistantClass ac where a.id=ac.assistantId and ac.classId="
|
||||
+ classId;
|
||||
return this.find(hql, pageNum, pageSize);
|
||||
}
|
||||
@Override
|
||||
public List<Adminusers> getAssistantNotBelongClass(int classId,
|
||||
String account, String name, String email, String no, int pageNum, int pageSize) {
|
||||
// TODO Auto-generated method stub
|
||||
String hql = "select distinct(a) from Adminusers a where a.role='assistant' and a.id not in (select ac.assistantId from AssistantClass ac where ac.classId=:classId)";
|
||||
if (account != null && account.length() > 0) {
|
||||
hql = hql + " and a.account like :account";
|
||||
}
|
||||
if (name != null && name.length() > 0) {
|
||||
hql = hql + " and a.name like :name";
|
||||
}
|
||||
if(email != null && email.length() > 0){
|
||||
hql = hql + " and a.email like :email";
|
||||
}
|
||||
if(no != null && no.length() > 0){
|
||||
hql = hql + " and a.no like :no";
|
||||
}
|
||||
Query q = this.getCurrentSession().createQuery(hql);
|
||||
q.setParameter("classId", classId);
|
||||
if (account != null && account.length() > 0)
|
||||
q.setParameter("account", "%" + account + "%");
|
||||
if (name != null && name.length() > 0)
|
||||
q.setParameter("name", "%" + name + "%");
|
||||
if(email != null && email.length() > 0)
|
||||
q.setParameter("email","%" + email + "%");
|
||||
if(no != null && no.length() > 0)
|
||||
q.setParameter("no", "%" + no + "%");
|
||||
return q.setFirstResult((pageNum - 1) * pageSize).setMaxResults(pageSize).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAssistantNotBelongClassNum(int classId,
|
||||
String account, String name, String email, String no){
|
||||
// TODO Auto-generated method stub
|
||||
String hql = "select distinct(a) from Adminusers a where a.role='assistant' and a.id not in (select ac.assistantId from AssistantClass ac where ac.classId=:classId)";
|
||||
if (account != null && account.length() > 0) {
|
||||
hql = hql + " and a.account like :account";
|
||||
}
|
||||
if (name != null && name.length() > 0) {
|
||||
hql = hql + " and a.name like :name";
|
||||
}
|
||||
if(email != null && email.length() > 0){
|
||||
hql = hql + " and a.email like :email";
|
||||
}
|
||||
if(no != null && no.length() > 0){
|
||||
hql = hql + " and a.no like :no";
|
||||
}
|
||||
Query q = this.getCurrentSession().createQuery(hql);
|
||||
q.setParameter("classId", classId);
|
||||
if (account != null && account.length() > 0)
|
||||
q.setParameter("account", "%" + account + "%");
|
||||
if (name != null && name.length() > 0)
|
||||
q.setParameter("name", "%" + name + "%");
|
||||
if(email != null && email.length() > 0)
|
||||
q.setParameter("email","%" + email + "%");
|
||||
if(no != null && no.length() > 0)
|
||||
q.setParameter("no", "%" + no + "%");
|
||||
return q.list().size();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
package com.example.aes.user.model;
|
||||
|
||||
public class UAssistant {
|
||||
private int assistantId;
|
||||
private int classId;
|
||||
|
||||
public UAssistant(){}
|
||||
|
||||
public UAssistant(int assistantId, int classId) {
|
||||
this.assistantId = assistantId;
|
||||
this.classId = classId;
|
||||
}
|
||||
|
||||
public int getAssistantId() {
|
||||
return assistantId;
|
||||
}
|
||||
|
||||
public void setAssistantId(int assistantId) {
|
||||
this.assistantId = assistantId;
|
||||
}
|
||||
|
||||
public int getClassId() {
|
||||
return classId;
|
||||
}
|
||||
|
||||
public void setClassId(int classId) {
|
||||
this.classId = classId;
|
||||
}
|
||||
}
|
||||
|
|
@ -28,5 +28,8 @@ public interface AdminusersServiceI {
|
|||
public boolean editAdminuser(PMAdminusers pmadminusers); // 编辑教师信息
|
||||
public boolean addAdminuser(PMAdminusers pmadminusers); // 添加教师
|
||||
public List<Adminusers> getTeacher();
|
||||
public DataGrid getAssistantByClassIdPage(int classId, int pageNum, int pageSize); // 获取班级所属的助教
|
||||
public DataGrid getAssistantNotBelongClass(int classId,
|
||||
String account, String name, String email, String no, int pageNum, int pageSize); // 查看不属于班级的助教
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -264,5 +264,56 @@ public class AdminusersServiceImpl implements AdminusersServiceI {
|
|||
else
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public DataGrid getAssistantByClassIdPage(int classId, int pageNum, int pageSize){
|
||||
long totalLines = adminusersDao.getAssistantByClassIdNum(classId);
|
||||
List<Adminusers> list = adminusersDao.getAssistantByClassIdPage(classId, pageNum, pageSize);
|
||||
List<PMAdminusers> plist = new ArrayList();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Adminusers a = list.get(i);
|
||||
PMAdminusers p = new PMAdminusers();
|
||||
p.setId(a.getId());
|
||||
p.setAccount(a.getAccount());
|
||||
p.setName(a.getName());
|
||||
p.setNo(a.getNo());
|
||||
p.setEmail(a.getEmail());
|
||||
plist.add(p);
|
||||
}
|
||||
DataGrid dg = new DataGrid();
|
||||
dg.setTotal(totalLines);
|
||||
dg.setPageSize(pageSize);
|
||||
dg.setTotalPages((long) (Math.ceil((double) dg.getTotal() / (double) dg.getPageSize())));
|
||||
dg.setPageNum(pageNum);
|
||||
dg.setCurrentPageLineNum(plist.size());
|
||||
dg.setList(plist);
|
||||
return dg;
|
||||
}
|
||||
@Override
|
||||
public DataGrid getAssistantNotBelongClass(int classId,
|
||||
String account, String name, String email, String no, int pageNum, int pageSize) {
|
||||
// TODO Auto-generated method stub
|
||||
DataGrid dg = new DataGrid();
|
||||
long totalLines = adminusersDao.getAssistantNotBelongClassNum(classId, account, name, email, no);
|
||||
List<Adminusers> list = adminusersDao.getAssistantNotBelongClass(
|
||||
classId, account, name, email, no, pageNum, pageSize);
|
||||
List<PMAdminusers> plist = new ArrayList();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Adminusers a = list.get(i);
|
||||
PMAdminusers p = new PMAdminusers();
|
||||
p.setId(a.getId());
|
||||
p.setAccount(a.getAccount());
|
||||
p.setName(a.getName());
|
||||
p.setEmail(a.getEmail());
|
||||
p.setNo(a.getNo());
|
||||
plist.add(p);
|
||||
}
|
||||
dg.setTotal(totalLines);
|
||||
dg.setPageSize(pageSize);
|
||||
dg.setTotalPages((long) (Math.ceil((double) dg.getTotal() / (double) dg.getPageSize())));
|
||||
dg.setPageNum(pageNum);
|
||||
dg.setCurrentPageLineNum(plist.size());
|
||||
dg.setList(plist);
|
||||
return dg;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue