You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.6 KiB
64 lines
1.6 KiB
package com.example.cat.controller;
|
|
|
|
import com.example.cat.entity.CatUser;
|
|
import com.example.cat.service.UserService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
|
|
/**
|
|
* @Author zhijun
|
|
* @Date 2019/12/13
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/orange/user")
|
|
@CrossOrigin
|
|
public class CatUserController {
|
|
|
|
@Autowired
|
|
private UserService userService;
|
|
|
|
/**
|
|
* 用户登录验证
|
|
* @param catUser
|
|
* @return
|
|
*/
|
|
@RequestMapping(value = "/login", method = RequestMethod.POST)
|
|
public Map<String, Object> userLogin(@RequestBody CatUser catUser) {
|
|
Map<String, Object> map = new HashMap<>();
|
|
CatUser user = userService.userLogin(catUser);
|
|
if (Objects.isNull(user)) {
|
|
map.put("flag", false);
|
|
map.put("msg", "login error");
|
|
return map;
|
|
}
|
|
map.put("flag", true);
|
|
map.put("data", user);
|
|
return map;
|
|
}
|
|
|
|
/**
|
|
* 用户注册验证
|
|
*
|
|
* @param catUser
|
|
* @return
|
|
*/
|
|
@RequestMapping(value = "/register", method = RequestMethod.POST)
|
|
public Map<String, Object> userRegister(@RequestBody CatUser catUser) {
|
|
Map<String, Object> map = new HashMap<>();
|
|
Integer insertFlag = userService.userRegister(catUser);
|
|
if (insertFlag > 0) {
|
|
map.put("flag", true);
|
|
map.put("msg", "register success");
|
|
return map;
|
|
}
|
|
map.put("flag", false);
|
|
map.put("msg", "register failed");
|
|
return map;
|
|
}
|
|
|
|
}
|