Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: "11"
java-version: "17"
distribution: "temurin"
cache: maven
- name: Install test dependencies
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ teedy-importer-win.exe
docs/*
!docs/.gitkeep

.vscode/
agent_tmp/

#macos
.DS_Store
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ ENV DEBIAN_FRONTEND noninteractive
# Configure env
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64/
ENV JAVA_HOME /usr/lib/jvm/java-17-openjdk-amd64/
ENV JAVA_OPTIONS -Dfile.encoding=UTF-8 -Xmx1g
ENV JETTY_VERSION 11.0.20
ENV JETTY_HOME /opt/jetty

# Install packages
RUN apt-get update && \
apt-get -y -q --no-install-recommends install \
vim less procps unzip wget tzdata openjdk-11-jdk \
vim less procps unzip wget tzdata openjdk-17-jdk \
ffmpeg \
mediainfo \
tesseract-ocr \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Teedy is an open source, lightweight document management system for individuals

![New!](https://teedy.io/img/laptop-demo.png?20180301)

# Demo
# Demolbf

A demo is available at [demo.teedy.io](https://demo.teedy.io)

Expand Down
4 changes: 2 additions & 2 deletions docs-android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue May 07 11:49:13 CEST 2019
#Thu Jul 09 09:10:37 CST 2026
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package com.sismics.docs.core.dao;

import com.sismics.docs.core.constant.AuditLogType;
import com.sismics.docs.core.model.jpa.Department;
import com.sismics.util.context.ThreadLocalContext;
import com.sismics.docs.core.util.AuditLogUtil;
import jakarta.persistence.EntityManager;
import jakarta.persistence.NoResultException;
import jakarta.persistence.TypedQuery;
import java.util.*;

/**
* Department DAO.
*/
public class DepartmentDao {

public String create(Department dept, String userId) {
dept.setId(UUID.randomUUID().toString());
dept.setCreateDate(new Date());
EntityManager em = ThreadLocalContext.get().getEntityManager();
em.persist(dept);
AuditLogUtil.create(dept, AuditLogType.CREATE, userId);
return dept.getId();
}

public Department getById(String id) {
EntityManager em = ThreadLocalContext.get().getEntityManager();
TypedQuery<Department> q = em.createQuery(
"select d from Department d where d.id = :id and d.deleteDate is null", Department.class);
q.setParameter("id", id);
try { return q.getSingleResult(); } catch (NoResultException e) { return null; }
}

/** Find all active departments, ordered by sortOrder */
public List<Department> findAll() {
EntityManager em = ThreadLocalContext.get().getEntityManager();
TypedQuery<Department> q = em.createQuery(
"select d from Department d where d.deleteDate is null order by d.sortOrder asc, d.name asc",
Department.class);
return q.getResultList();
}

/** Find child departments by parent ID */
public List<Department> findByParentId(String parentId) {
EntityManager em = ThreadLocalContext.get().getEntityManager();
TypedQuery<Department> q = em.createQuery(
"select d from Department d where d.parentId = :parentId and d.deleteDate is null order by d.sortOrder asc",
Department.class);
q.setParameter("parentId", parentId);
return q.getResultList();
}

/** Find root departments (no parent) */
public List<Department> findRoots() {
EntityManager em = ThreadLocalContext.get().getEntityManager();
TypedQuery<Department> q = em.createQuery(
"select d from Department d where d.parentId is null and d.deleteDate is null order by d.sortOrder asc",
Department.class);
return q.getResultList();
}

/** Get department and all its descendant IDs */
public List<String> getDepartmentAndChildren(String deptId) {
List<String> result = new ArrayList<>();
result.add(deptId);
Queue<String> queue = new LinkedList<>();
queue.add(deptId);
while (!queue.isEmpty()) {
List<Department> children = findByParentId(queue.poll());
for (Department child : children) {
result.add(child.getId());
queue.add(child.getId());
}
}
return result;
}

public Department update(Department dept, String userId) {
EntityManager em = ThreadLocalContext.get().getEntityManager();
Department db = getById(dept.getId());
if (db == null) return null;
db.setName(dept.getName());
db.setParentId(dept.getParentId());
db.setCode(dept.getCode());
db.setSortOrder(dept.getSortOrder());
AuditLogUtil.create(db, AuditLogType.UPDATE, userId);
return db;
}

public void delete(String id, String userId) {
EntityManager em = ThreadLocalContext.get().getEntityManager();
Department db = getById(id);
if (db != null) {
db.setDeleteDate(new Date());
AuditLogUtil.create(db, AuditLogType.DELETE, userId);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package com.sismics.docs.core.dao;

import com.sismics.docs.core.constant.AuditLogType;
import com.sismics.docs.core.model.jpa.DocumentClassification;
import com.sismics.util.context.ThreadLocalContext;
import com.sismics.docs.core.util.AuditLogUtil;
import jakarta.persistence.EntityManager;
import jakarta.persistence.NoResultException;
import jakarta.persistence.TypedQuery;
import java.util.*;

/**
* Document Classification DAO.
*/
public class DocumentClassificationDao {

public String create(DocumentClassification cls, String userId) {
cls.setId(UUID.randomUUID().toString());
cls.setCreateDate(new Date());
EntityManager em = ThreadLocalContext.get().getEntityManager();
em.persist(cls);
AuditLogUtil.create(cls, AuditLogType.CREATE, userId);
return cls.getId();
}

public DocumentClassification getById(String id) {
EntityManager em = ThreadLocalContext.get().getEntityManager();
TypedQuery<DocumentClassification> q = em.createQuery(
"select c from DocumentClassification c where c.id = :id and c.deleteDate is null",
DocumentClassification.class);
q.setParameter("id", id);
try { return q.getSingleResult(); } catch (NoResultException e) { return null; }
}

/** Find all active classifications, ordered by sortOrder */
public List<DocumentClassification> findAll() {
EntityManager em = ThreadLocalContext.get().getEntityManager();
TypedQuery<DocumentClassification> q = em.createQuery(
"select c from DocumentClassification c where c.deleteDate is null order by c.sortOrder asc",
DocumentClassification.class);
return q.getResultList();
}

/** Find classification by code */
public DocumentClassification findByCode(String code) {
EntityManager em = ThreadLocalContext.get().getEntityManager();
TypedQuery<DocumentClassification> q = em.createQuery(
"select c from DocumentClassification c where c.code = :code and c.deleteDate is null",
DocumentClassification.class);
q.setParameter("code", code);
try { return q.getSingleResult(); } catch (NoResultException e) { return null; }
}

public DocumentClassification update(DocumentClassification cls, String userId) {
EntityManager em = ThreadLocalContext.get().getEntityManager();
DocumentClassification db = getById(cls.getId());
if (db == null) return null;
db.setName(cls.getName());
db.setCode(cls.getCode());
db.setSortOrder(cls.getSortOrder());
AuditLogUtil.create(db, AuditLogType.UPDATE, userId);
return db;
}

public void delete(String id, String userId) {
EntityManager em = ThreadLocalContext.get().getEntityManager();
DocumentClassification db = getById(id);
if (db != null) {
db.setDeleteDate(new Date());
AuditLogUtil.create(db, AuditLogType.DELETE, userId);
}
}
}
26 changes: 24 additions & 2 deletions docs-core/src/main/java/com/sismics/docs/core/dao/DocumentDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public DocumentDto getDocument(String id, PermType perm, List<String> targetIdLi
StringBuilder sb = new StringBuilder("select distinct d.DOC_ID_C, d.DOC_TITLE_C, d.DOC_DESCRIPTION_C, d.DOC_SUBJECT_C, d.DOC_IDENTIFIER_C, d.DOC_PUBLISHER_C, d.DOC_FORMAT_C, d.DOC_SOURCE_C, d.DOC_TYPE_C, d.DOC_COVERAGE_C, d.DOC_RIGHTS_C, d.DOC_CREATEDATE_D, d.DOC_UPDATEDATE_D, d.DOC_LANGUAGE_C, d.DOC_IDFILE_C,");
sb.append(" (select count(s.SHA_ID_C) from T_SHARE s, T_ACL ac where ac.ACL_SOURCEID_C = d.DOC_ID_C and ac.ACL_TARGETID_C = s.SHA_ID_C and ac.ACL_DELETEDATE_D is null and s.SHA_DELETEDATE_D is null) shareCount, ");
sb.append(" (select count(f.FIL_ID_C) from T_FILE f where f.FIL_DELETEDATE_D is null and f.FIL_IDDOC_C = d.DOC_ID_C) fileCount, ");
sb.append(" u.USE_USERNAME_C ");
sb.append(" u.USE_USERNAME_C, ");
sb.append(" d.DOC_IDCLASSIFICATION_C, d.DOC_SECRECYLEVEL_C, d.DOC_URGENCY_C, d.DOC_DOCNO_C, d.DOC_FROMUNIT_C, d.DOC_IDHANDLERDEPT_C, d.DOC_STATUS_C, d.DOC_DOCDATE_D ");
sb.append(" from T_DOCUMENT d ");
sb.append(" join T_USER u on d.DOC_IDUSER_C = u.USE_ID_C ");
sb.append(" where d.DOC_ID_C = :id and d.DOC_DELETEDATE_D is null ");
Expand Down Expand Up @@ -124,7 +125,16 @@ public DocumentDto getDocument(String id, PermType perm, List<String> targetIdLi
documentDto.setFileId((String) o[i++]);
documentDto.setShared(((Number) o[i++]).intValue() > 0);
documentDto.setFileCount(((Number) o[i++]).intValue());
documentDto.setCreator((String) o[i]);
documentDto.setCreator((String) o[i++]);
// 机关单位扩展字段
documentDto.setClassificationId((String) o[i++]);
documentDto.setSecrecyLevel((String) o[i++]);
documentDto.setUrgency((String) o[i++]);
documentDto.setDocNo((String) o[i++]);
documentDto.setFromUnit((String) o[i++]);
documentDto.setHandlerDeptId((String) o[i++]);
documentDto.setStatus((String) o[i++]);
// docDate (o[i++]) is timestamp, skip or store if needed
return documentDto;
}

Expand Down Expand Up @@ -218,6 +228,18 @@ public Document update(Document document, String userId) {
documentDb.setLanguage(document.getLanguage());
documentDb.setFileId(document.getFileId());
documentDb.setUpdateDate(new Date());
// 机关单位扩展字段
documentDb.setClassificationId(document.getClassificationId());
documentDb.setSecrecyLevel(document.getSecrecyLevel());
documentDb.setUrgency(document.getUrgency());
documentDb.setDocNo(document.getDocNo());
documentDb.setFromUnit(document.getFromUnit());
documentDb.setHandlerDeptId(document.getHandlerDeptId());
documentDb.setHandlerUserId(document.getHandlerUserId());
documentDb.setDocDate(document.getDocDate());
documentDb.setRetention(document.getRetention());
documentDb.setArchiveNo(document.getArchiveNo());
documentDb.setStatus(document.getStatus());

// Create audit log
AuditLogUtil.create(documentDb, AuditLogType.UPDATE, userId);
Expand Down
82 changes: 82 additions & 0 deletions docs-core/src/main/java/com/sismics/docs/core/dao/PositionDao.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package com.sismics.docs.core.dao;

import com.sismics.docs.core.constant.AuditLogType;
import com.sismics.docs.core.model.jpa.Position;
import com.sismics.util.context.ThreadLocalContext;
import com.sismics.docs.core.util.AuditLogUtil;
import jakarta.persistence.EntityManager;
import jakarta.persistence.NoResultException;
import jakarta.persistence.TypedQuery;
import java.util.*;

/**
* Position DAO.
*/
public class PositionDao {

public String create(Position pos, String userId) {
pos.setId(UUID.randomUUID().toString());
pos.setCreateDate(new Date());
EntityManager em = ThreadLocalContext.get().getEntityManager();
em.persist(pos);
AuditLogUtil.create(pos, AuditLogType.CREATE, userId);
return pos.getId();
}

public Position getById(String id) {
EntityManager em = ThreadLocalContext.get().getEntityManager();
TypedQuery<Position> q = em.createQuery(
"select p from Position p where p.id = :id and p.deleteDate is null", Position.class);
q.setParameter("id", id);
try { return q.getSingleResult(); } catch (NoResultException e) { return null; }
}

/** Find all active positions, ordered by level desc */
public List<Position> findAll() {
EntityManager em = ThreadLocalContext.get().getEntityManager();
TypedQuery<Position> q = em.createQuery(
"select p from Position p where p.deleteDate is null order by p.level desc, p.name asc",
Position.class);
return q.getResultList();
}

/** Find positions by department ID */
public List<Position> findByDepartmentId(String deptId) {
EntityManager em = ThreadLocalContext.get().getEntityManager();
TypedQuery<Position> q = em.createQuery(
"select p from Position p where p.departmentId = :deptId and p.deleteDate is null order by p.level desc",
Position.class);
q.setParameter("deptId", deptId);
return q.getResultList();
}

/** Search positions by name (fuzzy match) */
public List<Position> searchByName(String keyword) {
EntityManager em = ThreadLocalContext.get().getEntityManager();
TypedQuery<Position> q = em.createQuery(
"select p from Position p where lower(p.name) like :kw and p.deleteDate is null order by p.level desc",
Position.class);
q.setParameter("kw", "%" + keyword.toLowerCase() + "%");
return q.getResultList();
}

public Position update(Position pos, String userId) {
EntityManager em = ThreadLocalContext.get().getEntityManager();
Position db = getById(pos.getId());
if (db == null) return null;
db.setName(pos.getName());
db.setLevel(pos.getLevel());
db.setDepartmentId(pos.getDepartmentId());
AuditLogUtil.create(db, AuditLogType.UPDATE, userId);
return db;
}

public void delete(String id, String userId) {
EntityManager em = ThreadLocalContext.get().getEntityManager();
Position db = getById(id);
if (db != null) {
db.setDeleteDate(new Date());
AuditLogUtil.create(db, AuditLogType.DELETE, userId);
}
}
}
Loading