📄 agentalbum.java
字号:
/**
* 代理人图片
*/
package com.NCL;
import java.util.*;
import com.sinosoft.common.*;
import java.io.*;
public class AgentAlbum {
protected IndexMap propList;
protected HashSet Property;
protected String fMakeDate;
protected String tMakeDate;
private List strList = new ArrayList();
private boolean EOF = false;
private int COUNT;
/**
* 构造函数
*
*/
public AgentAlbum(){
propList = new IndexMap();
Property = new HashSet();
Property.add("ID"); //ID
Property.add("AgentID"); //代理人号码
Property.add("PhotoPath"); //图片路径
Property.add("PhotoTitle"); //图片标题
Property.add("PhotoDescription"); //图片描述
Property.add("UseFlag"); //有效标志(0:无效 1:有效)
Property.add("MakeDate"); //上传时间
}
/**
* 初始化
* @param agentPhotoID 图片ID
*/
public void init(String agentPhotoID){
DBAccess d = new DBAccess();
String sql = "SELECT * from AgentAlbum where ID=?";
this.propList = d.init(sql,agentPhotoID,this.Property);
}
/**
* 创建代理人图片
* @return boolean
*/
public boolean createAgentAlbum(){
String sql = "INSERT into AgentAlbum(ID,AgentID,PhotoPath,PhotoTitle,PhotoDescription,USEFLAG,MakeDate) values (AGENTALBUMID_SQE.nextval,?,?,?,?,?,sysdate)";
DBAccess d = new DBAccess();
return d.execute(sql,this.propList);
}
/**
* 删除代理人图片
* @param agentPhotoID 图片ID
* @return boolean
*/
public boolean deleteAgentAlbum(String agentPhotoID){
DBAccess DBA= new DBAccess();
String SQL = "DELETE from AgentAlbum WHERE ID=?";
return DBA.executeDelete(SQL,agentPhotoID);
}
/**
* 根据条件查询代理人图片
* @param aa 对象
* @param pageSize 分页大小
* @param pageIndex 分页页码
* @return
*/
public String findAgentAlbum(AgentAlbum aa,int pageSize,int pageIndex){
String result = "";
StringBuffer SQL = new StringBuffer("SELECT ID from AgentAlbum where 1=1");
String agentID = aa.get("AgentID");
String photoTitle = aa.get("PhotoTitle");
String useFlag = aa.get("UseFlag");
if(Data.hasValue(agentID))
SQL.append(" and AgentID=?");
if(Data.hasValue(photoTitle))
SQL.append(" and PhotoTitle like ?");
if(Data.hasValue(this.getFMakeDate())){
if(this.getFMakeDate().length() != 10)
return "";
else
SQL.append(" and MakeDate>=to_date(" + Data.formatValue(this.getFMakeDate()) + ",'yyyy-MM-dd')");
}
if(Data.hasValue(this.getTMakeDate())){
if(this.getTMakeDate().length() != 10)
return "";
else
SQL.append(" and MakeDate<=to_date(" + Data.formatValue(this.getTMakeDate() + " 23:59:59") + ",'yyyy-MM-dd hh24:mi:ss')");
}
if(Data.hasValue(useFlag))
SQL.append(" and UseFlag=?");
SQL.append(" order by MakeDate desc");
DBAccess d = new DBAccess();
result = d.executeQuery(SQL.toString(),aa.propList,pageSize,pageIndex);
setCOUNT(d.COUNT);
setEOF(d.EOF);
return result;
}
/**
* 更新代理人图片
* @param aa 对象
* @param operate 操作类型
* @param root 路径
* @return boolean
*/
public boolean doEdit(AgentAlbum aa,String operate,String root){
boolean bl = false;
if("update".equals(operate)){
bl = aa.updateAgentAlbum();
}else if("delete".equals(operate)){
bl = aa.deleteAgentAlbum(aa.get("ID"));
if(bl){
String fileName = aa.get("PhotoPath");
File file = new File(root + fileName);
if(file.exists()){
file.delete();
}
}
}
return bl;
}
/**
* 更新代理人图片
* @return boolean
*/
public boolean updateAgentAlbum(){
try{
StringBuffer sql = new StringBuffer("update AgentAlbum 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("AgentAlbum.updateAgentAlbum():" + 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();
}
/**
* 返回fMakeDate
* @return String
*/
public String getFMakeDate() {
return fMakeDate;
}
/**
* 设置fMakeDate
* @param makeDate 日期
*/
public void setFMakeDate(String makeDate) {
fMakeDate = makeDate;
}
/**
* 返回tMakeDate
* @return String
*/
public String getTMakeDate() {
return tMakeDate;
}
/**
* 设置tMakeDate
* @param makeDate 日期
*/
public void setTMakeDate(String makeDate) {
tMakeDate = makeDate;
}
public static void main(String []ages){
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -