huanghongfa
2021-09-13 47b20dbb8f81f2a3ac113a7e209a8b4d1cb0146d
springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/api/ComPropertyAlarmApi.java
New file
@@ -0,0 +1,93 @@
package com.panzhihua.service_property.api;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.panzhihua.common.model.vos.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panzhihua.common.model.vos.property.ComPropertyAlarmVO;
import com.panzhihua.service_property.entity.ComPropertyAlarm;
import com.panzhihua.service_property.service.ComPropertyAlarmService;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;
/**
 * (ComPropertyAlarm)表控制层
 *
 * @author makejava
 * @since 2021-09-07 13:29:50
 */
@RestController
@RequestMapping("comPropertyAlarm")
public class ComPropertyAlarmApi {
    /**
     * 服务对象
     */
    @Resource
    private ComPropertyAlarmService comPropertyAlarmService;
    /**
     * 分页查询所有数据
     * @param commonPage 查询实体
     * @return 所有数据
     */
    @PostMapping("queryAll")
    public R selectAll(@RequestBody CommonPage commonPage) {
        return this.comPropertyAlarmService.pageList(commonPage);
    }
    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public R selectOne(@PathVariable("id") Integer id) {
        return this.comPropertyAlarmService.selectDetail(id);
    }
    /**
     * 新增数据
     *
     * @param comPropertyAlarmVO 实体对象
     * @return 新增结果
     */
    @PostMapping
    public R insert(@RequestBody ComPropertyAlarmVO comPropertyAlarmVO) {
        ComPropertyAlarm comPropertyAlarm=new ComPropertyAlarm();
        BeanUtils.copyProperties(comPropertyAlarmVO,comPropertyAlarm);
        comPropertyAlarm.setCreateTime(DateUtil.date());
        return R.ok(this.comPropertyAlarmService.save(comPropertyAlarm));
    }
    /**
     * 修改数据
     *
     * @param comPropertyAlarmVO 实体对象
     * @return 修改结果
     */
    @PostMapping("/update")
    public R update(@RequestBody ComPropertyAlarmVO comPropertyAlarmVO) {
        ComPropertyAlarm comPropertyAlarm=new ComPropertyAlarm();
        BeanUtils.copyProperties(comPropertyAlarmVO,comPropertyAlarm);
        return R.ok(this.comPropertyAlarmService.updateById(comPropertyAlarm));
    }
    /**
     * 删除数据
     *
     * @param id 主键结合
     * @return 删除结果
     */
    @GetMapping("del")
    public R delete(@RequestParam("id") Long id) {
        return R.ok(this.comPropertyAlarmService.removeById(id));
    }
}