AdminOpsLogController.java 3.03 KB
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);
    }
}