|
|
@@ -0,0 +1,77 @@
|
|
|
+package com.xintong.visualinspection.controller;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.xintong.visualinspection.bean.User;
|
|
|
+import com.xintong.visualinspection.service.UserService;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 文件名:TestController
|
|
|
+ * 版本信息:日期:2017/3/30 Copyright 江苏省交通规划设计院 Corporation 2017 版权所有.
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/user")
|
|
|
+public class UserController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
+ @RequestMapping(value = "/test")
|
|
|
+ public String test(){
|
|
|
+ User u = userService.getOne((long) 1);
|
|
|
+ return JSON.toJSON(u).toString();
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 添加用户
|
|
|
+ * @return
|
|
|
+ * String
|
|
|
+ * @exception
|
|
|
+ * @since 1.0.0
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/addUser")
|
|
|
+ public String addUser(@RequestBody User user) throws Exception{
|
|
|
+ user.setPassword(new Md5PasswordEncoder().encodePassword(user.getPassword(), null));
|
|
|
+ if(1==1) throw new Exception("dddd");
|
|
|
+ userService.insert(user);
|
|
|
+ return super.returnResult(0, "添加成功", null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改用户
|
|
|
+ * @return
|
|
|
+ * String
|
|
|
+ * @exception
|
|
|
+ * @since 1.0.0
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/updateUser")
|
|
|
+ public String updateUser(@RequestBody User user){
|
|
|
+ try{
|
|
|
+ userService.update(user);
|
|
|
+ return super.returnResult(0, "修改成功", null);
|
|
|
+ }catch(Exception e){
|
|
|
+ return super.returnResult(-1, "修改失败", null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除用户(软删除)
|
|
|
+ * @return
|
|
|
+ * String
|
|
|
+ * @exception
|
|
|
+ * @since 1.0.0
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/deleteUser")
|
|
|
+ public String deleteUser(@RequestBody String id){
|
|
|
+ try{
|
|
|
+ userService.delete(Long.parseLong(id));
|
|
|
+ return super.returnResult(0, "删除成功", null);
|
|
|
+ }catch(Exception e){
|
|
|
+ return super.returnResult(-1, "删除失败", null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|