首页>代码>Spring MVC+mybatis+mysql开发电信计费后台管理系统源码下载>/netctoss_demo/src/com/tarena/controller/AccountController.java
package com.tarena.controller;

import java.sql.Timestamp;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttributes;
import com.tarena.dao.AccountDao;
import com.tarena.dao.ServiceDao;
import com.tarena.entity.Account;
import com.tarena.entity.page.AccountPage;

@Controller
@RequestMapping("/account")
@SessionAttributes("accountPage")
public class AccountController extends BaseController {
	
	@Resource
	private AccountDao accountDao;
	
	@Resource
	private ServiceDao serviceDao;

	@RequestMapping("/findAccount.do")
	public String find(AccountPage page, Model model) {
		page.setRows(accountDao.findRows(page));
		model.addAttribute("accountPage", page);
		
		List<Account> list = accountDao.findByPage(page);
		model.addAttribute("accounts", list);
		
		return "account/account_list";
	}
	
	@RequestMapping("/startAccount.do")
	public String updateStart(@RequestParam("account_id") int id) {
		//暂停账务账号
		Account a = new Account();
		a.setAccount_id(id);
		a.setStatus("0");
		accountDao.updateStatus(a);
		return "redirect:findAccount.do";
	}
	
	@RequestMapping("/pauseAccount.do")
	public String updatePause(@RequestParam("account_id") int id) {
		//暂停账务账号
		Account a = new Account();
		a.setAccount_id(id);
		a.setStatus("1");
		accountDao.updateStatus(a);
		
		//暂停其下属的业务账号
		serviceDao.pauseByAccount(id);
		
		return "redirect:findAccount.do";
	}
	
	@RequestMapping("/deleteAccount.do")
	public String updateDelete(@RequestParam("account_id") int id) {
		//暂停账务账号
		Account a = new Account();
		a.setAccount_id(id);
		a.setStatus("2");
		accountDao.updateStatus(a);
		
		//删除其下属的业务账号
		serviceDao.deleteByAccount(id);
		
		return "redirect:findAccount.do";
	}
	
	@RequestMapping("/toUpdateAccount.do")
	public String toUpdate(@RequestParam("account_id") int id, Model model) {
		Account a = accountDao.findById(id);
		model.addAttribute("account", a);
		return "account/update_account";
	}
	
	@RequestMapping("/updateAccount.do")
	public String update(Account account) {
		accountDao.update(account);
		return "redirect:findAccount.do";
	}
	
	@RequestMapping("/toAddAccount.do")
	public String toAdd() {
		return "account/add_account";
	}
	
	@RequestMapping("/addAccount.do")
	public String add(Account account) {
		account.setStatus("0");
		account.setCreate_date(
			new Timestamp(System.currentTimeMillis()));
		accountDao.save(account);
		return "redirect:findAccount.do";
	}
	
	@RequestMapping("/searchAccount.do")
	@ResponseBody
	public Account searchAccount(String idcardNo) {
		return accountDao.findByIdcardNo(idcardNo);
	}

}
最近下载更多
微信网友_6602457430806528  LV6 2023年9月21日
xingbing  LV9 2023年2月15日
微信网友_6248713511227392  LV11 2022年12月5日
ming_123_9715  LV23 2022年9月22日
王乐22222  LV10 2022年5月13日
贝拉今天打什么  LV2 2022年3月28日
微笑刺客  LV15 2021年11月25日
葡萄树下酒庄  LV9 2021年6月18日
nitama  LV19 2021年5月17日
whsbuudjxbw  LV1 2021年4月6日
最近浏览更多
admin_z  LV22 1月29日
123456wadff  LV3 1月15日
black8angel  LV4 2023年12月22日
shuangfu  LV25 2023年12月2日
微信网友_6602457430806528  LV6 2023年9月21日
矿泉水  LV30 2023年8月10日
zhuwenjing 2023年6月14日
暂无贡献等级
c469893928  LV2 2023年6月10日
lpclpclpc  LV4 2023年5月30日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友