add 栏舍管理
This commit is contained in:
parent
daa17f8beb
commit
83b2195223
|
@ -0,0 +1,26 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
// 栏舍管理列表
|
||||
export function apiFenceHouseLists(params: any) {
|
||||
return request.get({ url: '/fence_house.fence_house/lists', params })
|
||||
}
|
||||
|
||||
// 添加栏舍管理
|
||||
export function apiFenceHouseAdd(params: any) {
|
||||
return request.post({ url: '/fence_house.fence_house/add', params })
|
||||
}
|
||||
|
||||
// 编辑栏舍管理
|
||||
export function apiFenceHouseEdit(params: any) {
|
||||
return request.post({ url: '/fence_house.fence_house/edit', params })
|
||||
}
|
||||
|
||||
// 删除栏舍管理
|
||||
export function apiFenceHouseDelete(params: any) {
|
||||
return request.post({ url: '/fence_house.fence_house/delete', params })
|
||||
}
|
||||
|
||||
// 栏舍管理详情
|
||||
export function apiFenceHouseDetail(params: any) {
|
||||
return request.get({ url: '/fence_house.fence_house/detail', params })
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
<template>
|
||||
<div class="edit-popup">
|
||||
<popup
|
||||
ref="popupRef"
|
||||
:title="popupTitle"
|
||||
:async="true"
|
||||
width="550px"
|
||||
@confirm="handleSubmit"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" label-width="90px" :rules="formRules">
|
||||
<el-form-item label="养殖基地id" prop="farm_id">
|
||||
<el-input v-model="formData.farm_id" clearable placeholder="请输入养殖基地id" />
|
||||
</el-form-item>
|
||||
<el-form-item label="栏舍名称" prop="fence_house_name">
|
||||
<el-input v-model="formData.fence_house_name" clearable placeholder="请输入栏舍名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="动物类型" prop="animal_type">
|
||||
<el-select class="flex-1" v-model="formData.animal_type" clearable placeholder="请选择动物类型">
|
||||
<el-option
|
||||
v-for="(item, index) in dictData.animal_type"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:value="parseInt(item.value)"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="栏舍类型" prop="fence_house_type">
|
||||
<el-select class="flex-1" v-model="formData.fence_house_type" clearable placeholder="请选择栏舍类型">
|
||||
<el-option
|
||||
v-for="(item, index) in dictData.fence_house_type"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:value="parseInt(item.value)"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="容量" prop="capacity">
|
||||
<el-input v-model="formData.capacity" clearable placeholder="请输入容量" />
|
||||
</el-form-item>
|
||||
<el-form-item label="负责人" prop="master">
|
||||
<el-input v-model="formData.master" clearable placeholder="请输入负责人" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-input v-model="formData.status" clearable placeholder="请输入状态" />
|
||||
</el-form-item>
|
||||
<el-form-item label="二维码" prop="qr_code">
|
||||
<el-input v-model="formData.qr_code" clearable placeholder="请输入二维码" />
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
</popup>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="fenceHouseEdit">
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import Popup from '@/components/popup/index.vue'
|
||||
import { apiFenceHouseAdd, apiFenceHouseEdit, apiFenceHouseDetail } from '@/api/fence_house'
|
||||
import { timeFormat } from '@/utils/util'
|
||||
import type { PropType } from 'vue'
|
||||
defineProps({
|
||||
dictData: {
|
||||
type: Object as PropType<Record<string, any[]>>,
|
||||
default: () => ({})
|
||||
}
|
||||
})
|
||||
const emit = defineEmits(['success', 'close'])
|
||||
const formRef = shallowRef<FormInstance>()
|
||||
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
||||
const mode = ref('add')
|
||||
|
||||
|
||||
// 弹窗标题
|
||||
const popupTitle = computed(() => {
|
||||
return mode.value == 'edit' ? '编辑栏舍管理' : '新增栏舍管理'
|
||||
})
|
||||
|
||||
// 表单数据
|
||||
const formData = reactive({
|
||||
id: '',
|
||||
farm_id: '',
|
||||
fence_house_name: '',
|
||||
animal_type: '',
|
||||
fence_house_type: '',
|
||||
capacity: '',
|
||||
master: '',
|
||||
status: '',
|
||||
qr_code: '',
|
||||
|
||||
})
|
||||
|
||||
|
||||
// 表单验证
|
||||
const formRules = reactive<any>({
|
||||
|
||||
})
|
||||
|
||||
|
||||
// 获取详情
|
||||
const setFormData = async (data: Record<any, any>) => {
|
||||
for (const key in formData) {
|
||||
if (data[key] != null && data[key] != undefined) {
|
||||
//@ts-ignore
|
||||
formData[key] = data[key]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
const getDetail = async (row: Record<string, any>) => {
|
||||
const data = await apiFenceHouseDetail({
|
||||
id: row.id
|
||||
})
|
||||
setFormData(data)
|
||||
}
|
||||
|
||||
|
||||
// 提交按钮
|
||||
const handleSubmit = async () => {
|
||||
await formRef.value?.validate()
|
||||
const data = { ...formData, }
|
||||
mode.value == 'edit'
|
||||
? await apiFenceHouseEdit(data)
|
||||
: await apiFenceHouseAdd(data)
|
||||
popupRef.value?.close()
|
||||
emit('success')
|
||||
}
|
||||
|
||||
//打开弹窗
|
||||
const open = (type = 'add') => {
|
||||
mode.value = type
|
||||
popupRef.value?.open()
|
||||
}
|
||||
|
||||
// 关闭回调
|
||||
const handleClose = () => {
|
||||
emit('close')
|
||||
}
|
||||
|
||||
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
setFormData,
|
||||
getDetail
|
||||
})
|
||||
</script>
|
|
@ -0,0 +1,141 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-card class="!border-none mb-4" shadow="never">
|
||||
<el-form
|
||||
class="mb-[-16px]"
|
||||
:model="queryParams"
|
||||
inline
|
||||
>
|
||||
<el-form-item label="栏舍名称" prop="fence_house_name">
|
||||
<el-input class="w-[280px]" v-model="queryParams.fence_house_name" clearable placeholder="请输入栏舍名称" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="resetPage">查询</el-button>
|
||||
<el-button @click="resetParams">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
|
||||
<el-button v-perms="['fence_house.fence_house/add']" type="primary" @click="handleAdd">
|
||||
<template #icon>
|
||||
<icon name="el-icon-Plus" />
|
||||
</template>
|
||||
新增
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['fence_house.fence_house/delete']"
|
||||
:disabled="!selectData.length"
|
||||
@click="handleDelete(selectData)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
<div class="mt-4">
|
||||
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column label="养殖基地id" prop="farm_id" show-overflow-tooltip />
|
||||
<el-table-column label="栏舍名称" prop="fence_house_name" show-overflow-tooltip />
|
||||
<el-table-column label="动物类型" prop="animal_type">
|
||||
<template #default="{ row }">
|
||||
<dict-value :options="dictData.animal_type" :value="row.animal_type" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="栏舍类型" prop="fence_house_type">
|
||||
<template #default="{ row }">
|
||||
<dict-value :options="dictData.fence_house_type" :value="row.fence_house_type" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="容量" prop="capacity" show-overflow-tooltip />
|
||||
<el-table-column label="负责人" prop="master" show-overflow-tooltip />
|
||||
<el-table-column label="状态" prop="status" show-overflow-tooltip />
|
||||
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-perms="['fence_house.fence_house/edit']"
|
||||
type="primary"
|
||||
link
|
||||
@click="handleEdit(row)"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['fence_house.fence_house/delete']"
|
||||
type="danger"
|
||||
link
|
||||
@click="handleDelete(row.id)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div class="flex mt-4 justify-end">
|
||||
<pagination v-model="pager" @change="getLists" />
|
||||
</div>
|
||||
</el-card>
|
||||
<edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="fenceHouseLists">
|
||||
import { usePaging } from '@/hooks/usePaging'
|
||||
import { useDictData } from '@/hooks/useDictOptions'
|
||||
import { apiFenceHouseLists, apiFenceHouseDelete } from '@/api/fence_house'
|
||||
import { timeFormat } from '@/utils/util'
|
||||
import feedback from '@/utils/feedback'
|
||||
import EditPopup from './edit.vue'
|
||||
|
||||
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
|
||||
// 是否显示编辑框
|
||||
const showEdit = ref(false)
|
||||
|
||||
|
||||
// 查询条件
|
||||
const queryParams = reactive({
|
||||
fence_house_name: '',
|
||||
})
|
||||
|
||||
// 选中数据
|
||||
const selectData = ref<any[]>([])
|
||||
|
||||
// 表格选择后回调事件
|
||||
const handleSelectionChange = (val: any[]) => {
|
||||
selectData.value = val.map(({ id }) => id)
|
||||
}
|
||||
|
||||
// 获取字典数据
|
||||
const { dictData } = useDictData('animal_type,fence_house_type')
|
||||
|
||||
// 分页相关
|
||||
const { pager, getLists, resetParams, resetPage } = usePaging({
|
||||
fetchFun: apiFenceHouseLists,
|
||||
params: queryParams
|
||||
})
|
||||
|
||||
// 添加
|
||||
const handleAdd = async () => {
|
||||
showEdit.value = true
|
||||
await nextTick()
|
||||
editRef.value?.open('add')
|
||||
}
|
||||
|
||||
// 编辑
|
||||
const handleEdit = async (data: any) => {
|
||||
showEdit.value = true
|
||||
await nextTick()
|
||||
editRef.value?.open('edit')
|
||||
editRef.value?.setFormData(data)
|
||||
}
|
||||
|
||||
// 删除
|
||||
const handleDelete = async (id: number | any[]) => {
|
||||
await feedback.confirm('确定要删除?')
|
||||
await apiFenceHouseDelete({ id })
|
||||
getLists()
|
||||
}
|
||||
|
||||
getLists()
|
||||
</script>
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\adminapi\controller\fence_house;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\fence_house\FenceHouseLists;
|
||||
use app\adminapi\logic\fence_house\FenceHouseLogic;
|
||||
use app\adminapi\validate\fence_house\FenceHouseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* FenceHouse控制器
|
||||
* Class FenceHouseController
|
||||
* @package app\adminapi\controller\fence_house
|
||||
*/
|
||||
class FenceHouseController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:15
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new FenceHouseLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:15
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new FenceHouseValidate())->post()->goCheck('add');
|
||||
$result = FenceHouseLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(FenceHouseLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:15
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new FenceHouseValidate())->post()->goCheck('edit');
|
||||
$result = FenceHouseLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(FenceHouseLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:15
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new FenceHouseValidate())->post()->goCheck('delete');
|
||||
FenceHouseLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:15
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new FenceHouseValidate())->goCheck('detail');
|
||||
$result = FenceHouseLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\lists\fence_house;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\fence_house\FenceHouse;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* FenceHouse列表
|
||||
* Class FenceHouseLists
|
||||
* @package app\adminapi\listsfence_house
|
||||
*/
|
||||
class FenceHouseLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:15
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['fence_house_name'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:15
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return FenceHouse::where($this->searchWhere)
|
||||
->field(['id', 'farm_id', 'fence_house_name', 'animal_type', 'fence_house_type', 'capacity', 'master', 'status'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:15
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return FenceHouse::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\fence_house;
|
||||
|
||||
|
||||
use app\common\model\fence_house\FenceHouse;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* FenceHouse逻辑
|
||||
* Class FenceHouseLogic
|
||||
* @package app\adminapi\logic\fence_house
|
||||
*/
|
||||
class FenceHouseLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:15
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
FenceHouse::create([
|
||||
'farm_id' => $params['farm_id'],
|
||||
'fence_house_name' => $params['fence_house_name'],
|
||||
'animal_type' => $params['animal_type'],
|
||||
'fence_house_type' => $params['fence_house_type'],
|
||||
'capacity' => $params['capacity'],
|
||||
'master' => $params['master'],
|
||||
'status' => $params['status'],
|
||||
'qr_code' => $params['qr_code'],
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:15
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
FenceHouse::where('id', $params['id'])->update([
|
||||
'farm_id' => $params['farm_id'],
|
||||
'fence_house_name' => $params['fence_house_name'],
|
||||
'animal_type' => $params['animal_type'],
|
||||
'fence_house_type' => $params['fence_house_type'],
|
||||
'capacity' => $params['capacity'],
|
||||
'master' => $params['master'],
|
||||
'status' => $params['status'],
|
||||
'qr_code' => $params['qr_code'],
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:15
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return FenceHouse::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:15
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return FenceHouse::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\fence_house;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* FenceHouse验证器
|
||||
* Class FenceHouseValidate
|
||||
* @package app\adminapi\validate\fence_house
|
||||
*/
|
||||
class FenceHouseValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return FenceHouseValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:15
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return FenceHouseValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:15
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return FenceHouseValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:15
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return FenceHouseValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:15
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model\fence_house;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* FenceHouse模型
|
||||
* Class FenceHouse
|
||||
* @package app\common\model\fence_house
|
||||
*/
|
||||
class FenceHouse extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'fence_house';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
|
||||
/**
|
||||
* @notes 关联farmAttr
|
||||
* @return \think\model\relation\HasOne
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:15
|
||||
*/
|
||||
public function farmAttr()
|
||||
{
|
||||
return $this->hasOne(\app\common\model\farm\Farm::class, 'id', 'farm_id');
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue