添加了可读的注释

develop
wht 11 months ago
parent cd2e82bfac
commit d063436351

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/touge" vcs="Git" /> <mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/touge/hotelbook-JavaWeb-master" vcs="Git" />
</component> </component>
</project> </project>

@ -6,46 +6,50 @@ import com.inks.hb.authinfo.pojo.AuthInfo;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
// 实现AuthService接口提供AuthInfo业务逻辑服务
public class AuthServiceImpl implements AuthService { public class AuthServiceImpl implements AuthService {
private AuthInfoDao dao = new AuthInfoDao(); private AuthInfoDao dao = new AuthInfoDao(); // AuthInfo数据访问对象
// 查询AuthInfo记录总数
@Override @Override
public int queryAuthInfoNum() throws SQLException { public int queryAuthInfoNum() throws SQLException {
return dao.queryDataNum(); // 调用DAO层的方法查询总数
return dao.queryDataNum();
} }
// 根据ID查询AuthInfo记录
@Override @Override
public AuthInfo query(int authId) throws SQLException { public AuthInfo query(int authId) throws SQLException {
AuthInfo authInfo = new AuthInfo(); AuthInfo authInfo = new AuthInfo(); // 创建AuthInfo对象
authInfo.setAuthId(authId); authInfo.setAuthId(authId); // 设置查询条件
return (AuthInfo) dao.query(authInfo); return (AuthInfo) dao.query(authInfo); // 调用DAO层的方法进行查询
} }
// 根据权限项名称查询AuthInfo记录
@Override @Override
public AuthInfo query(String authItem) throws SQLException { public AuthInfo query(String authItem) throws SQLException {
AuthInfo authInfo = new AuthInfo(); AuthInfo authInfo = new AuthInfo(); // 创建AuthInfo对象
authInfo.setAuthItem(authItem); authInfo.setAuthItem(authItem); // 设置查询条件
return dao.queryName(authInfo); return dao.queryName(authInfo); // 调用DAO层的方法进行查询
} }
// 分页查询AuthInfo记录
@Override @Override
public ArrayList query(int page, int limit) throws SQLException { public ArrayList query(int page, int limit) throws SQLException {
int start = (page * limit) - limit + 1; // 计算分页查询的起始位置
int start = (page * limit) - limit + 1; //每一页的起始位置 if (start < 1) {
start = 1; // 如果起始位置小于1则设置为1
if (start < 1) }
start = 1;
return dao.query(start, limit); return dao.query(start, limit); // 调用DAO层的方法进行分页查询
} }
// 更新AuthInfo记录
@Override @Override
public void updateAuthInfo(AuthInfo authInfo) throws SQLException { public void updateAuthInfo(AuthInfo authInfo) throws SQLException {
dao.updateData(authInfo); // 调用DAO层的方法进行更新操作
dao.updateData(authInfo);
} }
} }

@ -1,24 +1,31 @@
package com.inks.hb.billinfo.pojo; package com.inks.hb.billinfo.pojo;
/** /**
* *
*/ */
public class BillInfo { public class BillInfo {
// 账单ID
private int billId; private int billId;
// 审核ID
private String checkedId; private String checkedId;
// 费用金额
private String costMoney; private String costMoney;
// 费用日期
private String costDate; private String costDate;
// 备注
private String remark; private String remark;
// 默认构造方法
public BillInfo() { public BillInfo() {
super(); super();
} }
// 带参数的构造方法用于创建BillInfo对象时初始化字段
public BillInfo(int billId, String checkedId, String costMoney, String costDate, String remark) { public BillInfo(int billId, String checkedId, String costMoney, String costDate, String remark) {
this.billId = billId; this.billId = billId;
this.checkedId = checkedId; this.checkedId = checkedId;
@ -27,46 +34,57 @@ public class BillInfo {
this.remark = remark; this.remark = remark;
} }
// 获取账单ID
public int getBillId() { public int getBillId() {
return billId; return billId;
} }
// 设置账单ID
public void setBillId(int billId) { public void setBillId(int billId) {
this.billId = billId; this.billId = billId;
} }
// 获取审核ID
public String getCheckedId() { public String getCheckedId() {
return checkedId; return checkedId;
} }
// 设置审核ID
public void setCheckedId(String checkedId) { public void setCheckedId(String checkedId) {
this.checkedId = checkedId; this.checkedId = checkedId;
} }
// 获取费用金额
public String getCostMoney() { public String getCostMoney() {
return costMoney; return costMoney;
} }
// 设置费用金额
public void setCostMoney(String costMoney) { public void setCostMoney(String costMoney) {
this.costMoney = costMoney; this.costMoney = costMoney;
} }
// 获取费用日期
public String getCostDate() { public String getCostDate() {
return costDate; return costDate;
} }
// 设置费用日期
public void setCostDate(String costDate) { public void setCostDate(String costDate) {
this.costDate = costDate; this.costDate = costDate;
} }
// 获取备注
public String getRemark() { public String getRemark() {
return remark; return remark;
} }
// 设置备注
public void setRemark(String remark) { public void setRemark(String remark) {
this.remark = remark; this.remark = remark;
} }
// 重写toString方法用于打印BillInfo对象的字符串表示
@Override @Override
public String toString() { public String toString() {
return "BillInfo{" + return "BillInfo{" +

@ -5,18 +5,33 @@ import java.util.Base64;
public class MD5 { public class MD5 {
/**
* MD5Base64
* @param str
* @return Base64
*/
public String getMD5(String str) { public String getMD5(String str) {
// 在输入字符串前添加盐值
String Salt = "mH8yhBL-n*j-2gmC" + str; String Salt = "mH8yhBL-n*j-2gmC" + str;
// 将带盐值的字符串转换为字节数组并进行Base64编码
return Base64.getEncoder().encodeToString(Salt.getBytes(StandardCharsets.UTF_8)); return Base64.getEncoder().encodeToString(Salt.getBytes(StandardCharsets.UTF_8));
} }
/**
* MD5
* @param newStr
* @param oldStr
* @return truefalse
*/
public boolean checkMD5(String newStr, String oldStr) { public boolean checkMD5(String newStr, String oldStr) {
// 比较新字符串的MD5哈希值与旧字符串的哈希值是否相等
return getMD5(newStr).equals(oldStr); return getMD5(newStr).equals(oldStr);
} }
public static void main(String[] args) { public static void main(String[] args) {
// 创建MD5类的实例
MD5 md5 = new MD5(); MD5 md5 = new MD5();
// 输出字符串"toor"的MD5哈希值
System.out.println(md5.getMD5("toor")); System.out.println(md5.getMD5("toor"));
} }
} }

Loading…
Cancel
Save