Переглянути джерело

update

Signed-off-by: anderx <312518615@qq.com>
anderx 5 роки тому
батько
коміт
d127db2510

+ 2 - 2
src/main/java/com/goafanti/common/mapper/DemandCollectionMapper.xml

@@ -1923,7 +1923,7 @@
 	date_format(create_time,'%Y-%m-%d %H:%i:%S') createTimes
 	from skjt_user where 1=1
 	<if test="account != null">
-	and account like concat('%',#{admin},'%')
+	and account like concat('%',#{account},'%')
 	</if>
 	<if test="name != null">
 	and nickname like concat('%',#{name},'%')
@@ -1937,7 +1937,7 @@
 	select count(*)
 	from skjt_user where 1=1
 	<if test="account != null">
-	and account like concat('%',#{admin},'%')
+	and account like concat('%',#{account},'%')
 	</if>
 	<if test="name != null">
 	and nickname like concat('%',#{name},'%')

+ 21 - 0
src/main/java/com/goafanti/demandCollection/controller/DemandCollectionApiController.java

@@ -17,6 +17,7 @@ import com.goafanti.common.model.SkjtUser;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.demandCollection.bo.InputDemandCollection;
 import com.goafanti.demandCollection.bo.InputUserList;
+import com.goafanti.demandCollection.bo.SkjtConstants;
 import com.goafanti.demandCollection.service.DemandCollectionService;
 
 @RestController
@@ -91,6 +92,26 @@ public class DemandCollectionApiController  extends CertifyApiController {
 	}
 	
 	/**
+	   *修改密码
+	 * @param d
+	 * @return
+	 */
+	@RequestMapping(value="/api/updateUserPassword",method = RequestMethod.POST)
+	public Result updateUserPassword(String account,String usedPassword,String newPassword){
+		Result res =new Result();
+		if (StringUtils.isBlank(usedPassword)||StringUtils.isBlank(newPassword)) {
+			res.getError().add(buildError("密码不能为空!","密码不能为空!"));
+			return res;
+		}
+		if (TokenManager.hasRole(SkjtConstants.GLY)&&StringUtils.isBlank(account)) {
+			res.getError().add(buildError("账号不能为空!","账号不能为空!"));
+			return res;
+		}
+		res.setData(demandCollectionService.updateUserPassword(account,usedPassword,newPassword));
+		return res;
+		
+	}
+	/**
 	 * 	导出变更列表
      * 
      * @param response

+ 3 - 0
src/main/java/com/goafanti/demandCollection/service/DemandCollectionService.java

@@ -21,4 +21,7 @@ public interface DemandCollectionService {
 
 	Pagination<OutUserList> userList(InputUserList in);
 
+
+	int updateUserPassword( String account,String usedPassword, String newPassword);
+
 }

+ 28 - 0
src/main/java/com/goafanti/demandCollection/service/impl/DemandCollectionServiceImpl.java

@@ -25,6 +25,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import com.fasterxml.jackson.databind.ser.std.StdJdkSerializers;
 import com.goafanti.common.bo.Error;
 import com.goafanti.common.dao.DemandCollectionMapper;
 import com.goafanti.common.dao.SkjtUserMapper;
@@ -277,4 +278,31 @@ public class DemandCollectionServiceImpl extends BaseMybatisDao<DemandCollection
 		return (Pagination<OutUserList>) findPage("findUserList","findUserCount",
 				map, in.getPageNo(), in.getPageSize());
 	}
+	@Override
+	public int updateUserPassword( String account,String usedPassword, String newPassword) {
+		SkjtUser  s;
+		if (TokenManager.hasRole(SkjtConstants.GLY)) {
+			s=skjtUserMapper.selectByAccount(account);
+		}else {
+			s=skjtUserMapper.selectByPrimaryKey(TokenManager.getAdminId());
+		}
+		if (s!=null) {
+			String up=s.getPassword();
+			String np="";
+			Calendar c=Calendar.getInstance();
+			c.setTime(s.getCreateTime());
+			c.set(Calendar.MILLISECOND, 0);
+			s.setCreateTime(c.getTime());
+			s.setPassword(newPassword);
+			np=passwordUtil.getEncryptPwd(s);
+			if (np.equals(up)) {
+				SkjtUser us=new SkjtUser();
+				us.setId(s.getId());
+				us.setPassword(np);
+				skjtUserMapper.updateByPrimaryKeySelective(us);
+				return 1;
+			}
+		}
+		return 0;
+	}
 }