Authored by zhaoyue

ADD admin log interface

... ... @@ -2,7 +2,7 @@ git pull
git add --all src/main/java/*
git add push.sh
git add pom.xml
git commit -m "MOD add role_id limit"
git commit -m "ADD admin log interface"
#git push origin master
git push origin zhaoyue-dev4
git status
... ...
... ... @@ -77,6 +77,13 @@ public interface Constants {
*/
String ADMIN_TOKEN_PREFIX = "ADMINTOKENPREFIX";
/**
* 操作员操作类型
*/
public static final int OP_NEWUSER_REGISTER = 0;
public static final int OP_HELTH_EXAM = 1;
public static final int OP_OLDUSER_GUIDE = 2;
public static final int OP_NEWUSER_DIAGNOSE = 3;
public static final int MALE = 0;
public static final int FEMALE = 1;
... ...
... ... @@ -35,7 +35,10 @@ public enum ResultStatus {
COMPANY_ERROR(-11170,"用户所属公司信息有误/Company information error"),
// 112开头的与QR Code有关
INVALID_QR_CODE(-11201,"无效QR码/Invalid QR code");
INVALID_QR_CODE(-11201,"无效QR码/Invalid QR code"),
// 113开头的与操作统计有关
INVALID_OPERATION_CODE(-11301,"无效操作/Invalid operation");
... ...
package com.xkl.controller;
import com.wordnik.swagger.annotations.ApiImplicitParam;
import com.wordnik.swagger.annotations.ApiImplicitParams;
import com.wordnik.swagger.annotations.ApiOperation;
import com.xkl.authorization.annotation.*;
import com.xkl.config.Constants;
import com.xkl.config.ResultStatus;
import com.xkl.domain.User;
import com.xkl.domain.XklAdminEntity;
import com.xkl.domain.XklMemberEntity;
import com.xkl.domain.XklMemberOpenidEntity;
import com.xkl.model.QrCodeModel;
import com.xkl.model.ResultModel;
import com.xkl.model.UsrInfoModel;
import com.xkl.repository.UserRepository;
import com.xkl.repository.XklMemberOpenidRespository;
import com.xkl.repository.XklMemberRespository;
import com.xkl.security.AntiXSS;
import com.xkl.service.IAdminOpsService;
import com.xkl.service.ILoginService;
import com.xkl.service.IQRCodeService;
import com.xkl.service.QRCodeServiceImpl;
import com.xkl.tools.DESTools;
import com.xkl.tools.DatetimeTools;
import com.xkl.tools.HttpTools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Created by zhaoyue on 2017/04/04.
*/
@RestController
@RequestMapping("/adminOpLog")
public class AdminOpsLogController {
@Autowired
private IAdminOpsService adminOpsService;
@Autowired
private UserRepository userRepository;
@LogAnnotation
@AntiXSS
@Authorization
@Sign
@RequestMapping(method = RequestMethod.POST)
@ApiOperation(value = "admin 操作日志接口")
public ResponseEntity<ResultModel> register(HttpServletRequest request, @CurrentAdmin XklAdminEntity admin, @RequestParam String username,
@RequestParam int operation, @RequestParam String sign, @RequestParam long t, @RequestParam int type) {
if (!(boolean) request.getAttribute("signAspect"))
return new ResponseEntity<>(ResultModel.error(ResultStatus.SIGN_ERROR), HttpStatus.OK);
User user = userRepository.findByLoginAccountAndStatus(username, Constants.STATUS_OK2);
if (user == null) { //用户不存在
return new ResponseEntity<>(ResultModel.error(ResultStatus.USER_NOT_FOUND), HttpStatus.OK);
}
// 0 新用户注册;1 体检; 2 老用户引导; 3 问诊;
if (operation < 0 || operation > 3) {
return new ResponseEntity<>(ResultModel.error(ResultStatus.INVALID_OPERATION_CODE), HttpStatus.OK);
}
adminOpsService.addOperation(admin.getId(), user.getMemberId(), operation);
return new ResponseEntity<>(ResultModel.ok(), HttpStatus.OK);
}
}
\ No newline at end of file
... ...
... ... @@ -21,6 +21,7 @@ import com.xkl.repository.UserRepository;
import com.xkl.repository.XklMemberOpenidRespository;
import com.xkl.repository.XklMemberRespository;
import com.xkl.security.AntiXSS;
import com.xkl.service.IAdminOpsService;
import com.xkl.service.ILoginService;
import com.xkl.service.IQRCodeService;
import com.xkl.service.QRCodeServiceImpl;
... ... @@ -58,6 +59,7 @@ public class QRCodeController {
@Autowired
private XklMemberRespository xklMemberRespository;
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//小写的mm表示的是分钟
@LogAnnotation
... ...
package com.xkl.domain;
import lombok.Data;
import javax.persistence.*;
import java.sql.Timestamp;
/**
* @author zhaoyue
*/
@Data
@Entity
@Table(name = "xkl_admin_ops")
public class XklAdminOpsEntity {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Basic
@Column(name = "admin_id")
private long adminId;
@Basic
@Column(name = "member_id")
private long memberId;
@Basic
@Column(name = "time")
private Timestamp time;// 操作时间
@Basic
@Column(name = "operation")
private int operation;// 操作。0 新用户注册;1 体检; 2 老用户引导; 3 问诊;
public XklAdminOpsEntity(long adminId, long memberId, int operation) {
this.adminId = adminId;
this.memberId = memberId;
this.operation = operation;
this.time = new Timestamp(System.currentTimeMillis());
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getAdminId() {
return adminId;
}
public void setAdminId(long adminId) {
this.adminId = adminId;
}
public long getMemberId() {
return memberId;
}
public void setMemberId(long memberId) {
this.memberId = memberId;
}
public Timestamp getTime() {
return time;
}
public void setTime(Timestamp time) {
this.time = time;
}
public int getOperation() {
return operation;
}
public void setOperation(int operation) {
this.operation = operation;
}
}
... ...
package com.xkl.repository;
import com.xkl.domain.XklAdminOpsEntity;
import com.xkl.domain.XklAmpReportDetailEntity;
import org.springframework.data.repository.CrudRepository;
import java.util.List;
/**
* XklAdminOpsEntity 类的CRUD操作
*
* @see XklAdminOpsEntity
*/
public interface AdminOpsRepository extends CrudRepository<XklAdminOpsEntity, Long> {
}
... ...
package com.xkl.service;
import com.xkl.config.Constants;
import com.xkl.domain.XklAdminOpsEntity;
import com.xkl.repository.AdminOpsRepository;
import com.xkl.repository.ReportDetailRepository;
import com.xkl.tools.DESTools;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;
/**
* create by zhaoyue
* 2017-03-11
*/
@Service
@CommonsLog
public class AdminOpsServiceImpl implements IAdminOpsService, Constants {
@Autowired
private AdminOpsRepository adminOpsRepository;
@Override
public void addOperation(long adminId, long memberId, int operation) {
XklAdminOpsEntity xklAdminOpsEntity = new XklAdminOpsEntity(adminId, memberId, operation);
adminOpsRepository.save(xklAdminOpsEntity);
}
}
... ...
package com.xkl.service;
/**
* Created by zhaoyue on 2017/4/4.
*/
public interface IAdminOpsService {
public void addOperation(long adminId, long memberId, int operation);
}
\ No newline at end of file
... ...