XMTT 7 vuotta sitten
vanhempi
commit
2bd94a3dac

+ 15 - 4
src/main/java/com/ekexiu/console/system/dao/OrgDao.java

9
import org.jfw.apt.orm.annotation.dao.method.From;
9
import org.jfw.apt.orm.annotation.dao.method.From;
10
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
10
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
11
import org.jfw.apt.orm.annotation.dao.method.operator.*;
11
import org.jfw.apt.orm.annotation.dao.method.operator.*;
12
import org.jfw.apt.orm.annotation.dao.param.Like;
13
import org.jfw.apt.orm.annotation.dao.param.Set;
12
import org.jfw.apt.orm.annotation.dao.param.*;
14
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
13
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
15
import org.jfw.util.PageQueryResult;
14
import org.jfw.util.PageQueryResult;
16

15

36

35

37
	@Nullable
36
	@Nullable
38
	@QueryOne
37
	@QueryOne
39
	OrganizationInfo query(Connection con, String id) throws SQLException;
38
	Organization query(Connection con, String id) throws SQLException;
39

40
	@UpdateWith
41
	@From(Organization.class)
42
	int updateOrgName(Connection con,String id,@Set String name)throws SQLException;
40

43

41
	@UpdateWith
44
	@UpdateWith
42
	@From(Organization.class)
45
	@From(Organization.class)
44

47

45
	@PageQuery
48
	@PageQuery
46
	@OrderBy(" ORDER BY create_time DESC")
49
	@OrderBy(" ORDER BY create_time DESC")
47
	PageQueryResult<OrganizationInfo> query(Connection con,@Nullable @Like String inviterId, @Nullable @Like String name, @Nullable @Like String industry, @Nullable @Like String subject, @Nullable @Like String city, int pageSize, int pageNo) throws SQLException;
50
	PageQueryResult<OrganizationInfo> queryTime(Connection con, @Nullable @Like String name, @Nullable @Like String industry, @Nullable @Like String subject, @Nullable @Like String city, @Nullable String authStatus, @Nullable @GtEq @Alias("createTime") String bt, @Nullable @Alias("createTime") @LtEq String et, int pageSize, int pageNo) throws SQLException;
51

52
	@PageQuery
53
	@OrderBy(" ORDER BY page_views DESC")
54
	PageQueryResult<OrganizationInfo> queryViews(Connection con, @Nullable @Like String name, @Nullable @Like String industry, @Nullable @Like String subject, @Nullable @Like String city, @Nullable String authStatus, @Nullable @GtEq @Alias("createTime") String bt, @Nullable @Alias("createTime") @LtEq String et, int pageSize, int pageNo) throws SQLException;
48

55

49
	@Nullable
56
	@Nullable
50
	@QueryVal
57
	@QueryVal
52
	@From(Organization.class)
59
	@From(Organization.class)
53
	String queryByName(Connection con,String name)throws SQLException;
60
	String queryByName(Connection con,String name)throws SQLException;
54

61

62
	@Nullable
63
	@SelectOne
64
	Organization entryCheck(Connection con, @Nullable String name) throws SQLException;
65

55
}
66
}

+ 18 - 1
src/main/java/com/ekexiu/console/system/dao/OrgUserDao.java

1
package com.ekexiu.console.system.dao;
1
package com.ekexiu.console.system.dao;
2
2
3
import com.ekexiu.console.system.po.OrgUser;
3
import com.ekexiu.console.system.po.OrgUser;
4
import org.jfw.apt.annotation.Nullable;
4
import org.jfw.apt.orm.annotation.dao.DAO;
5
import org.jfw.apt.orm.annotation.dao.DAO;
5
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
6
import org.jfw.apt.orm.annotation.dao.method.From;
7
import org.jfw.apt.orm.annotation.dao.method.operator.*;
8
import org.jfw.apt.orm.annotation.dao.param.Set;
6
9
7
import java.sql.Connection;
10
import java.sql.Connection;
8
import java.sql.SQLException;
11
import java.sql.SQLException;
16
    @Insert
19
    @Insert
17
    int insert(Connection con, OrgUser orgUser) throws SQLException;
20
    int insert(Connection con, OrgUser orgUser) throws SQLException;
18
21
22
    @Nullable
23
    @QueryOne
24
    OrgUser query(Connection con, String id) throws SQLException;
25
26
    @Update
27
    int update(Connection con, OrgUser org) throws SQLException;
