1.24

今天实现Controller类
package com.example.controller;

import com.example.pojo.Application;
import com.example.pojo.Baoxiao;
import com.example.pojo.Result;
import com.example.service.UserService;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.rmi.server.RemoteRef;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    //登陆验证
    @GetMapping("/getByUser")
    public Result getByUser(String username, String password) {
        return Result.success(userService.getByUser(username, password));
    }

    @GetMapping("getName/{username}")
    public Result getName(@PathVariable("username") String username) {
        return Result.success(userService.getName(username));
    }

    @GetMapping("/count/{id}")
    public ResponseEntity<Integer> count(@PathVariable("id") String id) {
        int re = userService.count(id);
        return ResponseEntity.ok(re);
    }

    @PostMapping("/add1")
    public Result add1(@RequestBody Application application) {
        userService.add1(application);
        return Result.success(application);
    }

    @PostMapping("/update1")
    public Result update1(@RequestBody Application application) {
        userService.update1(application);
        return Result.success(application);
    }

    @GetMapping("/reasonable/{id}")
    public Result reasonable(@PathVariable("id") String id) {
        return Result.success(userService.reasonable(id));
    }

    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable("id") String id) {
        userService.delete(id);
        return Result.success();
    }

    @PostMapping("/add2")
    public Result add2(@RequestBody Baoxiao baoxiao) {
        userService.add2(baoxiao);
        return Result.success(baoxiao);
    }

    @GetMapping("/pay1/{id}")
    public ResponseEntity<Integer> pay1(@PathVariable("id") String id) {
        int re = userService.pay1(id);
        return ResponseEntity.ok(re);
    }

    @GetMapping("/examine/{id}")
    public Result examine(@PathVariable("id") String id) {
        return Result.success(userService.examine(id));
    }

    @PostMapping("/update2")
    public Result update2(@RequestBody Baoxiao baoxiao) {
        userService.update2(baoxiao);
        return Result.success(baoxiao);
    }

    @GetMapping("/SelectApp/{id}")
    public Result selectApp(@PathVariable("id") String id) {
        return Result.success(userService.selectApp(id));
    }

    @GetMapping("/SelectBao/{id}")
    public Result selectBao(@PathVariable("id") String id) {
        return Result.success(userService.selectBao(id));
    }

    @GetMapping("/Select1/{id}")
    public Result select1(@PathVariable("id") String id) {
        return Result.success(userService.select1(id));
    }

    @GetMapping("/updateById/{id}/{state}")
    public Result updateById(@PathVariable("id") String id, @PathVariable("state") String state) {
        userService.updateById(id, state);
        return Result.success();
    }

    @GetMapping("/updateById2/{id}/{state}")
    public Result updateById2(@PathVariable("id") String id, @PathVariable("state") String state) {
        userService.updateById2(id, state);
        return Result.success();
    }
}

 

posted @ 2024-01-26 18:14  七安。  阅读(2)  评论(0编辑  收藏  举报