package jj.tech.paolu.repository.mybatis.control;

import jj.tech.paolu.repository.mybatis.dao.Idc9998AdminInfoMapper;
import jj.tech.paolu.repository.mybatis.entity.Idc9998AdminInfo;
import jj.tech.paolu.utils.IDHelp;
import jj.tech.paolu.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("mybatis/idc9998AdminInfo")
public class Idc9998AdminInfoController {

    @Autowired
    public Idc9998AdminInfoMapper idc9998AdminInfoMapper;

    @PostMapping("findById/{id}")
    public Object findById(@PathVariable("id") String id) {
        return R.SUCCESS(idc9998AdminInfoMapper.selectByPrimaryKey(id).orElse(null));
    }

    @PostMapping("delete/{id}")
    public Object delete(@PathVariable("id") String id) {
        return R.SUCCESS(idc9998AdminInfoMapper.deleteByPrimaryKey(id));
    }

    @PostMapping("save")
    public Object save(@RequestBody Idc9998AdminInfo record) {
        record.setId(IDHelp.getInstance().nextId());
        return R.SUCCESS(idc9998AdminInfoMapper.insertSelective(record));
    }

    @PostMapping("update")
    public Object update(@RequestBody Idc9998AdminInfo record) {
        return R.SUCCESS(idc9998AdminInfoMapper.updateByPrimaryKeySelective(record));
    }
}