|
@@ -6,11 +6,14 @@ import com.caimei.modules.shiro.entity.CmMallAdminUser;
|
|
|
import com.caimei.modules.shiro.service.MallUserService;
|
|
|
import com.caimei.utils.JsonModel;
|
|
|
import com.caimei.utils.ResponseJson;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* Description
|
|
@@ -20,6 +23,7 @@ import javax.annotation.Resource;
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/other/user")
|
|
|
+@Slf4j
|
|
|
public class MallUserController {
|
|
|
|
|
|
@Autowired private MallUserService mallUserService;
|
|
@@ -28,14 +32,14 @@ public class MallUserController {
|
|
|
|
|
|
/**
|
|
|
* 后台用户列表
|
|
|
- * @param page
|
|
|
* @param cmMallAdminUser
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping(value = "/getMallUserInfo")
|
|
|
- public ResponseJson<Page<CmMallAdminUser>> getMallUserInfo(Page page, CmMallAdminUser cmMallAdminUser) {
|
|
|
- Page<CmMallAdminUser> mallUserInfo = mallUserService.getMallUserInfo(page, cmMallAdminUser);
|
|
|
- return ResponseJson.success(mallUserInfo);
|
|
|
+ public ResponseJson<Page<CmMallAdminUser>> getMallUserInfo(CmMallAdminUser cmMallAdminUser,
|
|
|
+ @RequestParam(value = "pageNum" , defaultValue = "1") Integer pageNum,
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize) {
|
|
|
+ return mallUserService.getMallUserInfo(cmMallAdminUser,pageNum, pageSize);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -55,6 +59,7 @@ public class MallUserController {
|
|
|
mallUserService.updateUser(status, id);
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 用户信息回显
|
|
|
* @param id
|
|
@@ -73,21 +78,60 @@ public class MallUserController {
|
|
|
* @return
|
|
|
*/
|
|
|
@PostMapping(value = "/saveUser")
|
|
|
- public ResponseJson saveUser(CmMallAdminUser cmMallAdminUser) {
|
|
|
+ public ResponseJson saveUser(@RequestBody CmMallAdminUser cmMallAdminUser) {
|
|
|
if (StringUtils.isEmpty(cmMallAdminUser.getPassword())) {
|
|
|
return ResponseJson.error(-1,"密码不能为空",null);
|
|
|
}
|
|
|
if (StringUtils.isEmpty(cmMallAdminUser.getOldPassword())) {
|
|
|
return ResponseJson.error(-1,"请确认密码",null);
|
|
|
}
|
|
|
+ String regex = "^[A-Za-z0-9]{8,16}$";
|
|
|
+ Pattern pattern = Pattern.compile(regex);
|
|
|
+ Matcher matcher = pattern.matcher(cmMallAdminUser.getPassword());
|
|
|
+ if (!matcher.matches()) {
|
|
|
+ return ResponseJson.error(-1,"密码格式不正确",null);
|
|
|
+ }
|
|
|
if (!cmMallAdminUser.getPassword().equals(cmMallAdminUser.getOldPassword())) {
|
|
|
return ResponseJson.error(-1,"两次密码不一致",null);
|
|
|
}
|
|
|
- Integer repeat = mallUserDao.getRepeat(cmMallAdminUser.getAccount(), null);
|
|
|
- if (null != repeat) {
|
|
|
- return ResponseJson.error(-1,"用户名已存在,请勿重复添加",null);
|
|
|
+ if (null == cmMallAdminUser.getId()) {
|
|
|
+ Integer repeat = mallUserDao.getRepeat(cmMallAdminUser.getAccount(), null);
|
|
|
+ if (null != repeat) {
|
|
|
+ return ResponseJson.error(-1, "用户名已存在,请勿重复添加", null);
|
|
|
+ }
|
|
|
}
|
|
|
mallUserService.saveUser(cmMallAdminUser);
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重置密码
|
|
|
+ * @param password
|
|
|
+ * @param oldPassword
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/repeatPassword")
|
|
|
+ public ResponseJson repeatPassword(String password, String oldPassword, Integer id){
|
|
|
+ if (StringUtils.isEmpty(password)) {
|
|
|
+ return ResponseJson.error(-1,"密码不能为空",null);
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(oldPassword)) {
|
|
|
+ return ResponseJson.error(-1,"确认密码不能为空",null);
|
|
|
+ }
|
|
|
+ String regex = "^[a-zA-Z0-9]{8,16}$";
|
|
|
+ Pattern pattern = Pattern.compile(regex);
|
|
|
+ Matcher matcher = pattern.matcher(password);
|
|
|
+ if (matcher.matches()) {
|
|
|
+ return ResponseJson.error(-1,"密码格式不正确",null);
|
|
|
+ }
|
|
|
+ if (!StringUtils.equals(password,oldPassword)) {
|
|
|
+ return ResponseJson.error(-1,"两次密码不相同",null);
|
|
|
+ }
|
|
|
+ if (null == id) {
|
|
|
+ return ResponseJson.error(-1,"用户Id不能为空",null);
|
|
|
+ }
|
|
|
+ return mallUserService.repeatPassword(password, id);
|
|
|
+ }
|
|
|
}
|