根据id更新问题状态

根据id更新问题状态接口应该怎么写,就给我传什么状态我就更新什么状态,很简单的那种,可是我不会,根据id然后更新问题状态

直接根据实体,调用更新的持久层接口

可以采用如下类似的方式写


   
  
//修改用户信息
    @RequestMapping("/updateEmp")
    public String updateEmp(Employee employee,Model model){
        empService.updateEmp(employee);
        return "show";
    }

参考一下:

package csdn005;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {
    
    @Autowired
    private UserDao userDao;

    @PostMapping("/updateTypeById")
    public Boolean updateTypeById(Long id,Integer type) {
        User user = new User();
        user.setId(id);
        user.setType(type);
        return userDao.updateById(user) == 1;
    }
}
class User {
    private Integer type;
    private Long id;

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
}

interface UserDao extends BaseMapper<User> {
    
}