test


public class TestSpring {

	public static void main(String[] args) {
		ApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "applicationContext.xml" });

		Category c = (Category) context.getBean("c");

		System.out.println(c.getName());
	}
}

package com.youcheng.mt.auth.controller;
/**
 * @program mtbackend
 * @author youcheng
 * @date 2019-10-12 14:37
 * @since 1.0
 * @version 1.0
 */

import com.youcheng.mt.auth.service.MtUserService;
import com.youcheng.mt.beans.dto.UserExistsDTO;
import com.youcheng.mt.beans.dto.UserSendDTO;
import com.youcheng.mt.utils.Constains;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 *  处理认证请求的控制器
 * @author youcheng
 */
@Controller
@RequestMapping("/sys")
public class UserController {
    @Resource
    private MtUserService userService;
    /**
     * 动作方法 --> 获取用户所有数据
     */
    @RequestMapping("/all")
    /**
     * ResponseBody  将数据转换成JSON
     */
    @ResponseBody
    public Object getAllUsers(){
        return userService.findAllUser();
    }
    
    @RequestMapping("/exists")
    @ResponseBody
    public Object exists(String userCode){
        UserExistsDTO dto = new UserExistsDTO();
        if (userService.existsUser(userCode)){
            dto.setMessage("用户名不存在");
        }else{
            dto.setMessage("用户名已存在");
        }
        return dto;
    }
    
    @RequestMapping("/send")
    @ResponseBody
    public Object send(String phone){
        UserSendDTO dto = new UserSendDTO();
        if (userService.sendValidCode(phone)){
            dto.setMessage(Constains.SEND_VALID_CODE_SUCCESS_MSG);
            dto.setErrorCode(Constains.SEND_VALID_CODE_SUCCESS);
        }else{
            dto.setMessage(Constains.SEND_VALID_CODE_FAILD_MSG);
            dto.setMessage(Constains.SEND_VALID_CODE_FAILD);
        }
        return dto;
    }

}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值