提交新增用户管理接口

dev-discount
yuanye 4 years ago
parent 08b58c2c63
commit 0d491e1591
  1. 119
      hai-bweb/src/main/java/com/bweb/controller/HighUserController.java
  2. 26
      hai-service/src/main/java/com/hai/service/HighUserService.java
  3. 64
      hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java

@ -0,0 +1,119 @@
package com.bweb.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.HighUser;
import com.hai.model.ResponseData;
import com.hai.service.HighUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Sum1Dream
*/
@RestController
@RequestMapping(value = "/highUser")
@Api(value = "用户管理")
public class HighUserController {
private static Logger log = LoggerFactory.getLogger(HighUserController.class);
@Resource
private HighUserService highUserService;
@RequestMapping(value = "/getListUser", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询用户列表")
public ResponseData getPagePosition(
@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "phone", required = false) String phone,
@RequestParam(value = "status", required = false) String status,
@RequestParam(value = "regTimeStart", required = false) String regTimeStart,
@RequestParam(value = "regTimeEnd", required = false) String regTimeEnd,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize
) {
try {
Map<String, String> map = new HashMap<>();
if (StringUtils.isNotBlank(name)) {
map.put("name", name);
}
if (StringUtils.isNotBlank(phone)) {
map.put("phone", phone);
}
if (StringUtils.isNotBlank(status)) {
map.put("status", status);
}
if (StringUtils.isNotBlank(regTimeStart)) {
map.put("regTimeStart", regTimeStart);
}
if (StringUtils.isNotBlank(regTimeEnd)) {
map.put("regTimeEnd", regTimeEnd);
}
PageHelper.startPage(pageNum, pageSize);
List<HighUser> highUsers = highUserService.getListUser(map);
return ResponseMsgUtil.success(new PageInfo<>(highUsers));
} catch (Exception e) {
log.error("HighUserController --> getListUser() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/findByUserId", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据id查询职位详情")
public ResponseData findById(@RequestParam(value = "userId", required = true) Long userId) {
try {
return ResponseMsgUtil.success(highUserService.findByUserId(userId));
} catch (Exception e) {
log.error("HighUserController --> findByUserId() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/forbiddenUser", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "禁用账号")
public ResponseData updatePosition(@RequestParam(value = "userId" , required = true) Long userId) {
try {
HighUser highUser = highUserService.findByUserId(userId);
if (highUser == null) {
log.error("HighUserController --> forbiddenUser() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_USER_ERROR, "");
}
return ResponseMsgUtil.success("修改成功");
} catch (Exception e) {
log.error("BsPositionController --> addPosition() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -18,9 +18,10 @@ public interface HighUserService {
*
* @Title: getListUser
* @Description: 查询用户列表
* @Date: 2021/03/09 10:23
* @author: Sum1Dream
* @param: [map] map参数
* @return: java.util.List<com.high.entity.HighUser>
* @return: java.util.List<com.hai.entity.HighUser>
* @throws Exception 抛出异常
*/
@ -30,10 +31,33 @@ public interface HighUserService {
*
* @Title: findByUserId
* @Description: 查询用户详情
* @Date: 2021/03/09 10:23
* @author: Sum1Dream
* @param: userId 用户id
* @return: HighUser
*/
HighUser findByUserId(Long userId);
/**
*
* @Title: updateUser
* @Description: 修改用户信息
* @author: Sum1Dream
* @Date: 2021/03/09 11:23
* @param: [highUser] 用户信息
* @return: com.hai.entity.HighUser
*/
void updateUser(HighUser highUser);
/**
*
* @Title: insertUser
* @Description: 新增用户
* @author: Sum1Dream
* @Date: 2021/03/09 11:23
* @param: [highUser] 用户信息
* @return: com.hai.entity.HighUser
*/
void insertUser(HighUser highUser);
}

@ -0,0 +1,64 @@
package com.hai.service.impl;
import com.hai.common.utils.DateUtil;
import com.hai.dao.HighUserMapper;
import com.hai.entity.HighUser;
import com.hai.entity.HighUserExample;
import com.hai.service.HighUserService;
import com.sun.xml.bind.v2.model.core.ID;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* @author Sum1Dream
*/
@Service("highUserServiceImpl")
public class HighUserServiceImpl implements HighUserService {
@Resource
private HighUserMapper highUserMapper;
@Override
public List<HighUser> getListUser(Map<String, String> map) {
HighUserExample example = new HighUserExample();
HighUserExample.Criteria criteria = example.createCriteria();
if (StringUtils.isNotBlank(map.get("phone"))) {
criteria.andPhoneEqualTo(Long.valueOf(map.get("phone")));
}
if (StringUtils.isNotBlank(map.get("name"))) {
criteria.andNameLike("%" + map.get("name") + "%");
}
if (StringUtils.isNotBlank(map.get("status"))) {
criteria.andStatusEqualTo(Integer.valueOf(map.get("status")));
}
if (StringUtils.isNotBlank(map.get("regTimeStart")) && StringUtils.isNotBlank(map.get("regTimeEnd"))) {
criteria.andRegTimeBetween(
DateUtil.format(map.get("regTimeStart") , "yyyy-MM-dd HH:mm:ss") ,
DateUtil.format(map.get("regTimeEnd") , "yyyy-MM-dd HH:mm:ss"));
}
return highUserMapper.selectByExample(example);
}
@Override
public HighUser findByUserId(Long userId) {
return highUserMapper.selectByPrimaryKey(userId);
}
@Override
public void updateUser(HighUser highUser) {
highUserMapper.updateByPrimaryKeySelective(highUser);
}
@Override
public void insertUser(HighUser highUser) {
highUserMapper.insert(highUser);
}
}
Loading…
Cancel
Save