Merge branch 'zhaoyue-dev4' into 'master'
ADD admin log interface See merge request !42
Showing
9 changed files
with
224 additions
and
2 deletions
@@ -2,7 +2,7 @@ git pull | @@ -2,7 +2,7 @@ git pull | ||
2 | git add --all src/main/java/* | 2 | git add --all src/main/java/* |
3 | git add push.sh | 3 | git add push.sh |
4 | git add pom.xml | 4 | git add pom.xml |
5 | -git commit -m "MOD add role_id limit" | 5 | +git commit -m "ADD admin log interface" |
6 | #git push origin master | 6 | #git push origin master |
7 | git push origin zhaoyue-dev4 | 7 | git push origin zhaoyue-dev4 |
8 | git status | 8 | git status |
@@ -77,6 +77,13 @@ public interface Constants { | @@ -77,6 +77,13 @@ public interface Constants { | ||
77 | */ | 77 | */ |
78 | String ADMIN_TOKEN_PREFIX = "ADMINTOKENPREFIX"; | 78 | String ADMIN_TOKEN_PREFIX = "ADMINTOKENPREFIX"; |
79 | 79 | ||
80 | + /** | ||
81 | + * 操作员操作类型,0 新用户注册;1 体检; 2 老用户引导; 3 问诊; | ||
82 | + */ | ||
83 | + public static final int OP_NEWUSER_REGISTER = 0; | ||
84 | + public static final int OP_HELTH_EXAM = 1; | ||
85 | + public static final int OP_OLDUSER_GUIDE = 2; | ||
86 | + public static final int OP_NEWUSER_DIAGNOSE = 3; | ||
80 | 87 | ||
81 | public static final int MALE = 0; | 88 | public static final int MALE = 0; |
82 | public static final int FEMALE = 1; | 89 | public static final int FEMALE = 1; |
@@ -35,7 +35,10 @@ public enum ResultStatus { | @@ -35,7 +35,10 @@ public enum ResultStatus { | ||
35 | COMPANY_ERROR(-11170,"用户所属公司信息有误/Company information error"), | 35 | COMPANY_ERROR(-11170,"用户所属公司信息有误/Company information error"), |
36 | 36 | ||
37 | // 112开头的与QR Code有关 | 37 | // 112开头的与QR Code有关 |
38 | - INVALID_QR_CODE(-11201,"无效QR码/Invalid QR code"); | 38 | + INVALID_QR_CODE(-11201,"无效QR码/Invalid QR code"), |
39 | + | ||
40 | + // 113开头的与操作统计有关 | ||
41 | + INVALID_OPERATION_CODE(-11301,"无效操作/Invalid operation"); | ||
39 | 42 | ||
40 | 43 | ||
41 | 44 |
1 | +package com.xkl.controller; | ||
2 | + | ||
3 | +import com.wordnik.swagger.annotations.ApiImplicitParam; | ||
4 | +import com.wordnik.swagger.annotations.ApiImplicitParams; | ||
5 | +import com.wordnik.swagger.annotations.ApiOperation; | ||
6 | +import com.xkl.authorization.annotation.*; | ||
7 | +import com.xkl.config.Constants; | ||
8 | +import com.xkl.config.ResultStatus; | ||
9 | +import com.xkl.domain.User; | ||
10 | +import com.xkl.domain.XklAdminEntity; | ||
11 | +import com.xkl.domain.XklMemberEntity; | ||
12 | +import com.xkl.domain.XklMemberOpenidEntity; | ||
13 | +import com.xkl.model.QrCodeModel; | ||
14 | +import com.xkl.model.ResultModel; | ||
15 | +import com.xkl.model.UsrInfoModel; | ||
16 | +import com.xkl.repository.UserRepository; | ||
17 | +import com.xkl.repository.XklMemberOpenidRespository; | ||
18 | +import com.xkl.repository.XklMemberRespository; | ||
19 | +import com.xkl.security.AntiXSS; | ||
20 | +import com.xkl.service.IAdminOpsService; | ||
21 | +import com.xkl.service.ILoginService; | ||
22 | +import com.xkl.service.IQRCodeService; | ||
23 | +import com.xkl.service.QRCodeServiceImpl; | ||
24 | +import com.xkl.tools.DESTools; | ||
25 | +import com.xkl.tools.DatetimeTools; | ||
26 | +import com.xkl.tools.HttpTools; | ||
27 | +import org.springframework.beans.factory.annotation.Autowired; | ||
28 | +import org.springframework.http.HttpStatus; | ||
29 | +import org.springframework.http.ResponseEntity; | ||
30 | +import org.springframework.util.Assert; | ||
31 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
32 | +import org.springframework.web.bind.annotation.RequestMethod; | ||
33 | +import org.springframework.web.bind.annotation.RequestParam; | ||
34 | +import org.springframework.web.bind.annotation.RestController; | ||
35 | + | ||
36 | +import javax.servlet.http.HttpServletRequest; | ||
37 | +import java.net.URLEncoder; | ||
38 | +import java.text.SimpleDateFormat; | ||
39 | +import java.util.Date; | ||
40 | + | ||
41 | +/** | ||
42 | + * Created by zhaoyue on 2017/04/04. | ||
43 | + */ | ||
44 | +@RestController | ||
45 | +@RequestMapping("/adminOpLog") | ||
46 | +public class AdminOpsLogController { | ||
47 | + @Autowired | ||
48 | + private IAdminOpsService adminOpsService; | ||
49 | + | ||
50 | + @Autowired | ||
51 | + private UserRepository userRepository; | ||
52 | + | ||
53 | + @LogAnnotation | ||
54 | + @AntiXSS | ||
55 | + @Authorization | ||
56 | + @Sign | ||
57 | + @RequestMapping(method = RequestMethod.POST) | ||
58 | + @ApiOperation(value = "admin 操作日志接口") | ||
59 | + public ResponseEntity<ResultModel> register(HttpServletRequest request, @CurrentAdmin XklAdminEntity admin, @RequestParam String username, | ||
60 | + @RequestParam int operation, @RequestParam String sign, @RequestParam long t, @RequestParam int type) { | ||
61 | + if (!(boolean) request.getAttribute("signAspect")) | ||
62 | + return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK); | ||
63 | + User user = userRepository.findByLoginAccountAndStatus(username, Constants.STATUS_OK2); | ||
64 | + if (user == null) { //用户不存在 | ||
65 | + return new ResponseEntity<>(ResultModel.error(ResultStatus.USER_NOT_FOUND), HttpStatus.OK); | ||
66 | + } | ||
67 | + // 0 新用户注册;1 体检; 2 老用户引导; 3 问诊; | ||
68 | + if (operation < 0 || operation > 3) { | ||
69 | + return new ResponseEntity<>(ResultModel.error(ResultStatus.INVALID_OPERATION_CODE), HttpStatus.OK); | ||
70 | + } | ||
71 | + adminOpsService.addOperation(admin.getId(), user.getMemberId(), operation); | ||
72 | + return new ResponseEntity<>(ResultModel.ok(), HttpStatus.OK); | ||
73 | + } | ||
74 | +} |
@@ -21,6 +21,7 @@ import com.xkl.repository.UserRepository; | @@ -21,6 +21,7 @@ import com.xkl.repository.UserRepository; | ||
21 | import com.xkl.repository.XklMemberOpenidRespository; | 21 | import com.xkl.repository.XklMemberOpenidRespository; |
22 | import com.xkl.repository.XklMemberRespository; | 22 | import com.xkl.repository.XklMemberRespository; |
23 | import com.xkl.security.AntiXSS; | 23 | import com.xkl.security.AntiXSS; |
24 | +import com.xkl.service.IAdminOpsService; | ||
24 | import com.xkl.service.ILoginService; | 25 | import com.xkl.service.ILoginService; |
25 | import com.xkl.service.IQRCodeService; | 26 | import com.xkl.service.IQRCodeService; |
26 | import com.xkl.service.QRCodeServiceImpl; | 27 | import com.xkl.service.QRCodeServiceImpl; |
@@ -58,6 +59,7 @@ public class QRCodeController { | @@ -58,6 +59,7 @@ public class QRCodeController { | ||
58 | @Autowired | 59 | @Autowired |
59 | private XklMemberRespository xklMemberRespository; | 60 | private XklMemberRespository xklMemberRespository; |
60 | 61 | ||
62 | + | ||
61 | private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//小写的mm表示的是分钟 | 63 | private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//小写的mm表示的是分钟 |
62 | 64 | ||
63 | @LogAnnotation | 65 | @LogAnnotation |
1 | +package com.xkl.domain; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | + | ||
5 | +import javax.persistence.*; | ||
6 | +import java.sql.Timestamp; | ||
7 | + | ||
8 | +/** | ||
9 | + * @author zhaoyue | ||
10 | + */ | ||
11 | +@Data | ||
12 | +@Entity | ||
13 | +@Table(name = "xkl_admin_ops") | ||
14 | +public class XklAdminOpsEntity { | ||
15 | + @Id | ||
16 | + @Column(name = "id") | ||
17 | + @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
18 | + private long id; | ||
19 | + @Basic | ||
20 | + @Column(name = "admin_id") | ||
21 | + private long adminId; | ||
22 | + @Basic | ||
23 | + @Column(name = "member_id") | ||
24 | + private long memberId; | ||
25 | + @Basic | ||
26 | + @Column(name = "time") | ||
27 | + private Timestamp time;// 操作时间 | ||
28 | + @Basic | ||
29 | + @Column(name = "operation") | ||
30 | + private int operation;// 操作。0 新用户注册;1 体检; 2 老用户引导; 3 问诊; | ||
31 | + | ||
32 | + public XklAdminOpsEntity(long adminId, long memberId, int operation) { | ||
33 | + this.adminId = adminId; | ||
34 | + this.memberId = memberId; | ||
35 | + this.operation = operation; | ||
36 | + this.time = new Timestamp(System.currentTimeMillis()); | ||
37 | + } | ||
38 | + | ||
39 | + public long getId() { | ||
40 | + return id; | ||
41 | + } | ||
42 | + | ||
43 | + public void setId(long id) { | ||
44 | + this.id = id; | ||
45 | + } | ||
46 | + | ||
47 | + public long getAdminId() { | ||
48 | + return adminId; | ||
49 | + } | ||
50 | + | ||
51 | + public void setAdminId(long adminId) { | ||
52 | + this.adminId = adminId; | ||
53 | + } | ||
54 | + | ||
55 | + public long getMemberId() { | ||
56 | + return memberId; | ||
57 | + } | ||
58 | + | ||
59 | + public void setMemberId(long memberId) { | ||
60 | + this.memberId = memberId; | ||
61 | + } | ||
62 | + | ||
63 | + public Timestamp getTime() { | ||
64 | + return time; | ||
65 | + } | ||
66 | + | ||
67 | + public void setTime(Timestamp time) { | ||
68 | + this.time = time; | ||
69 | + } | ||
70 | + | ||
71 | + public int getOperation() { | ||
72 | + return operation; | ||
73 | + } | ||
74 | + | ||
75 | + public void setOperation(int operation) { | ||
76 | + this.operation = operation; | ||
77 | + } | ||
78 | +} |
1 | +package com.xkl.repository; | ||
2 | + | ||
3 | +import com.xkl.domain.XklAdminOpsEntity; | ||
4 | +import com.xkl.domain.XklAmpReportDetailEntity; | ||
5 | +import org.springframework.data.repository.CrudRepository; | ||
6 | + | ||
7 | +import java.util.List; | ||
8 | + | ||
9 | +/** | ||
10 | + * XklAdminOpsEntity 类的CRUD操作 | ||
11 | + * | ||
12 | + * @see XklAdminOpsEntity | ||
13 | + */ | ||
14 | +public interface AdminOpsRepository extends CrudRepository<XklAdminOpsEntity, Long> { | ||
15 | +} |
1 | +package com.xkl.service; | ||
2 | + | ||
3 | +import com.xkl.config.Constants; | ||
4 | +import com.xkl.domain.XklAdminOpsEntity; | ||
5 | +import com.xkl.repository.AdminOpsRepository; | ||
6 | +import com.xkl.repository.ReportDetailRepository; | ||
7 | +import com.xkl.tools.DESTools; | ||
8 | +import lombok.extern.apachecommons.CommonsLog; | ||
9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
10 | +import org.springframework.data.redis.core.RedisTemplate; | ||
11 | +import org.springframework.stereotype.Service; | ||
12 | + | ||
13 | +import java.text.SimpleDateFormat; | ||
14 | +import java.util.Date; | ||
15 | +import java.util.concurrent.TimeUnit; | ||
16 | + | ||
17 | +/** | ||
18 | + * create by zhaoyue | ||
19 | + * 2017-03-11 | ||
20 | + */ | ||
21 | + | ||
22 | +@Service | ||
23 | +@CommonsLog | ||
24 | +public class AdminOpsServiceImpl implements IAdminOpsService, Constants { | ||
25 | + @Autowired | ||
26 | + private AdminOpsRepository adminOpsRepository; | ||
27 | + | ||
28 | + @Override | ||
29 | + public void addOperation(long adminId, long memberId, int operation) { | ||
30 | + XklAdminOpsEntity xklAdminOpsEntity = new XklAdminOpsEntity(adminId, memberId, operation); | ||
31 | + adminOpsRepository.save(xklAdminOpsEntity); | ||
32 | + } | ||
33 | + | ||
34 | + | ||
35 | +} |
-
Please register or login to post a comment