✨ 文章新增是否公开字段
This commit is contained in:
parent
791d967723
commit
58d8f7a3a7
@ -44,6 +44,19 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
return SUCCESS(response);
|
return SUCCESS(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询我的文章列表
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("mylist")]
|
||||||
|
public IActionResult QueryMyList([FromQuery] ArticleQueryDto parm)
|
||||||
|
{
|
||||||
|
parm.UserId = HttpContext.GetUId();
|
||||||
|
var response = _ArticleService.GetMyList(parm);
|
||||||
|
|
||||||
|
return SUCCESS(response);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询最新文章列表
|
/// 查询最新文章列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -53,6 +66,7 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
{
|
{
|
||||||
var predicate = Expressionable.Create<Article>();
|
var predicate = Expressionable.Create<Article>();
|
||||||
predicate = predicate.And(m => m.Status == "1");
|
predicate = predicate.And(m => m.Status == "1");
|
||||||
|
predicate = predicate.And(m => m.IsPublic == 1);
|
||||||
|
|
||||||
var response = _ArticleService.Queryable()
|
var response = _ArticleService.Queryable()
|
||||||
.Where(predicate.ToExpression())
|
.Where(predicate.ToExpression())
|
||||||
@ -72,8 +86,13 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public IActionResult Get(int id)
|
public IActionResult Get(int id)
|
||||||
{
|
{
|
||||||
|
long userId = HttpContext.GetUId();
|
||||||
var response = _ArticleService.GetId(id);
|
var response = _ArticleService.GetId(id);
|
||||||
var model = response.Adapt<ArticleDto>();
|
var model = response.Adapt<ArticleDto>();
|
||||||
|
if (model.IsPublic == 0 && userId != model.UserId)
|
||||||
|
{
|
||||||
|
return ToResponse(Infrastructure.ResultCode.CUSTOM_ERROR, "访问失败");
|
||||||
|
}
|
||||||
if (model != null)
|
if (model != null)
|
||||||
{
|
{
|
||||||
model.ArticleCategoryNav = _ArticleCategoryService.GetById(model.CategoryId);
|
model.ArticleCategoryNav = _ArticleCategoryService.GetById(model.CategoryId);
|
||||||
|
|||||||
@ -53,6 +53,9 @@ namespace ZR.Model.System
|
|||||||
/// 文章标签eg:Net5,java
|
/// 文章标签eg:Net5,java
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Tags { get; set; }
|
public string Tags { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 点击量
|
||||||
|
/// </summary>
|
||||||
public int Hits { get; set; }
|
public int Hits { get; set; }
|
||||||
[SugarColumn(ColumnName = "category_Id")]
|
[SugarColumn(ColumnName = "category_Id")]
|
||||||
public int CategoryId { get; set; }
|
public int CategoryId { get; set; }
|
||||||
@ -60,6 +63,10 @@ namespace ZR.Model.System
|
|||||||
/// 封面地址
|
/// 封面地址
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string CoverUrl { get; set; }
|
public string CoverUrl { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 是否公开 1、公开 0、不公开
|
||||||
|
/// </summary>
|
||||||
|
public int IsPublic { get; set; }
|
||||||
|
|
||||||
[Navigate(NavigateType.OneToOne, nameof(CategoryId), nameof(ArticleCategory.CategoryId))] //自定义关系映射
|
[Navigate(NavigateType.OneToOne, nameof(CategoryId), nameof(ArticleCategory.CategoryId))] //自定义关系映射
|
||||||
public ArticleCategory ArticleCategoryNav { get; set; }
|
public ArticleCategory ArticleCategoryNav { get; set; }
|
||||||
|
|||||||
@ -5,11 +5,11 @@ namespace ZR.Model.System.Dto
|
|||||||
{
|
{
|
||||||
public class ArticleQueryDto : PagerInfo
|
public class ArticleQueryDto : PagerInfo
|
||||||
{
|
{
|
||||||
|
public long? UserId { get; set; }
|
||||||
public string Status { get; set; }
|
public string Status { get; set; }
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
public DateTime BeginTime { get; set; }
|
public DateTime? BeginTime { get; set; }
|
||||||
public DateTime EndTime { get; set; }
|
public DateTime? EndTime { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -46,6 +46,6 @@ namespace ZR.Model.System.Dto
|
|||||||
|
|
||||||
public ArticleCategory ArticleCategoryNav { get; set; }
|
public ArticleCategory ArticleCategoryNav { get; set; }
|
||||||
public string[] TagList { get; set; }
|
public string[] TagList { get; set; }
|
||||||
|
public int IsPublic { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,6 +37,29 @@ namespace ZR.Service.System
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询我的文章列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public PagedInfo<ArticleDto> GetMyList(ArticleQueryDto parm)
|
||||||
|
{
|
||||||
|
var predicate = Expressionable.Create<Article>();
|
||||||
|
|
||||||
|
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.Title), m => m.Title.Contains(parm.Title));
|
||||||
|
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.Status), m => m.Status == parm.Status);
|
||||||
|
predicate = predicate.AndIF(parm.BeginTime != null, m => m.CreateTime >= parm.BeginTime);
|
||||||
|
predicate = predicate.AndIF(parm.EndTime != null, m => m.CreateTime <= parm.EndTime);
|
||||||
|
predicate = predicate.And(m => m.UserId == parm.UserId);
|
||||||
|
|
||||||
|
var response = Queryable()
|
||||||
|
.Includes(x => x.ArticleCategoryNav)
|
||||||
|
.Where(predicate.ToExpression())
|
||||||
|
.ToPage<Article, ArticleDto>(parm);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 修改文章管理
|
/// 修改文章管理
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -54,6 +77,7 @@ namespace ZR.Service.System
|
|||||||
CoverUrl = model.CoverUrl,
|
CoverUrl = model.CoverUrl,
|
||||||
CategoryId = model.CategoryId,
|
CategoryId = model.CategoryId,
|
||||||
FmtType = model.FmtType,
|
FmtType = model.FmtType,
|
||||||
|
IsPublic = model.IsPublic,
|
||||||
});
|
});
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ namespace ZR.Service.System.IService
|
|||||||
public interface IArticleService : IBaseService<Article>
|
public interface IArticleService : IBaseService<Article>
|
||||||
{
|
{
|
||||||
PagedInfo<ArticleDto> GetList(ArticleQueryDto parm);
|
PagedInfo<ArticleDto> GetList(ArticleQueryDto parm);
|
||||||
|
PagedInfo<ArticleDto> GetMyList(ArticleQueryDto parm);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 修改文章管理
|
/// 修改文章管理
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -333,6 +333,7 @@ CREATE TABLE `article` (
|
|||||||
`updateTime` datetime(6) NULL DEFAULT NULL COMMENT '修改时间',
|
`updateTime` datetime(6) NULL DEFAULT NULL COMMENT '修改时间',
|
||||||
`authorName` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '作者名',
|
`authorName` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '作者名',
|
||||||
`coverUrl` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '封面',
|
`coverUrl` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '封面',
|
||||||
|
`isPublic` int(4) NULL DEFAULT 0 COMMENT '是否公开',
|
||||||
PRIMARY KEY (`cid`) USING BTREE
|
PRIMARY KEY (`cid`) USING BTREE
|
||||||
) ENGINE = InnoDB AUTO_INCREMENT = 28 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
|
) ENGINE = InnoDB AUTO_INCREMENT = 28 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
@ -368,34 +369,43 @@ create table sys_config (
|
|||||||
primary key (configId)
|
primary key (configId)
|
||||||
) engine=innodb auto_increment=100 comment = '参数配置表';
|
) engine=innodb auto_increment=100 comment = '参数配置表';
|
||||||
|
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- 18、代码生成业务表
|
-- 18、代码生成业务表
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
drop table if exists gen_table;
|
DROP TABLE
|
||||||
create table gen_table (
|
IF
|
||||||
tableId bigint(20) not null auto_increment comment '编号',
|
EXISTS gen_table;
|
||||||
tableName varchar(200) default '' comment '表名称',
|
CREATE TABLE gen_table (
|
||||||
tableComment varchar(500) default '' comment '表描述',
|
tableId BIGINT ( 20 ) NOT NULL auto_increment COMMENT '编号',
|
||||||
subTableName varchar(64) default null comment '关联子表的表名',
|
tableName VARCHAR ( 200 ) DEFAULT '' COMMENT '表名称',
|
||||||
subTableFkName varchar(64) default null comment '子表关联的外键名',
|
tableComment VARCHAR ( 500 ) CHARACTER
|
||||||
className varchar(100) default '' comment '实体类名称',
|
SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '表描述',
|
||||||
tplCategory varchar(200) default 'crud' comment '使用的模板(crud单表操作 tree树表操作)',
|
subTableName VARCHAR ( 64 ) CHARACTER
|
||||||
baseNameSpace varchar(100) comment '生成命名空间前缀',
|
SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '关联子表的表名',
|
||||||
moduleName varchar(30) comment '生成模块名',
|
subTableFkName VARCHAR ( 64 ) CHARACTER
|
||||||
businessName varchar(30) comment '生成业务名',
|
SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '子表关联的外键名',
|
||||||
functionName varchar(50) comment '生成功能名',
|
className VARCHAR ( 100 ) DEFAULT '' COMMENT '实体类名称',
|
||||||
functionAuthor varchar(50) comment '生成功能作者',
|
tplCategory VARCHAR ( 200 ) DEFAULT 'crud' COMMENT '使用的模板(crud单表操作 tree树表操作)',
|
||||||
genType char(1) default '0' comment '生成代码方式(0zip压缩包 1自定义路径)',
|
baseNameSpace VARCHAR ( 100 ) COMMENT '生成命名空间前缀',
|
||||||
genPath varchar(200) default '/' comment '生成路径(不填默认项目路径)',
|
moduleName VARCHAR ( 30 ) CHARACTER
|
||||||
options varchar(1000) comment '其它生成选项',
|
SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '生成模块名',
|
||||||
create_by varchar(64) default '' comment '创建者',
|
businessName VARCHAR ( 30 ) CHARACTER
|
||||||
create_time datetime comment '创建时间',
|
SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '生成业务名',
|
||||||
update_by varchar(64) default '' comment '更新者',
|
functionName VARCHAR ( 50 ) CHARACTER
|
||||||
update_time datetime comment '更新时间',
|
SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '生成功能名',
|
||||||
remark varchar(500) default null comment '备注',
|
functionAuthor VARCHAR ( 50 ) COMMENT '生成功能作者',
|
||||||
dbName VARCHAR(100) comment '数据库名',
|
genType CHAR ( 1 ) DEFAULT '0' COMMENT '生成代码方式(0zip压缩包 1自定义路径)',
|
||||||
PRIMARY key (tableId)
|
genPath VARCHAR ( 200 ) DEFAULT '/' COMMENT '生成路径(不填默认项目路径)',
|
||||||
) engine=innodb auto_increment=1 comment = '代码生成业务表';
|
OPTIONS VARCHAR ( 1000 ) COMMENT '其它生成选项',
|
||||||
|
create_by VARCHAR ( 64 ) DEFAULT '' COMMENT '创建者',
|
||||||
|
create_time datetime COMMENT '创建时间',
|
||||||
|
update_by VARCHAR ( 64 ) DEFAULT '' COMMENT '更新者',
|
||||||
|
update_time datetime COMMENT '更新时间',
|
||||||
|
remark VARCHAR ( 500 ) DEFAULT NULL COMMENT '备注',
|
||||||
|
dbName VARCHAR ( 100 ) COMMENT '数据库名',
|
||||||
|
PRIMARY KEY ( tableId )
|
||||||
|
) ENGINE = INNODB auto_increment = 1 COMMENT = '代码生成业务表';
|
||||||
|
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
|||||||
@ -217,7 +217,8 @@ CREATE TABLE "public"."article" (
|
|||||||
"createtime" timestamp(6),
|
"createtime" timestamp(6),
|
||||||
"updatetime" timestamp(6),
|
"updatetime" timestamp(6),
|
||||||
"authorname" varchar(20) COLLATE "pg_catalog"."default",
|
"authorname" varchar(20) COLLATE "pg_catalog"."default",
|
||||||
"coverurl" varchar(255) COLLATE "pg_catalog"."default"
|
"coverurl" varchar(255) COLLATE "pg_catalog"."default",
|
||||||
|
"isPublic" int4
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
COMMENT ON COLUMN "public"."article"."title" IS '文章标题';
|
COMMENT ON COLUMN "public"."article"."title" IS '文章标题';
|
||||||
|
|||||||
@ -337,6 +337,7 @@ CREATE TABLE article (
|
|||||||
updateTime datetime NULL DEFAULT NULL , -- '修改时间',
|
updateTime datetime NULL DEFAULT NULL , -- '修改时间',
|
||||||
authorName varchar(20) DEFAULT NULL , -- '作者名',
|
authorName varchar(20) DEFAULT NULL , -- '作者名',
|
||||||
coverUrl varchar(300) NULL, --文章封面
|
coverUrl varchar(300) NULL, --文章封面
|
||||||
|
isPublic int default(0) --是否公开
|
||||||
)
|
)
|
||||||
GO
|
GO
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user