SSM02

public interface StaffMapper {

    public List getStaffList(@Param("departmentType") String dapartmentType, @Param("staffName") String staffName, @Param("staffId") Integer staffId);

    public Staff getStaffById(@Param("staffId") Integer staffId);

    public int updateStaffById(@Param("identityType") String identityType,@Param("email") String email,@Param("staffAddress") String staffAddress
            ,@Param("departName") String departName ,@Param("staffSex") String staffSex,@Param("staffId") Integer staffId);
}




    

    
    
        update staffinfo s,departmentinfo d
        
            
                s.email=#{email},
            
            
                s.identityType=#{identityType},
            
            
                s.staffAddress=#{staffAddress},
            
            
                d.departmentType=#{departName},
            
            
                s.staffSex=#{staffSex}
            
        
        where s.departmentId = d.departmentId
        and s.staffId=#{staffId}
    
    
          
          
          
          
          
          
          
          
          
          
        
        
        
        
        
        
    
public interface StaffService {
    public List QueryStaff(String staffName,String departmentType,Integer staffId);

    public Staff getStaffById(Integer staffId);

    public int updateStaffById(String identityType, String email, String staffAddress
            , String departName , String staffSex,Integer staffId);
}
@Service
public class StaffServiceImpl implements StaffService {
    @Autowired
    private StaffMapper staffMapper;

    @Override
    public List QueryStaff(String staffName, String departmentType, Integer staffId) {
        List staff = new ArrayList<>();

        staff = staffMapper.getStaffList(departmentType,staffName,staffId);

        return staff;
    }

    @Override
    public Staff getStaffById(Integer staffId) {
        Staff staff = new Staff();
        staff = staffMapper.getStaffById(staffId);

        return staff;
    }

    @Override
    public int updateStaffById(String identityType, String email, String staffAddress
            , String departName , String staffSex,Integer staffId){

        return staffMapper.updateStaffById(identityType,email,staffAddress,departName,staffSex,staffId);
    }
}
package com.zll.controller.staff;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zll.pojo.Staff;
import com.zll.service.staff.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

/**
 * @auther zll
 * @create 2020/7/28-17:38
 */
@Controller
@RequestMapping("/staff")
public class staffController {
    @Autowired
    private StaffService staffService;

    @RequestMapping("/look")
    public String query( String staffName, String departmentType, Integer staffId, @RequestParam(value = "pn",defaultValue = "1")  Integer pn, Model model){
        PageHelper.startPage(pn,2);
        List staff = new ArrayList<>();

        staff =  staffService.QueryStaff(staffName,departmentType,staffId);

        PageInfo pageInfo = new PageInfo(staff,3);

//        model.addAttribute("stafflist",staff);

        model.addAttribute("pageInfo",pageInfo);

        return "doctor/index";
    }

    @RequestMapping("/scan/{staffId}")
    public String look(@PathVariable Integer staffId,Model model){

        Staff staffById = staffService.getStaffById(staffId);

        model.addAttribute("staff",staffById);
        return "doctor/look";

    }

    @RequestMapping("/toupdate/{staffId}")
    public String toupdate(@PathVariable Integer staffId,Model model){
        Staff staffById = staffService.getStaffById(staffId);

        model.addAttribute("staff",staffById);

        return "doctor/edit";
    }
    @RequestMapping("/editstaff")
    public String updateStaff(String identityType, String email, String staffAddress
            , String departName , String staffSex,Integer staffId){

        System.out.println(identityType);
        System.out.println(email);
        staffService.updateStaffById(identityType,email,staffAddress,departName,staffSex,staffId);

        return "doctor/index";
    }

}

 

 

 

 

你可能感兴趣的:(作业)