1.23
今天实现Service类
package com.example.service; import com.example.mapper.UserMapper; import com.example.pojo.Application; import com.example.pojo.Baoxiao; import com.example.pojo.Staff; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; @Service public class UserService { @Autowired private UserMapper userMapper; public Staff getByUser(String username, String password) { return userMapper.getByUser(username, password); } public Staff getName(String username) { return userMapper.getName(username); } public int count(String id) { return userMapper.count(id); } public void add1(Application application) { String id = application.getId(); String name = application.getName(); String department = application.getDepartment(); String destination = application.getDestination(); LocalDateTime departureDate = application.getDepartureDate(); LocalDateTime returnDate = application.getReturnDate(); String type = application.getType(); String typeContent = application.getTypeContent(); String reason = application.getReason(); String state = application.getState(); userMapper.add1(id, name, department, destination, departureDate, returnDate, type, typeContent, reason, state); } public void update1(Application application) { String id = application.getId(); String name = application.getName(); String department = application.getDepartment(); String destination = application.getDestination(); LocalDateTime departureDate = application.getDepartureDate(); LocalDateTime returnDate = application.getReturnDate(); String type = application.getType(); String typeContent = application.getTypeContent(); String reason = application.getReason(); String state = application.getState(); userMapper.update1(id, name, department, destination, departureDate, returnDate, type, typeContent, reason, state); } public Application reasonable(String id) { String state = "待审批"; return userMapper.reasonable(id, state); } public void delete(String id) { userMapper.delete(id); } public void add2(Baoxiao baoxiao) { String id = baoxiao.getId(); String name = baoxiao.getName(); String department = baoxiao.getDepartment(); String destination = baoxiao.getDestination(); LocalDateTime departureDate = baoxiao.getDepartureDate(); LocalDateTime returnDate = baoxiao.getReturnDate(); String Reason = baoxiao.getReason(); int StartFare = baoxiao.getStartFare(); int ReturnFare = baoxiao.getReturnFare(); int foodAllowance = baoxiao.getFoodAllowance(); int localTrans = baoxiao.getLocalTrans(); int Accommodation = baoxiao.getAccommodation(); int totalAmount = baoxiao.getTotalAmount(); String schedule = baoxiao.getSchedule(); userMapper.add2(id, name, department, destination, departureDate, returnDate, Reason, StartFare, ReturnFare, foodAllowance, localTrans, Accommodation, totalAmount, schedule); } public int pay1(String id) { return userMapper.pay1(id); } public Baoxiao examine(String id) { String state = "退回"; return userMapper.examine(id, state); } public void update2(Baoxiao baoxiao) { String id = baoxiao.getId(); String name = baoxiao.getName(); String department = baoxiao.getDepartment(); String destination = baoxiao.getDestination(); LocalDateTime departureDate = baoxiao.getDepartureDate(); LocalDateTime returnDate = baoxiao.getReturnDate(); String Reason = baoxiao.getReason(); int StartFare = baoxiao.getStartFare(); int ReturnFare = baoxiao.getReturnFare(); int foodAllowance = baoxiao.getFoodAllowance(); int localTrans = baoxiao.getLocalTrans(); int Accommodation = baoxiao.getAccommodation(); int totalAmount = baoxiao.getTotalAmount(); String schedule = baoxiao.getSchedule(); userMapper.update2(id, name, department, destination, departureDate, returnDate, Reason, StartFare, ReturnFare, foodAllowance, localTrans, Accommodation, totalAmount, schedule); } public List<Application> selectApp(String name) { return userMapper.selectApp(name); } public List<Baoxiao> selectBao(String name) { return userMapper.selectBao(name); } public List<Application> select1(String id) { return userMapper.select1(id); } public void updateById(String id, String state) { userMapper.updateById(id, state); } public void updateById2(String id, String state) { userMapper.updateById2(id, state); } }