attachmentact.java

来自「JEECSM是JavaEE版网站管理系统(Java Enterprise Edi」· Java 代码 · 共 70 行

JAVA
70
字号
package com.jeecms.core.action;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Controller;

import com.jeecms.core.entity.Attachment;
import com.jeecms.core.manager.AttachmentMng;

@SuppressWarnings("serial")
@Scope("prototype")
@Controller("core.attachmentAct")
public class AttachmentAct extends com.jeecms.core.JeeCoreAction {
	private static final Logger log = LoggerFactory.getLogger(Attachment.class);

	public String list() {
		this.pagination = attachmentMng.getPage(getWebId(), pageNo,
				getCookieCount());
		return LIST;
	}

	public String add() {
		return ADD;
	}

	public String save() {
		attachmentMng.save(bean);
		log.info("添加  附件 成功:{}", bean.getName());
		return list();
	}

	public String edit() {
		this.bean = attachmentMng.findById(id);
		return EDIT;
	}

	public String update() {
		attachmentMng.updateDefault(bean);
		log.info("修改  附件 成功:{}", bean.getName());
		return list();
	}

	public String delete() {
		try {
			if (id != null) {
				attachmentMng.deleteById(id);
			} else {
				attachmentMng.deleteById(ids);
			}
		} catch (DataIntegrityViolationException e) {
			addActionError("记录已被引用,不能删除!");
		}
		return list();
	}

	@Autowired
	private AttachmentMng attachmentMng;
	private Attachment bean;

	public Attachment getBean() {
		return bean;
	}

	public void setBean(Attachment bean) {
		this.bean = bean;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?