easyUI网页datagrid的增删改查(2)
网页的前台展示和查询分页,增删改相关代码(后台分页)
-
后台contorller的代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31//查询客户来访信息记录
@RequestMapping("/finduservisithistory")
@ResponseBody
public String finduservisithistory(int companyid,int bNum,int rows) {
String res = taiZhangService.finduservisithistory(companyid,bNum, rows);
return res;
}
//新增客户来访信息记录
@RequestMapping("/saveuservisithistory")
@ResponseBody
public String saveuservisithistory(UserVisitHistory uvh,HttpSession session) {
String res = taiZhangService.saveuservisithistory(session, uvh);
return res;
}
//修改客户来访信息记录
@RequestMapping("/updateuservisithistory")
@ResponseBody
public String updateuservisithistory(UserVisitHistory uvh,HttpSession session) {
String res = taiZhangService.updateuservisithistory(session, uvh);
return res;
}
//删除客户来访信息记录
@RequestMapping("/deleteuservisithistory")
@ResponseBody
public String deleteuservisithistory(int id,HttpSession session) {
String res = taiZhangService.deleteuservisithistory(session,id);
return res;
} -
后台service实现类的代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73//查找客户来往记录信息并分页
@Override
public String finduservisithistory(int companyid,int bNum,int rows) {
List<UserVisitHistory> list = new ArrayList<UserVisitHistory>();
int size = 0;
//根据公司id,起始位置和行数查找客户来往记录信息
list = hetongtaizhangMapper.finduservisithistory(companyid,bNum, rows);
//根据公司id查找客户来往记录信息数量
size = hetongtaizhangMapper.finduservisithistoryCount(companyid);
JSONObject jObject = new JSONObject();
jObject.put("total",size);
jObject.put("rows", JSONArray.fromObject(list).toString());
return jObject.toString();
}
//新增客户来访信息记录
@Override
public String saveuservisithistory(HttpSession session,UserVisitHistory uvh) {
String res= "保存成功";
LoginUser login = (LoginUser) session.getAttribute("login");
String loginName = "";
String ip = "";
if(login != null && (!"".equals(login))){
loginName = login.getUserName();
}
try {
uvh.setLf_createName(loginName);
hetongtaizhangMapper.saveuservisithistory(uvh);
} catch (Exception e) {
res= "保存失败";
}
return res;
}
//修改客户来访信息记录
@Override
public String updateuservisithistory(HttpSession session,UserVisitHistory uvh) {
String res= "修改成功";
LoginUser login = (LoginUser) session.getAttribute("login");
String loginName = "";
String ip = "";
if(login != null && (!"".equals(login))){
loginName = login.getUserName();
}
try {
uvh.setLf_createName(loginName);
hetongtaizhangMapper.updateuservisithistory(uvh);
} catch (Exception e) {
res= "修改失败";
}
return res;
}
//删除客户来访信息记录
@Override
public String deleteuservisithistory(HttpSession session, int id) {
String res= "1";
LoginUser login = (LoginUser) session.getAttribute("login");
String loginName = "";
String ip = "";
if(login != null && (!"".equals(login))){
loginName = login.getUserName();
}
try {
hetongtaizhangMapper.deleteuservisithistory(id);
} catch (Exception e) {
res= "2";
}
return res;
} -
mapper.xml文件的代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49<select id="finduservisithistory" resultType="UserVisitHistory">
SELECT
*
FROM
t_ht_kehulaifangjilu
LEFT JOIN tb_customerinfo ON tb_customerinfo.C_ID = t_ht_kehulaifangjilu.lf_gongsi
WHERE 1 = 1
<if test=" companyid != 0">
and tb_customerinfo.C_ID = ${companyid}
</if>
limit #{bNum},#{rows}
</select>
<select id="finduservisithistoryCount" resultType="int">
SELECT
count(*)
FROM
t_ht_kehulaifangjilu
LEFT JOIN tb_customerinfo ON tb_customerinfo.C_ID = t_ht_kehulaifangjilu.lf_gongsi
WHERE 1 = 1
<if test=" companyid != 0">
and tb_customerinfo.C_ID = ${companyid}
</if>
</select>
<insert id="saveuservisithistory">
INSERT into t_ht_kehulaifangjilu (
lf_riqi,lf_gongsi,lf_lianxiren,lf_lianxidianhua,lf_xiangmudiqu,lf_xiangmumingcheng,
lf_xuqiu,lf_beizhu,lf_gongsifuzeren,lf_createTime,lf_createName
)
VALUES(
#{lf_riqi}, #{lf_gongsi},#{lf_lianxiren},#{lf_lianxidianhua},#{lf_xiangmudiqu},#{lf_xiangmumingcheng},
#{lf_xuqiu},#{lf_beizhu},#{lf_gongsifuzeren},SYSDATE(),#{lf_createName}
)
</insert>
<update id="updateuservisithistory">
UPDATE t_ht_kehulaifangjilu set
lf_riqi = #{lf_riqi},lf_lianxiren = #{lf_lianxiren},
lf_lianxidianhua = #{lf_lianxidianhua},lf_xiangmudiqu = #{lf_xiangmudiqu},
lf_xiangmumingcheng = #{lf_xiangmumingcheng},lf_xuqiu = #{lf_xuqiu},
lf_beizhu = #{lf_beizhu},lf_gongsifuzeren = #{lf_gongsifuzeren},
lf_createTime = SYSDATE(),lf_createName = #{lf_createName}
where id = #{id}
</update>
<delete id="deleteuservisithistory">
DELETE FROM t_ht_kehulaifangjilu where id = #{id}
</delete> -
实体类UserVisitHistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95public class UserVisitHistory {
private int id;
private String lf_riqi;
private int lf_gongsi;
private String lf_lianxiren;
private String lf_lianxidianhua;
private String lf_xiangmudiqu;
private String lf_xiangmumingcheng;
private String lf_xuqiu;
private String lf_beizhu;
private String lf_gongsifuzeren;
private String lf_createTime;
private String lf_createName;
//tb_customerinfo表的公司名称
private String C_COMPANY;
public String getC_COMPANY() {
return C_COMPANY;
}
public void setC_COMPANY(String c_COMPANY) {
C_COMPANY = c_COMPANY;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getLf_riqi() {
return lf_riqi;
}
public void setLf_riqi(String lf_riqi) {
this.lf_riqi = lf_riqi;
}
public int getLf_gongsi() {
return lf_gongsi;
}
public void setLf_gongsi(int lf_gongsi) {
this.lf_gongsi = lf_gongsi;
}
public String getLf_lianxiren() {
return lf_lianxiren;
}
public void setLf_lianxiren(String lf_lianxiren) {
this.lf_lianxiren = lf_lianxiren;
}
public String getLf_lianxidianhua() {
return lf_lianxidianhua;
}
public void setLf_lianxidianhua(String lf_lianxidianhua) {
this.lf_lianxidianhua = lf_lianxidianhua;
}
public String getLf_xiangmudiqu() {
return lf_xiangmudiqu;
}
public void setLf_xiangmudiqu(String lf_xiangmudiqu) {
this.lf_xiangmudiqu = lf_xiangmudiqu;
}
public String getLf_xiangmumingcheng() {
return lf_xiangmumingcheng;
}
public void setLf_xiangmumingcheng(String lf_xiangmumingcheng) {
this.lf_xiangmumingcheng = lf_xiangmumingcheng;
}
public String getLf_xuqiu() {
return lf_xuqiu;
}
public void setLf_xuqiu(String lf_xuqiu) {
this.lf_xuqiu = lf_xuqiu;
}
public String getLf_beizhu() {
return lf_beizhu;
}
public void setLf_beizhu(String lf_beizhu) {
this.lf_beizhu = lf_beizhu;
}
public String getLf_gongsifuzeren() {
return lf_gongsifuzeren;
}
public void setLf_gongsifuzeren(String lf_gongsifuzeren) {
this.lf_gongsifuzeren = lf_gongsifuzeren;
}
public String getLf_createTime() {
return lf_createTime;
}
public void setLf_createTime(String lf_createTime) {
this.lf_createTime = lf_createTime;
}
public String getLf_createName() {
return lf_createName;
}
public void setLf_createName(String lf_createName) {
this.lf_createName = lf_createName;
}
}
注意:easyUI的datebox对应数据库的date类型,实体类为String类型;easyUI的datetimebox对应数据库的datetime类型,实体类为String类型;后台使用SYSDATE()传入数据库datetime类型;
注意:实体类中的C_COMPANY传到前台的字段名为c_COMPANY.
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 WeiJia_Rao!