<commit_before>package com.meiziaccess;

import com.meiziaccess.CommandTool.MyHttpUtil;
import com.meiziaccess.model.*;
import com.meiziaccess.model.UploadItem;
import com.meiziaccess.model.UploadItemList;
import com.meiziaccess.model.UploadObject;
import com.meiziaccess.model.UploadRepository;

import com.meiziaccess.upload.UploadTool;
import com.meiziaccess.upload.UploadToolInterface;
import com.meiziaccess.uploadModel.UploadLogRepository;
import net.sf.json.JSONObject;
import org.apache.commons.collections.map.HashedMap;
import org.apache.poi.ss.usermodel.Workbook;
import org.jeecgframework.poi.excel.ExcelExportUtil;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.core.env.SystemEnvironmentPropertySource;
import org.springframework.http.HttpRequest;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.Null;
import java.util.*;
import com.meiziaccess.secure.*;



@SpringBootApplication
@RestController
@EnableRedisHttpSession
//@EnableScheduling
public class MeiziaccessApplication  {
	@Autowired
	UploadRepository uploadRepository;

//	private int vendor_type = 1;
//登录
	@RequestMapping(value = "/authenticate")
	public Map<String, Object> authenticate(HttpServletRequest request){

		Map<String, Object> model = new HashMap<String, Object>();
		if(request.getSession().getAttribute("username") != null){
			System.out.println("session-get-username=" +  request.getSession().getAttribute("username").toString());
			model.put("status", true);
			return model;
		}

		String username = request.getParameter("username");
		String password = request.getParameter("password");
		JSONObject objData = MyHttpUtil.post(username, password);

		if(objData == null){
			model.put("status", false);
		}else{
			if(objData.getInt("code") ==  200){
				model.put("status", true);
				int vendor_type = objData.getInt("data");
				System.out.println("session-set-username=" + username);
				request.getSession().setAttribute("username", username);
				request.getSession().setAttribute("vendor_type", vendor_type);
				System.out.println(objData.toString());
			}else{
				model.put("status", false);
			}
		}
		return model;
	}

	@RequestMapping(value = "/logout")
	public Map<String, Object> logout(HttpServletRequest request){
		Map<String, Object> model = new HashMap<String, Object>();
		if(request.getSession().getAttribute("username") != null){
			System.out.println("session-delete-username=" +  request.getSession().getAttribute("username").toString());
			request.getSession().removeAttribute("username");
			request.getSession().removeAttribute("vendor_type");
			return model;
		}
		model.put("status", false);
		return model;
	}

	@Value("${configure.upload.local_path}")
	private String upload_local_path;


	//xml，视频，关键帧在不同文件夹,home页面读取数据库数据
	@RequestMapping("/data-source-association")
	@ResponseBody
	public Map<String, Object> getItemsAssociation(HttpServletRequest request) {

		// 判断登录没有
		Object o = request.getSession().getAttribute("username");
		Map<String, Object> map = new HashMap<>();
		if (o == null){
			List<UploadItem> uploadstatus = new ArrayList<>();
			map.put("data",uploadstatus);
		}else{
			Object o = request.getSession().getAttribute("vendor_type");
			int vendor_type = Integer.parseInt(o.toString());
			List<UploadItem> uploadstatus = uploadRepository.findByStatusAndVendor_type(0,vendor_type);
			map.put("data",uploadstatus);
		}
		return map;<commit_msg>fix the bug of datasource is null when no logining<commit_after>package com.meiziaccess;

import com.meiziaccess.CommandTool.MyHttpUtil;
import com.meiziaccess.model.*;
import com.meiziaccess.model.UploadItem;
import com.meiziaccess.model.UploadItemList;
import com.meiziaccess.model.UploadObject;
import com.meiziaccess.model.UploadRepository;

import com.meiziaccess.upload.UploadTool;
import com.meiziaccess.upload.UploadToolInterface;
import com.meiziaccess.uploadModel.UploadLogRepository;
import net.sf.json.JSONObject;
import org.apache.commons.collections.map.HashedMap;
import org.apache.poi.ss.usermodel.Workbook;
import org.jeecgframework.poi.excel.ExcelExportUtil;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.core.env.SystemEnvironmentPropertySource;
import org.springframework.http.HttpRequest;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.Null;
import java.util.*;
import com.meiziaccess.secure.*;



@SpringBootApplication
@RestController
@EnableRedisHttpSession
//@EnableScheduling
public class MeiziaccessApplication  {
	@Autowired
	UploadRepository uploadRepository;

//	private int vendor_type = 1;
//登录
	@RequestMapping(value = "/authenticate")
	public Map<String, Object> authenticate(HttpServletRequest request){

		Map<String, Object> model = new HashMap<String, Object>();
		if(request.getSession().getAttribute("username") != null){
			System.out.println("session-get-username=" +  request.getSession().getAttribute("username").toString());
			model.put("status", true);
			return model;
		}

		String username = request.getParameter("username");
		String password = request.getParameter("password");
		JSONObject objData = MyHttpUtil.post(username, password);

		if(objData == null){
			model.put("status", false);
		}else{
			if(objData.getInt("code") ==  200){
				model.put("status", true);
				int vendor_type = objData.getInt("data");
				System.out.println("session-set-username=" + username);
				request.getSession().setAttribute("username", username);
				request.getSession().setAttribute("vendor_type", vendor_type);
				System.out.println(objData.toString());
			}else{
				model.put("status", false);
			}
		}
		return model;
	}

	@RequestMapping(value = "/logout")
	public Map<String, Object> logout(HttpServletRequest request){
		Map<String, Object> model = new HashMap<String, Object>();
		if(request.getSession().getAttribute("username") != null){
			System.out.println("session-delete-username=" +  request.getSession().getAttribute("username").toString());
			request.getSession().removeAttribute("username");
			request.getSession().removeAttribute("vendor_type");
			return model;
		}
		model.put("status", false);
		return model;
	}

	@Value("${configure.upload.local_path}")
	private String upload_local_path;


	//xml，视频，关键帧在不同文件夹,home页面读取数据库数据
	@RequestMapping("/data-source-association")
	@ResponseBody
	public Map<String, Object> getItemsAssociation(HttpServletRequest request) {

		// 判断登录没有
		Object name = request.getSession().getAttribute("username");
		Map<String, Object> map = new HashMap<>();
		if (name == null){
			List<UploadItem> uploadstatus = new ArrayList<>();
			map.put("data",uploadstatus);
		}else{
			Object type = request.getSession().getAttribute("vendor_type");
			int vendor_type = Integer.parseInt(type.toString());
			List<UploadItem> uploadstatus = uploadRepository.findByStatusAndVendor_type(0,vendor_type);
			map.put("data",uploadstatus);
		}
		return map;
{'fraction_non_alphanumeric': 0.1320359650203227, 'fraction_numerical': 0.001231678778174652, 'mean_word_length': 6.110332749562172, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '2493387', 'n_tokens_mistral': 2521, 'n_tokens_neox': 2394, 'n_words': 402}