|
|
|
package com.kiisoo.ic.employee.controller;
|
|
|
|
|
|
|
|
import com.kiisoo.ic.common.BaseController;
|
|
|
|
import com.kiisoo.ic.employee.entity.EmployeeDO;
|
|
|
|
import com.kiisoo.ic.employee.entity.PrivilageCpUserDO;
|
|
|
|
import com.kiisoo.ic.employee.service.EmployeeService;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Description: 用户管理controller
|
|
|
|
* @Auther: yechenhao
|
|
|
|
* @Date: 2020/4/7 0002 10:06
|
|
|
|
* @Version: v1
|
|
|
|
*/
|
|
|
|
@Controller
|
|
|
|
@RequestMapping("/user")
|
|
|
|
@Slf4j
|
|
|
|
public class EmployeeController extends BaseController {
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private EmployeeService employeeService;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 新增成员
|
|
|
|
* @param employee 成员实体
|
|
|
|
* @return
|
|
|
|
* @throws WxErrorException
|
|
|
|
*/
|
|
|
|
@RequestMapping(value = "list",method = RequestMethod.POST)
|
|
|
|
@ResponseBody
|
|
|
|
public Map<String,Object> listUser(){
|
|
|
|
try {
|
|
|
|
List<PrivilageCpUserDO> privilageCpUserDOS = employeeService.listUser();
|
|
|
|
return data(privilageCpUserDOS);
|
|
|
|
}catch (Exception e){
|
|
|
|
log.error("添加用户失败",e);
|
|
|
|
return fail();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 新增成员
|
|
|
|
* @param employee 成员实体
|
|
|
|
* @return
|
|
|
|
* @throws WxErrorException
|
|
|
|
*/
|
|
|
|
@RequestMapping(value = "sync",method = RequestMethod.GET)
|
|
|
|
@ResponseBody
|
|
|
|
public Map<String,Object> syncUser(){
|
|
|
|
try {
|
|
|
|
employeeService.syncUser();
|
|
|
|
return data(null);
|
|
|
|
}catch (Exception e){
|
|
|
|
log.error("添加用户失败",e);
|
|
|
|
return fail();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 新增成员
|
|
|
|
* @param employee 成员实体
|
|
|
|
* @return
|
|
|
|
* @throws WxErrorException
|
|
|
|
*/
|
|
|
|
@RequestMapping(value = "add",method = RequestMethod.POST)
|
|
|
|
@ResponseBody
|
|
|
|
public Map<String,Object> addUser(@RequestBody EmployeeDO employee){
|
|
|
|
try {
|
|
|
|
Boolean hasAdd = employeeService.addUser(employee);
|
|
|
|
return data(hasAdd);
|
|
|
|
}catch (Exception e){
|
|
|
|
log.error("添加用户失败",e);
|
|
|
|
return fail();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 修改成员
|
|
|
|
* @param employee 成员实体
|
|
|
|
* @return
|
|
|
|
* @throws WxErrorException
|
|
|
|
*/
|
|
|
|
@RequestMapping(value = "update",method = RequestMethod.POST)
|
|
|
|
@ResponseBody
|
|
|
|
public Map<String,Object> updateUser(@RequestBody EmployeeDO employee){
|
|
|
|
try {
|
|
|
|
Boolean hasAdd = employeeService.updateUser(employee);
|
|
|
|
return data(hasAdd);
|
|
|
|
}catch (Exception e){
|
|
|
|
log.error("修改用户失败",e);
|
|
|
|
return fail();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 删除成员
|
|
|
|
* @param employee 成员实体
|
|
|
|
* @return
|
|
|
|
* @throws WxErrorException
|
|
|
|
*/
|
|
|
|
@RequestMapping(value = "delete",method = RequestMethod.POST)
|
|
|
|
@ResponseBody
|
|
|
|
public Map<String,Object> deleteUser(@RequestParam("cpUserId") Long cpUserId){
|
|
|
|
try {
|
|
|
|
Boolean hasAdd = employeeService.deleteUser(cpUserId);
|
|
|
|
return data(hasAdd);
|
|
|
|
}catch (Exception e){
|
|
|
|
log.error("删除用户失败",e);
|
|
|
|
return fail();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|