<commit_before>package com.yz.action;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.RequestAware;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.interceptor.SessionAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.opensymphony.xwork2.ActionSupport;
import com.yz.model.Clue;
import com.yz.model.Injurycase;
import com.yz.model.Media;
import com.yz.model.Person;
import com.yz.service.IClueService;
import com.yz.service.IInjurycaseService;
import com.yz.service.IMediaService;
import com.yz.service.IPersonService;
import com.yz.util.DateTimeKit;
import com.yz.vo.AjaxMsgVO;

@Component("mediaAction")
@Scope("prototype")
public class MediaAction extends ActionSupport implements RequestAware,
		SessionAware, ServletResponseAware, ServletRequestAware {

	private static final long serialVersionUID = 1L;
	Map<String, Object> request;
	Map<String, Object> session;
	private javax.servlet.http.HttpServletResponse response;
	private javax.servlet.http.HttpServletRequest req;

	// 分页显示
	private String[] arg = new String[2];
	private int page;
	private final int size = 10;
	private int pageCount;
	private int totalCount;

	// 条件
	private int id;
	private int inid; // 案件id
	private int mid;// 媒体ID
	private int mtype;

	// service层对象

	private IMediaService mediaService;
	private IInjurycaseService injurycaseService;

	// 单个表对象
	private Injurycase injurycase;
	private Media media;

	// list表对象
	private List<Media> medias;


	/**
	 * 跳转到添加页面
	 * 
	 * @return
	 */
	public String goToAdd() {
		injurycase = injurycaseService.loadById(inid);
		return "add";
	}

	/**
	 * 添加
	 * 
	 * @return
	 * @throws Exception
	 */
	public String add() throws Exception {
		if (picture1 != null && picture1FileName != null
				&& !picture1FileName.replace(" ", "").equals("")) {
			String imageName = DateTimeKit.getDateRandom()
					+ picture1FileName.substring(picture1FileName.indexOf("."));
			this.upload("/media", imageName, picture1);
			media.setSrc("media" + "/" + imageName);
		}
		if (media.getInjurycase()!= null) {
			changeInjurycaseHandleState(media.getInjurycase().getId());
		}
		
		mediaService.add(media);
		return "success_child";
	}
	
	
	/*
	 * 修改案件状态
	 */
	private void changeInjurycaseHandleState(Integer inid) {

		Injurycase injurycase = injurycaseService.loadById(inid);
		if (injurycase != null) {
			if (injurycase.getHandleState() == 1) {
				injurycase.setHandleState(2);
				injurycaseService.update(injurycase);
			}
		}
	}<commit_msg>BUG修复<commit_after>package com.yz.action;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.RequestAware;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.interceptor.SessionAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.opensymphony.xwork2.ActionSupport;
import com.yz.model.Clue;
import com.yz.model.Injurycase;
import com.yz.model.Media;
import com.yz.model.Person;
import com.yz.service.IClueService;
import com.yz.service.IInjurycaseService;
import com.yz.service.IMediaService;
import com.yz.service.IPersonService;
import com.yz.util.DateTimeKit;
import com.yz.vo.AjaxMsgVO;

@Component("mediaAction")
@Scope("prototype")
public class MediaAction extends ActionSupport implements RequestAware,
		SessionAware, ServletResponseAware, ServletRequestAware {

	private static final long serialVersionUID = 1L;
	Map<String, Object> request;
	Map<String, Object> session;
	private javax.servlet.http.HttpServletResponse response;
	private javax.servlet.http.HttpServletRequest req;

	// 分页显示
	private String[] arg = new String[2];
	private int page;
	private final int size = 10;
	private int pageCount;
	private int totalCount;

	// 条件
	private int id;
	private int inid; // 案件id
	private int mid;// 媒体ID
	private int mtype;

	// service层对象

	private IMediaService mediaService;
	private IInjurycaseService injurycaseService;

	// 单个表对象
	private Injurycase injurycase;
	private Media media;

	// list表对象
	private List<Media> medias;
	private String picSrc;


	/**
	 * 跳转到添加页面
	 * 
	 * @return
	 */
	public String goToAdd() {
		injurycase = injurycaseService.loadById(inid);
		return "add";
	}

	/**
	 * 添加
	 * 
	 * @return
	 * @throws Exception
	 */
	public String add() throws Exception {
		if (picture1 != null && picture1FileName != null
				&& !picture1FileName.replace(" ", "").equals("")) {
			String imageName = DateTimeKit.getDateRandom()
					+ picture1FileName.substring(picture1FileName.indexOf("."));
			this.upload("/media", imageName, picture1);
			media.setSrc("media" + "/" + imageName);
		}
		
		if (media.getInjurycase()!= null) {
			changeInjurycaseHandleState(media.getInjurycase().getId());
		}
		
		mediaService.add(media);
		return "success_child";
	}
	
	
	/*
	 * 修改案件状态
	 */
	private void changeInjurycaseHandleState(Integer inid) {

		Injurycase injurycase = injurycaseService.loadById(inid);
		if (injurycase != null) {
			if (injurycase.getHandleState() == 1) {
				injurycase.setHandleState(2);
				injurycaseService.update(injurycase);
			}
		}
	}
{'fraction_non_alphanumeric': 0.11446663419386265, 'fraction_numerical': 0.0058451047247929854, 'mean_word_length': 4.7677902621722845, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1989793', 'n_tokens_mistral': 2179, 'n_tokens_neox': 2004, 'n_words': 411}