Quellcode durchsuchen

用户信息管理添加新增账户、修改账户信息功能

XMTT vor 7 Jahren
Ursprung
Commit
bfb3c4db0d

+ 26 - 0
src/main/java/com/ekexiu/console/system/dao/LuserDao.java

2
2
3
import com.ekexiu.console.system.po.Luser;
3
import com.ekexiu.console.system.po.Luser;
4
import org.jfw.apt.annotation.Nullable;
4
import org.jfw.apt.annotation.Nullable;
5
import org.jfw.apt.orm.annotation.dao.Column;
5
import org.jfw.apt.orm.annotation.dao.DAO;
6
import org.jfw.apt.orm.annotation.dao.DAO;
7
import org.jfw.apt.orm.annotation.dao.method.From;
6
import org.jfw.apt.orm.annotation.dao.method.Or;
8
import org.jfw.apt.orm.annotation.dao.method.Or;
7
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
9
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
10
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
8
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
11
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
12
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
9
import org.jfw.apt.orm.annotation.dao.param.Alias;
13
import org.jfw.apt.orm.annotation.dao.param.Alias;
14
import org.jfw.apt.orm.annotation.dao.param.Set;
15
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
10
16
11
import java.sql.Connection;
17
import java.sql.Connection;
12
import java.sql.SQLException;
18
import java.sql.SQLException;
24
30
25
    @Insert
31
    @Insert
26
    int insert(Connection con,Luser user)throws SQLException;
32
    int insert(Connection con,Luser user)throws SQLException;
33
34
    @Nullable
35
    @QueryVal
36
    @Column(handlerClass=StringHandler.class,value="id")
37
    @From(Luser.class)
38
    String queryByEmail(Connection con,String email)throws SQLException;
39
40
    @Nullable
41
    @QueryVal
42
    @Column(handlerClass=StringHandler.class,value="id")
43
    @From(Luser.class)
44
    String queryByPhone(Connection con,String mobilePhone)throws SQLException;
45
46
    @UpdateWith
47
    @From(Luser.class)
48
    int updateAccount(Connection con, String id, @Set String mobilePhone, @Set String email)throws SQLException;
49
50
    @SelectOne
51
    @Nullable
52
    Luser query(Connection con, String id) throws SQLException;
27
}
53
}

+ 2 - 2
src/main/java/com/ekexiu/console/system/service/OrgService.java

293

293

294
    @Path("/entryCheck")
294
    @Path("/entryCheck")
295
    @Get
295
    @Get
