Sfoglia il codice sorgente

注册用户 乘客

xiao547607 4 anni fa
parent
commit
8cf82e918b

+ 1 - 1
common/src/main/resources/mapper/bus/PassengerInfo.xml

@@ -126,7 +126,7 @@
 		]]>
 		<where>
 			a.del_flag = 0
-			<if test="searchParams.id != null">
+			<if test="seauserNamerchParams.id != null">
 				and a.ID_ like #{searchParams.id}
 			</if>
 			<if test="searchParams.vehiclePersonId != null">

+ 7 - 1
common/src/main/resources/mapper/bus/UserInfo.xml

@@ -105,7 +105,13 @@
 		<where>
 			del_flag = 0
 			<if test="searchParams.id != null">
-				and ID_ like #{searchParams.id}
+				and ID_ = #{searchParams.id}
+			</if>
+			<if test="searchParams.name != null">
+				and name_ like #{searchParams.name}
+			</if>
+			<if test="searchParams.phone != null">
+				and phone_ like #{searchParams.phone}
 			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">

+ 55 - 2
web/src/main/java/com/jpsoft/bus/modules/bus/controller/UserInfoController.java

@@ -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.bus.entity.UserInfo;
 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.sys.entity.User;
 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.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
@@ -29,6 +32,8 @@ public class UserInfoController {
 
     @Autowired
     private UserInfoService userInfoService;
+    @Value("${jwt.secret}")
+    private String jwtSecret;
 
     @ApiOperation(value="创建空记录")
     @GetMapping("create")
@@ -52,6 +57,8 @@ public class UserInfoController {
             userInfo.setDelFlag(false);
             userInfo.setCreateBy(subject);
             userInfo.setCreateTime(new Date());
+            DES3 des3 = new DES3();
+            userInfo.setPassword(des3.encrypt(jwtSecret,userInfo.getPassword()));
 
             int affectCount = userInfoService.insert(userInfo);
 
@@ -197,7 +204,9 @@ public class UserInfoController {
     @ApiOperation(value="列表")
     @RequestMapping(value = "pageList",method = RequestMethod.POST)
     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="pageSize",defaultValue="20") int pageSize,
             @RequestAttribute String subject){
@@ -213,7 +222,15 @@ public class UserInfoController {
         sortList.add(new Sort("id_","asc"));
 
         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);
@@ -223,4 +240,40 @@ public class UserInfoController {
 
         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;
+    }
 }