package com.newfiber.api.pc.controller.River; import com.github.pagehelper.PageInfo; import com.newfiber.api.core.bean.ReqBodyObj; import com.newfiber.api.core.bean.RespBodyObj; import com.newfiber.api.core.support.HttpCode; import com.newfiber.api.core.utils.Constant; import com.newfiber.api.pc.model.River.PatrolManageBaseRelation; import com.newfiber.api.pc.service.PatrolManageBaseRelationService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; import java.util.Map; /** * patrolManageBaseRelation控制层 * * @author luzhan * @since 2022-01-10 */ @RestController @RequestMapping("/patrolManageBaseRelation") @Api(value = "API - PatrolManageBaseRelationController", description = "") public class PatrolManageBaseRelationController { private static final Logger log = LoggerFactory.getLogger(PatrolManageBaseRelationController.class); @Autowired public PatrolManageBaseRelationService patrolManageBaseRelationService; /** * 获取patrolManageBaseRelation信息(分页) * @param params * @return */ @PostMapping("list") @ApiOperation(value = "获取patrol_manage_base_relation列表",notes="") public RespBodyObj<PageInfo<PatrolManageBaseRelation>> list(@RequestBody ReqBodyObj<Map<String, Object>> params) { Integer pageNo = params.getCurrent(); Integer pageSize = params.getSize(); String searchStr = String.valueOf(params.getData().get("searchStr" )); PageInfo<PatrolManageBaseRelation> patrolManageBaseRelation =patrolManageBaseRelationService.listForPage(searchStr, pageNo, pageSize); return RespBodyObj.ok(patrolManageBaseRelation); } /** * patrolManageBaseRelation添加或编辑 * @param param * @return */ @PostMapping("saveOrupdate") @ApiOperation(value = "新增或编辑patrol_manage_base_relation",notes="根据实体修改patrol_manage_base_relation") public RespBodyObj saveOrupdate(@RequestBody ReqBodyObj<PatrolManageBaseRelation> param) { try { boolean b = patrolManageBaseRelationService.insertOrUpdate(param.getData()); return b ? RespBodyObj.ok(Constant.SUCCESS) : RespBodyObj.error(Constant.FAILED); } catch (Exception e) { log.error("/patrolManageBaseRelation/saveOrupdate", e); return RespBodyObj.error(Constant.ERROR); } } /** * patrolManageBaseRelation批量移除 * * @param params * @return */ @PostMapping("removeBatch") @ApiOperation(value = "批量删除辑patrol_manage_base_relation",notes="根据id批量删除patrol_manage_base_relation") public RespBodyObj removeBatch(@RequestBody ReqBodyObj<Map<String, Object>> params) { try { List<String> list = (List<String>) params.getData().get("patrolManageBaseRelationList"); boolean b = patrolManageBaseRelationService.deleteBatchIds(list); return b ? RespBodyObj.ok(Constant.SUCCESS) : RespBodyObj.error(Constant.FAILED); } catch (Exception e) { log.error("/patrolManageBaseRelation/removeBatch", e); return RespBodyObj.error(Constant.ERROR); } } /** * patrolManageBaseRelation查询单个 * * @param params * @return */ @PostMapping("selectOne") @ApiOperation(value = "查询patrol_manage_base_relation",notes="根据主键查询patrol_manage_base_relation") public RespBodyObj<PatrolManageBaseRelation> selectOne(@RequestBody ReqBodyObj<Map<String, Object>> params) { if (params.getData() == null) { return RespBodyObj.error(HttpCode.BAD_REQUEST); } if (StringUtils.isEmpty(params.getData().get("id" ).toString())) { return RespBodyObj.error(HttpCode.BAD_REQUEST); } String id = params.getData().get("id" ).toString(); PatrolManageBaseRelation patrolManageBaseRelation = patrolManageBaseRelationService.selectById(id); return RespBodyObj.ok(patrolManageBaseRelation); } }