parent
08b58c2c63
commit
0d491e1591
@ -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); |
||||
} |
||||
} |
||||
|
||||
} |
@ -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…
Reference in new issue