123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <?php
- namespace app\controller;
- use app\BaseController;
- use app\service\InputuseService;
- use app\validate\Id;
- use app\validate\Page;
- use think\console\Input;
- use think\db\exception\DataNotFoundException;
- use think\db\exception\DbException;
- use think\db\exception\ModelNotFoundException;
- use think\exception\ValidateException;
- use think\response\Json;
- use think\annotation\Route;
- use think\annotation\route\Middleware;
- use hg\apidoc\annotation as Apidoc;
- /**
- * @Apidoc\Title("投入品使用")
- * @Apidoc\Group("inputuse")
- * @Apidoc\Sort(8)
- */
- class InputUse extends BaseController
- {
- use ResponseJson;
- /**
- * @Apidoc\Author("yang")
- * @Apidoc\Title("添加投入品使用")
- * @Apidoc\Tag("投入品使用")
- * @Apidoc\Method ("POST")
- * @Route("/addInputuse",method="POST")
- * @Middleware({"jwt"})
- */
- public function addInputuse(): Json
- {
- $inputInfo = $this->request->post();
- $inputInfo['creation_time'] = date('Y-m-d h:i:s', time());
- try {
- validate(\app\validate\Inputuse::class)->check($inputInfo);
- }catch (ValidateException $e){
- return $this->JsonError($e->getError());
- }
- return $this->JsonSucess(InputuseService::addInputUse($inputInfo));
- }
- /**
- * @Apidoc\Author("yang")
- * @throws ModelNotFoundException
- * @throws DataNotFoundException
- * @throws DbException
- * @Apidoc\Title("删除投入品使用")
- * @Apidoc\Tag("投入品使用")
- * @Apidoc\Method ("POST")
- * @Route("/delInputuse",method="POST")
- * @Middleware({"jwt"})
- */
- public function delInputuse(): Json
- {
- $id = $this->request->post();
- try {
- validate(Id::class)->check($id);
- } catch (ValidateException $e) {
- return $this->JsonError($e->getError(), 0);
- }
- return $this->JsonSucess(InputuseService::delInputUse($id["id"]));
- }
- /**
- * @Apidoc\Author("yang")
- * @throws ModelNotFoundException
- * @throws DataNotFoundException
- * @throws DbException
- * @Apidoc\Title("修改投入品使用")
- * @Apidoc\Tag("修改投入品使用")
- * @Apidoc\Method ("POST")
- * @Route("/editInputuse",method="POST")
- * @Middleware({"jwt"})
- */
- public function editInputuse(): Json
- {
- $info= $this->request->post();
- $info['last_update_time'] = date('Y-m-d h:i:s', time());
- try {
- validate(Id::class)->check($info);
- }catch (ValidateException $e){
- $this->JsonError($e->getError());
- }
- return $this->JsonSucess(InputuseService::editInputUse($info,$info["id"]));
- }
- /**
- * @Apidoc\Author("yang")
- * @throws ModelNotFoundException
- * @throws DataNotFoundException
- * @throws DbException
- * @Apidoc\Title("获取投入品使用记录")
- * @Apidoc\Tag("投入品")
- * @Apidoc\Method ("POST")
- * @Route("/getInputUseList",method="POST")
- * @Middleware({"jwt"})
- */
- public function getInputUseList(): Json
- {
- $page = $this->request->get();
- try {
- validate(Page::class)->check($page);
- }catch (ValidateException $e){
- return $this->JsonError($e->getError());
- }
- return $this->JsonSucess(InputuseService::getInputUseList($page,getQydm()));
- }
- /**
- * @Apidoc\Author("yang")
- * @throws ModelNotFoundException
- * @throws DataNotFoundException
- * @throws DbException
- * @Apidoc\Title("获取投入品使用详情")
- * @Apidoc\Tag("投入品")
- * @Apidoc\Method ("GET")
- * @Route("/getInputUseById",method="GET")
- * @Middleware({"jwt"})
- */
- public function getInputUseById(): Json
- {
- $id = $this->request->get();
- try {
- validate(Id::class)->check($id);
- }catch (ValidateException $e){
- return $this->JsonError($e->getError());
- }
- return $this->JsonSucess(InputuseService::getInputUseById($id["id"]));
- }
- }
|