|
|
|
|
package com.bsd.cases.controller;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.bsd.cases.model.CaseUsers;
|
|
|
|
|
import com.bsd.cases.service.CaseUsersService;
|
|
|
|
|
import com.bsd.cases.util.AjaxResult;
|
|
|
|
|
import com.bsd.cases.util.FileUtils;
|
|
|
|
|
import com.bsd.cases.util.PageAjax;
|
|
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresAuthentication;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("user")
|
|
|
|
|
public class CaseUserController {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private CaseUsersService caseUsersService;
|
|
|
|
|
@Value("${upload.path}")
|
|
|
|
|
private String uploadPath;
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "用户列表PC", notes = "用户列表PC")
|
|
|
|
|
@ApiImplicitParams({
|
|
|
|
|
@ApiImplicitParam(name = "page", value = "起始页码"),
|
|
|
|
|
@ApiImplicitParam(name = "name", value = "员工工号或者姓名"),
|
|
|
|
|
@ApiImplicitParam(name = "storeId", value = "店铺id"),
|
|
|
|
|
@ApiImplicitParam(name = "companyId", value = "公司id"),
|
|
|
|
|
@ApiImplicitParam(name = "activityState", value = "活动状态"),
|
|
|
|
|
@ApiImplicitParam(name = "state", value = "1:正常,0:删除")
|
|
|
|
|
})
|
|
|
|
|
@PostMapping("listbypage")
|
|
|
|
|
@RequiresAuthentication
|
|
|
|
|
public AjaxResult listByPage(@RequestBody JSONObject jsonObject) {
|
|
|
|
|
|
|
|
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
PageAjax<CaseUsers> pageAjax = caseUsersService.listByPage(jsonObject);
|
|
|
|
|
ajaxResult.setRetmsg("操作成功");
|
|
|
|
|
ajaxResult.setData(pageAjax);
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
ajaxResult.setRetmsg("操作失败:" + e.getMessage());
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
}
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "新增用户", notes = "新增用户")
|
|
|
|
|
@ApiImplicitParams({
|
|
|
|
|
@ApiImplicitParam(name = "userId", value = "员工id"),
|
|
|
|
|
@ApiImplicitParam(name = "userName", value = "姓名"),
|
|
|
|
|
@ApiImplicitParam(name = "userNo", value = "员工工号"),
|
|
|
|
|
@ApiImplicitParam(name = "storeId", value = "店铺id"),
|
|
|
|
|
@ApiImplicitParam(name = "companyId", value = "公司id"),
|
|
|
|
|
@ApiImplicitParam(name = "storeName", value = "店铺名称"),
|
|
|
|
|
@ApiImplicitParam(name = "companyName", value = "公司名称"),
|
|
|
|
|
@ApiImplicitParam(name = "state", value = "1:正常,0:删除")
|
|
|
|
|
})
|
|
|
|
|
@PostMapping("add")
|
|
|
|
|
@RequiresAuthentication
|
|
|
|
|
public AjaxResult add(@RequestBody JSONObject jsonObject) {
|
|
|
|
|
|
|
|
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
caseUsersService.add(jsonObject);
|
|
|
|
|
ajaxResult.setRetmsg("操作成功");
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
ajaxResult.setRetmsg("操作失败:" + e.getMessage());
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
}
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "用户详情", notes = "用户详情")
|
|
|
|
|
@ApiImplicitParams({
|
|
|
|
|
@ApiImplicitParam(name = "userId", value = "用户id")
|
|
|
|
|
})
|
|
|
|
|
@PostMapping("detail")
|
|
|
|
|
@RequiresAuthentication
|
|
|
|
|
public AjaxResult detail(@RequestBody JSONObject jsonObject) {
|
|
|
|
|
|
|
|
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
CaseUsers users = caseUsersService.detail(jsonObject);
|
|
|
|
|
ajaxResult.setData(users);
|
|
|
|
|
ajaxResult.setRetmsg("操作成功");
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
ajaxResult.setRetmsg("操作失败:" + e.getMessage());
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
}
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "删除用户", notes = "删除用户")
|
|
|
|
|
@ApiImplicitParams({
|
|
|
|
|
@ApiImplicitParam(name = "userId", value = "用户id")
|
|
|
|
|
})
|
|
|
|
|
@PostMapping("delete")
|
|
|
|
|
@RequiresAuthentication
|
|
|
|
|
public AjaxResult delete(@RequestBody JSONObject jsonObject) {
|
|
|
|
|
|
|
|
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
caseUsersService.delete(jsonObject);
|
|
|
|
|
ajaxResult.setRetmsg("操作成功");
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
ajaxResult.setRetmsg("操作失败:" + e.getMessage());
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
}
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "导出用户", notes = "导入用户")
|
|
|
|
|
@PostMapping(value = "export")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public AjaxResult export(@RequestBody JSONObject jsonObject) {
|
|
|
|
|
|
|
|
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
|
|
|
try {
|
|
|
|
|
String url = caseUsersService.export(jsonObject);
|
|
|
|
|
ajaxResult.setData(url);
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
}
|
|
|
|
|
//返回json
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//处理文件上传
|
|
|
|
|
@ApiOperation(value = "导入用户", notes = "导入用户")
|
|
|
|
|
@PostMapping(value = "uploadexcel")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public AjaxResult uploadExcel(@RequestParam("file") MultipartFile file) {
|
|
|
|
|
|
|
|
|
|
String fileName = file.getOriginalFilename();
|
|
|
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
|
|
|
try {
|
|
|
|
|
FileUtils.uploadFile(file.getBytes(), uploadPath, fileName);
|
|
|
|
|
caseUsersService.saveUserList(uploadPath, fileName);
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
}
|
|
|
|
|
//返回json
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|