首页 > 其他分享 >service层

service层

时间:2023-06-10 11:46:33浏览次数:35  
标签:return String service courseid Boolean import public

AnswerService

package com.example.academicadministration.service;

import com.example.academicadministration.dao.AnswerDao;
import com.example.academicadministration.pojo.Answer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class AnswerService  {
    @Autowired
    private AnswerDao answerDao;
    public Boolean addAnswer(Answer answer) {
        return answerDao.addAnswer(answer)>0;
    }

    public Boolean updateAnswer(Answer answer) {
        return answerDao.updateAnswer(answer)>0;
    }

    public Boolean updateScore(Answer answer) {
        return answerDao.updateScore(answer)>0;
    }
    public Boolean deleteAnswer(String stuid,String homeworkid){
        return answerDao.deleteAnswer(stuid,homeworkid)>0;
    }

    public Answer myAnswer(String stuid,String homeworkid) {
        return answerDao.myAnswer(stuid,homeworkid);
    }
}

CourseService

package com.example.academicadministration.service;

import com.example.academicadministration.dao.CourseDao;
import com.example.academicadministration.pojo.Course;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseService {
    @Autowired
    private CourseDao courseDao;
    public Boolean addCourse(Course course) {
        return courseDao.addCourse(course)>0;
    }

    public Boolean deleteCourse(String courseid) {


        return courseDao.deleteCourse(courseid)>0;
    }

    public List<Course> browseCourse(String condition) {
        return courseDao.browseCourse(condition);
    }
    public List<Course> myCourse(String stuid){
        return courseDao.myCourse(stuid);
    }
    public List<Course> TmyCourse(String teaid){
        return courseDao.TmyCourse(teaid);
    }
    public Boolean checkTeacher(String courseid,String teaid){return !courseDao.checkTeacher(courseid,teaid).isEmpty();}
    public Boolean addTeacherCourse(String teaid,String courseid){
        return courseDao.addTeacherCourse(teaid,courseid)>0;
    }
    public Boolean deleteTeacherCourse(String teaid,String courseid){
        return courseDao.deleteTeacherCourse(teaid,courseid)>0;
    }
    public Boolean addStudentCourse(String stuid,String courseid){
        return courseDao.addStudentCourse(stuid,courseid)>0;
    }
    public Boolean deleteStudentCourse(String stuid,String courseid){
        return courseDao.deleteStudentCourse(stuid,courseid)>0;
    }
    public Boolean addNum(String courseid){
        return courseDao.addNum(courseid)>0;
    }
    public Boolean deleteNum(String courseid){
        return courseDao.deleteNum(courseid)>0;
    }
    public String browseScore(String stuid,String courseid){
        return courseDao.browseScore(stuid,courseid);
    }
    public Boolean updateScore(String coursescore,String stuid,String courseid){
        return courseDao.updateScore(coursescore,stuid,courseid)>0;
    }
}

HomeworkService

package com.example.academicadministration.service;

import com.example.academicadministration.dao.HomeworkDao;
import com.example.academicadministration.pojo.Homework;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HomeworkService {
    @Autowired
    private HomeworkDao homeworkDao;
    public Boolean addHomework(Homework homework) {
        return homeworkDao.addHomework(homework)>0;
    }

    public Boolean deleteHomework(String homeworkid) {
        return homeworkDao.deleteHomework(homeworkid)>0;
    }

    public List<Homework> browseHomeworkAll(String courseid) {
        return homeworkDao.browseHomeworkAll(courseid);
    }

    public List<Homework> browseHomework1(String courseid) {
        return homeworkDao.browseHomework1(courseid);
    }

    public List<Homework> browseHomework2(String courseid) {
        return homeworkDao.browseHomework2(courseid);
    }
}

MangerService

package com.example.academicadministration.service;

import com.example.academicadministration.dao.MangerDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MangerService {
    @Autowired
    private MangerDao mangerDao;
    public String login(String id){
        return mangerDao.login(id);
    }

    public boolean reset(String mangerid,String oldpwd, String newpwd1) {
        return mangerDao.reset(mangerid,oldpwd,newpwd1)>0;
    }
}

