com.anhao.market.controller.AdminController.java Source code

Java tutorial

Introduction

Here is the source code for com.anhao.market.controller.AdminController.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.anhao.market.controller;

import com.anhao.admin.api.AdminService;
import com.anhao.admin.api.RoleService;
import com.anhao.admin.model.Admin;
import com.anhao.config.ConfigService;
import com.anhao.config.system.SystemConfig;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 *
 * @author Administrator
 */
@Controller
@RequestMapping("admin")
public class AdminController {

    @Resource
    ConfigService configService;

    @Resource
    RoleService roleService;

    @Resource
    AdminService adminService;

    @RequestMapping("list.do")
    public String displayAdminList(HttpServletRequest request) {
        //        String result = configService.get();
        //        roleService.get();
        //        SystemConfig config = configService.getSystemConfig();
        List<Admin> lists = adminService.findAll();

        for (Admin admin : lists) {
            System.out.println("id " + admin.getId() + "admin " + admin.toString());
        }
        //        System.out.println("config" + config.getDefaultPassword());
        System.out.println("$######################displayAdminList");
        //        System.out.println("$######################result" + result);
        return "list";
    }

    @RequestMapping("create.do")
    public String createAdmin(HttpServletRequest request) {
        Admin admin = new Admin();
        String randomId = RandomStringUtils.randomNumeric(10);

        admin.setId(randomId);
        admin.setCreateDate(new Date());
        admin.setDepartment("");
        admin.setEmail("845885222@qq.com");
        admin.setIsEnabled(Boolean.TRUE);
        admin.setIsLocked(Boolean.FALSE);
        admin.setLockedDate(new Date());
        admin.setLoginDate(new Date());
        admin.setLoginFailureCount(0);
        admin.setLoginIp(randomId);

        admin.setModifyDate(new Date());
        admin.setName(RandomStringUtils.randomNumeric(5));
        admin.setPassword(RandomStringUtils.randomNumeric(5));
        admin.setUsername(RandomStringUtils.randomNumeric(8));
        adminService.create(admin);
        return "list";
    }
}