28
29
    @UpdateWith
30
    @From(OrgUser.class)
31
    int updateEmail(Connection con,String id,@Set String email)throws SQLException;
32
33
    @Nullable
34
    @SelectOne
35
    OrgUser entryCheck(Connection con, @Nullable String email) throws SQLException;
19
}
36
}

+ 1 - 1
src/main/java/com/ekexiu/console/system/dao/UserInfoDao.java

44
    @PageQuery
44
    @PageQuery
45
    @OrderBy(" ORDER BY create_time DESC")
45
    @OrderBy(" ORDER BY create_time DESC")
46
    @Where("state<>'1'")
46
    @Where("state<>'1'")
47
    PageQueryResult<UserInfo> queryAll(Connection con, @Nullable @Like String name, @Nullable @Like String orgName, @Nullable String state, @Nullable @GtEq @Alias("createTime") String bt, @Nullable @Alias("createTime") @LtEq String et, int pageSize, int pageNo) throws SQLException;
47
    PageQueryResult<UserInfo> queryAll(Connection con,@Nullable @Like String creatorName, @Nullable @Like String name, @Nullable @Like String orgName, @Nullable String state, @Nullable @GtEq @Alias("createTime") String bt, @Nullable @Alias("createTime") @LtEq String et, int pageSize, int pageNo) throws SQLException;
48
48
49
    @Or
49
    @Or
50
    @Nullable
50
    @Nullable

+ 82 - 0
src/main/java/com/ekexiu/console/system/po/Organization.java

7
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
7
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
8
import org.jfw.apt.orm.annotation.entry.Table;
8
import org.jfw.apt.orm.annotation.entry.Table;
9
import org.jfw.apt.orm.core.defaultImpl.FixLenStringHandler;
9
import org.jfw.apt.orm.core.defaultImpl.FixLenStringHandler;
10
import org.jfw.apt.orm.core.defaultImpl.LongHandler;
10
import org.jfw.apt.orm.core.enums.DE;
11
import org.jfw.apt.orm.core.enums.DE;
11

12

12
@PrimaryKey("id")
13
@PrimaryKey("id")
32
    private String descp;
33
    private String descp;
33
    private String authStatus;
34
    private String authStatus;
34

35

36

37
    /**
38
     * 详细地址
39
     */
40
    private String addr;
41
    /**
42
     * 联系邮箱
43
     */
44
    private String email;
45
    /**
46
     * 联系电话
47
     */
48
    private String contactNum;
49
    /**
50
     * 客户领域
51
     */
52
    private String fieldOfCustomer;
53
    /**
54
     * 供应商领域
55
     */
56
    private String fieldOfSupplier;
57
    /**
58
     * 排序字段
59
     */
60
    private long sortNum;
61
    /**
62
     * 浏览量
63
     */
64
    private long pageViews;
65

35
    @Column(DE.string_de)
66
    @Column(DE.string_de)
36
    public String getAuthStatus() {
67
    public String getAuthStatus() {
37
        return authStatus;
68
        return authStatus;
192
        this.isJoin = isJoin;
223
        this.isJoin = isJoin;
193
    }
224
    }
194

225

226
    @Column(DE.Text_de)
227
    public String getAddr() {
228
        return addr;
229
    }
230
    public void setAddr(String addr) {
231
        this.addr = addr;
232
    }
233
    @Column(DE.Text_de)
234
    public String getEmail() {
235
        return email;
236
    }
237
    public void setEmail(String email) {
238
        this.email = email;
239
    }
240
    @Column(DE.Text_de)
241
    public String getContactNum() {
242
        return contactNum;
243
    }
244
    public void setContactNum(String contactNum) {
245
        this.contactNum = contactNum;
246
    }
247
    @Column(DE.Text_de)
248
    public String getFieldOfCustomer() {
249
        return fieldOfCustomer;
250
    }
251
    public void setFieldOfCustomer(String fieldOfCustomer) {
252
        this.fieldOfCustomer = fieldOfCustomer;
253
    }
254
    @Column(DE.Text_de)
255
    public String getFieldOfSupplier() {
256
        return fieldOfSupplier;
257
    }
258
    public void setFieldOfSupplier(String fieldOfSupplier) {
259
        this.fieldOfSupplier = fieldOfSupplier;
260
    }
261
    @Column(handlerClass=LongHandler.class,dbType="BIGINT",fixSqlValueWithInsert="0",insertable=true,renewable=false,nullable=false,queryable=true)