StudentService

package com.example.academicadministration.service;

import com.example.academicadministration.dao.StudentDao;
import com.example.academicadministration.pojo.Course;
import com.example.academicadministration.pojo.Homework;
import com.example.academicadministration.pojo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentService {
    @Autowired
    private StudentDao studentDao;
    @Autowired
    private CourseService courseService;
    @Autowired
    private HomeworkService homeworkService;
    @Autowired
    private AnswerService answerService;
    public Boolean addStudent(Student student){
        return studentDao.addStudent(student)>0;
    }
    public Boolean deleteStudent(String stuid){
        List<Course> courses=courseService.myCourse(stuid);
        for (Course i:courses){
            courseService.deleteNum(String.valueOf(i.getCourseid()));
            courseService.deleteStudentCourse(stuid, String.valueOf(i.getCourseid()));
            List<Homework> homework=homeworkService.browseHomeworkAll(String.valueOf(i.getCourseid()));
            for (Homework j:homework){
                answerService.deleteAnswer(stuid, String.valueOf(j.getHomeworkid()));
            }
        }
        return studentDao.deleteStudent(stuid)>0;
    }
    public Boolean auditStudent(String stuid){
        return studentDao.auditStudent(stuid)>0;
    }
    public Boolean  inauditStudent(String stuid){
        return studentDao.inauditStudent(stuid)>0;
    }
    public Boolean reset(String stuid,String stupwd,String newpwd){
        return studentDao.reset(stuid,stupwd,newpwd)>0;
    }
    public  List<Student> browseStudent(String condition){
        return studentDao.browseStudent(condition);
    }
    public List<Student> myStudent(String courseid){
        return studentDao.myStudent(courseid);
    }
}

TeacherService

package com.example.academicadministration.service;

import com.example.academicadministration.dao.TeacherDao;
import com.example.academicadministration.pojo.Course;
import com.example.academicadministration.pojo.Teacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TeacherService {
    @Autowired
    private TeacherDao teacherDao;
    @Autowired
    private CourseService courseService;
    public Boolean addTeacher(Teacher teacher){
        return teacherDao.addTeacher(teacher)>0;
    }
    public Boolean deleteTeacher(String teaid){
        List< Course> courses=courseService.TmyCourse(teaid);
        for(Course i:courses){
            courseService.deleteTeacherCourse(teaid, String.valueOf(i.getCourseid()));
        }
        return teacherDao.deleteTeacher(teaid)>0;
    }
    public Boolean  auditTeacher(String teaid){
        return teacherDao.auditTeacher(teaid)>0;
    }
    public Boolean inauditTeacher(String teaid){
        return teacherDao.inauditTeacher(teaid)>0;
    }
    public Boolean reset(String teaid,String teapwd,String newpwd){
        return teacherDao.reset(teaid,teapwd,newpwd)>0;
    }
    public List<Teacher> browseTeacher(String condition){
        return teacherDao.browseTeacher(condition);
    }

}

VideoService

package com.example.academicadministration.service;

import com.example.academicadministration.dao.VideoDao;
import com.example.academicadministration.pojo.Video;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.File;
import java.util.List;
@Service
public class VideoService  {
    @Autowired
    private VideoDao videoDao;
    public Boolean addVideo(Video video) {
        return videoDao.addVideo(video)>0;
    }

    public Boolean deleteVideo(String videoid) {
        List<Video> videoList=browseVideo("%%");
        for(Video i:videoList){
            if(videoid.equals(String.valueOf(i.getVideoid()))){
                new File("D:\\JavaProject\\AcademicAdministration\\src\\main\\resources\\static\\video\\"+i.getVideofile()).delete();
            }
        }
        return videoDao.deleteVideo(videoid)>0;
    }

    public List<Video> browseVideo(String condition) {
        return videoDao.browseVideo(condition);
    }

}

 

标签:return,String,service,courseid,Boolean,import,public
From: https://www.cnblogs.com/liyiyang/p/17470983.html

