科研项目信息

pull/3/head
F 2024-01-16 12:06:23 +08:00
parent 2c0ff52719
commit 34a1fe1ead
10 changed files with 609 additions and 0 deletions

View File

@ -0,0 +1,108 @@
/**
* Copyright 2023 UESTC
*/
package com.dkha.researchProjectInformation.controller;
import com.dkha.commons.tools.constant.Constant;
import com.dkha.commons.tools.page.PageData;
import com.dkha.commons.tools.excel.ExcelUtils;
import com.dkha.commons.tools.utils.Result;
import com.dkha.commons.tools.validator.AssertUtils;
import com.dkha.commons.tools.validator.ValidatorUtils;
import com.dkha.commons.tools.validator.group.AddGroup;
import com.dkha.commons.tools.validator.group.UpdateGroup;
import com.dkha.commons.tools.validator.group.DefaultGroup;
import com.dkha.researchProjectInformation.dto.ResearchProjectInformationDTO;
import com.dkha.researchProjectInformation.excel.ResearchProjectInformationExcel;
import com.dkha.researchProjectInformation.service.ResearchProjectInformationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
*
*
* @author li.zhan 719901725@qq.com
* @since v1.0.0 2024-01-09
*/
@RestController
@RequestMapping("researchProjectInformation")
@Api(tags="科研项目信息")
public class ResearchProjectInformationController {
@Autowired
private ResearchProjectInformationService researchProjectInformationService;
@GetMapping("page")
@ApiOperation("分页")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String")
})
public Result<PageData<ResearchProjectInformationDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<ResearchProjectInformationDTO> page = researchProjectInformationService.page(params);
return new Result<PageData<ResearchProjectInformationDTO>>().ok(page);
}
@GetMapping("{id}")
@ApiOperation("信息")
public Result<ResearchProjectInformationDTO> get(@PathVariable("id") String id){
ResearchProjectInformationDTO data = researchProjectInformationService.get(id);
return new Result<ResearchProjectInformationDTO>().ok(data);
}
@PostMapping
@ApiOperation("保存")
public Result save(@RequestBody ResearchProjectInformationDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
researchProjectInformationService.save(dto);
return new Result();
}
@PutMapping
@ApiOperation("修改")
public Result update(@RequestBody ResearchProjectInformationDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
researchProjectInformationService.update(dto);
return new Result();
}
@DeleteMapping
@ApiOperation("删除")
public Result delete(@RequestBody String[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
researchProjectInformationService.delete(ids);
return new Result();
}
@GetMapping("export")
@ApiOperation("导出")
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<ResearchProjectInformationDTO> list = researchProjectInformationService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, ResearchProjectInformationExcel.class);
}
}

View File

@ -0,0 +1,20 @@
/**
* Copyright 2023 UESTC
*/
package com.dkha.researchProjectInformation.dao;
import com.dkha.commons.mybatis.dao.BaseDao;
import com.dkha.researchProjectInformation.entity.ResearchProjectInformationEntity;
import org.apache.ibatis.annotations.Mapper;
/**
*
*
* @author li.zhan 719901725@qq.com
* @since v1.0.0 2024-01-09
*/
@Mapper
public interface ResearchProjectInformationDao extends BaseDao<ResearchProjectInformationEntity> {
}

View File

@ -0,0 +1,44 @@
/**
* Copyright 2023 UESTC
*/
package com.dkha.researchProjectInformation.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
*
*
* @author li.zhan 719901725@qq.com
* @since v1.0.0 2024-01-09
*/
@Data
@ApiModel(value = "科研项目信息")
public class ResearchProjectInformationDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID")
private Long id;
@ApiModelProperty(value = "科研编号")
private String researchId;
@ApiModelProperty(value = "项目编号")
private String projectId;
@ApiModelProperty(value = "预算余额")
private Double budgetBalance;
@ApiModelProperty(value = "创建人")
private String creator;
@ApiModelProperty(value = "创建时间")
private Date createDate;
}

View File

@ -0,0 +1,45 @@
/**
* Copyright 2023 UESTC
*/
package com.dkha.researchProjectInformation.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.dkha.commons.mybatis.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
*
*
* @author li.zhan 719901725@qq.com
* @since v1.0.0 2024-01-09
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("zhyy_research_project_information")
public class ResearchProjectInformationEntity extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
*
*/
private String researchId;
/**
*
*/
private String projectId;
/**
*
*/
private Double budgetBalance;
/**
*
*/
private Date createDate;
}

View File

