From b09f9a3ec05a8e405669e96674ba59e1dcb3466e Mon Sep 17 00:00:00 2001 From: gaoxq <376340421@qq.com> Date: Thu, 19 Mar 2026 22:53:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/biz/dao/MyWebsiteStorageDao.java | 15 ++ .../modules/biz/entity/MyWebsiteStorage.java | 74 ++++++ .../biz/service/MyWebsiteStorageService.java | 135 +++++++++++ .../biz/web/MyWebsiteStorageController.java | 146 ++++++++++++ .../modules/biz/MyWebsiteStorageDao.xml | 15 ++ .../packages/biz/api/biz/myWebsiteStorage.ts | 51 +++++ .../biz/views/biz/myWebsiteStorage/form.vue | 156 +++++++++++++ .../biz/views/biz/myWebsiteStorage/list.vue | 211 ++++++++++++++++++ 8 files changed, 803 insertions(+) create mode 100644 web-api/src/main/java/com/jeesite/modules/biz/dao/MyWebsiteStorageDao.java create mode 100644 web-api/src/main/java/com/jeesite/modules/biz/entity/MyWebsiteStorage.java create mode 100644 web-api/src/main/java/com/jeesite/modules/biz/service/MyWebsiteStorageService.java create mode 100644 web-api/src/main/java/com/jeesite/modules/biz/web/MyWebsiteStorageController.java create mode 100644 web-api/src/main/resources/mappings/modules/biz/MyWebsiteStorageDao.xml create mode 100644 web-vue/packages/biz/api/biz/myWebsiteStorage.ts create mode 100644 web-vue/packages/biz/views/biz/myWebsiteStorage/form.vue create mode 100644 web-vue/packages/biz/views/biz/myWebsiteStorage/list.vue diff --git a/web-api/src/main/java/com/jeesite/modules/biz/dao/MyWebsiteStorageDao.java b/web-api/src/main/java/com/jeesite/modules/biz/dao/MyWebsiteStorageDao.java new file mode 100644 index 0000000..cfbdf14 --- /dev/null +++ b/web-api/src/main/java/com/jeesite/modules/biz/dao/MyWebsiteStorageDao.java @@ -0,0 +1,15 @@ +package com.jeesite.modules.biz.dao; + +import com.jeesite.common.dao.CrudDao; +import com.jeesite.common.mybatis.annotation.MyBatisDao; +import com.jeesite.modules.biz.entity.MyWebsiteStorage; + +/** + * 网站信息 DAO 接口 + * @author gaoxq + * @version 2026-03-19 + */ +@MyBatisDao(dataSourceName="work") +public interface MyWebsiteStorageDao extends CrudDao { + +} \ No newline at end of file diff --git a/web-api/src/main/java/com/jeesite/modules/biz/entity/MyWebsiteStorage.java b/web-api/src/main/java/com/jeesite/modules/biz/entity/MyWebsiteStorage.java new file mode 100644 index 0000000..8f94f2a --- /dev/null +++ b/web-api/src/main/java/com/jeesite/modules/biz/entity/MyWebsiteStorage.java @@ -0,0 +1,74 @@ +package com.jeesite.modules.biz.entity; + +import java.io.Serializable; +import java.util.Date; +import com.jeesite.common.mybatis.annotation.JoinTable; +import com.jeesite.common.mybatis.annotation.JoinTable.Type; +import com.fasterxml.jackson.annotation.JsonFormat; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Size; + +import com.jeesite.common.entity.DataEntity; +import com.jeesite.common.mybatis.annotation.Column; +import com.jeesite.common.mybatis.annotation.Table; +import com.jeesite.common.mybatis.mapper.query.QueryType; +import com.jeesite.common.utils.excel.annotation.ExcelField; +import com.jeesite.common.utils.excel.annotation.ExcelField.Align; +import com.jeesite.common.utils.excel.annotation.ExcelFields; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serial; + +/** + * 网站信息 Entity + * @author gaoxq + * @version 2026-03-19 + */ +@EqualsAndHashCode(callSuper = true) +@Table(name="my_website_storage", alias="a", label="网站信息", columns={ + @Column(name="create_time", attrName="createTime", label="记录日期", isUpdate=false, isQuery=false, isUpdateForce=true), + @Column(name="website_id", attrName="websiteId", label="网站标识", isPK=true), + @Column(name="website_url", attrName="websiteUrl", label="网站地址", queryType=QueryType.LIKE), + @Column(name="website_name", attrName="websiteName", label="网站名称", queryType=QueryType.LIKE), + @Column(name="web_account", attrName="webAccount", label="登录账号", isQuery=false), + @Column(name="web_password", attrName="webPassword", label="登录密码", isQuery=false), + @Column(name="remarks", attrName="remarks", label="说明事项", isQuery=false), + @Column(name="login_user", attrName="loginUser", label="所属账户", isQuery=false), + @Column(name="ustatus", attrName="ustatus", label="状态"), + }, orderBy="a.create_time DESC" +) +@Data +public class MyWebsiteStorage extends DataEntity implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + private Date createTime; // 记录日期 + private String websiteId; // 网站标识 + private String websiteUrl; // 网站地址 + private String websiteName; // 网站名称 + private String webAccount; // 登录账号 + private String webPassword; // 登录密码 + private String loginUser; // 所属账户 + private String ustatus; // 状态 + + @ExcelFields({ + @ExcelField(title="记录日期", attrName="createTime", align=Align.CENTER, sort=10, dataFormat="yyyy-MM-dd hh:mm"), + @ExcelField(title="网站标识", attrName="websiteId", align=Align.CENTER, sort=20), + @ExcelField(title="网站地址", attrName="websiteUrl", align=Align.CENTER, sort=30), + @ExcelField(title="网站名称", attrName="websiteName", align=Align.CENTER, sort=40), + @ExcelField(title="登录账号", attrName="webAccount", align=Align.CENTER, sort=50), + @ExcelField(title="登录密码", attrName="webPassword", align=Align.CENTER, sort=60), + @ExcelField(title="说明事项", attrName="remarks", align=Align.CENTER, sort=70), + @ExcelField(title="所属账户", attrName="loginUser", align=Align.CENTER, sort=80), + @ExcelField(title="状态", attrName="ustatus", dictType="sys_status", align=Align.CENTER, sort=90), + }) + public MyWebsiteStorage() { + this(null); + } + + public MyWebsiteStorage(String id){ + super(id); + } + +} \ No newline at end of file diff --git a/web-api/src/main/java/com/jeesite/modules/biz/service/MyWebsiteStorageService.java b/web-api/src/main/java/com/jeesite/modules/biz/service/MyWebsiteStorageService.java new file mode 100644 index 0000000..d5243ac --- /dev/null +++ b/web-api/src/main/java/com/jeesite/modules/biz/service/MyWebsiteStorageService.java @@ -0,0 +1,135 @@ +package com.jeesite.modules.biz.service; + +import java.util.List; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.jeesite.common.entity.Page; +import com.jeesite.common.service.CrudService; +import com.jeesite.modules.biz.entity.MyWebsiteStorage; +import com.jeesite.modules.biz.dao.MyWebsiteStorageDao; +import com.jeesite.common.service.ServiceException; +import com.jeesite.common.config.Global; +import com.jeesite.common.validator.ValidatorUtils; +import com.jeesite.common.utils.excel.ExcelImport; +import org.springframework.web.multipart.MultipartFile; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.ConstraintViolationException; + +/** + * 网站信息 Service + * @author gaoxq + * @version 2026-03-19 + */ +@Service +public class MyWebsiteStorageService extends CrudService { + + /** + * 获取单条数据 + * @param myWebsiteStorage 主键 + */ + @Override + public MyWebsiteStorage get(MyWebsiteStorage myWebsiteStorage) { + return super.get(myWebsiteStorage); + } + + /** + * 查询分页数据 + * @param myWebsiteStorage 查询条件 + * @param myWebsiteStorage page 分页对象 + */ + @Override + public Page findPage(MyWebsiteStorage myWebsiteStorage) { + return super.findPage(myWebsiteStorage); + } + + /** + * 查询列表数据 + * @param myWebsiteStorage 查询条件 + */ + @Override + public List findList(MyWebsiteStorage myWebsiteStorage) { + return super.findList(myWebsiteStorage); + } + + /** + * 保存数据(插入或更新) + * @param myWebsiteStorage 数据对象 + */ + @Override + @Transactional + public void save(MyWebsiteStorage myWebsiteStorage) { + super.save(myWebsiteStorage); + } + + /** + * 导入数据 + * @param file 导入的数据文件 + */ + @Transactional + public String importData(MultipartFile file) { + if (file == null){ + throw new ServiceException(text("请选择导入的数据文件!")); + } + int successNum = 0; int failureNum = 0; + StringBuilder successMsg = new StringBuilder(); + StringBuilder failureMsg = new StringBuilder(); + try(ExcelImport ei = new ExcelImport(file, 2, 0)){ + List list = ei.getDataList(MyWebsiteStorage.class); + for (MyWebsiteStorage myWebsiteStorage : list) { + try{ + ValidatorUtils.validateWithException(myWebsiteStorage); + this.save(myWebsiteStorage); + successNum++; + successMsg.append("
" + successNum + "、编号 " + myWebsiteStorage.getId() + " 导入成功"); + } catch (Exception e) { + failureNum++; + String msg = "
" + failureNum + "、编号 " + myWebsiteStorage.getId() + " 导入失败:"; + if (e instanceof ConstraintViolationException){ + ConstraintViolationException cve = (ConstraintViolationException)e; + for (ConstraintViolation violation : cve.getConstraintViolations()) { + msg += Global.getText(violation.getMessage()) + " ("+violation.getPropertyPath()+")"; + } + }else{ + msg += e.getMessage(); + } + failureMsg.append(msg); + logger.error(msg, e); + } + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + failureMsg.append(e.getMessage()); + return failureMsg.toString(); + } + if (failureNum > 0) { + failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); + throw new ServiceException(failureMsg.toString()); + }else{ + successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); + } + return successMsg.toString(); + } + + /** + * 更新状态 + * @param myWebsiteStorage 数据对象 + */ + @Override + @Transactional + public void updateStatus(MyWebsiteStorage myWebsiteStorage) { + super.updateStatus(myWebsiteStorage); + } + + /** + * 删除数据 + * @param myWebsiteStorage 数据对象 + */ + @Override + @Transactional + public void delete(MyWebsiteStorage myWebsiteStorage) { + myWebsiteStorage.sqlMap().markIdDelete(); // 逻辑删除时标记ID值 + super.delete(myWebsiteStorage); + } + +} \ No newline at end of file diff --git a/web-api/src/main/java/com/jeesite/modules/biz/web/MyWebsiteStorageController.java b/web-api/src/main/java/com/jeesite/modules/biz/web/MyWebsiteStorageController.java new file mode 100644 index 0000000..75fab16 --- /dev/null +++ b/web-api/src/main/java/com/jeesite/modules/biz/web/MyWebsiteStorageController.java @@ -0,0 +1,146 @@ +package com.jeesite.modules.biz.web; + +import java.util.List; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.jeesite.common.config.Global; +import com.jeesite.common.collect.ListUtils; +import com.jeesite.common.entity.Page; +import com.jeesite.common.lang.DateUtils; +import com.jeesite.common.utils.excel.ExcelExport; +import com.jeesite.common.utils.excel.annotation.ExcelField.Type; +import org.springframework.web.multipart.MultipartFile; +import com.jeesite.common.web.BaseController; +import com.jeesite.modules.biz.entity.MyWebsiteStorage; +import com.jeesite.modules.biz.service.MyWebsiteStorageService; + +/** + * 网站信息 Controller + * @author gaoxq + * @version 2026-03-19 + */ +@Controller +@RequestMapping(value = "${adminPath}/biz/myWebsiteStorage") +public class MyWebsiteStorageController extends BaseController { + + private final MyWebsiteStorageService myWebsiteStorageService; + + public MyWebsiteStorageController(MyWebsiteStorageService myWebsiteStorageService) { + this.myWebsiteStorageService = myWebsiteStorageService; + } + + /** + * 获取数据 + */ + @ModelAttribute + public MyWebsiteStorage get(String websiteId, boolean isNewRecord) { + return myWebsiteStorageService.get(websiteId, isNewRecord); + } + + /** + * 查询列表 + */ + @RequiresPermissions("biz:myWebsiteStorage:view") + @RequestMapping(value = {"list", ""}) + public String list(MyWebsiteStorage myWebsiteStorage, Model model) { + model.addAttribute("myWebsiteStorage", myWebsiteStorage); + return "modules/biz/myWebsiteStorageList"; + } + + /** + * 查询列表数据 + */ + @RequiresPermissions("biz:myWebsiteStorage:view") + @RequestMapping(value = "listData") + @ResponseBody + public Page listData(MyWebsiteStorage myWebsiteStorage, HttpServletRequest request, HttpServletResponse response) { + myWebsiteStorage.setPage(new Page<>(request, response)); + Page page = myWebsiteStorageService.findPage(myWebsiteStorage); + return page; + } + + /** + * 查看编辑表单 + */ + @RequiresPermissions("biz:myWebsiteStorage:view") + @RequestMapping(value = "form") + public String form(MyWebsiteStorage myWebsiteStorage, Model model) { + model.addAttribute("myWebsiteStorage", myWebsiteStorage); + return "modules/biz/myWebsiteStorageForm"; + } + + /** + * 保存数据 + */ + @RequiresPermissions("biz:myWebsiteStorage:edit") + @PostMapping(value = "save") + @ResponseBody + public String save(@Validated MyWebsiteStorage myWebsiteStorage) { + myWebsiteStorageService.save(myWebsiteStorage); + return renderResult(Global.TRUE, text("保存网站成功!")); + } + + /** + * 导出数据 + */ + @RequiresPermissions("biz:myWebsiteStorage:view") + @RequestMapping(value = "exportData") + public void exportData(MyWebsiteStorage myWebsiteStorage, HttpServletResponse response) { + List list = myWebsiteStorageService.findList(myWebsiteStorage); + String fileName = "网站" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx"; + try(ExcelExport ee = new ExcelExport("网站", MyWebsiteStorage.class)){ + ee.setDataList(list).write(response, fileName); + } + } + + /** + * 下载模板 + */ + @RequiresPermissions("biz:myWebsiteStorage:view") + @RequestMapping(value = "importTemplate") + public void importTemplate(HttpServletResponse response) { + MyWebsiteStorage myWebsiteStorage = new MyWebsiteStorage(); + List list = ListUtils.newArrayList(myWebsiteStorage); + String fileName = "网站模板.xlsx"; + try(ExcelExport ee = new ExcelExport("网站", MyWebsiteStorage.class, Type.IMPORT)){ + ee.setDataList(list).write(response, fileName); + } + } + + /** + * 导入数据 + */ + @ResponseBody + @RequiresPermissions("biz:myWebsiteStorage:edit") + @PostMapping(value = "importData") + public String importData(MultipartFile file) { + try { + String message = myWebsiteStorageService.importData(file); + return renderResult(Global.TRUE, "posfull:"+message); + } catch (Exception ex) { + return renderResult(Global.FALSE, "posfull:"+ex.getMessage()); + } + } + + /** + * 删除数据 + */ + @RequiresPermissions("biz:myWebsiteStorage:edit") + @RequestMapping(value = "delete") + @ResponseBody + public String delete(MyWebsiteStorage myWebsiteStorage) { + myWebsiteStorageService.delete(myWebsiteStorage); + return renderResult(Global.TRUE, text("删除网站成功!")); + } + +} \ No newline at end of file diff --git a/web-api/src/main/resources/mappings/modules/biz/MyWebsiteStorageDao.xml b/web-api/src/main/resources/mappings/modules/biz/MyWebsiteStorageDao.xml new file mode 100644 index 0000000..4e67ad3 --- /dev/null +++ b/web-api/src/main/resources/mappings/modules/biz/MyWebsiteStorageDao.xml @@ -0,0 +1,15 @@ + + + + + + + \ No newline at end of file diff --git a/web-vue/packages/biz/api/biz/myWebsiteStorage.ts b/web-vue/packages/biz/api/biz/myWebsiteStorage.ts new file mode 100644 index 0000000..92f896d --- /dev/null +++ b/web-vue/packages/biz/api/biz/myWebsiteStorage.ts @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2013-Now https://jeesite.com All rights reserved. + * No deletion without permission, or be held responsible to law. + * @author gaoxq + */ +import { defHttp } from '@jeesite/core/utils/http/axios'; +import { useGlobSetting } from '@jeesite/core/hooks/setting'; +import { BasicModel, Page } from '@jeesite/core/api/model/baseModel'; +import { UploadApiResult } from '@jeesite/core/api/sys/upload'; +import { UploadFileParams } from '@jeesite/types/axios'; +import { AxiosProgressEvent } from 'axios'; + +const { ctxPath, adminPath } = useGlobSetting(); + +export interface MyWebsiteStorage extends BasicModel { + createTime?: string; // 记录日期 + websiteId?: string; // 网站标识 + websiteUrl: string; // 网站地址 + websiteName: string; // 网站名称 + webAccount?: string; // 登录账号 + webPassword?: string; // 登录密码 + loginUser?: string; // 所属账户 + ustatus: string; // 状态 +} + +export const myWebsiteStorageList = (params?: MyWebsiteStorage | any) => + defHttp.get({ url: adminPath + '/biz/myWebsiteStorage/list', params }); + +export const myWebsiteStorageListData = (params?: MyWebsiteStorage | any) => + defHttp.post>({ url: adminPath + '/biz/myWebsiteStorage/listData', params }); + +export const myWebsiteStorageForm = (params?: MyWebsiteStorage | any) => + defHttp.get({ url: adminPath + '/biz/myWebsiteStorage/form', params }); + +export const myWebsiteStorageSave = (params?: any, data?: MyWebsiteStorage | any) => + defHttp.postJson({ url: adminPath + '/biz/myWebsiteStorage/save', params, data }); + +export const myWebsiteStorageImportData = ( + params: UploadFileParams, + onUploadProgress: (progressEvent: AxiosProgressEvent) => void, +) => + defHttp.uploadFile( + { + url: ctxPath + adminPath + '/biz/myWebsiteStorage/importData', + onUploadProgress, + }, + params, + ); + +export const myWebsiteStorageDelete = (params?: MyWebsiteStorage | any) => + defHttp.get({ url: adminPath + '/biz/myWebsiteStorage/delete', params }); diff --git a/web-vue/packages/biz/views/biz/myWebsiteStorage/form.vue b/web-vue/packages/biz/views/biz/myWebsiteStorage/form.vue new file mode 100644 index 0000000..4c48406 --- /dev/null +++ b/web-vue/packages/biz/views/biz/myWebsiteStorage/form.vue @@ -0,0 +1,156 @@ + + + diff --git a/web-vue/packages/biz/views/biz/myWebsiteStorage/list.vue b/web-vue/packages/biz/views/biz/myWebsiteStorage/list.vue new file mode 100644 index 0000000..6885fd7 --- /dev/null +++ b/web-vue/packages/biz/views/biz/myWebsiteStorage/list.vue @@ -0,0 +1,211 @@ + + +