package com.luowei.app_sb.controller;

import com.luowei.app_sb.service.PersonBaseInfo_881_1Service;
import com.luowei.app_sb.utility.ResponseUtility;
import com.luowei.app_sb.vo.PersonBaseInfo_881_1Vo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;


//这版不如20250605上课时讲的写得好。在E:\test\2xuewei\20250301\html5\2班\20250605中
@RestController
@RequestMapping("PersonBaseInfo_881_1")
public class PersonBaseInfo_881_1Controller {
    @Autowired
    PersonBaseInfo_881_1Service personBaseInfo_881_1Service;
    @Autowired
    ResponseUtility R;
    //http://localhost:58301/personBaseInfo_881_1/selectAll
    @RequestMapping("selectAll")
    public ResponseUtility selectAll(){
        List<PersonBaseInfo_881_1Vo> personBaseInfo_881_1Vos=personBaseInfo_881_1Service.selectAll();
        if(personBaseInfo_881_1Vos.size()>0){
            R.setResponseCode("1");
            R.setResponseString("查询数据成功");
            R.setResponseData(personBaseInfo_881_1Vos);
        }else{
            R.setResponseCode("2");
            R.setResponseString("查询数据失败");
            R.setResponseData(null);
        }
        System.out.println(R);
        return R;
    }

    //http://localhost:58301/PersonBaseInfo_881_1/select?id=510103234
    @RequestMapping("select")
    public ResponseUtility select(String id){
        PersonBaseInfo_881_1Vo PersonBaseInfo_881_1Vo=personBaseInfo_881_1Service.select(id);
        if(PersonBaseInfo_881_1Vo!=null){
            R.setResponseCode("1");
            R.setResponseString("查询数据成功");
            R.setResponseData(PersonBaseInfo_881_1Vo);
        }else{
            R.setResponseCode("2");
            R.setResponseString("查询数据失败");
            R.setResponseData(null);
        }
        return R;
    }
    //http://localhost:58301/PersonBaseInfo_881_1/insert?id=001&name=luowei2008&sbp=123&dbp=75
    @RequestMapping("insert")
    public ResponseUtility insert(PersonBaseInfo_881_1Vo PersonBaseInfo_881_1Vo) throws IOException {
        return personBaseInfo_881_1Service.insert(PersonBaseInfo_881_1Vo);
    }
    //http://localhost:58301/PersonBaseInfo_881_1/update?id=001&name=luowei&sbp=123&dbp=77
    @RequestMapping("update")
    //public ResponseUtility update(PersonBaseInfo_881_1Vo PersonBaseInfo_881_1Vo, @RequestParam("photoData")MultipartFile photoData) throws IOException {
    public ResponseUtility update(PersonBaseInfo_881_1Vo PersonBaseInfo_881_1Vo) throws IOException {

        return personBaseInfo_881_1Service.update(PersonBaseInfo_881_1Vo);

    }
    //http://localhost:58301/PersonBaseInfo_881_1/delete?id=001
    @RequestMapping("delete")
    public ResponseUtility delete(String id){
        System.out.println(id);
        return personBaseInfo_881_1Service.delete(id);

    }

}
