Browse Source

增加删除资源的接口,删除资源时判断该资源时候存在资源申请,如果存在资源申请不允许删除资源。资源申请者在资源拥有者未回复该申请之前可以删除该申请。

zzy.zhiyuan.foxmail 8 years ago
parent
commit
b06000b432

+ 40 - 3
src/main/java/com/ekexiu/portal/dao/OperationDao.java

@ -15,6 +15,7 @@ import org.jfw.apt.orm.annotation.dao.DAO;
15 15
import org.jfw.apt.orm.annotation.dao.method.From;
16 16
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
17 17
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
18
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
18 19
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
19 20
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
20 21
import org.jfw.apt.orm.annotation.dao.param.Set;
@ -675,13 +676,49 @@ public abstract class OperationDao {
675 676
//		}
676 677
//	}
677 678
	
679
	@SelectList
680
	public abstract List<Operation> queryResourceId(Connection con, String resourceId) throws SQLException;
681
	
678 682
	@DeleteWith
679 683
	@From(Operation.class)
680 684
	public abstract int delete(Connection con, String operationId) throws SQLException;
681 685
	
682
	@DeleteWith
683
	@From(Operation.class)
684
	public abstract int deleteProRes(Connection con, String demandId, String resourceId) throws SQLException;
686
	/**
687
	 * 获取当前资源申请的状态值。
688
	 * @param con
689
	 * @param operationId 资源申请ID
690
	 * @return 返回资源申请状态值
691
	 * @throws SQLException
692
	 */
693
	public int queryOper(Connection con, String operationId) throws SQLException{
694
		String sql = "SELECT OPERATION_STATUS FROM OPERATION WHERE OPERATION_ID = ?";
695
		PreparedStatement ps = con.prepareStatement(sql);
696
		try {
697
			ps.setString(1, operationId);
698
			ResultSet rs = ps.executeQuery();
699
			try{
700
				rs.next();
701
				return rs.getInt(1);
702
			}finally{
703
                try{rs.close();}catch(Exception _m_2){}
704
            }
705
		}finally{
706
            try{ps.close();}catch(Exception _m_3){}
707
        }
708
	}
709
	
710
	public int deleteDem(Connection con,String operationId,String demandId) throws SQLException{
711
        int _m_1 = 1;
712
        String sql = "DELETE FROM OPERATION WHERE OPERATION_STATUS = 1 AND DEMAND_ID = ? AND OPERATION_ID = ?";
713
        PreparedStatement ps = con.prepareStatement(sql);
714
        try{
715
            ps.setString(_m_1++,demandId);
716
            ps.setString(_m_1++,operationId);
717
            return ps.executeUpdate();
718
        }finally{
719
            try{ps.close();}catch(Exception _m_2){}
720
        }
721
    }
685 722
	
686 723
	/**
687 724
	 * 分页查询资源申请 多条件模糊查询

+ 1 - 1
src/main/java/com/ekexiu/portal/dao/PayHistoryDao.java

@ -89,7 +89,7 @@ public abstract class PayHistoryDao {
89 89
                    _obj.setRemark(_m_2);
90 90
                    _obj.setIsonline(rs.getInt(6));
91 91
                    _obj.setPayType(rs.getInt(7));
92
                    _obj.setPayStatus(rs.getShort(8));
92
                    _obj.setPayStatus(rs.getInt(8));
93 93
                    _obj.setCreateTime(rs.getString(9));
94 94
                    operation.setDealPrice(rs.getBigDecimal(10));
95 95
                    operation.setCreateTime(rs.getString(11));

+ 13 - 8
src/main/java/com/ekexiu/portal/service/OperationService.java

@ -133,16 +133,21 @@ public class OperationService {
133 133
		this.operationDao.updatePayMethod(con, operationId, payMethod);
134 134
	}
135 135
	
136
	@Delete
137
	@Path("/{operationId}")
138
	public void delete(@JdbcConn(true) Connection con, String operationId) throws SQLException{
139
		this.operationDao.delete(con, operationId);
140
	}
136
//	@Delete
137
//	@Path("/{operationId}")
138
//	public void delete(@JdbcConn(true) Connection con, String operationId) throws SQLException{
139
//		this.operationDao.delete(con, operationId);
140
//	}
141 141
	
142 142
	@Delete
143
	@Path("/deleteprores")
144
	public void deleteProRes(@JdbcConn(true) Connection con, String demandId, String resourceId) throws SQLException {
145
		this.operationDao.deleteProRes(con, demandId, resourceId);
143
	@Path("/deleteDem")
144
	public boolean deleteDem(@JdbcConn(true) Connection con, String operationId, String demandId) throws SQLException {
145
		if(1 == this.operationDao.queryOper(con, operationId)){
146
			this.operationDao.deleteDem(con, operationId, demandId);
147
			return true;
148
		}else{
149
			return false;
150
		}
146 151
	}
147 152
	
148 153
	@Get

+ 21 - 3
src/main/java/com/ekexiu/portal/service/ResourceService.java

@ -18,7 +18,9 @@ import org.jfw.util.PageQueryResult;
18 18
import org.jfw.util.StringUtil;
19 19

20 20
import com.ekexiu.portal.dao.ImageDao;
21
import com.ekexiu.portal.dao.OperationDao;
21 22
import com.ekexiu.portal.dao.ResourceDao;
23
import com.ekexiu.portal.po.Operation;
22 24
import com.ekexiu.portal.po.Resource;
23 25

24 26
@Path("/resource")
@ -29,6 +31,16 @@ public class ResourceService {
29 31
	private ResourceDao resourceDao;
30 32
	@Autowrie
31 33
	private ImagesService imagesService;
34
	@Autowrie
35
	private OperationDao operationDao;
36

37
	public OperationDao getOperationDao() {
38
		return operationDao;
39
	}
40

41
	public void setOperationDao(OperationDao operationDao) {
42
		this.operationDao = operationDao;
43
	}
32 44

33 45
	public ImageDao getImageDao() {
34 46
		return imageDao;
@ -134,9 +146,15 @@ public class ResourceService {
134 146
	
135 147
	@Delete
136 148
	@Path("/{resourceId}")
137
	public void delete(@JdbcConn(true) Connection con, @PathVar String resourceId) throws SQLException {
138
		this.imageDao.deleteRes(con, resourceId);
139
		this.resourceDao.delete(con, resourceId);
149
	public boolean delete(@JdbcConn(true) Connection con, @PathVar String resourceId) throws SQLException {
150
		List<Operation> operations = this.operationDao.queryResourceId(con, resourceId);
151
		if(operations.isEmpty()){
152
			this.imageDao.deleteRes(con, resourceId);
153
			this.resourceDao.delete(con, resourceId);
154
			return true;
155
		}else{
156
			return false;
157
		}
140 158
	}
141 159
	
142 160
	@Get