296
    public int entryCheck(@JdbcConn Connection con, String name, String email) throws SQLException, JfwBaseException {
296
    public int entryCheck(@JdbcConn Connection con, String name, String email) throws SQLException {
297
        OrgUser orgUser = this.orgUserDao.entryCheck(con, email);
297
        OrgUser orgUser = this.orgUserDao.entryCheck(con, email);
298
        if (orgUser != null) {
298
        if (orgUser != null) {
299
            return 1;//该邮箱已被注册
299
            return 1;//该邮箱已被注册
307

307

308
    @Path("/editCheck")
308
    @Path("/editCheck")
309
    @Get
309
    @Get
310
    public int editCheck(@JdbcConn Connection con, String name, String email,String id) throws SQLException, JfwBaseException {
310
    public int editCheck(@JdbcConn Connection con, String name, String email,String id) throws SQLException {
311
        String orgUserId = this.orgUserDao.queryByEmail(con, email);
311
        String orgUserId = this.orgUserDao.queryByEmail(con, email);
312
        if ((orgUserId != null)&&(!Objects.equals(orgUserId, id))) {
312
        if ((orgUserId != null)&&(!Objects.equals(orgUserId, id))) {
313
            return 2;//该邮箱已被注册
313
            return 2;//该邮箱已被注册

+ 58 - 2
src/main/java/com/ekexiu/console/system/service/ProfessorService.java

22
import org.jfw.util.DateUtil;
22
import org.jfw.util.DateUtil;
23
import org.jfw.util.PageQueryResult;
23
import org.jfw.util.PageQueryResult;
24
import org.jfw.util.StringUtil;
24
import org.jfw.util.StringUtil;
25
import org.jfw.util.exception.JfwBaseException;
25
26
26
import java.io.IOException;
27
import java.io.IOException;
27
import java.sql.Connection;
28
import java.sql.Connection;
28
import java.sql.SQLException;
29
import java.sql.SQLException;
30
import java.util.Objects;
29
import java.util.Random;
31
import java.util.Random;
30
32
31
/**
33
/**
177
        this.professorDao.updateBusinessData(con, id, authentication, authStatus, authStatusExpert, sortFirst);
179
        this.professorDao.updateBusinessData(con, id, authentication, authStatus, authStatusExpert, sortFirst);
178
    }
180
    }
179
181
182
    @Path("/createCheck")
183
    @Get
184
    public boolean entryCheck(@JdbcConn Connection con, @Nullable String mobile, @Nullable String email) throws SQLException {
185
        Luser luser1 = this.luserDao.check(con, mobile);
186
        Luser luser2 = this.luserDao.check(con, email);
187
        return luser1 == null && luser2 == null;
188
    }
189
190
    @Path("/updateCheck")
191
    @Get
192
    public int editCheck(@JdbcConn Connection con,@Nullable String mobile, @Nullable String email,String id) throws SQLException {
193
        String luserId = this.luserDao.queryByEmail(con, email);
194
        if ((luserId != null)&&(!Objects.equals(luserId, id))) {
195
            return 2;//该邮箱已被注册
196
        }
197
        String luserId1 = this.luserDao.queryByPhone(con, mobile);
198
        if ((luserId1 != null) && (!Objects.equals(luserId1, id))) {
199
            return 3;//该手机已被注册
200
        }
201
        return 1;
202
    }
203
180
    @Post
204
    @Post
181
    @Path("/createAccount")
205
    @Path("/createAccount")
182
    public void insert(@JdbcConn(true) Connection con,String name, @Nullable String mobile,@Nullable String email)throws SQLException {
206
    public void insert(@JdbcConn(true) Connection con,String name, @Nullable String mobile,@Nullable String email)throws SQLException,JfwBaseException {
183
207
208
        String luserId = this.luserDao.queryByEmail(con, email);
209
        if (luserId != null) {
210
            throw new JfwBaseException(40001, "邮箱已被注册");
211
        }
212
        String luserId1 = this.luserDao.queryByPhone(con, mobile);
213
        if (luserId1 != null) {
214
            throw new JfwBaseException(40002, "该电话已被注册");
215
        }
184
        String id = StringUtil.buildUUID();
216
        String id = StringUtil.buildUUID();
185
        Luser luser = new Luser();
217
        Luser luser = new Luser();
186
        luser.setId(id);
218
        luser.setId(id);
187
        luser.setEmail(email);
188
        Random rd = new Random();
219
        Random rd = new Random();
189
        int code = rd.nextInt(1000000);
220
        int code = rd.nextInt(1000000);
190
        String inviteCode = String.format("%06d", code);
221
        String inviteCode = String.format("%06d", code);
191
        luser.setInviteCode(inviteCode);
222
        luser.setInviteCode(inviteCode);
223
        luser.setEmail(email);
192
        luser.setMobilePhone(mobile);
224
        luser.setMobilePhone(mobile);
193
        luser.setPasswd(DEFAULT_PASS_WORD);
225
        luser.setPasswd(DEFAULT_PASS_WORD);
194
        luser.setUserType("0");
226
        luser.setUserType("0");
205
        professor.setAuthStatusExpert(0);
237
        professor.setAuthStatusExpert(0);
206
        professor.setSortFirst(0);
238
        professor.setSortFirst(0);
207
        professor.setProfessorState(0);
239
        professor.setProfessorState(0);
240
        professor.setAuthentication(0);
241
        professor.setOrgAuth("0");
208
        this.professorDao.insert(con, professor);
242
        this.professorDao.insert(con, professor);
243
    }
209
244
245
    @Post
246
    @Path("/updateAccount")
247
    public void updateAccount(@JdbcConn(true) Connection con,@Nullable String mobile, @Nullable String email,String id) throws SQLException, JfwBaseException {
248
        String luserId = this.luserDao.queryByEmail(con, email);
249
        if ((luserId != null)&&(!Objects.equals(luserId, id))) {
250
            throw new JfwBaseException(40001, "该邮箱已被注册");
251
        }
252
        String luserId1 = this.luserDao.queryByPhone(con, mobile);
253
        if ((luserId1 != null) && (!Objects.equals(luserId1, id))) {
254
            throw new JfwBaseException(40002, "该电话已被注册");
255
        }
256
        this.luserDao.updateAccount(con, id, mobile, email);
257
    }
210
258
259
    @Get
260
    @Path("/luserId/{id}")
261
    public Luser queryAccount(@JdbcConn Connection con, @PathVar String id)throws SQLException {
262
        Luser luser = this.luserDao.query(con, id);
263
        if (luser != null) {
264
            luser.setPasswd(null);
265
        }
266
        return luser;
211
    }
267
    }
212
}
268
}

+ 4 - 4
src/main/java/com/ekexiu/console/system/service/UserInfoService.java

187
    @Path("/editCheck")
187
    @Path("/editCheck")
188
    @Get
188
    @Get
189
    public Boolean editCheck(@JdbcConn Connection con, @Nullable String mobile, @Nullable String email,String id) throws SQLException {
189
    public Boolean editCheck(@JdbcConn Connection con, @Nullable String mobile, @Nullable String email,String id) throws SQLException {
190
        String orgId = this.userInfoDao.queryByKey(con, mobile);
191
        if ((orgId != null) && (!Objects.equals(orgId, id))){
190
        String userInfoId = this.userInfoDao.queryByKey(con, mobile);
191
        if ((userInfoId != null) && (!Objects.equals(userInfoId, id))){
192
            return false;
192
            return false;
193
        }
193
        }
194
        String orgId1 = this.userInfoDao.queryByKey(con, email);
195
        if ((orgId1 != null) && (!Objects.equals(orgId, id))){
194
        String userInfoId1 = this.userInfoDao.queryByKey(con, email);
195
        if ((userInfoId1 != null) && (!Objects.equals(userInfoId1, id))){
196
            return false;
196
            return false;
197
        }
197
        }
198
        Luser luser1 = this.luserDao.check(con, mobile);
198
        Luser luser1 = this.luserDao.check(con, mobile);