262
    public long getSortNum() {
263
        return sortNum;
264
    }
265
    public void setSortNum(long sortNum) {
266
        this.sortNum = sortNum;
267
    }
268
    @Column(handlerClass=LongHandler.class,dbType="BIGINT",fixSqlValueWithInsert="0",insertable=true,renewable=false,nullable=false,queryable=true)
269
    public long getPageViews() {
270
        return pageViews;
271
    }
272
    public void setPageViews(long pageViews) {
273
        this.pageViews = pageViews;
274
    }
275

276

195

277

196
}
278
}

+ 5 - 6
src/main/java/com/ekexiu/console/system/pojo/OrganizationInfo.java

12
public class OrganizationInfo extends Organization {
12
public class OrganizationInfo extends Organization {
13
    private String principal;
13
    private String principal;
14
    private String inviterId;
14
    private String inviterId;
15
    private String email;
15
    private String registerEmail;
16
    private boolean hasOrgLogo;
16
    private boolean hasOrgLogo;
17
17
18
    public boolean isHasOrgLogo() {
18
    public boolean isHasOrgLogo() {
24
    }
24
    }
25
25
26
    @CalcColumn(handlerClass = StringHandler.class, column = "ou.email")
26
    @CalcColumn(handlerClass = StringHandler.class, column = "ou.email")
27
    public String getEmail() {
28
        return email;
27
    public String getRegisterEmail() {
28
        return registerEmail;
29
    }
29
    }
30
31
    public void setEmail(String email) {
32
        this.email = email;
30
    public void setRegisterEmail(String registerEmail) {
31
        this.registerEmail = registerEmail;
33
    }
32
    }
34
33
35
    @CalcColumn(handlerClass = StringHandler.class, column = "ou.inviter_id")
34
    @CalcColumn(handlerClass = StringHandler.class, column = "ou.inviter_id")

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

15
import org.jfw.apt.web.annotation.operate.Delete;
15
import org.jfw.apt.web.annotation.operate.Delete;
16
import org.jfw.apt.web.annotation.operate.Get;
16
import org.jfw.apt.web.annotation.operate.Get;
17
import org.jfw.apt.web.annotation.operate.Post;
17
import org.jfw.apt.web.annotation.operate.Post;
18
import org.jfw.apt.web.annotation.param.FieldParam;
19
import org.jfw.apt.web.annotation.param.JdbcConn;
18
import org.jfw.apt.web.annotation.param.JdbcConn;
20
import org.jfw.apt.web.annotation.param.PathVar;
19
import org.jfw.apt.web.annotation.param.PathVar;
21
import org.jfw.apt.web.annotation.param.RequestParam;
20
import org.jfw.apt.web.annotation.param.RequestParam;
22
import org.jfw.util.JpgUtil;
21
import org.jfw.util.JpgUtil;
23
import org.jfw.util.PageQueryResult;
22
import org.jfw.util.PageQueryResult;
24
import org.jfw.util.StringUtil;
23
import org.jfw.util.StringUtil;
24
import org.jfw.util.exception.JfwBaseException;
25
import org.jfw.util.io.IoUtil;
25
import org.jfw.util.io.IoUtil;
26

26

27
import java.io.*;
27
import java.io.*;
260

260

261
    @Post
261
    @Post
262
    @Path("/create")
262
    @Path("/create")
263
    public String insertOrg(@JdbcConn(true) Connection con,
264
                            @RequestParam(fields = {@FieldParam(value = "email", valueClass = String.class, required = true),
265
                                    @FieldParam(value = "inviterId", valueClass = String.class, required = true),
266
                                    @FieldParam(value = "name", valueClass = String.class, required = true),
267
                                    @FieldParam(value = "forShort", valueClass = String.class, required = true),
268
                                    @FieldParam(value = "province", valueClass = String.class, required = true),
269
                                    @FieldParam(value = "city", valueClass = String.class, required = true),
270
                                    @FieldParam(value = "foundTime", valueClass = String.class, required = false),
271
                                    @FieldParam(value = "descp", valueClass = String.class, required = false),
272
                                    @FieldParam(value = "orgType", valueClass = String.class, required = false),
273
                                    @FieldParam(value = "industry", valueClass = String.class, required = false),
274
                                    @FieldParam(value = "subject", valueClass = String.class, required = false),
275
                                    @FieldParam(value = "orgSize", valueClass = String.class, required = false),
276
                                    @FieldParam(value = "qualification", valueClass = String.class, required = false),
277
                                    @FieldParam(value = "orgUrl", valueClass = String.class, required = false)}) OrganizationInfo info,@Nullable String fn)
263
    public String insertOrg(@JdbcConn(true) Connection con, OrganizationInfo info,@Nullable String fn)
278
            throws SQLException,IOException {
264
            throws SQLException,IOException {
279
        String id = StringUtil.buildUUID();
265
        String id = StringUtil.buildUUID();
280
        OrgUser orgUser = new OrgUser();
266
        OrgUser orgUser = new OrgUser();
292
        return orgUser.getId();
278
        return orgUser.getId();
293
    }
279
    }
294

280

281
    @Path("/entryCheck")
282
    @Get
283
    public void entryCheck(@JdbcConn Connection con, String name, String email) throws SQLException, JfwBaseException {
284
        OrgUser orgUser = this.orgUserDao.entryCheck(con, email);
285
        if (orgUser != null) {
286
            throw new JfwBaseException(1, "该邮箱已被注册");
287
        }
288
        String orgId = this.orgDao.queryByName(con, name);
289
        if ((orgId != null) && (this.orgUserDao.query(con, orgId) != null)) {
290
            throw new JfwBaseException(2, "该企业已注册科袖账号");
291
        }
292
    }
293

294
    @Post
295
    @Path("/createAccount")
296
    public void createOrg(@JdbcConn(true) Connection con, String email,String name,@LoginUser ConsoleAuthUser user) throws SQLException, IOException, JfwBaseException {
297
        String orgId = this.orgDao.queryByName(con, name);
298
        if ((orgId != null) && (this.orgUserDao.query(con, orgId) != null)) {
299
            throw new JfwBaseException(2, "该企业已注册科袖账号");
300
        }
301
        String id = this.createOrganization(con, name);
302
        OrgUser orgUser = new OrgUser();
303
        orgUser.setId(id);
304
        orgUser.setEmail(email);
305
        orgUser.setInviterId(user.getId());
306
        orgUser.setPasswd(DEFAULT_PW_STR);
307
        orgUser.setUserType("1");
308
        this.orgUserDao.insert(con, orgUser);
309
    }
310

311
    @Get
312
    @Path("/queryAccount/{id}")
313
    public Account queryAccount(@JdbcConn Connection con,@PathVar String id)throws SQLException {
314
        Organization organization = this.orgDao.query(con, id);
315
        OrgUser orgUser = this.orgUserDao.query(con, id);
316
        Account account = new Account();
317
        if (orgUser!=null) {
318
            account.setEmail(orgUser.getEmail());
319
        }
320
        account.setName(organization.getName());
321
        account.setId(id);
322

323
        return account;
324
    }
325

326

327

328
    @Post
329
    @Path("/updateAccount")
330
    public void updateAccount(@JdbcConn(true) Connection con, String email, String name, String id) throws SQLException {
331
        this.orgUserDao.updateEmail(con, id, email);
332
        this.orgDao.updateOrgName(con, id, name);
333
    }
334

335

336

295
    @Post
337
    @Post
296
    @Path("/update")
338
    @Path("/update")
297
    public void update(@JdbcConn(true) Connection con, Organization orgn,@Nullable String fn) throws SQLException, IOException {
298
        if(fn != null){
339
    public void update(@JdbcConn(true) Connection con, Organization orgn, @Nullable String fn) throws SQLException, IOException {
340
        if (fn != null) {
299
            this.saveOrgLogo(orgn.getId(), fn);
341
            this.saveOrgLogo(orgn.getId(), fn);
300
        }
342
        }
301
        this.orgDao.update(con, orgn);
343
        this.orgDao.update(con, orgn);
303

345

304
    @Get
346
    @Get
305
    @Path("/pq")
347
    @Path("/pq")
306
    public PageQueryResult<OrganizationInfo> pageQuery(@JdbcConn Connection con, @LoginUser ConsoleAuthUser cau, @Nullable @Like String name, @Nullable @Like String industry, @Nullable @Like String subject, @Nullable @Like String city, @DefaultValue("1") int pageNo, @DefaultValue("10") int pageSize) throws SQLException {
307
        String cName = null;
308
        if (name != null) {
309
            cName = "%" + name + "%";
310
        }
311
        String cIndustry = null;
312
        if (industry != null) {
313
            cIndustry = "%" + industry + "%";
314
        }
315
        String cSubject = null;
316
        if (subject != null) {
317
            cSubject = "%" + subject + "%";
318
        }
319
        String cCity = null;
320
        if (city != null) {
321
            cCity = "%" + city + "%";
348
    public PageQueryResult<OrganizationInfo> pageQuery(@JdbcConn Connection con, @Nullable @Like String name, @Nullable @Like String industry, @Nullable @Like String subject, @Nullable @Like String city,@Nullable String authStatus,int orderBy, @Nullable String bt, @Nullable String et,  @DefaultValue("1") int pageNo, @DefaultValue("10") int pageSize) throws SQLException {
349
        if (orderBy == 1) {
350
            return this.orgDao.queryTime(con, name == null ? null : "%" + name + "%", industry == null ? null : "%" + industry + "%", subject == null ? null : "%" + subject + "%", city == null ? null : "%" + city + "%", authStatus, bt == null ? null : bt + "000000", et == null ? null : et + "235959", pageSize, pageNo);
351
        }else{
352
            return this.orgDao.queryViews(con, name == null ? null : "%" + name + "%", industry == null ? null : "%" + industry + "%", subject == null ? null : "%" + subject + "%", city == null ? null : "%" + city + "%", authStatus, bt == null ? null : bt + "000000", et == null ? null : et + "235959", pageSize, pageNo);
322
        }
353
        }
323
        return this.orgDao.query(con,cau.getId(), cName, cIndustry, cSubject, cCity, pageSize, pageNo);
324
    }
354
    }
325

355

326
    @Get
356
    @Get
327
    @Path("/id/{id}")
357
    @Path("/id/{id}")
328
    public OrganizationInfo query(@JdbcConn Connection con, @PathVar String id) throws SQLException {
329
        OrganizationInfo organizationInfo = this.orgDao.query(con, id);
330
        if (organizationInfo != null) {
331
            organizationInfo.setHasOrgLogo(this.hasOrgLogo(organizationInfo.getId()));
332
        }
333
        return organizationInfo;
358
    public Organization query(@JdbcConn Connection con, @PathVar String id) throws SQLException {
359
        return this.orgDao.query(con, id);
334
    }
360
    }
335

361

336
    @Delete
362
    @Delete
369
        return id;
395
        return id;
370
    }
396
    }
371

397

398
    public static class Account{
399
        private String id;
400
        private String email;
401
        private String name;
402

403
        public String getId() {
404
            return id;
405
        }
406

407
        public void setId(String id) {
408
            this.id = id;
409
        }
410

411
        public String getEmail() {
412
            return email;
413
        }
414

415
        public void setEmail(String email) {
416
            this.email = email;
417
        }
418

419
        public String getName() {
420
            return name;
421
        }
422

423
        public void setName(String name) {
424
            this.name = name;
425
        }
426

427
    }
428

372

429

373
}
430
}

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

