| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- package cn.com.goldenwater.dcproj.controller.base;
- import cn.com.goldenwater.dcproj.dto.PersGroupDto;
- import cn.com.goldenwater.dcproj.model.AttUserBase;
- import cn.com.goldenwater.dcproj.param.AttUserBaseParam;
- import cn.com.goldenwater.dcproj.param.UserRoleParam;
- import cn.com.goldenwater.dcproj.service.AttUserBaseService;
- import cn.com.goldenwater.core.web.BaseController;
- import cn.com.goldenwater.core.web.BaseResponse;
- import cn.com.goldenwater.dcproj.utils.MD5;
- import com.github.pagehelper.PageInfo;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import org.apache.commons.lang3.StringUtils;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.util.Assert;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
- import java.util.UUID;
- /**
- * @author lune
- * @date 2019-2-18
- */
- @Api(value = "用户管理",tags="007用户管理(新)")
- @RestController
- @RequestMapping("/dc/user")
- public class AttUserBaseController extends BaseController {
- private Logger logger = LoggerFactory.getLogger(getClass());
- @Autowired
- private AttUserBaseService attUserBaseService;
- @ApiOperation(value = "添加")
- @RequestMapping(value = "/insertUser", method = RequestMethod.POST)
- public BaseResponse<String> insert(@ApiParam(name = "attUserBase", value = "AttUserBase", required = true) @RequestBody AttUserBase attUserBase) {
- String uuid = UUID.randomUUID().toString().replaceAll("-",""); // 生成uuid
- attUserBase.setGuid(uuid);
- attUserBase.setUserGuid(uuid);
- attUserBase.setFromDate(new Date());
- if (StringUtils.isNotBlank(attUserBase.getPassword())){
- attUserBase.setPassword(MD5.getMD5(attUserBase.getPassword()));
- }
- ArrayList<UserRoleParam> userRoleParams = new ArrayList<>();
- if (null != attUserBase.getRoleIds() && attUserBase.getRoleIds().size() > 0){
- for (String roleId : attUserBase.getRoleIds()) {
- UserRoleParam userRoleParam = new UserRoleParam();
- userRoleParam.setUserId(attUserBase.getGuid());
- userRoleParam.setRoleId(roleId);
- userRoleParams.add(userRoleParam);
- }
- }
- UserRoleParam param = new UserRoleParam();
- param.setUserId(attUserBase.getGuid());
- attUserBaseService.insertUser(attUserBase, userRoleParams, param);
- return buildSuccessResponse(uuid);
- }
- @ApiOperation(value = "修改用户(关联角色)")
- @RequestMapping(value = "updateUser", method = RequestMethod.POST)
- public BaseResponse<String> updateUser(@ApiParam(name = "attUserBase", value = "AttUserBase", required = true) @RequestBody AttUserBase attUserBase) {
- Assert.notNull(attUserBase, "用户对象不能为空");
- attUserBase.setPassword(null);
- ArrayList<UserRoleParam> userRoleParams = new ArrayList<>();
- if (null != attUserBase.getRoleIds() && attUserBase.getRoleIds().size() > 0){
- for (String roleId : attUserBase.getRoleIds()) {
- UserRoleParam userRoleParam = new UserRoleParam();
- userRoleParam.setUserId(attUserBase.getGuid());
- userRoleParam.setRoleId(roleId);
- userRoleParams.add(userRoleParam);
- }
- }
- UserRoleParam param = new UserRoleParam();
- param.setUserId(attUserBase.getGuid());
- attUserBaseService.updateUser(attUserBase, userRoleParams, param);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "根据ID删除")
- @RequestMapping(value = "/{guid}", method = RequestMethod.POST)
- public BaseResponse delete(@ApiParam(name = "guid", value = "guid", required = true) @PathVariable String guid) {
- int ret = attUserBaseService.delete(guid);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "更新信息")
- @RequestMapping(value = "/update", method = RequestMethod.POST)
- public BaseResponse update(@ApiParam(name = "attUserBase", value = "AttUserBase", required = true) @RequestBody AttUserBase attUserBase) {
- Assert.notNull(attUserBase.getGuid(), "主键guid为必填参数");
- int ret = attUserBaseService.update(attUserBase);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "根据ID获取")
- @RequestMapping(value = "/{guid}", method = RequestMethod.GET)
- public BaseResponse<AttUserBase> get(@ApiParam(name = "guid", value = "guid", required = true) @PathVariable String guid) {
- AttUserBase attUserBase = attUserBaseService.get(guid);
- return buildSuccessResponse(attUserBase);
- }
- @ApiOperation(value = "分页获取用户列表-包含分页信息")
- @RequestMapping(value = "/pageInfo", method = RequestMethod.GET)
- public BaseResponse<PageInfo<AttUserBase>> getMenuPageInfo(@ApiParam(name = "attUserBaseParam", value = "attUserBaseParam", required = false) AttUserBaseParam attUserBaseParam) {
- PageInfo<AttUserBase> page = attUserBaseService.findPageInfo(attUserBaseParam);
- return buildSuccessResponse(page);
- }
- /**
- *
- * @param persid 用户ID
- * @param ptype 督查类型
- * @param groupName 督查组名称
- * @param plnaId 督查计划节点Id
- * @param tabType 页签 0全部 1当前 2历史
- * @return
- */
- @ApiOperation(value = "获取用户所在组")
- @RequestMapping(value = "/getGroupByPersid", method = RequestMethod.GET)
- public BaseResponse<List<PersGroupDto>> getGroupByPersid(@ApiParam(name = "persid", value = "persid", required = true) @RequestParam String persid,
- @ApiParam(name = "ptype", value = "ptype", required = false) @RequestParam String ptype,
- @ApiParam(name = "groupName", value = "groupName", required = false) @RequestParam(required = false) String groupName,
- @ApiParam(name = "plnaId", value = "plnaId", required = false) @RequestParam(required = false) String plnaId,
- @ApiParam(name = "tabType", value = "tabType", required = false) @RequestParam(required = false,defaultValue = "0") String tabType) {
- List<PersGroupDto> persGroupDtoList = attUserBaseService.getGroupByPersid(persid,ptype,groupName,getCurrentOrgId(),tabType,plnaId);
- return buildSuccessResponse(persGroupDtoList);
- }
- @ApiOperation(value = "获取所有最后一级分组")
- @RequestMapping(value = "/getGroupByPersidNew", method = RequestMethod.GET)
- public BaseResponse<List<PersGroupDto>> getGroupByPersidNew(@ApiParam(name = "persid", value = "persid", required = true) @RequestParam String persid,
- @ApiParam(name = "ptype", value = "ptype", required = false) @RequestParam String ptype,
- @ApiParam(name = "groupName", value = "groupName", required = false) @RequestParam(required = false) String groupName) {
- List<PersGroupDto> persGroupDtoList = attUserBaseService.getGroupByPersidNew(persid,ptype,groupName,getCurrentOrgId());
- return buildSuccessResponse(persGroupDtoList);
- }
- }
|