Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Education
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
Education
Commits
788bcac4
Commit
788bcac4
authored
4 years ago
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
公告调整
parent
75299302
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
287 additions
and
2 deletions
+287
-2
RB_Notice_Dept.cs
Edu.Model/Entity/User/RB_Notice_Dept.cs
+30
-0
RB_Notice_ViewModel.cs
Edu.Model/ViewModel/User/RB_Notice_ViewModel.cs
+10
-0
NoticeModule.cs
Edu.Module.User/NoticeModule.cs
+106
-1
RB_NoticeRepository.cs
Edu.Repository/User/RB_NoticeRepository.cs
+69
-1
RB_Notice_DeptRepository.cs
Edu.Repository/User/RB_Notice_DeptRepository.cs
+42
-0
UserCenterController.cs
Edu.WebApi/Controllers/User/UserCenterController.cs
+30
-0
No files found.
Edu.Model/Entity/User/RB_Notice_Dept.cs
0 → 100644
View file @
788bcac4
using
Edu.Common.Enum
;
using
Edu.Common.Enum.User
;
using
System
;
using
VT.FW.DB
;
namespace
Edu.Model.Entity.User
{
/// <summary>
/// 公告部门实体类
/// </summary>
[
Serializable
]
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
RB_Notice_Dept
{
/// <summary>
/// 主键
/// </summary>
public
int
Id
{
get
;
set
;
}
/// <summary>
/// 公告id
/// </summary>
public
int
NoticeId
{
get
;
set
;
}
/// <summary>
/// 部门id
/// </summary>
public
int
DeptId
{
get
;
set
;
}
}
}
This diff is collapsed.
Click to expand it.
Edu.Model/ViewModel/User/RB_Notice_ViewModel.cs
View file @
788bcac4
...
...
@@ -19,5 +19,15 @@ namespace Edu.Model.ViewModel.User
/// 文件列表
/// </summary>
public
List
<
FileModel
>
FileList
{
get
;
set
;
}
/// <summary>
/// 排序 1日期升序 2置顶升序
/// </summary>
public
int
OrderBy
{
get
;
set
;
}
/// <summary>
/// 部门id
/// </summary>
public
int
DeptId
{
get
;
set
;
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Edu.Module.User/NoticeModule.cs
View file @
788bcac4
...
...
@@ -31,6 +31,10 @@ namespace Edu.Module.User
/// </summary>
private
readonly
RB_Notice_ReadRepository
notice_ReadRepository
=
new
RB_Notice_ReadRepository
();
/// <summary>
/// 公告部门
/// </summary>
private
readonly
RB_Notice_DeptRepository
notice_DeptRepository
=
new
RB_Notice_DeptRepository
();
/// <summary>
/// 部门
/// </summary>
private
readonly
RB_DepartmentRepository
departmentRepository
=
new
RB_DepartmentRepository
();
...
...
@@ -115,8 +119,57 @@ namespace Edu.Module.User
//查询阅读人数
string
NoticeIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
Id
));
var
readList
=
notice_ReadRepository
.
GetNoticeReadNumList
(
NoticeIds
);
//var dList = notice_DeptRepository.GetList(new RB_Notice_Dept() { }, NoticeIds);
foreach
(
var
item
in
list
)
{
item
.
ReadNum
=
readList
.
Where
(
x
=>
x
.
NoticeId
==
item
.
Id
).
FirstOrDefault
()?.
ReadNum
??
0
;
//var idList = dList.Where(x => x.NoticeId == item.Id).ToList();
//if (idList.Any())
//{
// item.To = string.Join(",", idList.Select(x => x.DeptId));
//}
//else
//{
// item.To = "-1";
//}
}
}
return
list
;
}
/// <summary>
/// 获取我的公告分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="dmodel"></param>
/// <returns></returns>
public
List
<
RB_Notice_ViewModel
>
GetMyNoticePageList
(
int
pageIndex
,
int
pageSize
,
out
long
rowsCount
,
RB_Notice_ViewModel
dmodel
)
{
#
region
我的上级部门
var
dlist
=
departmentRepository
.
GetAllSuperiorDepartmentListRepository
(
dmodel
.
DeptId
);
if
(
dlist
.
Any
())
{
dmodel
.
To
=
string
.
Join
(
","
,
dlist
.
Select
(
x
=>
x
.
DeptId
));
}
#
endregion
var
list
=
noticeRepository
.
GetMyPageList
(
pageIndex
,
pageSize
,
out
rowsCount
,
dmodel
);
if
(
list
.
Any
())
{
//查询阅读人数
string
NoticeIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
Id
));
var
readList
=
notice_ReadRepository
.
GetNoticeReadNumList
(
NoticeIds
);
//var dList = notice_DeptRepository.GetList(new RB_Notice_Dept() { }, NoticeIds);
foreach
(
var
item
in
list
)
{
item
.
ReadNum
=
readList
.
Where
(
x
=>
x
.
NoticeId
==
item
.
Id
).
FirstOrDefault
()?.
ReadNum
??
0
;
//var idList = dList.Where(x => x.NoticeId == item.Id).ToList();
//if (idList.Any())
//{
// item.To = string.Join(",", idList.Select(x => x.DeptId));
//}
//else {
// item.To = "-1";
//}
}
}
return
list
;
...
...
@@ -131,6 +184,11 @@ namespace Edu.Module.User
{
var
model
=
noticeRepository
.
GetEntity
<
RB_Notice_ViewModel
>(
noticeId
);
if
(
model
==
null
)
{
return
ApiResult
.
ParamIsNull
();
}
var
dList
=
notice_DeptRepository
.
GetList
(
new
RB_Notice_Dept
()
{
NoticeId
=
noticeId
},
""
);
model
.
To
=
"-1"
;
if
(
dList
.
Any
())
{
model
.
To
=
string
.
Join
(
","
,
dList
.
Select
(
x
=>
x
.
DeptId
));
}
List
<
object
>
DepartmentList
=
new
List
<
object
>()
{
new
{
DepartmentId
=
-
1
,
DeptName
=
"全公司"
}
};
if
(!
string
.
IsNullOrEmpty
(
model
.
To
)
&&
model
.
To
!=
"-1"
)
{
//查询所有的部门
...
...
@@ -295,6 +353,37 @@ namespace Edu.Module.User
}
};
bool
flag
=
noticeRepository
.
Update
(
keyValues
,
wheres
);
if
(
flag
)
{
//更新部门
var
dList
=
notice_DeptRepository
.
GetList
(
new
RB_Notice_Dept
()
{
NoticeId
=
demodel
.
Id
},
""
);
if
(
demodel
.
To
!=
"-1"
)
{
List
<
int
>
ToList
=
JsonHelper
.
DeserializeObject
<
List
<
int
>>(
"["
+
demodel
.
To
+
"]"
);
var
insertList
=
ToList
.
Where
(
x
=>
!
dList
.
Select
(
z
=>
z
.
DeptId
).
Contains
(
x
)).
ToList
();
var
delList
=
dList
.
Where
(
x
=>
!
ToList
.
Contains
(
x
.
DeptId
)).
ToList
();
foreach
(
var
item
in
insertList
)
{
notice_DeptRepository
.
Insert
(
new
RB_Notice_Dept
()
{
Id
=
0
,
DeptId
=
item
,
NoticeId
=
demodel
.
Id
});
}
foreach
(
var
item
in
delList
)
{
notice_DeptRepository
.
Delete
(
item
);
}
}
else
{
//删除部门关联
foreach
(
var
item
in
dList
)
{
notice_DeptRepository
.
Delete
(
item
);
}
}
}
if
(
flag
&&
oldModel
.
NoticeState
==
Common
.
Enum
.
User
.
NoticeStateEnum
.
Draft
&&
demodel
.
NoticeState
==
Common
.
Enum
.
User
.
NoticeStateEnum
.
Publish
)
{
//推送消息
...
...
@@ -336,7 +425,23 @@ namespace Edu.Module.User
}
}
bool
flag
=
noticeRepository
.
Insert
(
demodel
)
>
0
;
int
Id
=
noticeRepository
.
Insert
(
demodel
);
bool
flag
=
Id
>
0
;
if
(
flag
)
{
//更新部门
if
(
demodel
.
To
!=
"-1"
)
{
List
<
int
>
ToList
=
JsonHelper
.
DeserializeObject
<
List
<
int
>>(
"["
+
demodel
.
To
+
"]"
);
foreach
(
var
item
in
ToList
)
{
notice_DeptRepository
.
Insert
(
new
RB_Notice_Dept
()
{
Id
=
0
,
DeptId
=
item
,
NoticeId
=
Id
});
}
}
}
if
(
flag
&&
demodel
.
NoticeState
==
Common
.
Enum
.
User
.
NoticeStateEnum
.
Publish
)
{
//推送消息
...
...
This diff is collapsed.
Click to expand it.
Edu.Repository/User/RB_NoticeRepository.cs
View file @
788bcac4
...
...
@@ -54,7 +54,16 @@ namespace Edu.Repository.User
where
+=
$@" and
{
nameof
(
RB_Notice
.
UpdateBy
)}
=
{
demodel
.
UpdateBy
}
"
;
}
string
sql
=
$@" select * from RB_Notice where
{
where
}
order by Id desc"
;
string
OrderBy
=
" Id desc"
;
if
(
demodel
.
OrderBy
==
1
)
{
OrderBy
=
" UpdateTime desc"
;
}
else
if
(
demodel
.
OrderBy
==
2
)
{
OrderBy
=
" Is_Top asc,UpdateTime desc"
;
}
string
sql
=
$@" select * from RB_Notice where
{
where
}
order by
{
OrderBy
}
"
;
return
GetPage
<
RB_Notice_ViewModel
>(
pageIndex
,
pageSize
,
out
count
,
sql
).
ToList
();
}
...
...
@@ -106,5 +115,64 @@ namespace Edu.Repository.User
return
obj
.
ToString
();
}
}
/// <summary>
/// 分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public
List
<
RB_Notice_ViewModel
>
GetMyPageList
(
int
pageIndex
,
int
pageSize
,
out
long
count
,
RB_Notice_ViewModel
demodel
)
{
string
where
=
$@" 1=1 and n.
{
nameof
(
RB_Notice
.
Status
)}
=0 "
;
if
(
demodel
.
Group_Id
>
0
)
{
where
+=
$@" and n.
{
nameof
(
RB_Notice
.
Group_Id
)}
=
{
demodel
.
Group_Id
}
"
;
}
if
(
demodel
.
School_Id
>
0
)
{
where
+=
$@" and n.
{
nameof
(
RB_Notice
.
School_Id
)}
=
{
demodel
.
School_Id
}
"
;
}
if
(!
string
.
IsNullOrEmpty
(
demodel
.
Title
))
{
where
+=
$@" and n.
{
nameof
(
RB_Notice
.
Title
)}
like '%
{
demodel
.
Title
}
%'"
;
}
if
(!
string
.
IsNullOrEmpty
(
demodel
.
Number
))
{
where
+=
$@" and n.
{
nameof
(
RB_Notice
.
Number
)}
like '%
{
demodel
.
Number
}
%'"
;
}
if
(
demodel
.
NoticeState
>
0
)
{
where
+=
$@" and n.
{
nameof
(
RB_Notice
.
NoticeState
)}
=
{(
int
)
demodel
.
NoticeState
}
"
;
}
if
(
demodel
.
Is_Top
>
0
)
{
where
+=
$@" and n.
{
nameof
(
RB_Notice
.
Is_Top
)}
=
{
demodel
.
Is_Top
}
"
;
}
if
(
demodel
.
UpdateBy
>
0
)
{
where
+=
$@" and n.
{
nameof
(
RB_Notice
.
UpdateBy
)}
=
{
demodel
.
UpdateBy
}
"
;
}
if
(!
string
.
IsNullOrEmpty
(
demodel
.
To
))
{
where
+=
$@" and (FIND_IN_SET(n.DeptId,'
{
demodel
.
To
}
') or n.DeptId =-1)"
;
}
string
OrderBy
=
" n.Id desc"
;
if
(
demodel
.
OrderBy
==
1
)
{
OrderBy
=
" n.UpdateTime desc"
;
}
else
if
(
demodel
.
OrderBy
==
2
)
{
OrderBy
=
" n.Is_Top asc,n.UpdateTime desc"
;
}
string
sql
=
$@" select n.* from RB_Notice n
left join rb_notice_dept d on n.Id = d.NoticeId
where
{
where
}
group by n.Id order by
{
OrderBy
}
"
;
return
GetPage
<
RB_Notice_ViewModel
>(
pageIndex
,
pageSize
,
out
count
,
sql
).
ToList
();
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Edu.Repository/User/RB_Notice_DeptRepository.cs
0 → 100644
View file @
788bcac4
using
Edu.Common.Enum
;
using
Edu.Model.Entity.User
;
using
Edu.Model.ViewModel.User
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
VT.FW.DB.Dapper
;
namespace
Edu.Repository.User
{
/// <summary>
/// 公告部门仓储层
/// </summary>
public
class
RB_Notice_DeptRepository
:
BaseRepository
<
RB_Notice_Dept
>
{
/// <summary>
/// 获取列表
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public
List
<
RB_Notice_Dept
>
GetList
(
RB_Notice_Dept
demodel
,
string
NoticeIds
)
{
string
where
=
"1=1"
;
if
(
demodel
.
NoticeId
>
0
)
{
where
+=
$@" and
{
nameof
(
RB_Notice_Dept
.
NoticeId
)}
=
{
demodel
.
NoticeId
}
"
;
}
if
(!
string
.
IsNullOrEmpty
(
NoticeIds
))
{
where
+=
$@" and
{
nameof
(
RB_Notice_Dept
.
NoticeId
)}
in(
{
NoticeIds
}
)"
;
}
if
(
demodel
.
DeptId
>
0
)
{
where
+=
$@" and
{
nameof
(
RB_Notice_Dept
.
DeptId
)}
=
{
demodel
.
DeptId
}
"
;
}
string
sql
=
$@" select * from RB_Notice_Dept where
{
where
}
"
;
return
Get
<
RB_Notice_Dept
>(
sql
).
ToList
();
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Edu.WebApi/Controllers/User/UserCenterController.cs
View file @
788bcac4
...
...
@@ -229,6 +229,36 @@ namespace Edu.WebApi.Controllers.User
}));
}
/// <summary>
/// 获取我的公告分页列表
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetMyNoticePageList
()
{
var
pageModel
=
JsonHelper
.
DeserializeObject
<
ResultPageModel
>(
RequestParm
.
Msg
.
ToString
());
var
query
=
JsonHelper
.
DeserializeObject
<
RB_Notice_ViewModel
>(
RequestParm
.
Msg
.
ToString
());
query
.
Group_Id
=
base
.
UserInfo
.
Group_Id
;
query
.
DeptId
=
base
.
UserInfo
.
DeptId
;
var
list
=
noticeModule
.
GetMyNoticePageList
(
pageModel
.
PageIndex
,
pageModel
.
PageSize
,
out
long
rowsCount
,
query
);
pageModel
.
Count
=
rowsCount
;
pageModel
.
PageData
=
list
.
Select
(
x
=>
new
{
x
.
Id
,
x
.
From
,
x
.
Number
,
x
.
Title
,
x
.
NoticeState
,
NoticeStateName
=
x
.
NoticeState
.
ToName
(),
x
.
Is_Top
,
x
.
ReadNum
,
x
.
UpdateBy
,
UpdateByName
=
UserReidsCache
.
GetUserLoginInfo
(
x
.
UpdateBy
)?.
AccountName
??
""
,
UpdateTime
=
x
.
UpdateTime
.
HasValue
?
x
.
UpdateTime
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
:
""
});
return
ApiResult
.
Success
(
""
,
pageModel
);
}
#
endregion
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment