首页>代码>基于springMVC+springSecurity3.x+Mybaits3.x普通web新版蓝缘后台管理系统 >/普通web新版蓝缘管理系统/lanyuan/src/com/lanyuan/controller/AccountController.java
package com.lanyuan.controller;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.lanyuan.entity.Account;
import com.lanyuan.entity.Resources;
import com.lanyuan.pulgin.mybatis.plugin.PageView;
import com.lanyuan.service.AccountService;
import com.lanyuan.util.Common;
import com.lanyuan.util.Md5Tool;
import com.lanyuan.util.POIUtils;
/**
*
* @author lanyuan
* 2013-11-19
* @Email: mmm333zzz520@163.com
* @version 1.0v
*/
@Controller
@RequestMapping("/background/account/")
public class AccountController extends BaseController{
@Inject
private AccountService accountService;
@RequestMapping("list")
public String list(Model model, Resources menu, String pageNow) {
return Common.BACKGROUND_PATH+"/account/list";
}
/**
* @param model
* 存放返回界面的model
* @return
*/
@ResponseBody
@RequestMapping("query")
public PageView query(Account account,String pageNow,String pagesize) {
pageView = accountService.query(getPageView(pageNow,pagesize), account);
return pageView;
}
@RequestMapping("exportExcel")
public void exportExcel(HttpServletResponse response,Account account) {
List<Account> acs =accountService.queryAll(account);
POIUtils.exportToExcel(response, "账号报表", acs, Account.class, "账号", acs.size());
}
/**
* 保存数据
*
* @param model
* @param videoType
* @return
* @throws Exception
*/
@RequestMapping("add")
@ResponseBody
public Map<String, Object> add(Account account) {
Map<String, Object> map = new HashMap<String, Object>();
try {
account.setPassword(Md5Tool.getMd5(account.getPassword()));
accountService.add(account);
map.put("flag", "true");
} catch (Exception e) {
map.put("flag", "false");
}
return map;
}
/**
* 跑到新增界面
*
* @param model
* @return
*/
@RequestMapping("addUI")
public String addUI() {
return Common.BACKGROUND_PATH+"/account/add";
}
/**
* 账号角色页面
*
* @param model
* @return
*/
@RequestMapping("accRole")
public String accRole(Model model,String accountName,String roleName) {
try {
accountName=java.net.URLDecoder.decode(accountName,"UTF-8");
roleName= java.net.URLDecoder.decode(roleName,"UTF-8");
} catch (UnsupportedEncodingException e) {
}
model.addAttribute("accountName", accountName);
model.addAttribute("roleName", roleName);
return Common.BACKGROUND_PATH+"/account/acc_role";
}
/**
* 跑到新增界面
*
* @param model
* @return
*/
@RequestMapping("editUI")
public String editUI(Model model,String accountId) {
Account account = accountService.getById(accountId);
model.addAttribute("account", account);
return Common.BACKGROUND_PATH+"/account/edit";
}
/**
* 验证账号是否存在
* @author lanyuan
* Email:mmm333zzz520@163.com
* date:2014-2-19
* @param name
* @return
*/
@RequestMapping("isExist")
@ResponseBody
public boolean isExist(String name){
Account account = accountService.isExist(name);
if(account == null){
return true;
}else{
return false;
}
}
/**
* 删除
*
* @param model
* @param videoTypeId
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("deleteById")
public Map<String, Object> deleteById(Model model, String ids) {
Map<String, Object> map = new HashMap<String, Object>();
try {
String id[] = ids.split(",");
for (String string : id) {
if(!Common.isEmpty(string)){
accountService.delete(string);
}
}
map.put("flag", "true");
} catch (Exception e) {
map.put("flag", "false");
}
return map;
}
/**
* 删除
*
* @param model
* @param videoTypeId
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("updateState")
public Map<String, Object> updateState(Model model, String ids,String state) {
Map<String, Object> map = new HashMap<String, Object>();
try {
String id[] = ids.split(",");
for (String string : id) {
if(!Common.isEmpty(string)){
Account account = new Account();
account.setId(Integer.parseInt(string));
account.setState(state);
accountService.update(account);
}
}
map.put("flag", "true");
} catch (Exception e) {
map.put("flag", "false");
}
return map;
}
/**
* 更新类型
*
* @param model
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("update")
public Map<String, Object> update(Model model, Account account) {
Map<String, Object> map = new HashMap<String, Object>();
try {
account.setPassword(Md5Tool.getMd5(account.getPassword()));
accountService.update(account);
map.put("flag", "true");
} catch (Exception e) {
map.put("flag", "false");
}
return map;
}
}
最近下载更多
最近浏览更多
微信网友_7391151377240064
2月19日
暂无贡献等级
微信网友_6641066057273344 LV1
2023年10月27日
dsadasdwf LV12
2023年10月23日
zhy1989wz LV7
2023年7月6日
Erago LV2
2023年6月8日
yunYUN123 LV1
2023年5月18日
sweetbox LV10
2023年2月21日
微信网友_6248713511227392 LV11
2022年12月5日
zxc131313 LV12
2022年11月28日
trwtysfsyfs LV1
2022年10月15日