@ -0,0 +1,31 @@
/**
* Copyright 2023 UESTC
*/
package com.dkha.researchProjectInformation.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.util.Date;
/**
*
*
* @author li.zhan 719901725@qq.com
* @since v1.0.0 2024-01-09
*/
@Data
public class ResearchProjectInformationExcel {
@Excel(name = "主键ID")
private Long id;
@Excel(name = "科研编号")
private String researchId;
@Excel(name = "项目编号")
private String projectId;
@Excel(name = "预算余额")
private Double budgetBalance;
@Excel(name = "创建时间")
private Date createDate;
}

View File

@ -0,0 +1,34 @@
/**
* Copyright 2023 UESTC
*/
package com.dkha.researchProjectInformation.redis;
import com.dkha.commons.tools.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
*
*
* @author li.zhan 719901725@qq.com
* @since v1.0.0 2024-01-09
*/
@Component
public class ResearchProjectInformationRedis {
@Autowired
private RedisUtils redisUtils;
public void delete(Object[] ids) {
}
public void set(){
}
public String get(String id){
return null;
}
}

View File

@ -0,0 +1,33 @@
/**
* Copyright 2023 UESTC
*/
package com.dkha.researchProjectInformation.service;
import com.dkha.commons.mybatis.service.BaseService;
import com.dkha.commons.tools.page.PageData;
import com.dkha.researchProjectInformation.dto.ResearchProjectInformationDTO;
import com.dkha.researchProjectInformation.entity.ResearchProjectInformationEntity;
import java.util.List;
import java.util.Map;
/**
*
*
* @author li.zhan 719901725@qq.com
* @since v1.0.0 2024-01-09
*/
public interface ResearchProjectInformationService extends BaseService<ResearchProjectInformationEntity> {
PageData<ResearchProjectInformationDTO> page(Map<String, Object> params);
List<ResearchProjectInformationDTO> list(Map<String, Object> params);
ResearchProjectInformationDTO get(String id);
void save(ResearchProjectInformationDTO dto);
void update(ResearchProjectInformationDTO dto);
void delete(String[] ids);
}

View File

@ -0,0 +1,106 @@
/**
* Copyright 2023 UESTC
*/
package com.dkha.researchProjectInformation.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dkha.commons.mybatis.service.impl.BaseServiceImpl;
import com.dkha.commons.tools.constant.Constant;
import com.dkha.commons.tools.page.PageData;
import com.dkha.commons.tools.utils.ConvertUtils;
import com.dkha.researchProjectInformation.dao.ResearchProjectInformationDao;
import com.dkha.researchProjectInformation.dto.ResearchProjectInformationDTO;
import com.dkha.researchProjectInformation.entity.ResearchProjectInformationEntity;
import com.dkha.researchProjectInformation.redis.ResearchProjectInformationRedis;
import com.dkha.researchProjectInformation.service.ResearchProjectInformationService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
*
*
* @author li.zhan 719901725@qq.com
* @since v1.0.0 2024-01-09
*/
@Service
public class ResearchProjectInformationServiceImpl extends BaseServiceImpl<ResearchProjectInformationDao, ResearchProjectInformationEntity> implements ResearchProjectInformationService {
@Autowired
private ResearchProjectInformationRedis researchProjectInformationRedis;
@Override
public PageData<ResearchProjectInformationDTO> page(Map<String, Object> params) {
IPage<ResearchProjectInformationEntity> page = baseDao.selectPage(
getPage(params, Constant.CREATE_DATE, false),
getWrapper(params)
);
return getPageData(page, ResearchProjectInformationDTO.class);
}
@Override
public List<ResearchProjectInformationDTO> list(Map<String, Object> params) {
List<ResearchProjectInformationEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, ResearchProjectInformationDTO.class);
}
private QueryWrapper<ResearchProjectInformationEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get("id");
String researchId = (String)params.get("researchId");
String projectId = (String)params.get("projectId");
String startTime = (String)params.get("startTime");
String endTime = (String)params.get("endTime");
QueryWrapper<ResearchProjectInformationEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), "id", id);
wrapper.like(StringUtils.isNotBlank(researchId), "research_id", researchId);
wrapper.like(StringUtils.isNotBlank(projectId), "project_id", projectId);
wrapper.gt(StringUtils.isNotBlank(startTime),"create_date",startTime);
wrapper.lt(StringUtils.isNotBlank(endTime),"create_date",endTime);
//wrapper.eq(Constant.DEL_FLAG, DelFlagEnum.NORMAL.value());
return wrapper;
}
@Override
public ResearchProjectInformationDTO get(String id) {
ResearchProjectInformationEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, ResearchProjectInformationDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(ResearchProjectInformationDTO dto) {
ResearchProjectInformationEntity entity = ConvertUtils.sourceToTarget(dto, ResearchProjectInformationEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(ResearchProjectInformationDTO dto) {
ResearchProjectInformationEntity entity = ConvertUtils.sourceToTarget(dto, ResearchProjectInformationEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
//逻辑删除
//logicDelete(ids, ResearchProjectInformationEntity.class);
//物理删除
baseDao.deleteBatchIds(Arrays.asList(ids));
}
}

View File

@ -0,0 +1,100 @@
<template>
<el-dialog :visible.sync="visible" :title="!dataForm.id ? $t('add') : $t('update')" :close-on-click-modal="false" :close-on-press-escape="false">
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" :label-width="$i18n.locale === 'en-US' ? '200px' : '150px'">
<el-form-item label="科研编号" prop="researchId">
<el-input v-model="dataForm.researchId" placeholder="科研编号"></el-input>
</el-form-item>
<el-form-item label="项目编号" prop="projectId">
<el-input v-model="dataForm.projectId" placeholder="项目编号"></el-input>
</el-form-item>
<el-form-item label="预算余额(万元)" prop="budgetBalance">
<el-input v-model="dataForm.budgetBalance" placeholder="预算余额"></el-input>
</el-form-item>
</el-form>
<template slot="footer">
<el-button @click="visible = false">{{ $t('cancel') }}</el-button>
<el-button type="primary" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button>
</template>
</el-dialog>
</template>
<script>
import debounce from 'lodash/debounce'
export default {
data () {
return {
visible: false,
dataForm: {
id: '',
researchId: '',
projectId: '',
budgetBalance: '',
createDate: ''
}
}
},
computed: {
dataRule () {
return {
researchId: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
projectId: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
budgetBalance: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
createDate: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
]
}
}
},
methods: {
init () {
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.id) {
this.getInfo()
}
})
},
//
getInfo () {
this.$http.get(`/system/researchProjectInformation/${this.dataForm.id}`).then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.dataForm = {
...this.dataForm,
...res.data
}
}).catch(() => {})
},
//
dataFormSubmitHandle: debounce(function () {
this.$refs['dataForm'].validate((valid) => {
if (!valid) {
return false
}
this.$http[!this.dataForm.id ? 'post' : 'put']('/system/researchProjectInformation/', this.dataForm).then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.$message({
message: this.$t('prompt.success'),
type: 'success',
duration: 500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
}).catch(() => {})
})
}, 1000, { 'leading': true, 'trailing': false })
}
}
</script>

