package io.renren.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.stereotype.Controller;

import io.renren.entity.ConferenceUserEntity;
import io.renren.service.ConferenceUserService;
import io.renren.utils.PageUtils;
import io.renren.utils.R;

import io.renren.entity.SysUserEntity;
import io.renren.service.SysUserService;
import io.renren.utils.ShiroUtils;
/**
 * 
 * 
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2017-03-02 09:56:17
 */
@Controller
@RequestMapping("/sys/conference")
public class ConferenceUserController {
	@Autowired
	private ConferenceUserService conferenceUserService;
    @Autowired
    private SysUserService sysUserService;

	@RequestMapping("/conferenceuser.html")
	public String list(){
		return "conferenceuser/conferenceuser.html";
	}
	
	/**
	 * 列表
	 */
//	@ResponseBody
//	@RequestMapping("/list")
//	@RequiresPermissions("sys:conference:list")
//	public R list(Integer page, Integer limit){
//		Map<String, Object> map = new HashMap<>();
//		map.put("offset", (page - 1) * limit);
//		map.put("limit", limit);
//
//
//		//查询列表数据
//		List<ConferenceUserEntity> conferenceUserList = conferenceUserService.queryList(map);
//		int total = conferenceUserService.queryTotal(map);
//
//
//		PageUtils pageUtil = new PageUtils(conferenceUserList, total, limit, page);
//
//		return R.ok().put("page", pageUtil);
//	}
    @ResponseBody
    @RequestMapping("/list")
    @RequiresPermissions("sys:conference:list")
    public R list(String name,Integer page, Integer limit){
        Map<String, Object> map = new HashMap<>();
        Long userId = ShiroUtils.getUserId();
        SysUserEntity user = sysUserService.queryObject(userId);
        name  = user.getUsername();
        System.out.println("name : " +name);
        map.put("name", name);
        map.put("offset", (page - 1) * limit);
        map.put("limit", limit);

        //查询列表数据

        List<ConferenceUserEntity> conferenceUserList = conferenceUserService.queryList(map);
        int total = conferenceUserService.queryTotal(map);

//        for(int i =0; i< total; i++){
//            ConferenceUserEntity user =   conferenceUserList.get(i);
//            String testtype = user.getTestType().trim();
//        }
        PageUtils pageUtil = new PageUtils(conferenceUserList, total, limit, page);

        return R.ok().put("page", pageUtil);
    }
	/**
	 * 信息
	 */
	@ResponseBody
	@RequestMapping("/info/{id}")
	@RequiresPermissions("sys:conference:info")
	public R info(@PathVariable("id") Integer id){
		ConferenceUserEntity conferenceUser = conferenceUserService.queryObject(id);
		
		return R.ok().put("conferenceUser", conferenceUser);
	}
	
	/**
	 * 保存
	 */
	@ResponseBody
	@RequestMapping("/save")
	@RequiresPermissions("sys:conference:save")
	public R save(@RequestBody ConferenceUserEntity conferenceUser){
		conferenceUserService.save(conferenceUser);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@ResponseBody
	@RequestMapping("/update")
	@RequiresPermissions("sys:conference:update")
	public R update(@RequestBody ConferenceUserEntity conferenceUser){
		conferenceUserService.update(conferenceUser);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@ResponseBody
	@RequestMapping("/delete")
	@RequiresPermissions("sys:conference:delete")
	public R delete(@RequestBody Integer[] ids){
		conferenceUserService.deleteBatch(ids);
		
		return R.ok();
	}
	
}

@@ -809,16 +809,69 @@
 oUtils;%0A
+import simplemail.Mail;%0Aimport simplemail.MailUtil;%0A%0A
 /**%0A * %0A
@@ -3365,34 +3365,76 @@
 onferenceUser);%0A
-%09%09
+        sendMail(conferenceUser.getEmail());
 %0A%09%09return R.ok()
@@ -3906,12 +3906,518 @@
 k();%0A%09%7D%0A
-%09
+%0A    private boolean sendMail(String receiver)%7B%0A%0A        Mail mail = new Mail();%0A%0A        mail.setHost(%22smtp.wxgyxy.cn%22);%0A        mail.setSender(%22heyg@wxgyxy.cn%22);%0A        mail.setUsername(%22heyg@wxgyxy.cn%22);%0A        mail.setPassword(%22wxgy2013%22);%0A%0A        mail.setReceiver(receiver);%0A%0A        mail.setSubject(%22%E6%9B%B4%E6%96%B0%E4%B8%AA%E4%BA%BA%E4%BF%A1%E6%81%AF%22);%0A        mail.setMessage(%22%E6%9B%B4%E6%96%B0%E4%B8%AA%E4%BA%BA%E4%BF%A1%E6%81%AF%E6%88%90%E5%8A%9F%22);%0A        MailUtil util = new MailUtil();%0A        if(util.send(mail))%7B%0A%0A            return true;%0A        %7Delse%7B%0A            return false;%0A        %7D%0A    %7D
 %0A%7D%0A

Add mail