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
e26e6e7d
Commit
e26e6e7d
authored
May 12, 2019
by
shj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
历史预算功能:某用户的历史预算列表,根据日期降序,页面展示完成;下一步:在预算列表页面点击查看某个预算
parent
bac7ff0c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
149 additions
and
7 deletions
+149
-7
IUserBudgetDao.java
src/main/java/dao/IUserBudgetDao.java
+4
-0
IUserBudgetDao.xml
src/main/java/dao/IUserBudgetDao.xml
+4
-0
BudgetHandler.java
src/main/java/handlers/BudgetHandler.java
+40
-6
IUserBudgetService.java
src/main/java/service/IUserBudgetService.java
+4
-0
UserBudgetService.java
src/main/java/service/impl/UserBudgetService.java
+9
-0
history.jsp
src/main/webapp/history.jsp
+86
-0
index.jsp
src/main/webapp/index.jsp
+2
-1
No files found.
src/main/java/dao/IUserBudgetDao.java
View file @
e26e6e7d
...
...
@@ -2,6 +2,10 @@ package dao;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
public
interface
IUserBudgetDao
{
void
insertUserBudget
(
@Param
(
"userid"
)
Integer
userid
,
@Param
(
"budgetid"
)
Long
budgetid
);
List
<
Long
>
selectBudgetByUserid
(
@Param
(
"userid"
)
Integer
userid
);
}
src/main/java/dao/IUserBudgetDao.xml
View file @
e26e6e7d
...
...
@@ -5,4 +5,7 @@
<insert
id=
"insertUserBudget"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into user_budget(userid,budgetid) values (#{userid},#{budgetid})
</insert>
<select
id=
"selectBudgetByUserid"
resultType=
"java.lang.Long"
>
select budgetid from user_budget where userid=#{userid} order by budgetid desc
</select>
</mapper>
\ No newline at end of file
src/main/java/handlers/BudgetHandler.java
View file @
e26e6e7d
package
handlers
;
import
beans.*
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
dao.*
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -21,10 +23,8 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
java.io.*
;
import
java.util.Date
;
import
java.util.Enumeration
;
import
java.util.List
;
import
java.util.Map
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
@Controller
@RequestMapping
(
"/Budget"
)
...
...
@@ -124,8 +124,7 @@ public class BudgetHandler {
System
.
out
.
println
(
"ContextPath: "
+
request
.
getContextPath
());
System
.
out
.
println
(
session
.
getServletContext
().
getRealPath
(
""
));
//budgetToOutputStream(budget, response.getOutputStream());
response
.
getWriter
().
write
(
"success"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -185,6 +184,41 @@ public class BudgetHandler {
return
modelAndView
;
}
@RequestMapping
(
"/HistoryPage"
)
public
ModelAndView
historyPage
(
HttpServletRequest
request
,
HttpServletResponse
response
){
ModelAndView
modelAndView
=
new
ModelAndView
();
modelAndView
.
setViewName
(
"/history.jsp"
);
return
modelAndView
;
}
@RequestMapping
(
"/HistoryList"
)
public
void
historyList
(
HttpServletRequest
request
,
HttpServletResponse
response
){
try
{
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setContentType
(
"text/html;charset=utf-8"
);
PrintWriter
writer
=
response
.
getWriter
();
JSONObject
object
=
new
JSONObject
();
//String sessionID = BudgetHandler.getSessionID(request.getCookies());
Cookie
useridCookie
=
CookieUtil
.
getCookieByName
(
request
.
getCookies
(),
"userid"
);
Integer
userid
=
Integer
.
valueOf
(
useridCookie
.
getValue
());
List
<
Long
>
budgetList
=
userBudgetService
.
getBudgetByUserid
(
userid
);
List
<
JSONObject
>
list
=
new
LinkedList
<>();
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
for
(
Long
budget
:
budgetList
)
{
JSONObject
obj
=
new
JSONObject
();
obj
.
put
(
"id"
,
budget
);
Date
date
=
new
Date
(
budget
);
obj
.
put
(
"date"
,
format
.
format
(
date
));
list
.
add
(
obj
);
}
object
.
put
(
"data"
,
list
);
writer
.
write
(
JSON
.
toJSONString
(
object
));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
...
...
src/main/java/service/IUserBudgetService.java
View file @
e26e6e7d
package
service
;
import
java.util.List
;
/**
* 维护用户与预算文件的关系
*/
public
interface
IUserBudgetService
{
void
addUserBudget
(
Integer
userid
,
Long
id
);
List
<
Long
>
getBudgetByUserid
(
Integer
userid
);
}
src/main/java/service/impl/UserBudgetService.java
View file @
e26e6e7d
...
...
@@ -4,6 +4,9 @@ import dao.IUserBudgetDao;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
service.IUserBudgetService
;
import
java.util.List
;
@Service
public
class
UserBudgetService
implements
IUserBudgetService
{
@Autowired
...
...
@@ -14,4 +17,10 @@ public class UserBudgetService implements IUserBudgetService {
userBudgetDao
.
insertUserBudget
(
userid
,
budgetid
);
System
.
out
.
println
(
"add User-Budget"
);
}
@Override
public
List
<
Long
>
getBudgetByUserid
(
Integer
userid
)
{
List
<
Long
>
budgets
=
userBudgetDao
.
selectBudgetByUserid
(
userid
);
return
budgets
;
}
}
src/main/webapp/history.jsp
0 → 100644
View file @
e26e6e7d
<
%
--
Created
by
IntelliJ
IDEA
.
User:
Song
Date:
2019
/
5
/
12
Time:
16:49
To
change
this
template
use
File
|
Settings
|
File
Templates
.
--
%
>
<
%@
page
contentType=
"text/html;charset=UTF-8"
language=
"java"
%
>
<html>
<head>
<title>
历史预算
</title>
<link
rel=
"stylesheet"
href=
"https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css"
integrity=
"sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin=
"anonymous"
>
<!-- 可选的 Bootstrap 主题文件(一般不用引入) -->
<link
rel=
"stylesheet"
href=
"https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap-theme.min.css"
integrity=
"sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp"
crossorigin=
"anonymous"
>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script
src=
"https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"
integrity=
"sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin=
"anonymous"
></script>
<link
rel=
"stylesheet"
href=
"https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css"
>
<script
src=
"https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"
></script>
<script
src=
"https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"
></script>
<
%
--
<
script
type=
"text/javascript"
src=
"${pageContext.request.contextPath}/js/modifyDetail.js"
></script>
--%>
<style
type=
"text/css"
>
body
{
padding-top
:
70px
;
}
</style>
<script
src=
"https://cdn.jsdelivr.net/npm/vue/dist/vue.js"
></script>
<script
src=
"https://cdn.staticfile.org/vue-resource/1.5.1/vue-resource.min.js"
></script>
</head>
<body
onload=
"budgetListVue.getBudgetHistory()"
>
<nav
class=
"navbar navbar-default navbar-fixed-top"
role=
"navigation"
>
<div
class=
"container-fluid"
>
<div
class=
"navbar-header"
>
<a
class=
"navbar-brand"
href=
"${pageContext.request.contextPath}/"
>
预算辅助管理系统
</a>
</div>
<div>
<ul
class=
"nav navbar-nav"
>
<li><a
href=
"${pageContext.request.contextPath}/"
>
创建预算
</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
class=
"active"
><a
href=
"#"
>
测试
</a></li>
</ul>
</div>
</div>
</nav>
<div
id=
"budgetList"
>
<ul>
<li
v-for=
"budget in budgetList"
><a
href=
"#"
>
{{budget.id}}, {{budget.date}}
</a></li>
</ul>
</div>
<script
type=
"text/javascript"
>
var
budgetListVue
=
new
Vue
({
el
:
"#budgetList"
,
data
:{
budgetList
:[]
},
methods
:{
getBudgetHistory
:
function
()
{
/*alert("getBudgetHistory")*/
this
.
$http
.
get
(
"${pageContext.request.contextPath}/Budget/HistoryList"
).
then
(
function
(
data
)
{
this
.
budgetList
=
data
.
body
.
data
;
console
.
log
(
"show history list"
);
},
function
(
error
)
{
console
.
log
(
error
)
}
)
}
}
})
</script>
</body>
</html>
src/main/webapp/index.jsp
View file @
e26e6e7d
...
...
@@ -46,6 +46,7 @@
<li><a
href=
"${pageContext.request.contextPath}/Budget/Download"
>
导出最新预算
</a></li>
<li><a
href=
"${pageContext.request.contextPath}/Test"
>
测试
</a></li>
<li><a
href=
"${pageContext.request.contextPath}/Logout"
>
注销
</a></li>
<li><a
href=
"${pageContext.request.contextPath}/Budget/HistoryPage"
>
历史预算
</a></li>
</ul>
</div>
</div>
...
...
@@ -68,7 +69,7 @@
others =
0;
%
>
<iframe
hidden
id=
"hidden_frame"
name=
"hidden_frame"
></iframe>
<form
class=
"form-horizontal"
method=
"post"
action=
"${pageContext.request.contextPath}/Budget/Generate"
target=
"
hidden_frame
"
>
<form
class=
"form-horizontal"
method=
"post"
action=
"${pageContext.request.contextPath}/Budget/Generate"
target=
"
_blank
"
>
<div
class=
"form-group"
>
<label
class=
"control-label col-sm-4"
>
总预算(万元)
</label>
...
...
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