|
@@ -5,13 +5,16 @@ import com.jpsoft.bus.modules.common.dto.MessageResult;
|
|
import com.jpsoft.bus.modules.common.dto.Sort;
|
|
import com.jpsoft.bus.modules.common.dto.Sort;
|
|
import com.jpsoft.bus.modules.bus.entity.UserInfo;
|
|
import com.jpsoft.bus.modules.bus.entity.UserInfo;
|
|
import com.jpsoft.bus.modules.bus.service.UserInfoService;
|
|
import com.jpsoft.bus.modules.bus.service.UserInfoService;
|
|
|
|
+import com.jpsoft.bus.modules.common.utils.DES3;
|
|
import com.jpsoft.bus.modules.common.utils.PojoUtils;
|
|
import com.jpsoft.bus.modules.common.utils.PojoUtils;
|
|
|
|
+import com.jpsoft.bus.modules.sys.entity.User;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
@@ -29,6 +32,8 @@ public class UserInfoController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private UserInfoService userInfoService;
|
|
private UserInfoService userInfoService;
|
|
|
|
+ @Value("${jwt.secret}")
|
|
|
|
+ private String jwtSecret;
|
|
|
|
|
|
@ApiOperation(value="创建空记录")
|
|
@ApiOperation(value="创建空记录")
|
|
@GetMapping("create")
|
|
@GetMapping("create")
|
|
@@ -52,6 +57,8 @@ public class UserInfoController {
|
|
userInfo.setDelFlag(false);
|
|
userInfo.setDelFlag(false);
|
|
userInfo.setCreateBy(subject);
|
|
userInfo.setCreateBy(subject);
|
|
userInfo.setCreateTime(new Date());
|
|
userInfo.setCreateTime(new Date());
|
|
|
|
+ DES3 des3 = new DES3();
|
|
|
|
+ userInfo.setPassword(des3.encrypt(jwtSecret,userInfo.getPassword()));
|
|
|
|
|
|
int affectCount = userInfoService.insert(userInfo);
|
|
int affectCount = userInfoService.insert(userInfo);
|
|
|
|
|
|
@@ -197,7 +204,9 @@ public class UserInfoController {
|
|
@ApiOperation(value="列表")
|
|
@ApiOperation(value="列表")
|
|
@RequestMapping(value = "pageList",method = RequestMethod.POST)
|
|
@RequestMapping(value = "pageList",method = RequestMethod.POST)
|
|
public MessageResult<Map> pageList(
|
|
public MessageResult<Map> pageList(
|
|
- String id,
|
|
|
|
|
|
+ @RequestParam(value="id",defaultValue="") String id,
|
|
|
|
+ @RequestParam(value="name",defaultValue="") String name,
|
|
|
|
+ @RequestParam(value="phone",defaultValue="") String phone,
|
|
@RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
@RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
@RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
@RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
@RequestAttribute String subject){
|
|
@RequestAttribute String subject){
|
|
@@ -213,7 +222,15 @@ public class UserInfoController {
|
|
sortList.add(new Sort("id_","asc"));
|
|
sortList.add(new Sort("id_","asc"));
|
|
|
|
|
|
if (StringUtils.isNotEmpty(id)) {
|
|
if (StringUtils.isNotEmpty(id)) {
|
|
- searchParams.put("id","%" + id + "%");
|
|
|
|
|
|
+ searchParams.put("id",id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isNotEmpty(name)) {
|
|
|
|
+ searchParams.put("name","%" + name + "%");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isNotEmpty(phone)) {
|
|
|
|
+ searchParams.put("phone","%" + phone + "%");
|
|
}
|
|
}
|
|
|
|
|
|
Page<UserInfo> page = userInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
Page<UserInfo> page = userInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
@@ -223,4 +240,40 @@ public class UserInfoController {
|
|
|
|
|
|
return msgResult;
|
|
return msgResult;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="修改用户密码")
|
|
|
|
+ @PostMapping("changePassword")
|
|
|
|
+ public MessageResult<Integer> changePassword(String userId,String newPwd,@RequestAttribute String subject) {
|
|
|
|
+
|
|
|
|
+ MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ UserInfo userInfo = userInfoService.get(userId);
|
|
|
|
+
|
|
|
|
+ DES3 des3 = new DES3();
|
|
|
|
+
|
|
|
|
+ userInfo.setPassword(des3.encrypt(jwtSecret, newPwd));
|
|
|
|
+ userInfo.setUpdateBy(subject);
|
|
|
|
+ userInfo.setUpdateTime(new Date());
|
|
|
|
+
|
|
|
|
+ int affectCount = userInfoService.update(userInfo);
|
|
|
|
+
|
|
|
|
+ if(affectCount>0){
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ msgResult.setData(affectCount);
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage("修改失败!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch(Exception ex){
|
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return msgResult;
|
|
|
|
+ }
|
|
}
|
|
}
|