Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
BudgetManagementSystem
Overview
Overview
Details
Activity
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
王利雷
BudgetManagementSystem
Commits
8b0d1c3a
Commit
8b0d1c3a
authored
May 13, 2019
by
shj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
历史预算列表的展示优化,在历史预算列表可以进行预算文件的删除
parent
367acd13
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
10 deletions
+73
-10
IUserBudgetDao.java
src/main/java/dao/IUserBudgetDao.java
+2
-0
IUserBudgetDao.xml
src/main/java/dao/IUserBudgetDao.xml
+4
-0
BudgetHandler.java
src/main/java/handlers/BudgetHandler.java
+15
-0
IUserBudgetService.java
src/main/java/service/IUserBudgetService.java
+2
-0
UserBudgetService.java
src/main/java/service/impl/UserBudgetService.java
+5
-0
history.jsp
src/main/webapp/history.jsp
+45
-10
No files found.
src/main/java/dao/IUserBudgetDao.java
View file @
8b0d1c3a
...
...
@@ -8,4 +8,6 @@ public interface IUserBudgetDao {
void
insertUserBudget
(
@Param
(
"userid"
)
Integer
userid
,
@Param
(
"budgetid"
)
Long
budgetid
);
List
<
Long
>
selectBudgetByUserid
(
@Param
(
"userid"
)
Integer
userid
);
void
deleteUserBudget
(
@Param
(
"userid"
)
Integer
userid
,
@Param
(
"budgetid"
)
Long
budgetId
);
}
src/main/java/dao/IUserBudgetDao.xml
View file @
8b0d1c3a
...
...
@@ -8,4 +8,7 @@
<select
id=
"selectBudgetByUserid"
resultType=
"java.lang.Long"
>
select budgetid from user_budget where userid=#{userid} order by budgetid desc
</select>
<delete
id=
"deleteUserBudget"
>
delete from user_budget where userid=#{userid} and budgetid=#{budgetid}
</delete>
</mapper>
\ No newline at end of file
src/main/java/handlers/BudgetHandler.java
View file @
8b0d1c3a
...
...
@@ -197,6 +197,21 @@ public class BudgetHandler {
return
modelAndView
;
}
@RequestMapping
(
"/Delete/{budgetId}"
)
public
void
deleteBudgetById
(
@PathVariable
(
"budgetId"
)
Long
budgetId
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
if
(
budgetId
==
null
)
return
;
Cookie
useridCookie
=
CookieUtil
.
getCookieByName
(
request
.
getCookies
(),
"userid"
);
Integer
userid
=
Integer
.
valueOf
(
useridCookie
.
getValue
());
//删除数据库记录
userBudgetService
.
deleteUserBudget
(
userid
,
budgetId
);
//删除文件
String
filePath
=
getFilePath
(
budgetId
.
toString
());
File
budgetFile
=
new
File
(
filePath
);
if
(
budgetFile
.
delete
()){
System
.
out
.
println
(
"成功删除文件"
);
}
}
@RequestMapping
(
"/HistoryPage"
)
public
ModelAndView
historyPage
(
HttpServletRequest
request
,
HttpServletResponse
response
){
ModelAndView
modelAndView
=
new
ModelAndView
();
...
...
src/main/java/service/IUserBudgetService.java
View file @
8b0d1c3a
...
...
@@ -9,4 +9,6 @@ public interface IUserBudgetService {
void
addUserBudget
(
Integer
userid
,
Long
id
);
List
<
Long
>
getBudgetByUserid
(
Integer
userid
);
void
deleteUserBudget
(
Integer
userid
,
Long
budgetId
);
}
src/main/java/service/impl/UserBudgetService.java
View file @
8b0d1c3a
...
...
@@ -23,4 +23,9 @@ public class UserBudgetService implements IUserBudgetService {
List
<
Long
>
budgets
=
userBudgetDao
.
selectBudgetByUserid
(
userid
);
return
budgets
;
}
@Override
public
void
deleteUserBudget
(
Integer
userid
,
Long
budgetId
)
{
userBudgetDao
.
deleteUserBudget
(
userid
,
budgetId
);
}
}
src/main/webapp/history.jsp
View file @
8b0d1c3a
...
...
@@ -45,7 +45,7 @@
<ul
class=
"nav navbar-nav"
>
<li><a
href=
"${pageContext.request.contextPath}/"
>
创建预算
</a></li>
<li
class=
"active"
><a
href=
"${pageContext.request.contextPath}/Budget/HistoryPage"
>
历史预算
</a></li>
<li><a
href=
"${pageContext.request.contextPath}/Budget/Detail"
>
修改预算
</a></li>
<li><a
href=
"${pageContext.request.contextPath}/Budget/Detail"
>
修改预算
</a></li>
<li><a
href=
"${pageContext.request.contextPath}/Rule/"
>
修改规则
</a></li>
<li><a
href=
"${pageContext.request.contextPath}/Budget/Download"
>
导出最新预算
</a></li>
<li><a
href=
"${pageContext.request.contextPath}/Test"
>
测试
</a></li>
...
...
@@ -56,24 +56,47 @@
</nav>
<div
id=
"budgetList"
>
<ul>
<
%
--
<
ul
>
<li
v-for=
"budget in budgetList"
>
<a
v-bind:href=
"'${pageContext.request.contextPath}/Budget/Detail/'+budget.id"
>
{{budget.id}},创建时间:{{budget.date}}
</a>
</li>
</ul>
</ul>
--%>
<table
class=
"table table-hover"
>
<thead>
<tr>
<th>
预算ID
</th>
<th>
创建时间
</th>
<th>
操作
</th>
</tr>
</thead>
<tbody>
<tr
v-for=
"budget in budgetList"
>
<td>
{{budget.id}}
</td>
<td>
{{budget.date}}
</td>
<td>
<a
v-bind:href=
"'${pageContext.request.contextPath}/Budget/Detail/'+budget.id"
>
<button
class=
"btn btn-success"
>
查看详情
</button>
</a>
<button
class=
"btn btn-danger"
@
click=
"del(budget.id)"
>
删除
</button>
</td>
</tr>
</tbody>
</table>
</div>
<script
type=
"text/javascript"
>
var
budgetListVue
=
new
Vue
({
el
:
"#budgetList"
,
data
:{
budgetList
:[]
var
budgetListVue
=
new
Vue
({
el
:
"#budgetList"
,
data
:
{
budgetList
:
[]
},
methods
:{
getBudgetHistory
:
function
()
{
methods
:
{
getBudgetHistory
:
function
()
{
/*alert("getBudgetHistory")*/
this
.
$http
.
get
(
"${pageContext.request.contextPath}/Budget/HistoryList"
).
then
(
function
(
data
)
{
...
...
@@ -84,7 +107,19 @@
}
)
},
detail
:
function
(
budget
)
{
detail
:
function
(
budget
)
{
},
del
:
function
(
budgetid
)
{
//alert(budgetid)
if
(
confirm
(
"确定删除预算文件?"
))
{
this
.
$http
.
get
(
"${pageContext.request.contextPath}/Budget/Delete/"
+
budgetid
).
then
(
function
(
data
)
{
this
.
getBudgetHistory
()
},
function
(
error
)
{
console
.
log
(
error
)
}
)
}
}
}
})
...
...
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