add 档案管理
This commit is contained in:
parent
83b2195223
commit
00830de89a
|
@ -0,0 +1,26 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
// 动物档案列表
|
||||
export function apiAnimalInfoLists(params: any) {
|
||||
return request.get({ url: '/animal_info.animal_info/lists', params })
|
||||
}
|
||||
|
||||
// 添加动物档案
|
||||
export function apiAnimalInfoAdd(params: any) {
|
||||
return request.post({ url: '/animal_info.animal_info/add', params })
|
||||
}
|
||||
|
||||
// 编辑动物档案
|
||||
export function apiAnimalInfoEdit(params: any) {
|
||||
return request.post({ url: '/animal_info.animal_info/edit', params })
|
||||
}
|
||||
|
||||
// 删除动物档案
|
||||
export function apiAnimalInfoDelete(params: any) {
|
||||
return request.post({ url: '/animal_info.animal_info/delete', params })
|
||||
}
|
||||
|
||||
// 动物档案详情
|
||||
export function apiAnimalInfoDetail(params: any) {
|
||||
return request.get({ url: '/animal_info.animal_info/detail', params })
|
||||
}
|
|
@ -0,0 +1,170 @@
|
|||
<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="fence_house_id">
|
||||
<el-input v-model="formData.fence_house_id" clearable placeholder="请输入栏舍id" />
|
||||
</el-form-item>
|
||||
<el-form-item label="耳号" prop="sn">
|
||||
<el-input v-model="formData.sn" 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="brand">
|
||||
<el-input v-model="formData.brand" clearable placeholder="请输入品种" />
|
||||
</el-form-item>
|
||||
<el-form-item label="生理阶段" prop="physi_stage">
|
||||
<el-input v-model="formData.physi_stage" clearable placeholder="请输入生理阶段" />
|
||||
</el-form-item>
|
||||
<el-form-item label="性别" prop="gender">
|
||||
<el-input v-model="formData.gender" clearable placeholder="请输入性别" />
|
||||
</el-form-item>
|
||||
<el-form-item label="血统纯度" prop="blood_purity">
|
||||
<el-input v-model="formData.blood_purity" clearable placeholder="请输入血统纯度" />
|
||||
</el-form-item>
|
||||
<el-form-item label="来源" prop="animal_source">
|
||||
<el-input v-model="formData.animal_source" clearable placeholder="请输入来源" />
|
||||
</el-form-item>
|
||||
<el-form-item label="现估量" prop="current_estimation">
|
||||
<el-input v-model="formData.current_estimation" clearable placeholder="请输入现估量" />
|
||||
</el-form-item>
|
||||
<el-form-item label="代数" prop="algebra">
|
||||
<el-input v-model="formData.algebra" clearable placeholder="请输入代数" />
|
||||
</el-form-item>
|
||||
<el-form-item label="出生日期" prop="birth">
|
||||
<el-input v-model="formData.birth" clearable placeholder="请输入出生日期" />
|
||||
</el-form-item>
|
||||
<el-form-item label="入场日期" prop="entry_date">
|
||||
<el-input v-model="formData.entry_date" clearable placeholder="请输入入场日期" />
|
||||
</el-form-item>
|
||||
<el-form-item label="出生体重" prop="birth_estimation">
|
||||
<el-input v-model="formData.birth_estimation" clearable placeholder="请输入出生体重" />
|
||||
</el-form-item>
|
||||
<el-form-item label="健康状况" prop="health_condition">
|
||||
<el-input v-model="formData.health_condition" clearable placeholder="请输入健康状况" />
|
||||
</el-form-item>
|
||||
<el-form-item label="图片" prop="image">
|
||||
<el-input v-model="formData.image" clearable placeholder="请输入图片" />
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
</popup>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="animalInfoEdit">
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import Popup from '@/components/popup/index.vue'
|
||||
import { apiAnimalInfoAdd, apiAnimalInfoEdit, apiAnimalInfoDetail } from '@/api/animal_info'
|
||||
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: '',
|
||||
fence_house_id: '',
|
||||
sn: '',
|
||||
animal_type: '',
|
||||
brand: '',
|
||||
physi_stage: '',
|
||||
gender: '',
|
||||
blood_purity: '',
|
||||
animal_source: '',
|
||||
current_estimation: '',
|
||||
algebra: '',
|
||||
birth: '',
|
||||
entry_date: '',
|
||||
birth_estimation: '',
|
||||
health_condition: '',
|
||||
image: '',
|
||||
|
||||
})
|
||||
|
||||
|
||||
// 表单验证
|
||||
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 apiAnimalInfoDetail({
|
||||
id: row.id
|
||||
})
|
||||
setFormData(data)
|
||||
}
|
||||
|
||||
|
||||
// 提交按钮
|
||||
const handleSubmit = async () => {
|
||||
await formRef.value?.validate()
|
||||
const data = { ...formData, }
|
||||
mode.value == 'edit'
|
||||
? await apiAnimalInfoEdit(data)
|
||||
: await apiAnimalInfoAdd(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,144 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-card class="!border-none mb-4" shadow="never">
|
||||
<el-form
|
||||
class="mb-[-16px]"
|
||||
:model="queryParams"
|
||||
inline
|
||||
>
|
||||
<el-form-item label="耳号" prop="sn">
|
||||
<el-input class="w-[280px]" v-model="queryParams.sn" 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="['animal_info.animal_info/add']" type="primary" @click="handleAdd">
|
||||
<template #icon>
|
||||
<icon name="el-icon-Plus" />
|
||||
</template>
|
||||
新增
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['animal_info.animal_info/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="fence_house_id" show-overflow-tooltip />
|
||||
<el-table-column label="耳号" prop="sn" 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="brand" show-overflow-tooltip />
|
||||
<el-table-column label="生理阶段" prop="physi_stage" show-overflow-tooltip />
|
||||
<el-table-column label="性别" prop="gender" show-overflow-tooltip />
|
||||
<el-table-column label="血统纯度" prop="blood_purity" show-overflow-tooltip />
|
||||
<el-table-column label="来源" prop="animal_source" show-overflow-tooltip />
|
||||
<el-table-column label="现估量" prop="current_estimation" show-overflow-tooltip />
|
||||
<el-table-column label="代数" prop="algebra" show-overflow-tooltip />
|
||||
<el-table-column label="出生日期" prop="birth" show-overflow-tooltip />
|
||||
<el-table-column label="入场日期" prop="entry_date" show-overflow-tooltip />
|
||||
<el-table-column label="出生体重" prop="birth_estimation" show-overflow-tooltip />
|
||||
<el-table-column label="健康状况" prop="health_condition" show-overflow-tooltip />
|
||||
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-perms="['animal_info.animal_info/edit']"
|
||||
type="primary"
|
||||
link
|
||||
@click="handleEdit(row)"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['animal_info.animal_info/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="animalInfoLists">
|
||||
import { usePaging } from '@/hooks/usePaging'
|
||||
import { useDictData } from '@/hooks/useDictOptions'
|
||||
import { apiAnimalInfoLists, apiAnimalInfoDelete } from '@/api/animal_info'
|
||||
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({
|
||||
sn: '',
|
||||
})
|
||||
|
||||
// 选中数据
|
||||
const selectData = ref<any[]>([])
|
||||
|
||||
// 表格选择后回调事件
|
||||
const handleSelectionChange = (val: any[]) => {
|
||||
selectData.value = val.map(({ id }) => id)
|
||||
}
|
||||
|
||||
// 获取字典数据
|
||||
const { dictData } = useDictData('animal_type')
|
||||
|
||||
// 分页相关
|
||||
const { pager, getLists, resetParams, resetPage } = usePaging({
|
||||
fetchFun: apiAnimalInfoLists,
|
||||
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 apiAnimalInfoDelete({ 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\animal_info;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\animal_info\AnimalInfoLists;
|
||||
use app\adminapi\logic\animal_info\AnimalInfoLogic;
|
||||
use app\adminapi\validate\animal_info\AnimalInfoValidate;
|
||||
|
||||
|
||||
/**
|
||||
* AnimalInfo控制器
|
||||
* Class AnimalInfoController
|
||||
* @package app\adminapi\controller\animal_info
|
||||
*/
|
||||
class AnimalInfoController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:53
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new AnimalInfoLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:53
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new AnimalInfoValidate())->post()->goCheck('add');
|
||||
$result = AnimalInfoLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(AnimalInfoLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:53
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new AnimalInfoValidate())->post()->goCheck('edit');
|
||||
$result = AnimalInfoLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(AnimalInfoLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:53
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new AnimalInfoValidate())->post()->goCheck('delete');
|
||||
AnimalInfoLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:53
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new AnimalInfoValidate())->goCheck('detail');
|
||||
$result = AnimalInfoLogic::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\animal_info;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\animal_info\AnimalInfo;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* AnimalInfo列表
|
||||
* Class AnimalInfoLists
|
||||
* @package app\adminapi\listsanimal_info
|
||||
*/
|
||||
class AnimalInfoLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:53
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['sn'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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:53
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return AnimalInfo::where($this->searchWhere)
|
||||
->field(['id', 'fence_house_id', 'sn', 'animal_type', 'brand', 'physi_stage', 'gender', 'blood_purity', 'animal_source', 'current_estimation', 'algebra', 'birth', 'entry_date', 'birth_estimation', 'health_condition'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:53
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return AnimalInfo::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,134 @@
|
|||
<?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\animal_info;
|
||||
|
||||
|
||||
use app\common\model\animal_info\AnimalInfo;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* AnimalInfo逻辑
|
||||
* Class AnimalInfoLogic
|
||||
* @package app\adminapi\logic\animal_info
|
||||
*/
|
||||
class AnimalInfoLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:53
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
AnimalInfo::create([
|
||||
'fence_house_id' => $params['fence_house_id'],
|
||||
'sn' => $params['sn'],
|
||||
'animal_type' => $params['animal_type'],
|
||||
'brand' => $params['brand'],
|
||||
'physi_stage' => $params['physi_stage'],
|
||||
'gender' => $params['gender'],
|
||||
'blood_purity' => $params['blood_purity'],
|
||||
'animal_source' => $params['animal_source'],
|
||||
'current_estimation' => $params['current_estimation'],
|
||||
'algebra' => $params['algebra'],
|
||||
'birth' => $params['birth'],
|
||||
'entry_date' => $params['entry_date'],
|
||||
'birth_estimation' => $params['birth_estimation'],
|
||||
'health_condition' => $params['health_condition'],
|
||||
'image' => $params['image'],
|
||||
]);
|
||||
|
||||
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:53
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
AnimalInfo::where('id', $params['id'])->update([
|
||||
'fence_house_id' => $params['fence_house_id'],
|
||||
'sn' => $params['sn'],
|
||||
'animal_type' => $params['animal_type'],
|
||||
'brand' => $params['brand'],
|
||||
'physi_stage' => $params['physi_stage'],
|
||||
'gender' => $params['gender'],
|
||||
'blood_purity' => $params['blood_purity'],
|
||||
'animal_source' => $params['animal_source'],
|
||||
'current_estimation' => $params['current_estimation'],
|
||||
'algebra' => $params['algebra'],
|
||||
'birth' => $params['birth'],
|
||||
'entry_date' => $params['entry_date'],
|
||||
'birth_estimation' => $params['birth_estimation'],
|
||||
'health_condition' => $params['health_condition'],
|
||||
'image' => $params['image'],
|
||||
]);
|
||||
|
||||
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:53
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return AnimalInfo::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:53
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return AnimalInfo::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\animal_info;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* AnimalInfo验证器
|
||||
* Class AnimalInfoValidate
|
||||
* @package app\adminapi\validate\animal_info
|
||||
*/
|
||||
class AnimalInfoValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return AnimalInfoValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:53
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return AnimalInfoValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:53
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return AnimalInfoValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:53
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return AnimalInfoValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:53
|
||||
*/
|
||||
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\animal_info;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* AnimalInfo模型
|
||||
* Class AnimalInfo
|
||||
* @package app\common\model\animal_info
|
||||
*/
|
||||
class AnimalInfo extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'animal_info';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
|
||||
/**
|
||||
* @notes 关联fenceHouseAttr
|
||||
* @return \think\model\relation\HasOne
|
||||
* @author likeadmin
|
||||
* @date 2024/01/10 15:53
|
||||
*/
|
||||
public function fenceHouseAttr()
|
||||
{
|
||||
return $this->hasOne(\app\common\model\fence_house\FenceHouse::class, 'id', 'fence_house_id');
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue