PersonController.java 1.5 KB
Newer Older
Q
qinyingjie 已提交
1 2 3 4 5
package com.kwan.springbootkwan.controller;

import com.kwan.springbootkwan.entity.Person;
import com.kwan.springbootkwan.entity.User;
import com.kwan.springbootkwan.service.IUserService;
Q
qinyingjie 已提交
6 7
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
Q
qinyingjie 已提交
8 9 10
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.launch.JobLauncher;
Q
qinyingjie 已提交
11 12 13 14 15 16 17 18 19 20 21 22 23
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * Person相关
 *
 * @author : qinyingjie
 * @version : 2.2.0
 * @date : 2022/12/19 16:08
 */
Q
qinyingjie 已提交
24
@Api(description = "person用户信息", tags = "PersonController")
Q
qinyingjie 已提交
25 26 27
@RestController
@RequestMapping("/person")
public class PersonController {
Q
qinyingjie 已提交
28 29 30 31 32 33

    @Autowired
    private JobLauncher jobLauncher;
    @Autowired
    private Job job;

Q
qinyingjie 已提交
34 35 36 37 38 39 40
    /**
     * {
     * "name": "zhang san",
     * "age": 24,
     * "birthday": "2022-12-19"
     * }
     */
Q
qinyingjie 已提交
41
    @ApiOperation(value = "json返回", notes = "json返回")
Q
qinyingjie 已提交
42 43 44
    @GetMapping("/person")
    public Person person() {
        Person person = new Person();
Q
qinyingjie 已提交
45 46 47
        person.setUsername("zhang san");
        person.setId(24);
        person.setAddress("湖北");
Q
qinyingjie 已提交
48 49
        return person;
    }
Q
qinyingjie 已提交
50 51 52 53 54 55 56 57 58

    @GetMapping("/hello")
    public void hello() {
        try {
            jobLauncher.run(job, new JobParameters());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
Q
qinyingjie 已提交
59
}