View File

@ -0,0 +1,88 @@
<template>
<el-card shadow="never" class="aui-card--fill">
<div class="mod-researchProjectInformation__researchprojectinformation}">
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
<el-form-item label="科研编号" prop="researchId">
<el-input v-model="dataForm.researchId" placeholder="科研编号" clearable></el-input>
</el-form-item>
<el-form-item label="项目编号" prop="projectId">
<el-input v-model="dataForm.projectId" placeholder="项目编号" clearable></el-input>
</el-form-item>
<el-form-item label="开始时间" prop="startTime">
<el-date-picker
v-model="dataForm.startTime"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="开始时间">
</el-date-picker>
</el-form-item>
<el-form-item label="结束时间" prop="endTime">
<el-date-picker
v-model="dataForm.endTime"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="结束时间">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button @click="getDataList()">{{ $t('query') }}</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>
</el-form-item>
<el-form-item>
<el-button type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>
</el-form-item>
</el-form>
<el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;">
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
<el-table-column type="index" label="序号" align="center" width="50"></el-table-column>
<el-table-column prop="researchId" label="科研编号" header-align="center" align="center"></el-table-column>
<el-table-column prop="projectId" label="项目编号" header-align="center" align="center"></el-table-column>
<el-table-column prop="budgetBalance" label="预算余额(万元)" header-align="center" align="center"></el-table-column>
<el-table-column prop="createDate" label="创建时间" header-align="center" align="center"></el-table-column>
<el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="200">
<template slot-scope="scope">
<el-button @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button>
<el-button @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
:current-page="page"
:page-sizes="[10, 20, 50, 100]"
:page-size="limit"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="pageSizeChangeHandle"
@current-change="pageCurrentChangeHandle">
</el-pagination>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
</div>
</el-card>
</template>
<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './researchprojectinformation-add-or-update'
export default {
mixins: [mixinViewModule],
data () {
return {
mixinViewModuleOptions: {
getDataListURL: '/system/researchProjectInformation/page',
getDataListIsPage: true,
deleteURL: '/system/researchProjectInformation',
deleteIsBatch: true
},
dataForm: {
}
}
},
components: {
AddOrUpdate
}
}
</script>