Merge remote-tracking branch 'origin/feature_重大事项' into release_20260829
This commit is contained in:
+208
@@ -0,0 +1,208 @@
|
||||
package com.budwk.app.zhgh.dayofficework.material.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.annotation.SLog;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.param.PageForm;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.utils.PageUtil;
|
||||
import com.budwk.app.zhgh.dayofficework.material.model.MaterialItem;
|
||||
import com.budwk.app.zhgh.dayofficework.material.model.MaterialType;
|
||||
import com.budwk.app.zhgh.dayofficework.material.service.MaterialItemService;
|
||||
import com.budwk.app.zhgh.dayofficework.material.service.MaterialTypeService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.cri.SqlExpressionGroup;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@Api(tags = "重大事项")
|
||||
@At("/platform/material/item")
|
||||
public class MaterialItemController {
|
||||
|
||||
@Inject
|
||||
private MaterialItemService itemService;
|
||||
@Inject
|
||||
private MaterialTypeService typeService;
|
||||
|
||||
@At("")
|
||||
@SaCheckPermission("material.item")
|
||||
@Ok("beetl:/platform/zhgh/dayofficework/material/item/index.html")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("重大事项展示")
|
||||
@SaCheckPermission("material.display")
|
||||
@Ok("beetl:/platform/zhgh/dayofficework/material/display/index.html")
|
||||
public void displayIndex() {
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("分页查询")
|
||||
@SaCheckPermission("material.item")
|
||||
public Result pageData(PageForm pageForm, @Param("typeId") String typeId, @Param("visible") String visible) {
|
||||
Sql sql = Sqls.create("select mi.id, mi.typeId, mi.title, mi.remark, mi.visible, mi.createdAt, mi.updatedAt, " +
|
||||
"mt.name as typeName " +
|
||||
"from material_item mi left join material_type mt on mi.typeId = mt.id $condition");
|
||||
Cnd cnd = Cnd.where("mi.delFlag", "=", false).and("mt.delFlag", "=", false);
|
||||
cnd.andEX("mi.typeId", "=", typeId);
|
||||
if (StrUtil.isNotBlank(visible)) {
|
||||
cnd.and("mi.visible", "=", Boolean.parseBoolean(visible));
|
||||
}
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.or("mi.title", "like", "%" + pageForm.getSearchKeyword() + "%");
|
||||
seg.or("mi.remark", "like", "%" + pageForm.getSearchKeyword() + "%");
|
||||
cnd.and(seg);
|
||||
}
|
||||
if (StrUtil.isAllBlank(pageForm.getPageOrderName(), pageForm.getPageOrderBy())) {
|
||||
cnd.asc("mt.sort").desc("mi.createdAt");
|
||||
} else {
|
||||
cnd.orderBy(pageForm.getPageOrderName(), PageUtil.getOrder(pageForm.getPageOrderBy()));
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = itemService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
return Result.success(pagination);
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("新增/修改重大事项")
|
||||
@SaCheckPermission("material.item")
|
||||
@SLog(tag = "重大事项-事项管理", msg = "新增/修改重大事项")
|
||||
public Object submit(@Param("data") MaterialItem item) {
|
||||
if (item.getVisible() == null) {
|
||||
item.setVisible(true);
|
||||
}
|
||||
itemService.insertOrUpdate(item);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("更新重大事项公开状态")
|
||||
@SaCheckPermission("material.item")
|
||||
@SLog(tag = "重大事项-事项管理", msg = "更新公开状态")
|
||||
public Object updateVisible(String id, @Param("visible") String visible) {
|
||||
if (StrUtil.isBlank(id) || StrUtil.isBlank(visible)) {
|
||||
return Result.error("参数不能为空");
|
||||
}
|
||||
if (!StrUtil.equalsAnyIgnoreCase(visible, "true", "false")) {
|
||||
return Result.error("公开状态不正确");
|
||||
}
|
||||
itemService.update(
|
||||
Chain.make("visible", Boolean.parseBoolean(visible)).add("updatedAt", System.currentTimeMillis()),
|
||||
Cnd.where(MaterialItem::getId, "=", id).and(MaterialItem::getDelFlag, "=", false)
|
||||
);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("删除重大事项")
|
||||
@SaCheckPermission("material.item")
|
||||
@SLog(tag = "重大事项-事项管理", msg = "删除重大事项")
|
||||
public Object delete(String id) {
|
||||
itemService.vDelete(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("查询单个重大事项")
|
||||
@SaCheckLogin
|
||||
public Result info(String id) {
|
||||
MaterialItem item = itemService.fetch(id);
|
||||
if (item == null || Boolean.TRUE.equals(item.getDelFlag())) {
|
||||
return Result.error("数据不存在");
|
||||
}
|
||||
NutMap map = org.nutz.lang.Lang.obj2nutmap(item);
|
||||
MaterialType type = typeService.fetch(item.getTypeId());
|
||||
if (type != null) {
|
||||
map.put("typeName", type.getName());
|
||||
}
|
||||
return Result.success(map);
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("公开展示分组查询")
|
||||
@SaCheckLogin
|
||||
public Result display(PageForm pageForm, @Param("typeIds") String typeIds) {
|
||||
List<String> typeIdList = parseTypeIds(typeIds);
|
||||
Cnd typeCnd = Cnd.where(MaterialType::getDelFlag, "=", false);
|
||||
if (!typeIdList.isEmpty()) {
|
||||
typeCnd.and(MaterialType::getId, "in", typeIdList);
|
||||
}
|
||||
typeCnd.asc(MaterialType::getSort).asc(MaterialType::getCreatedAt);
|
||||
Pagination pagination = typeService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), typeCnd);
|
||||
List<NutMap> types = pagination.getList(NutMap.class);
|
||||
if (types.isEmpty()) {
|
||||
return Result.success(pagination);
|
||||
}
|
||||
|
||||
List<String> pageTypeIds = types.stream().map(type -> type.getString("id")).collect(Collectors.toList());
|
||||
List<MaterialItem> items = itemService.query(Cnd.where(MaterialItem::getDelFlag, "=", false)
|
||||
.and(MaterialItem::getVisible, "=", true)
|
||||
.and(MaterialItem::getTypeId, "in", pageTypeIds)
|
||||
.desc(MaterialItem::getUpdatedAt)
|
||||
.desc(MaterialItem::getCreatedAt));
|
||||
Map<String, List<MaterialItem>> itemMap = items.stream().collect(Collectors.groupingBy(MaterialItem::getTypeId));
|
||||
for (NutMap type : types) {
|
||||
List<NutMap> details = itemMap.getOrDefault(type.getString("id"), Collections.emptyList())
|
||||
.stream()
|
||||
.limit(5)
|
||||
.map(org.nutz.lang.Lang::obj2nutmap)
|
||||
.collect(Collectors.toList());
|
||||
type.put("details", details);
|
||||
}
|
||||
return Result.success(pagination);
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("公开事项列表")
|
||||
@SaCheckLogin
|
||||
public Result detailList(PageForm pageForm, @Param("typeId") String typeId) {
|
||||
Cnd cnd = Cnd.where(MaterialItem::getDelFlag, "=", false)
|
||||
.and(MaterialItem::getVisible, "=", true)
|
||||
.and(MaterialItem::getTypeId, "=", typeId);
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
SqlExpressionGroup seg = new SqlExpressionGroup();
|
||||
seg.or(MaterialItem::getTitle, "like", "%" + pageForm.getSearchKeyword() + "%");
|
||||
seg.or(MaterialItem::getRemark, "like", "%" + pageForm.getSearchKeyword() + "%");
|
||||
cnd.and(seg);
|
||||
}
|
||||
cnd.desc(MaterialItem::getUpdatedAt);
|
||||
cnd.desc(MaterialItem::getCreatedAt);
|
||||
Pagination pagination = itemService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), cnd);
|
||||
return Result.success(pagination);
|
||||
}
|
||||
|
||||
private List<String> parseTypeIds(String typeIds) {
|
||||
if (StrUtil.isBlank(typeIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
try {
|
||||
return Json.fromJsonAsList(String.class, typeIds);
|
||||
} catch (Exception e) {
|
||||
return List.of(typeIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
package com.budwk.app.zhgh.dayofficework.material.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.annotation.SLog;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.param.PageForm;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.utils.PageUtil;
|
||||
import com.budwk.app.zhgh.dayofficework.material.model.MaterialType;
|
||||
import com.budwk.app.zhgh.dayofficework.material.service.MaterialTypeService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@Api(tags = "重大事项类型")
|
||||
@At("/platform/material/type")
|
||||
public class MaterialTypeController {
|
||||
|
||||
@Inject
|
||||
private MaterialTypeService typeService;
|
||||
|
||||
@At("")
|
||||
@SaCheckPermission("material.type")
|
||||
@Ok("beetl:/platform/zhgh/dayofficework/material/type/index.html")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("分页查询")
|
||||
@SaCheckPermission("material.type")
|
||||
public Result pageData(PageForm pageForm) {
|
||||
Cnd cnd = Cnd.where(MaterialType::getDelFlag, "=", false);
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
cnd.and(MaterialType::getName, "like", "%" + pageForm.getSearchKeyword() + "%");
|
||||
}
|
||||
if (StrUtil.isAllBlank(pageForm.getPageOrderName(), pageForm.getPageOrderBy())) {
|
||||
cnd.asc(MaterialType::getSort).asc(MaterialType::getCreatedAt);
|
||||
} else {
|
||||
cnd.orderBy(pageForm.getPageOrderName(), PageUtil.getOrder(pageForm.getPageOrderBy()));
|
||||
}
|
||||
Pagination pagination = typeService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), cnd);
|
||||
return Result.success(pagination);
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("新增/修改重大事项类型")
|
||||
@SaCheckPermission("material.type")
|
||||
@SLog(tag = "重大事项-类型管理", msg = "新增/修改重大事项类型")
|
||||
public Object submit(MaterialType type) {
|
||||
typeService.insertOrUpdate(type);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("删除重大事项类型")
|
||||
@SaCheckPermission("material.type")
|
||||
@SLog(tag = "重大事项-类型管理", msg = "删除重大事项类型")
|
||||
public Object delete(String id) {
|
||||
typeService.vDelete(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@At
|
||||
@ApiOperation("查询重大事项类型")
|
||||
@SaCheckLogin
|
||||
public Result list() {
|
||||
List<MaterialType> list = typeService.query(Cnd.where(MaterialType::getDelFlag, "=", false)
|
||||
.asc(MaterialType::getSort)
|
||||
.asc(MaterialType::getCreatedAt));
|
||||
return Result.success(list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.budwk.app.zhgh.dayofficework.material.model;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.nutz.dao.entity.annotation.ColDefine;
|
||||
import org.nutz.dao.entity.annotation.ColType;
|
||||
import org.nutz.dao.entity.annotation.Column;
|
||||
import org.nutz.dao.entity.annotation.Comment;
|
||||
import org.nutz.dao.entity.annotation.Default;
|
||||
import org.nutz.dao.entity.annotation.Name;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
@Data
|
||||
@Comment("重大事项")
|
||||
@Accessors(chain = true)
|
||||
@Table("material_item")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class MaterialItem extends BaseModel {
|
||||
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 64)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 64)
|
||||
@Comment("重大事项类型ID")
|
||||
private String typeId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
@Comment("标题")
|
||||
private String title;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.TEXT)
|
||||
@Comment("内容")
|
||||
private String content;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
@Comment("备注")
|
||||
private String remark;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
@Comment("是否公开")
|
||||
@Default("1")
|
||||
private Boolean visible;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.budwk.app.zhgh.dayofficework.material.model;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.nutz.dao.entity.annotation.ColDefine;
|
||||
import org.nutz.dao.entity.annotation.ColType;
|
||||
import org.nutz.dao.entity.annotation.Column;
|
||||
import org.nutz.dao.entity.annotation.Comment;
|
||||
import org.nutz.dao.entity.annotation.Name;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
@Data
|
||||
@Comment("重大事项类型")
|
||||
@Accessors(chain = true)
|
||||
@Table("material_type")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class MaterialType extends BaseModel {
|
||||
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 64)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
@Comment("类型名称")
|
||||
private String name;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT)
|
||||
@Comment("排序")
|
||||
private Integer sort;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.budwk.app.zhgh.dayofficework.material.service;
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.zhgh.dayofficework.material.model.MaterialItem;
|
||||
|
||||
public interface MaterialItemService extends BaseService<MaterialItem> {
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.budwk.app.zhgh.dayofficework.material.service;
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.zhgh.dayofficework.material.model.MaterialType;
|
||||
|
||||
public interface MaterialTypeService extends BaseService<MaterialType> {
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.budwk.app.zhgh.dayofficework.material.service.impl;
|
||||
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.zhgh.dayofficework.material.model.MaterialItem;
|
||||
import com.budwk.app.zhgh.dayofficework.material.service.MaterialItemService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
@Slf4j
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class MaterialItemServiceImpl extends BaseServiceImpl<MaterialItem> implements MaterialItemService {
|
||||
|
||||
public MaterialItemServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.budwk.app.zhgh.dayofficework.material.service.impl;
|
||||
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.zhgh.dayofficework.material.model.MaterialType;
|
||||
import com.budwk.app.zhgh.dayofficework.material.service.MaterialTypeService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
@Slf4j
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class MaterialTypeServiceImpl extends BaseServiceImpl<MaterialType> implements MaterialTypeService {
|
||||
|
||||
public MaterialTypeServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user