170
170
171
    @Path("/pqAll")
171
    @Path("/pqAll")
172
    @Get
172
    @Get
173
    PageQueryResult<UserInfo> pageQueryAll(@JdbcConn Connection con, @Nullable String name, @Nullable String orgName, @Nullable String state, @Nullable String bt, @Nullable String et, @DefaultValue("1") int pageNo, @DefaultValue("10") int pageSize) throws SQLException {
174
        return this.userInfoDao.queryAll(con, name == null ? null : "%" + name + "%", orgName == null ? null : "%" + orgName + "%", state, bt == null ? null : bt + "000000", et == null ? null : et + "235959", pageSize, pageNo);
173
    PageQueryResult<UserInfo> pageQueryAll(@JdbcConn Connection con,@Nullable String creatorName, @Nullable String name, @Nullable String orgName, @Nullable String state, @Nullable String bt, @Nullable String et, @DefaultValue("1") int pageNo, @DefaultValue("10") int pageSize) throws SQLException {
174
        return this.userInfoDao.queryAll(con, creatorName == null ? null : "%" + creatorName + "%",name == null ? null : "%" + name + "%", orgName == null ? null : "%" + orgName + "%", state, bt == null ? null : bt + "000000", et == null ? null : et + "235959", pageSize, pageNo);
175
    }
175
    }
176
176
177
    @Path("/entryCheck")
177
    @Path("/entryCheck")