diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/resource/controller/ResourceController.java b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/resource/controller/ResourceController.java new file mode 100644 index 00000000..5274f6a0 --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/resource/controller/ResourceController.java @@ -0,0 +1,182 @@ +package org.jeecg.modules.gen.resource.controller; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.system.query.QueryGenerator; +import org.jeecg.common.system.query.QueryRuleEnum; +import org.jeecg.common.util.oConvertUtils; +import org.jeecg.modules.gen.resource.entity.Resource; +import org.jeecg.modules.gen.resource.service.IResourceService; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import lombok.extern.slf4j.Slf4j; + +import org.jeecgframework.poi.excel.ExcelImportUtil; +import org.jeecgframework.poi.excel.def.NormalExcelConstants; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.entity.ImportParams; +import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; +import org.jeecg.common.system.base.controller.JeecgController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; +import org.springframework.web.servlet.ModelAndView; +import com.alibaba.fastjson.JSON; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import org.jeecg.common.aspect.annotation.AutoLog; +import org.apache.shiro.authz.annotation.RequiresPermissions; + /** + * @Description: 资源表 + * @Author: jeecg-boot + * @Date: 2025-08-09 + * @Version: V1.0 + */ +@Tag(name="资源表") +@RestController +@RequestMapping("/gen/resource/resource") +@Slf4j +public class ResourceController extends JeecgController { + @Autowired + private IResourceService resourceService; + + /** + * 分页列表查询 + * + * @param resource + * @param pageNo + * @param pageSize + * @param req + * @return + */ + //@AutoLog(value = "资源表-分页列表查询") + @Operation(summary="资源表-分页列表查询") + @GetMapping(value = "/list") + public Result> queryPageList(Resource resource, + @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, + HttpServletRequest req) { + + + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(resource, req.getParameterMap()); + Page page = new Page(pageNo, pageSize); + IPage pageList = resourceService.page(page, queryWrapper); + return Result.OK(pageList); + } + + /** + * 添加 + * + * @param resource + * @return + */ + @AutoLog(value = "资源表-添加") + @Operation(summary="资源表-添加") + @RequiresPermissions("gen.resource:resource:add") + @PostMapping(value = "/add") + public Result add(@RequestBody Resource resource) { + resourceService.save(resource); + + return Result.OK("添加成功!"); + } + + /** + * 编辑 + * + * @param resource + * @return + */ + @AutoLog(value = "资源表-编辑") + @Operation(summary="资源表-编辑") + @RequiresPermissions("gen.resource:resource:edit") + @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) + public Result edit(@RequestBody Resource resource) { + resourceService.updateById(resource); + return Result.OK("编辑成功!"); + } + + /** + * 通过id删除 + * + * @param id + * @return + */ + @AutoLog(value = "资源表-通过id删除") + @Operation(summary="资源表-通过id删除") + @RequiresPermissions("gen.resource:resource:delete") + @DeleteMapping(value = "/delete") + public Result delete(@RequestParam(name="id",required=true) String id) { + resourceService.removeById(id); + return Result.OK("删除成功!"); + } + + /** + * 批量删除 + * + * @param ids + * @return + */ + @AutoLog(value = "资源表-批量删除") + @Operation(summary="资源表-批量删除") + @RequiresPermissions("gen.resource:resource:deleteBatch") + @DeleteMapping(value = "/deleteBatch") + public Result deleteBatch(@RequestParam(name="ids",required=true) String ids) { + this.resourceService.removeByIds(Arrays.asList(ids.split(","))); + return Result.OK("批量删除成功!"); + } + + /** + * 通过id查询 + * + * @param id + * @return + */ + //@AutoLog(value = "资源表-通过id查询") + @Operation(summary="资源表-通过id查询") + @GetMapping(value = "/queryById") + public Result queryById(@RequestParam(name="id",required=true) String id) { + Resource resource = resourceService.getById(id); + if(resource==null) { + return Result.error("未找到对应数据"); + } + return Result.OK(resource); + } + + /** + * 导出excel + * + * @param request + * @param resource + */ + @RequiresPermissions("gen.resource:resource:exportXls") + @RequestMapping(value = "/exportXls") + public ModelAndView exportXls(HttpServletRequest request, Resource resource) { + return super.exportXls(request, resource, Resource.class, "资源表"); + } + + /** + * 通过excel导入数据 + * + * @param request + * @param response + * @return + */ + @RequiresPermissions("gen.resource:resource:importExcel") + @RequestMapping(value = "/importExcel", method = RequestMethod.POST) + public Result importExcel(HttpServletRequest request, HttpServletResponse response) { + return super.importExcel(request, response, Resource.class); + } + +} diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/resource/entity/Resource.java b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/resource/entity/Resource.java new file mode 100644 index 00000000..96b8d72b --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/resource/entity/Resource.java @@ -0,0 +1,103 @@ +package org.jeecg.modules.gen.resource.entity; + +import java.io.Serializable; +import java.io.UnsupportedEncodingException; +import java.util.Date; +import java.math.BigDecimal; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.TableLogic; +import org.jeecg.common.constant.ProvinceCityArea; +import org.jeecg.common.util.SpringContextUtils; +import lombok.Data; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.springframework.format.annotation.DateTimeFormat; +import org.jeecgframework.poi.excel.annotation.Excel; +import org.jeecg.common.aspect.annotation.Dict; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * @Description: 资源表 + * @Author: jeecg-boot + * @Date: 2025-08-09 + * @Version: V1.0 + */ +@Data +@TableName("resource") +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = false) +@Schema(description="资源表") +public class Resource implements Serializable { + private static final long serialVersionUID = 1L; + + /**主键*/ + @TableId(type = IdType.ASSIGN_ID) + @Schema(description = "主键") + private java.lang.String id; + /**资源名*/ + @Excel(name = "资源名", width = 15) + @Schema(description = "资源名") + private java.lang.String name; + /**描述*/ + @Excel(name = "描述", width = 15) + @Schema(description = "描述") + private java.lang.String description; + /**资源类型*/ + @Excel(name = "资源类型", width = 15, dicCode = "resource_type") + @Dict(dicCode = "resource_type") + @Schema(description = "资源类型") + private java.lang.Integer type; + /**文件url*/ + @Excel(name = "文件url", width = 15) + @Schema(description = "文件url") + private java.lang.String fileUrl; + /**缩略图url*/ + @Excel(name = "缩略图url", width = 15) + @Schema(description = "缩略图url") + private java.lang.String thumbnailUrl; + /**时长*/ + @Excel(name = "时长", width = 15) + @Schema(description = "时长") + private java.lang.Integer duration; + /**文件大小*/ + @Excel(name = "文件大小", width = 15) + @Schema(description = "文件大小") + private java.lang.Integer fileSize; + /**文件元数据*/ + @Excel(name = "文件元数据", width = 15) + @Schema(description = "文件元数据") + private java.lang.String metadata; + /**是否精选*/ + @Excel(name = "是否精选", width = 15, dicCode = "resource_iz_featured") + @Dict(dicCode = "resource_iz_featured") + @Schema(description = "是否精选") + private java.lang.Integer izFeatured; + /**状态*/ + @Excel(name = "状态", width = 15, dicCode = "resource_status") + @Dict(dicCode = "resource_status") + @Schema(description = "状态") + private java.lang.Integer status; + /**创建人*/ + @Excel(name = "创建人", width = 15) + @Schema(description = "创建人") + private java.lang.String createdBy; + /**创建时间*/ + @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @Schema(description = "创建时间") + private java.util.Date createdTime; + /**更新人*/ + @Excel(name = "更新人", width = 15) + @Schema(description = "更新人") + private java.lang.String updatedBy; + /**更新时间*/ + @Excel(name = "更新时间", width = 20, format = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @Schema(description = "更新时间") + private java.util.Date updatedTime; +} diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/resource/mapper/ResourceMapper.java b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/resource/mapper/ResourceMapper.java new file mode 100644 index 00000000..8aad90e8 --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/resource/mapper/ResourceMapper.java @@ -0,0 +1,17 @@ +package org.jeecg.modules.gen.resource.mapper; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; +import org.jeecg.modules.gen.resource.entity.Resource; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * @Description: 资源表 + * @Author: jeecg-boot + * @Date: 2025-08-09 + * @Version: V1.0 + */ +public interface ResourceMapper extends BaseMapper { + +} diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/resource/mapper/xml/ResourceMapper.xml b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/resource/mapper/xml/ResourceMapper.xml new file mode 100644 index 00000000..fa73755a --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/resource/mapper/xml/ResourceMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/resource/service/IResourceService.java b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/resource/service/IResourceService.java new file mode 100644 index 00000000..b7344fc6 --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/resource/service/IResourceService.java @@ -0,0 +1,14 @@ +package org.jeecg.modules.gen.resource.service; + +import org.jeecg.modules.gen.resource.entity.Resource; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * @Description: 资源表 + * @Author: jeecg-boot + * @Date: 2025-08-09 + * @Version: V1.0 + */ +public interface IResourceService extends IService { + +} diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/resource/service/impl/ResourceServiceImpl.java b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/resource/service/impl/ResourceServiceImpl.java new file mode 100644 index 00000000..b6a67124 --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-learn/src/main/java/org/jeecg/modules/gen/resource/service/impl/ResourceServiceImpl.java @@ -0,0 +1,19 @@ +package org.jeecg.modules.gen.resource.service.impl; + +import org.jeecg.modules.gen.resource.entity.Resource; +import org.jeecg.modules.gen.resource.mapper.ResourceMapper; +import org.jeecg.modules.gen.resource.service.IResourceService; +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +/** + * @Description: 资源表 + * @Author: jeecg-boot + * @Date: 2025-08-09 + * @Version: V1.0 + */ +@Service +public class ResourceServiceImpl extends ServiceImpl implements IResourceService { + +} diff --git a/jeecgboot-vue3/src/views/gen/resource/Resource.api.ts b/jeecgboot-vue3/src/views/gen/resource/Resource.api.ts new file mode 100644 index 00000000..2f198e1a --- /dev/null +++ b/jeecgboot-vue3/src/views/gen/resource/Resource.api.ts @@ -0,0 +1,64 @@ +import {defHttp} from '/@/utils/http/axios'; +import { useMessage } from "/@/hooks/web/useMessage"; + +const { createConfirm } = useMessage(); + +enum Api { + list = '/gen/resource/resource/list', + save='/gen/resource/resource/add', + edit='/gen/resource/resource/edit', + deleteOne = '/gen/resource/resource/delete', + deleteBatch = '/gen/resource/resource/deleteBatch', + importExcel = '/gen/resource/resource/importExcel', + exportXls = '/gen/resource/resource/exportXls', +} +/** + * 导出api + * @param params + */ +export const getExportUrl = Api.exportXls; +/** + * 导入api + */ +export const getImportUrl = Api.importExcel; +/** + * 列表接口 + * @param params + */ +export const list = (params) => + defHttp.get({url: Api.list, params}); + +/** + * 删除单个 + */ +export const deleteOne = (params,handleSuccess) => { + return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => { + handleSuccess(); + }); +} +/** + * 批量删除 + * @param params + */ +export const batchDelete = (params, handleSuccess) => { + createConfirm({ + iconType: 'warning', + title: '确认删除', + content: '是否删除选中数据', + okText: '确认', + cancelText: '取消', + onOk: () => { + return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => { + handleSuccess(); + }); + } + }); +} +/** + * 保存或者更新 + * @param params + */ +export const saveOrUpdate = (params, isUpdate) => { + let url = isUpdate ? Api.edit : Api.save; + return defHttp.post({url: url, params}); +} diff --git a/jeecgboot-vue3/src/views/gen/resource/Resource.data.ts b/jeecgboot-vue3/src/views/gen/resource/Resource.data.ts new file mode 100644 index 00000000..3e907ca5 --- /dev/null +++ b/jeecgboot-vue3/src/views/gen/resource/Resource.data.ts @@ -0,0 +1,155 @@ +import {BasicColumn} from '/@/components/Table'; +import {FormSchema} from '/@/components/Table'; +import { rules} from '/@/utils/helper/validator'; +import { render } from '/@/utils/common/renderUtils'; +import { getWeekMonthQuarterYear } from '/@/utils'; +//列表数据 +export const columns: BasicColumn[] = [ + { + title: '资源名', + align:"center", + dataIndex: 'name' + }, + { + title: '描述', + align:"center", + dataIndex: 'description' + }, + { + title: '资源类型', + align:"center", + dataIndex: 'type_dictText' + }, + { + title: '文件url', + align:"center", + dataIndex: 'fileUrl' + }, + { + title: '缩略图url', + align:"center", + dataIndex: 'thumbnailUrl' + }, + { + title: '时长', + align:"center", + dataIndex: 'duration' + }, + { + title: '文件大小', + align:"center", + dataIndex: 'fileSize' + }, + { + title: '文件元数据', + align:"center", + dataIndex: 'metadata' + }, + { + title: '是否精选', + align:"center", + dataIndex: 'izFeatured_dictText' + }, + { + title: '状态', + align:"center", + dataIndex: 'status_dictText' + }, +]; +//查询数据 +export const searchFormSchema: FormSchema[] = [ +]; +//表单数据 +export const formSchema: FormSchema[] = [ + { + label: '资源名', + field: 'name', + component: 'Input', + }, + { + label: '描述', + field: 'description', + component: 'Input', + }, + { + label: '资源类型', + field: 'type', + component: 'JDictSelectTag', + componentProps:{ + dictCode:"resource_type" + }, + }, + { + label: '文件url', + field: 'fileUrl', + component: 'Input', + }, + { + label: '缩略图url', + field: 'thumbnailUrl', + component: 'Input', + }, + { + label: '时长', + field: 'duration', + component: 'InputNumber', + }, + { + label: '文件大小', + field: 'fileSize', + component: 'InputNumber', + }, + { + label: '文件元数据', + field: 'metadata', + component: 'Input', + }, + { + label: '是否精选', + field: 'izFeatured', + component: 'JDictSelectTag', + componentProps:{ + dictCode:"resource_iz_featured", + type: "radio" + }, + }, + { + label: '状态', + field: 'status', + component: 'JDictSelectTag', + componentProps:{ + dictCode:"resource_status", + type: "radio" + }, + }, + // TODO 主键隐藏字段,目前写死为ID + { + label: '', + field: 'id', + component: 'Input', + show: false + }, +]; + +// 高级查询数据 +export const superQuerySchema = { + name: {title: '资源名',order: 0,view: 'text', type: 'string',}, + description: {title: '描述',order: 1,view: 'text', type: 'string',}, + type: {title: '资源类型',order: 2,view: 'number', type: 'number',dictCode: 'resource_type',}, + fileUrl: {title: '文件url',order: 3,view: 'text', type: 'string',}, + thumbnailUrl: {title: '缩略图url',order: 4,view: 'text', type: 'string',}, + duration: {title: '时长',order: 5,view: 'number', type: 'number',}, + fileSize: {title: '文件大小',order: 6,view: 'number', type: 'number',}, + metadata: {title: '文件元数据',order: 7,view: 'text', type: 'string',}, + izFeatured: {title: '是否精选',order: 8,view: 'number', type: 'number',dictCode: 'resource_iz_featured',}, + status: {title: '状态',order: 9,view: 'number', type: 'number',dictCode: 'resource_status',}, +}; + +/** +* 流程表单调用这个方法获取formSchema +* @param param +*/ +export function getBpmFormSchema(_formData): FormSchema[]{ + // 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema + return formSchema; +} \ No newline at end of file diff --git a/jeecgboot-vue3/src/views/gen/resource/ResourceList.vue b/jeecgboot-vue3/src/views/gen/resource/ResourceList.vue new file mode 100644 index 00000000..71e0fa59 --- /dev/null +++ b/jeecgboot-vue3/src/views/gen/resource/ResourceList.vue @@ -0,0 +1,206 @@ + + + + + \ No newline at end of file diff --git a/jeecgboot-vue3/src/views/gen/resource/components/ResourceForm.vue b/jeecgboot-vue3/src/views/gen/resource/components/ResourceForm.vue new file mode 100644 index 00000000..a4250e8b --- /dev/null +++ b/jeecgboot-vue3/src/views/gen/resource/components/ResourceForm.vue @@ -0,0 +1,70 @@ + + + \ No newline at end of file diff --git a/jeecgboot-vue3/src/views/gen/resource/components/ResourceModal.vue b/jeecgboot-vue3/src/views/gen/resource/components/ResourceModal.vue new file mode 100644 index 00000000..890b5c37 --- /dev/null +++ b/jeecgboot-vue3/src/views/gen/resource/components/ResourceModal.vue @@ -0,0 +1,99 @@ + + + + + \ No newline at end of file