相关文章

  • 使用Axis开发Web Service程序
    今天是感恩节,差点又要在公司加班了。好在WebService程序并不是特别难搞,下午终于在eclipse下调通过了,正确产生了服务器端和客户端的Java代码,apache的东西的确很不错。说道WebService的程序开发,八个月前我加班调试公司和中国电信的商务领航系统的接口的时候,用的就是WebService......
  • webservice: Could not initialize Service NoSuchMethodException getPortClassMap()
    webservicejaxws webservice中碰到的问题:CouldnotinitializeServiceNoSuchMethodExceptiongetPortClassMap()情况如下:A应用是用jaxws编写的webservice客户端,单独运行该客户端成功。B应用是基于xfire的webservice服务,在B中调用A,结果在构造一个Service类的似乎出了上......
  • OpenHarmony系统之Service代码一键生成工具介绍
    作者:苟晶晶前言当开发者为OpenHarmony系统框架开发某些功能时,有时需要将这个功能包装成一个独立的服务进程运行在系统中,为了其它应用进程能够调用此服务,开发人员需要基于系统IPC通信框架编写一套远程接口调用实现。实现Service远程调用接口需要开发人员熟悉IPC通信框架,了解proxy/......
  • Java SPI META-INF/services 详解
    目录什么是SPISPI和API的使用场景SPI的简单实现SPI原理解析DubboSPI总结什么是SPISPI(ServiceProviderInterface)是JDK提供的一套用来被第三方实现或者扩展的接口,它可以用来启用框架扩展和替换组件。SPI的作用就是为这些被扩展的API寻找服务实现。SPI和API的使用场景......
  • 【Azure 应用服务】App Service 默认页面暴露Tomcat版本信息,存在安全风险
    问题描述在创建AzureAppService时,服务端的配置使用Java8+Tomcat8.5。默认的根目录页面显示出AppServiceTomcat版本信息,存在一定的安全隐患。如何来避免这个问题呢? 问题解答因为在初始创建AppService时,Azure会根据所选Stack,WebServer的信息默认生成首页内容。大多是情况......
  • [转]解决WebService 测试窗体只能用于来自本地计算机的请求
    [转自]原文地址:https://www.cnblogs.com/JuneZhang/archive/2013/01/24/net.html问题:WebService部署成站点之后,如果在本地测试webservice可以运行,在远程却显示“测试窗体只能用于来自本地计算机的请求”或者"Thetestformisonlyavailableforrequestsfromthelocalma......
  • 立即报名 | Microservices June 微服务之月再度开启
    原文作者:NGINX原文链接:立即报名|MicroservicesJune微服务之月再度开启转载来源:NGINX官方网站NGINX唯一中文官方社区,尽在 nginx.org.cn又是一个热情似火的六月,一年一度的MicroservicesJune微服务之月再次回归!微服务之月是NGINX一年一度的免费线上教学项目,今......
  • service开机启动项设置
    我们用户级别程序启动需要一个依赖网络,驱动等加载初始化,所以要在一个启动级别非常靠后的位置,他们建议在rc.local中启动,这一个在他们的启动时序中是最后的级别,因此改动如下: 还有一个rc-local.service的文件,一般是systemctlstart/enablerc-local使用,/etc/systemd/system下的ser......
  • HttpURLConnection调用webservice,c#、java、python等HTTP调用webservice,简单的webserv
    以前调用webservice一般使用axis、axis2先生成java类后,直接引用,多方便。但是有的webservice接口非常的函数,生成的java类非常多,有没有一种非常简化的方法。axis2有不生成类直接调用的方法,但是QName不容易找,每次查N久不到。有的反馈,使用CXF调用一样方便,但CXF还要使用maven下载jar,而......
  • Kubernetes(k8s)服务service:service的发现和service的发布
    目录一.系统环境二.前言三.Kubernetesservice简介四.使用hostPort向外界暴露应用程序4.1创建deploy4.2使用hostPort向外界暴露pod的端口五.使用service服务向外界暴露应用程序5.1使用service服务向外界暴露pod5.1.1创建service服务5.1.2测试svc的负载均衡六.service服务的发......