|
|
@ -0,0 +1,54 @@ |
|
|
|
package com.dreamworks.boditech.controller; |
|
|
|
import com.dreamworks.boditech.controller.entity.ApiResponse; |
|
|
|
import com.dreamworks.boditech.entity.User; |
|
|
|
import com.dreamworks.boditech.mapper.UserMapper; |
|
|
|
import jakarta.annotation.Resource; |
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
|
|
|
|
@Controller |
|
|
|
public class UserController extends BaseController { |
|
|
|
@Resource |
|
|
|
UserMapper userMapper; |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
@PostMapping("/api/user/login") |
|
|
|
public ApiResponse login( String name, String pin ) { |
|
|
|
User user = userMapper.findByName(name); |
|
|
|
if ( null == user || !user.pin.equals(pin) ) { |
|
|
|
return this.error("无效的用户名或PIN"); |
|
|
|
} |
|
|
|
return this.success(user); |
|
|
|
} |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
@PostMapping("/api/user/pin-update") |
|
|
|
public ApiResponse pinUpdate( int id, String pin ) { |
|
|
|
User user = userMapper.findById(id); |
|
|
|
if ( null == user ) { |
|
|
|
return this.error("无效的用户id : " + id); |
|
|
|
} |
|
|
|
user.pin = pin; |
|
|
|
int changeCount = userMapper.update(user); |
|
|
|
if ( 1 != changeCount ) { |
|
|
|
return this.error("数据更新异常"); |
|
|
|
} |
|
|
|
return this.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
@PostMapping("/api/user/delete") |
|
|
|
public ApiResponse delete( int id ) { |
|
|
|
User user = userMapper.findById(id); |
|
|
|
if ( null == user ) { |
|
|
|
return this.error("无效的用户id : " + id); |
|
|
|
} |
|
|
|
|
|
|
|
int deleteCount = userMapper.delete(user); |
|
|
|
if ( 1 != deleteCount ) { |
|
|
|
return this.error("数据删除异常"); |
|
|
|
} |
|
|
|
return this.success(); |
|
|
|
} |
|
|
|
} |