77import com .zhazhapan .efo .entity .User ;
88import com .zhazhapan .efo .modules .constant .ConfigConsts ;
99import com .zhazhapan .efo .service .IUserService ;
10+ import com .zhazhapan .efo .util .BeanUtils ;
1011import com .zhazhapan .modules .constant .ValueConsts ;
1112import com .zhazhapan .util .Checker ;
1213import com .zhazhapan .util .DateUtils ;
14+ import com .zhazhapan .util .MailSender ;
15+ import org .apache .log4j .Logger ;
1316import org .springframework .beans .factory .annotation .Autowired ;
1417import org .springframework .stereotype .Service ;
1518
1619import javax .servlet .http .Cookie ;
1720import javax .servlet .http .HttpServletResponse ;
21+ import java .util .List ;
1822import java .util .regex .Pattern ;
1923
2024import static com .zhazhapan .efo .EfoApplication .settings ;
@@ -29,9 +33,41 @@ public class UserServiceImpl implements IUserService {
2933
3034 private final UserDAO userDAO ;
3135
36+ private Logger logger = Logger .getLogger (UserServiceImpl .class );
37+
3238 @ Autowired
3339 public UserServiceImpl (UserDAO userDAO ) {this .userDAO = userDAO ;}
3440
41+ @ Override
42+ public boolean updatePermission (int id , int permission ) {
43+ return userDAO .updatePermission (id , permission > 2 ? 2 : permission );
44+ }
45+
46+ @ Override
47+ public boolean resetPassword (int id , String password ) {
48+ boolean result = Checker .isNotEmpty (password ) && userDAO .updatePasswordById (id , password );
49+ if (result ) {
50+ removeTokenByValue (id );
51+ try {
52+ MailSender .sendMail (getUserById (id ).getEmail (), "密码重置通知" , "您的密码已被管理员重置为:" + password );
53+ } catch (Exception e ) {
54+ logger .error (e .getMessage ());
55+ }
56+ }
57+ return result ;
58+ }
59+
60+ @ Override
61+ public boolean updateFileAuth (int id , String auths ) {
62+ int [] auth = BeanUtils .getAuth (auths );
63+ return userDAO .updateAuthById (id , auth [0 ], auth [1 ], auth [2 ], auth [3 ], auth [4 ]);
64+ }
65+
66+ @ Override
67+ public List <User > getUser (int permission , String condition , int offset ) {
68+ return userDAO .getUserBy (permission , condition , offset );
69+ }
70+
3571 @ Override
3672 public User login (String loginName , String password , String token , HttpServletResponse response ) {
3773 boolean allowLogin = settings .getBooleanUseEval (ConfigConsts .ALLOW_LOGIN_OF_SETTINGS );
0 commit comments