<commit_before>/**
 * 
 */
package com.domeke.app.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.domeke.app.message.impl.DomekeMaiSenderImpl;
import com.domeke.app.model.User;
import com.domeke.app.utils.EncryptKit;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.jfinal.plugin.spring.Inject;
import com.jfinal.plugin.spring.IocInterceptor;

/**
 * @author <EMAIL>
 *
 */
@Before(IocInterceptor.class)
public class UserController extends Controller {
	
	@Inject.BY_NAME
	private DomekeMaiSenderImpl domekeMailSender;

	public void save() {
		User user = getModel(User.class);
		user.saveUser();
	}

	public void goRegist() {
		render("/demo/regist.html");
	}
	
	public void goLogin(){
		render("/demo/login.html");
	}
	//@Before({RegistValidator.class,MailAuthInterceptor.class})
	public void regist() {
		User user = getModel(User.class);
		user.saveUser();
		render("/demo/login.html");
	}
	public void goUserManage(){
		userManage();
		render("/demo/userManage.html");
	}
	
	public void userManage(){
		User user = getModel(User.class);
		List<User> userList = user.getUser();
		this.setAttr("userList", userList);
	}
	public void goUserUpdate(){
		getUser();
		render("/demo/userUpdate.html");
	}
	public void getUser(){
		User user = getModel(User.class);
		user = user.findById(getParaToInt());
		this.setAttr("user", user);
	}
	public void update(){
		User user = getModel(User.class);
		user.update();
		goUserManage();
	}
	public void delete(){
		User user = getModel(User.class);
		user.deleteById(getParaToInt());
		goUserManage();
	}
	public void reset(){
		User user = getModel(User.class);
		String password = "<PASSWORD>";
		int userid = getParaToInt();
		password = EncryptKit.encryptMd5(password);
		user.updateReset(userid, password);
		goUserManage();
	}
	public void search(){
		 List<Map<String,Object>> params = new ArrayList<Map<String,Object>>();
		 String[] to = new String[]{"634775305<EMAIL>"};
		 domekeMailSender.send("<EMAIL>", to, null, "", params);
	}

	public DomekeMaiSenderImpl getDomekeMailSender() {
		return domekeMailSender;
	}

	public void setDomekeMailSender(DomekeMaiSenderImpl domekeMailSender) {
		this.domekeMailSender = domekeMailSender;
	}
}<commit_msg>添加用户邮箱找回密码<commit_after>/**
 * 
 */
package com.domeke.app.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;

import com.domeke.app.message.impl.DomekeMaiSenderImpl;
import com.domeke.app.model.User;
import com.domeke.app.utils.EncryptKit;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.jfinal.plugin.spring.Inject;
import com.jfinal.plugin.spring.IocInterceptor;

/**
 * @author <EMAIL>
 *
 */
@Before(IocInterceptor.class)
public class UserController extends Controller {
	
	@Inject.BY_NAME
	private DomekeMaiSenderImpl domekeMailSender;

	public void save() {
		User user = getModel(User.class);
		user.saveUser();
	}

	public void goRegist() {
		render("/demo/regist.html");
	}
	
	public void goLogin(){
		render("/demo/login.html");
	}
	//@Before({RegistValidator.class,MailAuthInterceptor.class})
	public void regist() {
		User user = getModel(User.class);
		user.saveUser();
		render("/demo/login.html");
	}
	public void goUserManage(){
		userManage();
		render("/demo/userManage.html");
	}
	
	public void userManage(){
		User user = getModel(User.class);
		List<User> userList = user.getUser();
		this.setAttr("userList", userList);
	}
	public void goUserUpdate(){
		getUser();
		render("/demo/userUpdate.html");
	}
	public void getUser(){
		User user = getModel(User.class);
		user = user.findById(getParaToInt());
		this.setAttr("user", user);
	}
	public void update(){
		User user = getModel(User.class);
		user.update();
		goUserManage();
	}
	public void delete(){
		User user = getModel(User.class);
		user.deleteById(getParaToInt());
		goUserManage();
	}
	public void reset(){
		User user = getModel(User.class);
		String password = "<PASSWORD>";
		int userid = getParaToInt();
		password = <PASSWORD>Kit.encryptMd5(password);
		user.updateReset(userid, password);
		goUserManage();
	}
	public void search(){
		 render("/demo/userEmail.html");	 
	}
	public void sendPassword(){
		User user = getModel(User.class);
		String email = getPara("email");
		user = user.getCloumValue("email",email);
		if(user!=null){
			List<Map<String,Object>> params = new ArrayList<Map<String,Object>>();
			String[] to = new String[]{email};
			String password1  = <PASSWORD>String(6);
			String password = EncryptKit.encryptMd5(password1);
			user.updatePassword(user.get("userid"),password);
			String msg = "新生成的密码为："+password1+"，请及时登录 系统修改";
			domekeMailSender.send("<EMAIL>", to, null, msg, params);
		}
		
	}
	public DomekeMaiSenderImpl getDomekeMailSender() {
		return domekeMailSender;
	}

	public void setDomekeMailSender(DomekeMaiSenderImpl domekeMailSender) {
		this.domekeMailSender = domekeMailSender;
	}
	
	public static String getRandomString(int length) { 
		//length表示生成字符串的长度  
	    String base = "abcdefghijklmnopqrstuvwxyz0123456789";     
	    Random random = new Random();     
	    StringBuffer sb = new StringBuffer();     
	    for (int i = 0; i < length; i++) {     
	        int number = random.nextInt(base.length());     
	        sb.append(base.charAt(number));     
	    }     
	    return sb.toString();     
	 } 
}
{'fraction_non_alphanumeric': 0.14705338998706816, 'fraction_numerical': 0.004987991871420654, 'mean_word_length': 4.376365441906653, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 22, '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': '6888643', 'n_tokens_mistral': 2028, 'n_tokens_neox': 1884, 'n_words': 355}