package com.tuoheng.admin.controller;

import com.tuoheng.admin.entity.Structure;
import com.tuoheng.admin.query.StructureQuery;
import com.tuoheng.admin.service.structure.IStructureService;
import com.tuoheng.common.core.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author ChengWang
 * @Date 2022/11/17
 */
@RestController
@RequestMapping("/structure")
public class StructureController {

    @Autowired
    private IStructureService structureService;

    /**
     * 获取构造物列表(分页)
     * @param query
     * @return
     */
    @GetMapping("/index")
    public JsonResult index(StructureQuery query){
        return structureService.queryPage(query);
    }

    /**
     * 获取构造物列表
     * @param query
     * @return
     */
    @GetMapping("/getList")
    public JsonResult getList(StructureQuery query){
        return structureService.getListInfo(query);
    }

    /**
     * 新增构造物
     * @param entity
     * @return
     */
    @PostMapping("/add")
    public JsonResult add(@RequestBody Structure entity){
        return structureService.editInfo(entity);
    }

    /**
     * 编辑构造物
     * @param entity
     * @return
     */
    @PutMapping("/edit")
    public JsonResult update(@RequestBody Structure entity){
        return structureService.editInfo(entity);
    }

    /**
     * 删除构造物
     * @param ids
     * @return
     */
    @DeleteMapping("/delete/{ids}")
    public JsonResult delete(@PathVariable String[] ids){
        return structureService.deleteByIds(ids);
    }

    /**
     * 根据登录人获取构造物信息列表
     * @return
     */
    @GetMapping("/getSectionInfo")
    public JsonResult getSectionInfo(){
        return structureService.getSectionInfo();
    }

}
