📄 productrelatedinfo.java
字号:
/**
* 卡式保单产品相关信息(产品简介、产品特点、条款、投保规则、业务介绍)
*/
package com.NCL;
import java.util.*;
import java.io.*;
import com.sinosoft.common.*;
//卡式保单产品相关信息(产品简介、产品特点、条款、投保规则、业务介绍)
public class ProductRelatedInfo {
protected IndexMap propList;
protected HashSet Property;
private List strList = new ArrayList();
private boolean EOF = false;
private int COUNT;
/**
* 构造函数
*
*/
public ProductRelatedInfo(){
propList = new IndexMap();
Property = new HashSet();
Property.add("ID"); //自增长ID
Property.add("ProductID"); //产品ID
Property.add("InfoType"); //信息类型(产品简介、产品特点、条款、投保规则、业务介绍)
Property.add("InfoContent"); //信息内容--改存文件名字
}
/**
* 初始化
* @param productRelatedInfoID ID
*/
public void init(String productRelatedInfoID){
DBAccess d = new DBAccess();
String sql = "SELECT * from ProductRelatedInfo where ID=?";
this.propList = d.init(sql,productRelatedInfoID,this.Property);
}
/**
* 创建
* @return boolean
*/
public boolean createProductRelatedInfo(){
String sql = "INSERT into ProductRelatedInfo values (PRODUCTRELATEDINFOID_SQE.nextval,?,?,?)";
DBAccess d = new DBAccess();
return d.execute(sql,this.propList);
}
/**
* 删除
* @param agentPhotoID 自增长ID
* @return boolean
*/
public boolean deleteProductRelatedInfo(String agentPhotoID){
DBAccess DBA= new DBAccess();
String SQL = "DELETE from ProductRelatedInfo WHERE ID=?";
return DBA.executeDelete(SQL,agentPhotoID);
}
/**
* 批量删除
* @param l 对象
* @return boolean
*/
public boolean mulDeleteProductRelatedInfo(List l){
DBAccess DBA= new DBAccess();
String SQL = "DELETE from ProductRelatedInfo WHERE ID=?";
return DBA.mulExecute(SQL,l);
}
/**
* 根据条件查询
* @param pri 对象
* @param pageSize 分页大小
* @param pageIndex 分页页码
* @return String
*/
public String findProductRelatedInfo(ProductRelatedInfo pri,int pageSize,int pageIndex){
String result = "";
StringBuffer SQL = new StringBuffer("SELECT ID from ProductRelatedInfo where 1=1");
String productID = pri.get("ProductID");
String infoType = pri.get("InfoType");
if(Data.hasValue(productID))
SQL.append(" and ProductID=?");
if(Data.hasValue(infoType))
SQL.append(" and InfoType=?");
DBAccess d = new DBAccess();
result = d.executeQuery(SQL.toString(),pri.propList,pageSize,pageIndex);
setCOUNT(d.COUNT);
setEOF(d.EOF);
return result;
}
/**
* 获取产品相关信息
* @param productID 产品ID
* @return HashMap
*/
public HashMap getRelatedInfo(String productID){
HashMap hm = new HashMap();
this.set("ProductID",productID);
String result = this.findProductRelatedInfo(this,0,1);
if(result != null && !"".equals(result)){
String[] infoIDs = result.split(",");
for(int i = 0; i < infoIDs.length; i++){
this.init(infoIDs[i]);
hm.put(this.get("InfoType"),this.get("InfoContent"));
this.clear();
}
}else{
hm = null;
}
return hm;
}
/**
* 对产品的相关信息进行操作
* @param pri 对象
* @param operate 操作类型
* @param root 文件路径
* @return boolean
*/
public boolean doEdit(ProductRelatedInfo pri,String operate,String root){
boolean bl = false;
if("create".equals(operate)){
bl = this.createProductRelatedInfo();
}else if("update".equals(operate)){
bl = pri.updateProductRelatedInfo();
}else if("delete".equals(operate)){
bl = pri.deleteProductRelatedInfo(pri.get("ID"));
if(bl){
String fileName = pri.get("InfoContent");
System.out.println(root + fileName);
File file = new File(root + fileName);
if(file.exists()){
file.delete();
}
}
}
return bl;
}
/**
* 更新产品的相关信息
* @return boolean
*/
public boolean updateProductRelatedInfo(){
try{
StringBuffer sql = new StringBuffer("update ProductRelatedInfo set ");
List l = new ArrayList();
for(int i=0;i<strList.size();i++){
Object[] strArray =(Object[]) strList.get(i);
sql.append(strArray[0]);
sql.append("=?,");
l.add(strArray[1]);
}
sql.deleteCharAt(sql.lastIndexOf(","));
sql.append(" where ID=?");
l.add(this.get("ID"));
strList.clear();
DBAccess q = new DBAccess();
return q.executeUpdate(sql.toString(),l);
}catch(Exception e){
e.printStackTrace();
System.out.println("ProductRelatedInfo.updateProductRelatedInfo():" + e.getMessage());
return false;
}
}
/**
* 在此映射中关联指定值与指定键
* @param name 指定键
* @param value 指定值
*/
public void setUpdateValue(String name,Object value){
if(this.set(name,value)){
Object[] uValue = new Object[2];
uValue[0] = name;
uValue[1] = value;
strList.add(uValue);
}
}
/**
* 在此映射中关联指定值与指定键
* @param name 指定键
* @param value 指定值
*/
public boolean set(String name, Object value){
if(Property.contains(name)){
propList.put(name,value);
return true;
}else
return false;
}
/**
* 返回指定键在此映射中所映射的值
* @param name 指定键
* @return
*/
public String get(String name){
if (Property.contains(name)){
String value = (String)propList.get(name);
if(value != null && !value.equals(""))
return value;
else
return "";
}else
return "";
}
/**
* 返回COUNT
* @return int
*/
public int getCOUNT() {
return COUNT;
}
/**
* 设置COUNT
* @param count
*/
public void setCOUNT(int count) {
COUNT = count;
}
/**
* 返回EOF
* @return boolean
*/
public boolean isEOF() {
return EOF;
}
/**
* 设置EOF
* @param eof
*/
public void setEOF(boolean eof) {
EOF = eof;
}
/**
* 清空propList
*
*/
public void clear(){
propList.clear();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -