Authored by zhaoyue

Merge branch 'zhaoyue-dev' into 'master'

Zhaoyue dev



See merge request !16
git add --all src/*
git add push.sh
git add pom.xml
git commit -m "Add login and mod pwd"
git commit -m "Add admin info inter"
git push origin zhaoyue-dev
git status
git pull
... ...
... ... @@ -28,9 +28,12 @@ public enum ResultStatus {
REPORT_INVALID__ERROR(-11142,"报告在数据库中不存在/Report is not exist in the DB"),
INVALID_USER_ERROR(-11150,"报告所属用户未注册/Report user's account is not exist"),
INVALID_ADMIN_RPDEL_ERROR(-11151,"报告非此操作员创建,无权删除!/Operator can not delete this report"),
INVALID_ADMIN_RPDEL_ERROR(-11151,"报告非此操作员创建,无权删除!/Operator can not delete the report which is not create by him"),
DB_ERROR(-11160,"服务器错误,无法写入数据库/Server error, can not write into database"),
COMPANY_ERROR(-11170,"用户所属公司信息有误/Company infomation error");
DB_ERROR(-11160,"服务器错误,无法写入数据库/Server error, can not write into database");
... ...
package com.xkl.controller.uploadsoft;
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.authorization.manager.ITokenManager;
import com.xkl.config.Constants;
import com.xkl.config.ResultStatus;
import com.xkl.domain.User;
import com.xkl.domain.XklAdminEntity;
import com.xkl.domain.XklCompanyEntity;
import com.xkl.domain.XklMemberEntity;
import com.xkl.model.AdminInfoModel;
import com.xkl.model.ResultModel;
import com.xkl.repository.AdminRepository;
import com.xkl.repository.UserRepository;
import com.xkl.repository.XklCompanyRepository;
import com.xkl.repository.XklMemberRespository;
import com.xkl.security.AntiXSS;
import com.xkl.security.SecurityTool;
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;
/**
* 操作员信息查询接口
*/
@RestController
@RequestMapping("/adminInfo")
public class AdminInfoController {
@Autowired
private XklCompanyRepository xklCompanyRepository;
@RequestMapping(method = RequestMethod.GET)
@Authorization
@ApiOperation(value = "操作员信息查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"),
})
public ResponseEntity<ResultModel> getAdminInfo(@CurrentAdmin XklAdminEntity admin) {
XklCompanyEntity companyEntity = xklCompanyRepository.findById(admin.getCoid());
if(companyEntity==null){
return new ResponseEntity<>(ResultModel.error(ResultStatus.COMPANY_ERROR),HttpStatus.OK);
}
AdminInfoModel adminInfoModel = new AdminInfoModel(admin.getId(), admin.getAccount(), companyEntity.getId(), companyEntity.getName());
return new ResponseEntity<>(ResultModel.ok(adminInfoModel), HttpStatus.OK);
}
}
... ...
package com.xkl.domain;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* 公司数据的domain类
*/
@Entity
@Table(name = "xkl_company")
public class XklCompanyEntity {
//公司id
@Id
@Column(name = "id")
private long id;
@Column(name = "name")
private String name;
@Column(name = "parent_id")
private long parentId;
@Column(name = "province_id")
private long provinceId;
@Column(name = "city_id")
private long cityId;
@Column(name = "country_id")
private long countryId;
@Column(name = "company_code")
private long companyCode;
@Column(name = "company_type")
private int companyType;
@Column(name = "level")
private int level;
@Column(name = "show_level")
private int showLevel;
@Column(name = "status")
private int status;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public long getParentId() {
return parentId;
}
public void setParentId(long parentId) {
this.parentId = parentId;
}
public long getProvinceId() {
return provinceId;
}
public void setProvinceId(long provinceId) {
this.provinceId = provinceId;
}
public long getCityId() {
return cityId;
}
public void setCityId(long cityId) {
this.cityId = cityId;
}
public long getCountryId() {
return countryId;
}
public void setCountryId(long countryId) {
this.countryId = countryId;
}
public long getCompanyCode() {
return companyCode;
}
public void setCompanyCode(long companyCode) {
this.companyCode = companyCode;
}
public int getCompanyType() {
return companyType;
}
public void setCompanyType(int companyType) {
this.companyType = companyType;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public int getShowLevel() {
return showLevel;
}
public void setShowLevel(int showLevel) {
this.showLevel = showLevel;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}
... ...
package com.xkl.model;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* 管理员信息
*/
@Data
public class AdminInfoModel {
public long adminId;
public String adminAccount;
public long comId;
public String comName;
public AdminInfoModel(long adminId, String adminAccount, long comId, String comName) {
this.adminId = adminId;
this.adminAccount = adminAccount;
this.comId = comId;
this.comName = comName;
}
public long getAdminId() {
return adminId;
}
public void setAdminId(long adminId) {
this.adminId = adminId;
}
public String getAdminAccount() {
return adminAccount;
}
public void setAdminAccount(String adminAccount) {
this.adminAccount = adminAccount;
}
public long getComId() {
return comId;
}
public void setComId(long comId) {
this.comId = comId;
}
public String getComName() {
return comName;
}
public void setComName(String comName) {
this.comName = comName;
}
}
... ...
package com.xkl.repository;
import com.xkl.domain.XklAmpReportEntity;
import com.xkl.domain.XklCompanyEntity;
import org.springframework.data.repository.CrudRepository;
/**
* XklCompany类的CRUD操作
*
* @see XklCompanyEntity
*/
public interface XklCompanyRepository extends CrudRepository<XklCompanyEntity, Long> {
public XklCompanyEntity findById(long id);
}
... ...