📄 iserviceimpl.java
字号:
IDao idao = BeanFactory.getDao();
role = idao.getRoleById(id);
} catch (Exception e) {
e.printStackTrace();
throw new BossServiceException("根据ID查询角色失败");
}
return role;
}
public void updateRole(Role role) throws BossServiceException {
Transaction tran = null;
try {
IDao idao = BeanFactory.getDao();
tran = BeanFactory.getTransaction();
tran.beginTransaction();
idao.saveOrUpdateRole(role);
tran.commit();
} catch (Exception e) {
tran.rollback();
e.printStackTrace();
throw new BossServiceException("修改角色失败");
}
}
public void addRole(Role role) throws BossServiceException {
Transaction tran = null;
try {
IDao idao = BeanFactory.getDao();
tran = BeanFactory.getTransaction();
tran.beginTransaction();
idao.saveOrUpdateRole(role);
tran.commit();
} catch (Exception e) {
tran.rollback();
e.printStackTrace();
throw new BossServiceException("添加新角色失败");
}
}
public void deleteRole(Long[] selItem) throws BossServiceException {
Transaction tran = null;
try {
IDao idao = BeanFactory.getDao();
tran = BeanFactory.getTransaction();
tran.beginTransaction();
for (int i = 0; i < selItem.length; i++) {
idao.deleteRole(selItem[i]);
}
tran.commit();
} catch (Exception e) {
tran.rollback();
e.printStackTrace();
throw new BossServiceException("删除角色失败");
}
}
public List getAllProducts() throws BossServiceException {
try {
IDao idao = BeanFactory.getDao();
return idao.getAllProducts();
} catch (Exception e) {
e.printStackTrace();
throw new BossServiceException("查询所有品牌失败");
}
}
public void addProduct(Product product) throws BossServiceException {
Transaction tran = null;
try {
IDao idao = BeanFactory.getDao();
tran = BeanFactory.getTransaction();
tran.beginTransaction();
idao.saveOrUpdateProduct(product);
tran.commit();
} catch (Exception e) {
tran.rollback();
e.printStackTrace();
throw new BossServiceException("添加新品牌失败");
}
}
public void updateProduct(Product product) throws BossServiceException {
Transaction tran = null;
try {
IDao idao = BeanFactory.getDao();
tran = BeanFactory.getTransaction();
tran.beginTransaction();
idao.saveOrUpdateProduct(product);
tran.commit();
} catch (Exception e) {
tran.rollback();
e.printStackTrace();
throw new BossServiceException("修改品牌信息失败");
}
}
public List getProductByNum(int offset, int maxNumPerPage)
throws BossServiceException {
List products;
try {
IDao idao = BeanFactory.getDao();
products = idao.getProductByNum(offset, maxNumPerPage);
} catch (Exception e) {
e.printStackTrace();
throw new BossServiceException("查询品牌信息失败");
}
return products;
}
public Integer getProductCount() throws BossServiceException {
Integer count;
try {
IDao idao = BeanFactory.getDao();
count = idao.getProductCount();
} catch (Exception e) {
e.printStackTrace();
throw new BossServiceException("查询品牌数量失败");
}
return count;
}
public Product getProductById(Long id) throws BossServiceException {
Product product = null;
try {
IDao idao = BeanFactory.getDao();
product = idao.getProductById(id);
} catch (Exception e) {
e.printStackTrace();
throw new BossServiceException("根据ID查询品牌失败");
}
return product;
}
public List getAllProductTypes() throws BossServiceException {
List productTypes = null;
try {
IDao idao = BeanFactory.getDao();
productTypes = idao.getAllProductTypes();
} catch (Exception e) {
e.printStackTrace();
throw new BossServiceException("查询品牌类型失败");
}
return productTypes;
}
public void deleteProduct(Long[] selItem) throws BossServiceException {
Transaction tran = null;
try {
IDao idao = BeanFactory.getDao();
tran = BeanFactory.getTransaction();
tran.beginTransaction();
for (int i = 0; i < selItem.length; i++) {
idao.deleteProduct(selItem[i]);
}
tran.commit();
} catch (Exception e) {
tran.rollback();
e.printStackTrace();
throw new BossServiceException("删除产品失败");
}
}
public List showBusinessMonth() throws BossServiceException {
List bmonth;
try {
IDao idao = BeanFactory.getDao();
bmonth = idao.getBusinessMonth();
} catch (Exception e) {
e.printStackTrace();
throw new BossServiceException("查询BusinessMonth失败");
}
return bmonth;
}
public List showBusinessYear() throws BossServiceException {
List byear;
try {
IDao idao = BeanFactory.getDao();
byear = idao.getBusinessYear();
} catch (Exception e) {
e.printStackTrace();
throw new BossServiceException("查询BusinessYear失败");
}
return byear;
}
public List showNasDay(String year, String month, String day)
throws BossServiceException {
List nasday;
int iyear;
int imonth;
int iday;
if (checkString(year) && checkString(month) && checkString(day)) {
iyear = Integer.parseInt(year);
imonth = Integer.parseInt(month);
iday = Integer.parseInt(day);
} else {
Calendar cal = Calendar.getInstance();
iyear = cal.get(Calendar.YEAR);
imonth = cal.get(Calendar.MONTH) + 1;
iday = cal.get(Calendar.DAY_OF_MONTH);
}
year = Integer.toString(iyear);
month = formatDate(imonth);
day = formatDate(iday);
String date = year + month + day;
try {
IDao idao = BeanFactory.getDao();
nasday = idao.getNasDay(date);
} catch (Exception e) {
e.printStackTrace();
throw new BossServiceException("查询NasDay失败");
}
return nasday;
}
public List showNasMonth(String year, String month)
throws BossServiceException {
List nasmonth;
int iyear;
int imonth;
if (checkString(year) && checkString(month)) {
iyear = Integer.parseInt(year);
imonth = Integer.parseInt(month);
} else {
Calendar cal = Calendar.getInstance();
iyear = cal.get(Calendar.YEAR);
imonth = cal.get(Calendar.MONTH) + 1;
}
year = Integer.toString(iyear);
month = formatDate(imonth);
String date = year + month;
try {
IDao idao = BeanFactory.getDao();
nasmonth = idao.getNasMonth(date);
} catch (Exception e) {
e.printStackTrace();
throw new BossServiceException("查询NasMonth失败");
}
return nasmonth;
}
public List showNasYear(String year) throws BossServiceException {
List nasyear;
int iyear;
if (checkString(year)) {
iyear = Integer.parseInt(year);
} else {
Calendar cal = Calendar.getInstance();
iyear = cal.get(Calendar.YEAR);
}
year = Integer.toString(iyear);
try {
IDao idao = BeanFactory.getDao();
nasyear = idao.getNasYear(year);
} catch (Exception e) {
e.printStackTrace();
throw new BossServiceException("查询NasYear失败");
}
return nasyear;
}
private boolean checkString(String checkString) {
if (checkString != null && checkString.trim().length() > 0)
return true;
else
return false;
}
private String formatDate(int idate) {
String sdate;
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMinimumIntegerDigits(2);
sdate = numberFormat.format(idate);
return sdate;
}
public Map showUserDetail(ShowUserDetailForm showUserDetailForm,
Integer offset, Integer maxNumPerPage) throws BossServiceException {
Map radaccts = new HashMap();
String businessName = showUserDetailForm.getBusinessName();
String startDate = showUserDetailForm.getStartDate();
String endDate = showUserDetailForm.getEndDate();
try {
IDao idao = BeanFactory.getDao();
SimpleDateFormat formatter = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
Date sdate = formatter.parse(startDate);
Date edate = formatter.parse(endDate);
List lradaccts = idao.getRadacctByCondition(businessName, sdate,
edate, offset, maxNumPerPage);
Integer count = idao.getRadacctCount(businessName, sdate, edate);
radaccts.put(count, lradaccts);
} catch (Exception e) {
e.printStackTrace();
throw new BossServiceException("查询用户上网详细记录失败");
}
return radaccts;
}
public List showUserDay(String name, String year, String month, String day)
throws BossServiceException {
List lreturn = new ArrayList();
List userdays;
Radcheck radcheck;
if (day.trim().length() != 2) {
day = "0" + day;
}
if (month.trim().length() != 2) {
month = "0" + month;
}
try {
IDao idao = BeanFactory.getDao();
userdays = idao.getUserDay(name, year, month, day);
radcheck = idao.getRadcheckByName(name);
lreturn.add(radcheck);
lreturn.add(userdays);
} catch (Exception e) {
e.printStackTrace();
throw new BossServiceException("查询用户天消费信息失败");
}
return lreturn;
}
public List showUserMonth(String name, String year, String month)
throws BossServiceException {
List lreturn = new ArrayList();
List usermonths;
Radcheck radcheck;
if (month.trim().length() != 2) {
month = "0" + month;
}
try {
IDao idao = BeanFactory.getDao();
usermonths = idao.getUserMonth(name, year, month);
radcheck = idao.getRadcheckByName(name);
lreturn.add(radcheck);
lreturn.add(usermonths);
} catch (Exception e) {
e.printStackTrace();
throw new BossServiceException("查询用户月消费信息失败");
}
return lreturn;
}
public List showUserYear(String name, String year)
throws BossServiceException {
List lreturn = new ArrayList();
try {
IDao idao = BeanFactory.getDao();
List useryears = idao.getUserYear(name, year);
Radcheck radcheck = idao.getRadcheckByName(name);
lreturn.add(radcheck);
lreturn.add(useryears);
} catch (Exception e) {
e.printStackTrace();
throw new BossServiceException("查询用户年消费信息失败");
}
return lreturn;
}
public Long getHighValue() throws BossServiceException {
Transaction tran = null;
Long value = null;
try {
IDao idao = BeanFactory.getDao();
tran = BeanFactory.getTransaction();
tran.beginTransaction();
value = idao.getHighValue();
tran.commit();
} catch (Exception e) {
tran.rollback();
e.printStackTrace();
throw new BossServiceException("获取高值失败");
}
return value;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -