package com.lxzn.ucenter.controller;
|
|
import com.lxzn.api.ucenter.ObjectControllerApi;
|
import com.lxzn.framework.domain.ucenter.Button;
|
import com.lxzn.framework.domain.ucenter.ObjectBase;
|
import com.lxzn.framework.domain.ucenter.request.ObjectBaseRequest;
|
import com.lxzn.framework.model.response.CommonCode;
|
import com.lxzn.framework.model.response.QueryPageResponseResult;
|
import com.lxzn.framework.model.response.ResponseResult;
|
import com.lxzn.ucenter.service.IObjectService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.List;
|
|
@RestController
|
@RequestMapping("/ucenter/obj")
|
public class ObjectController implements ObjectControllerApi {
|
@Autowired
|
private IObjectService objectService;
|
|
@Override
|
@PostMapping("/add")
|
public ResponseResult addObject(@RequestBody ObjectBase objectBase) {
|
boolean b = objectService.addObject(objectBase);
|
if(b) {
|
return new ResponseResult(CommonCode.SUCCESS);
|
}
|
return new ResponseResult(CommonCode.FAIL);
|
}
|
|
@Override
|
@PutMapping("/edit/{id}")
|
public ResponseResult editObject(@PathVariable("id") String id,@RequestBody ObjectBase objectBase) {
|
boolean b = objectService.editObject(id,objectBase);
|
if(b) {
|
return new ResponseResult(CommonCode.SUCCESS);
|
}
|
return new ResponseResult(CommonCode.FAIL);
|
}
|
|
@Override
|
@GetMapping("/find/page/{page}/{size}")
|
public QueryPageResponseResult<ObjectBase> findByPageList(@PathVariable("page") int page,@PathVariable("size") int size, ObjectBaseRequest objectRequest) {
|
return objectService.findPageList(page,size,objectRequest);
|
}
|
|
@Override
|
@DeleteMapping("/delete")
|
public ResponseResult deleteObjectById(@RequestParam("id") String id) {
|
boolean b = objectService.deleteObjectById(id);
|
if(b) {
|
return new ResponseResult(CommonCode.SUCCESS);
|
}
|
return new ResponseResult(CommonCode.FAIL);
|
}
|
|
@Override
|
@PostMapping("/assign/button/{objectId}")
|
public ResponseResult assignButton(@PathVariable("objectId") String objectId, @RequestBody List<Button> buttonList) {
|
boolean b = objectService.assignButton(objectId, buttonList);
|
if(b) {
|
return new ResponseResult(CommonCode.SUCCESS);
|
}
|
return new ResponseResult(CommonCode.FAIL);
|
}
|
}
|