class UserManageController extends BaseController {

    @Resource(name = "appEmailUtil")
    private AppEmailUtil appEmailUtil;

    /**
     * 用户初始化
     *
     * @param id 用户id
     * @return
     */
    @RequestMapping(value = "/init")
    public ModelAndView doUserInit(HttpServletRequest request,
                                   HttpServletResponse response, Model model, Long id) {
        if (id != null) {
            AppUser user = userService.get(id);
            model.addAttribute("user", user);
            model.addAttribute("modify", true);
        }
        return new ModelAndView("manage/user/initUser");
    }

    /**
     * 更新用户
     *
     * @param name
     * @param chName
     * @param email
     * @param mobile
     * @param weChat
     * @param type
     * @param userId
     * @return
     */
    @RequestMapping(value = "/add")
    public ModelAndView doAddUser(HttpServletRequest request,
                                  HttpServletResponse response, Model model, String name, String chName, String email, String mobile, String weChat,
                                  Integer type, Long userId, Integer isAlert, String company, String purpose) {
        // 后台暂时不对参数进行验证
        AppUser appUser = AppUser.buildFrom(userId, name, chName, email, mobile, weChat, type, isAlert, company, purpose);
        try {
            if (userId == null) {
                appUser.setPassword(ConstUtils.DEFAULT_USER_PASSWORD);
                userService.save(appUser);
            } else {
                userService.update(appUser);
            }
            write(response, String.valueOf(SuccessEnum.SUCCESS.value()));
        } catch (Exception e) {
            write(response, String.valueOf(SuccessEnum.FAIL.value()));
            logger.error(e.getMessage(), e);
        }
        return null;
    }

    /**
     * 删除用户
     *
     * @param userId
     * @return
     */
    @RequestMapping(value = "/delete")
    public ModelAndView doDeleteUser(HttpServletRequest request,
                                     HttpServletResponse response, Model model, Long userId) {
        userService.delete(userId);
        return new ModelAndView("redirect:/manage/user/list");
    }

    /**
     * 重置密码
     *
     * @param userId
     * @return
     */
    @RequestMapping(value = "/resetPwd")
    public ModelAndView doResetUserPwd(HttpServletRequest request,
                                     HttpServletResponse response, Model model, Long userId) {
        userService.resetPwd(userId);
        return new ModelAndView("redirect:/manage/user/list");
    }

    /**
     * 修改密码
     *
     * @param userId
     * @return
     */
    @RequestMapping(value = "/updatePwd")
    public ModelAndView doResetUserPwd(HttpServletRequest request,
                                       HttpServletResponse response, Model model, Long userId, String password) {
        SuccessEnum successEnum = userService.updatePwd(userId, password);
        if(successEnum.equals(SuccessEnum.SUCCESS)){
            write(response, String.valueOf(SuccessEnum.SUCCESS.value()));
        }else{
            write(response, String.valueOf(SuccessEnum.FAIL.value()));
        }
        return null;
    }

    /**
     * 用户列表
     *
     * @param  searchChName 中文名
     * @return
     */
    @RequestMapping(value = "/list")
    public ModelAndView doUserList(HttpServletRequest request,
                                   HttpServletResponse response, Model model, String searchChName) {
        List<AppUser> users = userService.getUserList(searchChName);
        model.addAttribute("users", users);
        model.addAttribute("searchChName", searchChName);
        model.addAttribute("userActive", SuccessEnum.SUCCESS.value());
        return new ModelAndView("manage/user/list");
    }

    @RequestMapping(value = "/addAuditStatus")
    public ModelAndView doAddAuditStatus(HttpServletRequest request,
                                         HttpServletResponse response, Model model, Integer status, Integer type,
                                         Long appAuditId, String refuseReason, Long appId) {<FILL_FUNCTION_BODY>}

}

        AppAudit appAudit = appService.getAppAuditById(appAuditId);
        AppUser appUser = userService.get(appAudit.getUserId());
        // 通过或者驳回并记录日志
        appService.updateUserAuditStatus(appAuditId, status, appUser.getId());

        // 记录驳回原因
        if (AppCheckEnum.APP_REJECT.value().equals(status)) {
            appAudit.setRefuseReason(refuseReason);
            appService.updateRefuseReason(appAudit, getUserInfo(request));
            userService.delete(appUser.getId());
        }

        // 发邮件统计
        if (AppCheckEnum.APP_PASS.value().equals(status)
                || AppCheckEnum.APP_REJECT.value().equals(status)) {
            appUser.setType(AppUserTypeEnum.REGULAR_USER.value());
            appAudit.setStatus(status);
            userService.update(appUser);
            appEmailUtil.noticeUserResult(appUser, appAudit);
        }

        // 批准成功直接跳转
        if (AppCheckEnum.APP_PASS.value().equals(status)) {
            return new ModelAndView("redirect:/manage/app/auditList");
        }

        write(response, String.valueOf(SuccessEnum.SUCCESS.value()));
        return null;
    
<methods>public non-sealed void <init>() ,public boolean clearTempResource(java.lang.String) ,public java.lang.String getTempResource(java.lang.String) ,public com.sohu.cache.entity.AppUser getUserInfo(javax.servlet.http.HttpServletRequest) ,public java.lang.String markdown2html(java.lang.String, java.lang.String) throws java.lang.Exception,public byte[] read(java.io.InputStream) throws java.io.IOException,public java.lang.Boolean saveTempResource(java.lang.String, java.lang.String) ,public void sendMessage(javax.servlet.http.HttpServletResponse, java.lang.String) <variables>protected com.sohu.cache.dao.AppAuditDao appAuditDao,protected com.sohu.cache.dao.AppAuditLogDao appAuditLogDao,protected com.sohu.cache.stats.app.AppDeployCenter appDeployCenter,protected com.sohu.cache.web.util.AppEmailUtil appEmailUtil,protected com.sohu.cache.dao.AppImportDao appImportDao,protected com.sohu.cache.web.service.AppService appService,protected com.sohu.cache.stats.app.AppStatsCenter appStatsCenter,com.sohu.cache.redis.AssistRedisService assistRedisService,protected com.sohu.cache.async.AsyncService asyncService,protected com.sohu.cache.dao.InstanceDao instanceDao,protected com.sohu.cache.stats.instance.InstanceDeployCenter instanceDeployCenter,protected final org.slf4j.Logger logger,protected com.sohu.cache.machine.MachineCenter machineCenter,protected com.sohu.cache.redis.RedisCenter redisCenter,protected com.sohu.cache.redis.RedisConfigTemplateService redisConfigTemplateService,protected com.sohu.cache.redis.RedisDeployCenter redisDeployCenter,protected com.sohu.cache.web.service.ResourceService resourceService,protected com.sohu.cache.web.service.UserLoginStatusService userLoginStatusService,protected com.sohu.cache.web.service.UserService userService