XMTT 7 年之前
父節點
當前提交
c1cc84be12

+ 5 - 0
src/main/java/com/ekexiu/portal/ware/WareDao.java

@ -4,6 +4,7 @@ import org.jfw.apt.annotation.DefaultValue;
4 4
import org.jfw.apt.annotation.Nullable;
5 5
import org.jfw.apt.orm.annotation.dao.Column;
6 6
import org.jfw.apt.orm.annotation.dao.DAO;
7
import org.jfw.apt.orm.annotation.dao.method.Exclude;
7 8
import org.jfw.apt.orm.annotation.dao.method.From;
8 9
import org.jfw.apt.orm.annotation.dao.method.LimitColumn;
9 10
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
@ -161,4 +162,8 @@ public abstract class WareDao {
161 162
			"CATEGORY ='2' AND OWNER IN(SELECT ID FROM ORGANIZATION WHERE NAME LIKE ? OR FOR_SHORT LIKE ?)" }, additional = 1, isAnd = false, force = true) String key,
162 163
			long sortFirst, String modifyTime, String id, int rows) throws SQLException;
163 164

165
	@Update
166
	@Exclude("modifyTime")
167
	public abstract int conUpdate(Connection con, Ware ware) throws SQLException;
168

164 169
}

+ 50 - 0
src/main/java/com/ekexiu/portal/ware/WareService.java

@ -785,4 +785,54 @@ public class WareService {
785 785
			this.size = size;
786 786
		}
787 787
	}
788

789

790
	/**
791
	 * 后台管理系统中使用
792
	 */
793
	public boolean conUpdate(Connection con, Ware ware, String[] professor, String[] resource) throws SQLException, IOException {
794
		String id = ware.getId();
795
		if (wareDao.conUpdate(con, ware) > 0) {
796
			this.saveSmallImg(ware.getImages());
797
			String[] kws = null;
798
			if (ware.getKeywords() != null) {
799
				kws = ListUtil.splitTrimExcludeEmpty(ware.getKeywords(), ',').toArray(new String[0]);
800
			}
801
			if (ware.getState().equals("1")) {
802
				keyWordService.refreshWrae(con, id, kws);
803
			} else {
804
				keyWordService.deleteWare(con, id);
805
			}
806
			wareDao.deleteWareRes(con, id);
807
			if (resource != null && resource.length > 0) {
808
				for (String rid : resource) {
809
					WareRes wr = new WareRes();
810
					wr.setId(id);
811
					wr.setResource(rid);
812
					wareDao.insert(con, wr);
813
				}
814
			}
815
			wareDao.deleteWarePro(con, id);
816
			if (professor != null && professor.length > 0) {
817
				for (String pid : professor) {
818
					WarePro wp = new WarePro();
819
					wp.setId(id);
820
					wp.setProfessor(pid);
821
					wareDao.insert(con, wp);
822
				}
823
			}
824
			return true;
825
		}
826
		return false;
827
	}
828

829
	@Post
830
	@Path("/publish/conUpdate")
831
	public boolean conUpdatePublish(@JdbcConn(true) Connection con,
832
								 @RequestParam(excludeFields = { "category", "state", "createTime", "modifyTime", "shareId", "pageViews", "sortFirst" }) Ware ware,
833
								 @Nullable String[] resource,@Nullable String[] professor) throws SQLException, IOException {
834
		ware.setState("1");
835
		//ware.setCategory("1");
836
		return conUpdate(con, ware, professor, resource);
837
	}
788 838
}