New file |
| | |
| | | package com.zy.asrs.common.sys.controller; |
| | | |
| | | import com.zy.asrs.common.sys.service.HostService; |
| | | import com.zy.asrs.common.web.BaseController; |
| | | import com.zy.asrs.framework.common.R; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | @RestController |
| | | public class HostController extends BaseController { |
| | | |
| | | @Autowired |
| | | private HostService hostService; |
| | | |
| | | @RequestMapping(value = "/host/{id}/auth") |
| | | // @ManagerAuth |
| | | public R get(@PathVariable("id") Long id) { |
| | | return R.ok(hostService.getById(String.valueOf(id))); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.zy.asrs.common.sys.entity.Config; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface ConfigMapper extends BaseMapper<Config> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.zy.asrs.common.sys.entity.Host; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface HostMapper extends BaseMapper<Host> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.zy.asrs.common.sys.entity.OperateLog; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.annotations.Select; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface OperateLogMapper extends BaseMapper<OperateLog> { |
| | | |
| | | @Select("select count(1) from sys_operate_log where yearweek(date_format(create_time,'%Y-%m-%d')) = yearweek(now());") |
| | | int selectCountByCurrentWeek(); |
| | | |
| | | @Select("select MONTH(create_time) as node , count(1) as val from sys_operate_log where 1 = 1 and year(create_time) = #{year} group by MONTH(create_time)") |
| | | List<Map<String, Object>> getReportByYear(@Param("year") Integer year); |
| | | |
| | | @Select("select DAYOFMONTH(create_time) as node,count(1) as val from sys_operate_log where 1 = 1 and year(create_time) = #{year} and month(create_time) = #{month} group by DAYOFMONTH(create_time)") |
| | | List<Map<String, Object>> getReportByMonth(@Param("year") Integer year, @Param("month") Integer month); |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.zy.asrs.common.sys.entity.Resource; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface ResourceMapper extends BaseMapper<Resource> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.zy.asrs.common.sys.entity.Role; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface RoleMapper extends BaseMapper<Role> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.zy.asrs.common.sys.entity.Resource; |
| | | import com.zy.asrs.common.sys.entity.RoleResource; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.annotations.Select; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface RoleResourceMapper extends BaseMapper<RoleResource> { |
| | | |
| | | @Select("select sr.* from sys_resource sr left join sys_role_resource srr on srr.resource_id = sr.id left join sys_user su on su.role_id = srr.role_id where 1 = 1 and su.id = #{userId} and sr. level = 3 and sr.resource_id = #{fatherResourceId} and sr. status = 1 order by sr.sort") |
| | | List<Resource> getMenuButtomResource(@Param("fatherResourceId") Long fatherResourceId, @Param("userId") Long userId); |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.zy.asrs.common.sys.entity.UserLogin; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Select; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface UserLoginMapper extends BaseMapper<UserLogin> { |
| | | |
| | | @Select("select count(1) from sys_user_login where yearweek(date_format(create_time,'%Y-%m-%d')) = yearweek(now())") |
| | | int selectCountByCurrentWeek(); |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.zy.asrs.common.sys.entity.User; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface UserMapper extends BaseMapper<User> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.entity; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @TableName("sys_config") |
| | | public class Config implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 编号 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 名称 |
| | | */ |
| | | private String name; |
| | | |
| | | /** |
| | | * 编码 |
| | | */ |
| | | private String code; |
| | | |
| | | /** |
| | | * 对应值 |
| | | */ |
| | | private String value; |
| | | |
| | | /** |
| | | * 类型 1: String 2: JSON |
| | | */ |
| | | private Short type; |
| | | |
| | | /** |
| | | * 状态 1: 正常 0: 禁用 |
| | | */ |
| | | private Short status; |
| | | |
| | | public Config() {} |
| | | |
| | | public Config(String name,String code,String value,Short type,Short status) { |
| | | this.name = name; |
| | | this.code = code; |
| | | this.value = value; |
| | | this.type = type; |
| | | this.status = status; |
| | | } |
| | | |
| | | |
| | | public String getType$(){ |
| | | if (null == this.type){ return null; } |
| | | switch (this.type){ |
| | | case 1: |
| | | return "String"; |
| | | case 2: |
| | | return "JSON"; |
| | | default: |
| | | return String.valueOf(this.type); |
| | | } |
| | | } |
| | | |
| | | public String getStatus$(){ |
| | | if (null == this.status){ return null; } |
| | | switch (this.status){ |
| | | case 1: |
| | | return "正常"; |
| | | case 0: |
| | | return "禁用"; |
| | | default: |
| | | return String.valueOf(this.status); |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.entity; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @TableName("sys_host") |
| | | public class Host implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 编号 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 商户名称 |
| | | */ |
| | | private String name; |
| | | |
| | | /** |
| | | * 标识 |
| | | */ |
| | | private String flag; |
| | | |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 修改时间 |
| | | */ |
| | | private Date updateTime; |
| | | |
| | | /** |
| | | * 状态 1: 正常 0: 禁用 |
| | | */ |
| | | private Integer status; |
| | | |
| | | public Host() {} |
| | | |
| | | public Host(String name,String flag,Date createTime,Date updateTime,Integer status) { |
| | | this.name = name; |
| | | this.flag = flag; |
| | | this.createTime = createTime; |
| | | this.updateTime = updateTime; |
| | | this.status = status; |
| | | } |
| | | |
| | | // Host host = new Host( |
| | | // null, // 商户名称[非空] |
| | | // null, // 标识[非空] |
| | | // null, // 添加时间[非空] |
| | | // null, // 修改时间 |
| | | // null // 状态[非空] |
| | | // ); |
| | | |
| | | |
| | | public String getCreateTime$(){ |
| | | if (Cools.isEmpty(this.createTime)){ |
| | | return ""; |
| | | } |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.createTime); |
| | | } |
| | | |
| | | public Date getUpdateTime() { |
| | | return updateTime; |
| | | } |
| | | |
| | | public String getUpdateTime$(){ |
| | | if (Cools.isEmpty(this.updateTime)){ |
| | | return ""; |
| | | } |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.updateTime); |
| | | } |
| | | |
| | | public String getStatus$(){ |
| | | if (null == this.status){ return null; } |
| | | switch (this.status){ |
| | | case 1: |
| | | return "正常"; |
| | | case 0: |
| | | return "禁用"; |
| | | default: |
| | | return String.valueOf(this.status); |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.zy.asrs.common.sys.service.UserService; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @TableName("sys_operate_log") |
| | | public class OperateLog implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 编号 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 访问地址 |
| | | */ |
| | | private String action; |
| | | |
| | | /** |
| | | * 用户 |
| | | */ |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 客户端IP |
| | | */ |
| | | private String ip; |
| | | |
| | | /** |
| | | * 请求数据 |
| | | */ |
| | | private String request; |
| | | |
| | | /** |
| | | * 响应数据 |
| | | */ |
| | | private String response; |
| | | |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | public String getUserId$(){ |
| | | UserService service = SpringUtils.getBean(UserService.class); |
| | | User user = service.getById(this.userId); |
| | | if (!Cools.isEmpty(user)){ |
| | | return user.getUsername(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getCreateTime$(){ |
| | | if (Cools.isEmpty(this.createTime)){ |
| | | return ""; |
| | | } |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.createTime); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.zy.asrs.common.sys.service.ResourceService; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @TableName("sys_resource") |
| | | public class Resource implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 编号 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 菜单编码 |
| | | */ |
| | | private String code; |
| | | |
| | | /** |
| | | * 菜单名称 |
| | | */ |
| | | private String name; |
| | | |
| | | /** |
| | | * 父级菜单 |
| | | */ |
| | | private Long resourceId; |
| | | |
| | | /** |
| | | * 菜单等级 1: 一级菜单 2: 二级菜单 |
| | | */ |
| | | private Short level; |
| | | |
| | | /** |
| | | * 排序 |
| | | */ |
| | | private Integer sort; |
| | | |
| | | /** |
| | | * 状态 1: 正常 0: 禁用 |
| | | */ |
| | | private Short status; |
| | | |
| | | public Resource() {} |
| | | |
| | | public Resource(String code,String name,Long resourceId,Short level,Integer sort,Short status) { |
| | | this.code = code; |
| | | this.name = name; |
| | | this.resourceId = resourceId; |
| | | this.level = level; |
| | | this.sort = sort; |
| | | this.status = status; |
| | | } |
| | | |
| | | // Resource resource = new Resource( |
| | | // null, // 菜单编码[非空] |
| | | // null, // 菜单名称[非空] |
| | | // null, // 父级菜单 |
| | | // null, // 菜单等级[非空] |
| | | // null, // 排序 |
| | | // null // 状态[非空] |
| | | // ); |
| | | |
| | | |
| | | public String getResourceName(){ |
| | | ResourceService service = SpringUtils.getBean(ResourceService.class); |
| | | Resource resource = service.getById(this.resourceId); |
| | | if (!Cools.isEmpty(resource)){ |
| | | return resource.getName(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getLevel$(){ |
| | | if (null == this.level){ return null; } |
| | | switch (this.level){ |
| | | case 1: |
| | | return "一级菜单"; |
| | | case 2: |
| | | return "二级菜单"; |
| | | case 3: |
| | | return "三级菜单"; |
| | | default: |
| | | return String.valueOf(this.level); |
| | | } |
| | | } |
| | | |
| | | public String getStatus$(){ |
| | | if (null == this.status){ return null; } |
| | | switch (this.status){ |
| | | case 1: |
| | | return "正常"; |
| | | case 0: |
| | | return "禁用"; |
| | | default: |
| | | return String.valueOf(this.status); |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.zy.asrs.common.sys.service.RoleService; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @TableName("sys_role") |
| | | public class Role implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 编号 |
| | | */ |
| | | @ApiModelProperty(value= "编号") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 编码 |
| | | */ |
| | | @ApiModelProperty(value= "编码") |
| | | private String code; |
| | | |
| | | /** |
| | | * 名称 |
| | | */ |
| | | @ApiModelProperty(value= "名称") |
| | | private String name; |
| | | |
| | | /** |
| | | * 上级 |
| | | */ |
| | | @ApiModelProperty(value= "上级") |
| | | private Long leader; |
| | | |
| | | /** |
| | | * 角色等级 1: 一级 2: 二级 3: 三级 4: 四级 5: 五级 |
| | | */ |
| | | @ApiModelProperty(value= "角色等级 1: 一级 2: 二级 3: 三级 4: 四级 5: 五级 ") |
| | | private Short level; |
| | | |
| | | public Role() {} |
| | | |
| | | public Role(String code,String name,Long leader,Short level) { |
| | | this.code = code; |
| | | this.name = name; |
| | | this.leader = leader; |
| | | this.level = level; |
| | | } |
| | | |
| | | // Role role = new Role( |
| | | // null, // 编码[非空] |
| | | // null, // 名称[非空] |
| | | // null, // 上级 |
| | | // null // 角色等级 |
| | | // ); |
| | | |
| | | public String getLeader$(){ |
| | | RoleService service = SpringUtils.getBean(RoleService.class); |
| | | Role role = service.getById(this.leader); |
| | | if (!Cools.isEmpty(role)){ |
| | | return String.valueOf(role.getName()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getLevel$(){ |
| | | if (null == this.level){ return null; } |
| | | switch (this.level){ |
| | | case 1: |
| | | return "一级"; |
| | | case 2: |
| | | return "二级"; |
| | | case 3: |
| | | return "三级"; |
| | | case 4: |
| | | return "四级"; |
| | | case 5: |
| | | return "五级"; |
| | | default: |
| | | return String.valueOf(this.level); |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @TableName("sys_role_resource") |
| | | public class RoleResource implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 编号 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 角色 |
| | | */ |
| | | private Long roleId; |
| | | |
| | | /** |
| | | * 资源 |
| | | */ |
| | | private Long resourceId; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.zy.asrs.common.sys.service.HostService; |
| | | import com.zy.asrs.common.sys.service.RoleService; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @TableName("sys_user") |
| | | public class User implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 编号 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 授权商户 |
| | | */ |
| | | private Long hostId; |
| | | |
| | | |
| | | /** |
| | | * 所属部门 |
| | | */ |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * 角色 |
| | | */ |
| | | private Long roleId; |
| | | |
| | | /** |
| | | * 账号 |
| | | */ |
| | | private String username; |
| | | |
| | | /** |
| | | * 名称 |
| | | */ |
| | | private String nickname; |
| | | |
| | | /** |
| | | * 手机号 |
| | | */ |
| | | private String mobile; |
| | | |
| | | /** |
| | | * 密码 |
| | | */ |
| | | private String password; |
| | | |
| | | /** |
| | | * 头像 |
| | | */ |
| | | private String avatar; |
| | | |
| | | /** |
| | | * 邮箱 |
| | | */ |
| | | private String email; |
| | | |
| | | /** |
| | | * 性别 0: 男 1: 女 2: 未知 |
| | | */ |
| | | private Integer sex; |
| | | |
| | | /** |
| | | * 注册时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 状态 1: 启用 0: 禁用 |
| | | */ |
| | | private Integer status; |
| | | |
| | | public String getHostName() { |
| | | HostService service = SpringUtils.getBean(HostService.class); |
| | | Host host = service.getById(this.hostId); |
| | | if (!Cools.isEmpty(host)){ |
| | | return host.getName(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public String getSex$(){ |
| | | if (null == this.sex){ return null; } |
| | | switch (this.sex){ |
| | | case 0: |
| | | return "男"; |
| | | case 1: |
| | | return "女"; |
| | | case 2: |
| | | return "未知"; |
| | | default: |
| | | return String.valueOf(this.sex); |
| | | } |
| | | } |
| | | |
| | | public String getRoleName(){ |
| | | RoleService service = SpringUtils.getBean(RoleService.class); |
| | | Role role = service.getById(this.roleId); |
| | | if (!Cools.isEmpty(role)){ |
| | | return role.getName(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getCreateTime$(){ |
| | | if (Cools.isEmpty(this.createTime)){ |
| | | return ""; |
| | | } |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.createTime); |
| | | } |
| | | |
| | | public String getStatus$(){ |
| | | if (null == this.status){ return null; } |
| | | switch (this.status){ |
| | | case 1: |
| | | return "启用"; |
| | | case 0: |
| | | return "禁用"; |
| | | default: |
| | | return String.valueOf(this.status); |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.entity; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.zy.asrs.common.sys.service.UserService; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @TableName("sys_user_login") |
| | | public class UserLogin implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 编号 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 员工 |
| | | */ |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 凭证值 |
| | | */ |
| | | private String token; |
| | | |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | public String getUserUsername(){ |
| | | UserService service = SpringUtils.getBean(UserService.class); |
| | | User user = service.getById(this.userId); |
| | | if (!Cools.isEmpty(user)){ |
| | | return user.getUsername(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getCreateTime$(){ |
| | | if (Cools.isEmpty(this.createTime)){ |
| | | return ""; |
| | | } |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.createTime); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.service; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.zy.asrs.common.sys.entity.Config; |
| | | |
| | | public interface ConfigService extends IService<Config> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.service; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.zy.asrs.common.sys.entity.Host; |
| | | |
| | | public interface HostService extends IService<Host> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.service; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.zy.asrs.common.sys.entity.OperateLog; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public interface OperateLogService extends IService<OperateLog> { |
| | | |
| | | int selectCountByCurrentWeek(); |
| | | |
| | | List<Map<String, Object>> getReport(Integer year, Integer month); |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.zy.asrs.common.sys.entity.Resource; |
| | | |
| | | public interface ResourceService extends IService<Resource> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.service; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.zy.asrs.common.sys.entity.Resource; |
| | | import com.zy.asrs.common.sys.entity.RoleResource; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface RoleResourceService extends IService<RoleResource> { |
| | | |
| | | List<Resource> getMenuButtomResource(Long fatherResourceId, Long userId); |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.service; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.zy.asrs.common.sys.entity.Role; |
| | | |
| | | public interface RoleService extends IService<Role> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.zy.asrs.common.sys.entity.UserLogin; |
| | | |
| | | public interface UserLoginService extends IService<UserLogin> { |
| | | |
| | | int selectCountByCurrentWeek(); |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.zy.asrs.common.sys.entity.User; |
| | | |
| | | public interface UserService extends IService<User> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.zy.asrs.common.sys.entity.Config; |
| | | import com.zy.asrs.common.sys.dao.ConfigMapper; |
| | | import com.zy.asrs.common.sys.service.ConfigService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service("configService") |
| | | public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> implements ConfigService { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.zy.asrs.common.sys.entity.Host; |
| | | import com.zy.asrs.common.sys.dao.HostMapper; |
| | | import com.zy.asrs.common.sys.service.HostService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service("hostService") |
| | | public class HostServiceImpl extends ServiceImpl<HostMapper, Host> implements HostService { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.zy.asrs.common.sys.entity.OperateLog; |
| | | import com.zy.asrs.common.sys.dao.OperateLogMapper; |
| | | import com.zy.asrs.common.sys.service.OperateLogService; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service("operateLogService") |
| | | public class OperateLogServiceImpl extends ServiceImpl<OperateLogMapper, OperateLog> implements OperateLogService { |
| | | |
| | | @Autowired |
| | | private OperateLogMapper operateLogMapper; |
| | | |
| | | @Override |
| | | public int selectCountByCurrentWeek() { |
| | | return operateLogMapper.selectCountByCurrentWeek(); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getReport(Integer year, Integer month) { |
| | | if (Cools.isEmpty(month)) { |
| | | return operateLogMapper.getReportByYear(year); |
| | | } |
| | | return operateLogMapper.getReportByMonth(year, month); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.zy.asrs.common.sys.entity.Resource; |
| | | import com.zy.asrs.common.sys.dao.ResourceMapper; |
| | | import com.zy.asrs.common.sys.service.ResourceService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service("resourceService") |
| | | public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> implements ResourceService { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.zy.asrs.common.sys.entity.Resource; |
| | | import com.zy.asrs.common.sys.entity.RoleResource; |
| | | import com.zy.asrs.common.sys.dao.RoleResourceMapper; |
| | | import com.zy.asrs.common.sys.service.RoleResourceService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Service("roleResourceService") |
| | | public class RoleResourceServiceImpl extends ServiceImpl<RoleResourceMapper, RoleResource> implements RoleResourceService { |
| | | |
| | | @Override |
| | | public List<Resource> getMenuButtomResource(Long fatherResourceId, Long userId) { |
| | | return this.baseMapper.getMenuButtomResource(fatherResourceId, userId); |
| | | } |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.zy.asrs.common.sys.entity.Role; |
| | | import com.zy.asrs.common.sys.dao.RoleMapper; |
| | | import com.zy.asrs.common.sys.service.RoleService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service("roleService") |
| | | public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.zy.asrs.common.sys.entity.UserLogin; |
| | | import com.zy.asrs.common.sys.dao.UserLoginMapper; |
| | | import com.zy.asrs.common.sys.service.UserLoginService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service("userLoginService") |
| | | public class UserLoginServiceImpl extends ServiceImpl<UserLoginMapper, UserLogin> implements UserLoginService { |
| | | |
| | | @Autowired |
| | | private UserLoginMapper userLoginMapper; |
| | | |
| | | @Override |
| | | public int selectCountByCurrentWeek() { |
| | | return userLoginMapper.selectCountByCurrentWeek(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.sys.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.zy.asrs.common.sys.entity.User; |
| | | import com.zy.asrs.common.sys.dao.UserMapper; |
| | | import com.zy.asrs.common.sys.service.UserService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service("userService") |
| | | public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.web; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zy.asrs.common.sys.entity.User; |
| | | import com.zy.asrs.common.sys.service.UserService; |
| | | import com.zy.asrs.framework.common.BaseRes; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.controller.AbstractBaseController; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.lang.reflect.Field; |
| | | import java.lang.reflect.Modifier; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * Created by vincent on 2019-09-09 |
| | | */ |
| | | public class BaseController extends AbstractBaseController { |
| | | |
| | | protected static final String RANGE_TIME_LINK = " - "; |
| | | |
| | | @Autowired |
| | | protected HttpServletRequest request; |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | protected Long getUserId(){ |
| | | return Long.parseLong(String.valueOf(request.getAttribute("userId"))); |
| | | } |
| | | |
| | | protected User getUser(){ |
| | | User user = userService.getById(getUserId()); |
| | | if (null == user) { |
| | | throw new CoolException(BaseRes.DENIED); |
| | | } |
| | | return user; |
| | | } |
| | | |
| | | protected String getComment(Class<?> cls, String fieldName){ |
| | | Field[] fields = Cools.getAllFields(cls); |
| | | for (Field field : fields){ |
| | | if (fieldName.equals(field.getName())){ |
| | | return field.getAnnotation(ApiModelProperty.class).value(); |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 分页组装 |
| | | * @param pageNumber |
| | | * @param pageSize |
| | | * @param map |
| | | * @param cls |
| | | * @param <T> |
| | | * @return |
| | | */ |
| | | protected <T> Page<T> toPage(Integer pageNumber, Integer pageSize, Map<String, Object> map, Class<T> cls){ |
| | | // 分页索引和单页数量组装 |
| | | pageNumber = Optional.ofNullable(pageNumber).orElse(1); |
| | | pageSize = Optional.ofNullable(pageSize).orElse(10); |
| | | Page<T> page = new Page<>(pageNumber, pageSize); |
| | | map.put("pageNumber", pageNumber); |
| | | map.put("pageSize", pageSize); |
| | | |
| | | // 全字段模糊搜索 todo |
| | | if (!Cools.isEmpty(map.get("condition"))) { |
| | | Set<String> columns = new HashSet<>(); |
| | | for (Field field : Cools.getAllFields(cls)){ |
| | | if (Modifier.isFinal(field.getModifiers()) |
| | | || Modifier.isStatic(field.getModifiers()) |
| | | || Modifier.isTransient(field.getModifiers())){ |
| | | continue; |
| | | } |
| | | String column = null; |
| | | if (field.isAnnotationPresent(TableField.class)) { |
| | | column = field.getAnnotation(TableField.class).value(); |
| | | } |
| | | if (Cools.isEmpty(column)) { |
| | | column = field.getName(); |
| | | } |
| | | if (!map.keySet().contains(column)) { |
| | | columns.add(column); |
| | | } |
| | | } |
| | | columns.forEach(col->map.put(col, map.get("condition"))); |
| | | } |
| | | // page.setCondition(map); |
| | | return page; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zy.asrs.common.sys.dao.HostMapper"> |
| | | |
| | | </mapper> |
| | |
| | | public boolean entity = true; |
| | | public boolean xml = true; |
| | | public boolean html = true; |
| | | public boolean htmlDetail = false; |
| | | public boolean js = true; |
| | | public boolean sql = true; |
| | | public SqlOsType sqlOsType; |
| | | public String backendPrefixPath; |
| | | public String frontendPrefixPath; |
| | | |
| | | private List<Column> columns = new ArrayList<>(); |
| | | private String fullEntityName; |
| | |
| | | switch (template){ |
| | | case "Controller": |
| | | pass = controller; |
| | | directory = JAVA_DIR + packagePath.replace(".", "/")+"/"+templatePath+"/"; |
| | | directory = backendPrefixPath + JAVA_DIR + packagePath.replace(".", "/")+"/"+templatePath+"/"; |
| | | fileName = fullEntityName+template+".java"; |
| | | break; |
| | | case "Service": |
| | | pass = service; |
| | | directory = JAVA_DIR + packagePath.replace(".", "/")+"/"+templatePath+"/"; |
| | | directory = backendPrefixPath + JAVA_DIR + packagePath.replace(".", "/")+"/"+templatePath+"/"; |
| | | fileName = fullEntityName+template+".java"; |
| | | break; |
| | | case "ServiceImpl": |
| | | pass = service; |
| | | directory = JAVA_DIR + packagePath.replace(".", "/")+"/"+templatePath+"/"; |
| | | directory = backendPrefixPath + JAVA_DIR + packagePath.replace(".", "/")+"/"+templatePath+"/"; |
| | | fileName = fullEntityName+template+".java"; |
| | | break; |
| | | case "Mapper": |
| | | pass = mapper; |
| | | directory = JAVA_DIR + packagePath.replace(".", "/")+"/"+templatePath+"/"; |
| | | directory = backendPrefixPath + JAVA_DIR + packagePath.replace(".", "/")+"/"+templatePath+"/"; |
| | | fileName = fullEntityName+template+".java"; |
| | | break; |
| | | case "Entity": |
| | | pass = entity; |
| | | directory = JAVA_DIR + packagePath.replace(".", "/")+"/"+templatePath+"/"; |
| | | directory = backendPrefixPath + JAVA_DIR + packagePath.replace(".", "/")+"/"+templatePath+"/"; |
| | | fileName = fullEntityName+".java"; |
| | | break; |
| | | case "Xml": |
| | | pass = xml; |
| | | directory = XML_DIR; |
| | | directory = backendPrefixPath + XML_DIR; |
| | | fileName = fullEntityName+"Mapper.xml"; |
| | | break; |
| | | case "Sql": |
| | | pass = sql; |
| | | directory = backendPrefixPath + JAVA_DIR; |
| | | fileName = simpleEntityName+".sql"; |
| | | break; |
| | | case "Html": |
| | | pass = html; |
| | | directory = HTML_DIR + "/views/" + simpleEntityName + "/"; |
| | | directory = frontendPrefixPath + HTML_DIR + "/views/" + simpleEntityName + "/"; |
| | | fileName = simpleEntityName+".html"; |
| | | break; |
| | | case "Js": |
| | | pass = js; |
| | | directory = HTML_DIR + "/static/js/" + simpleEntityName + "/"; |
| | | directory = frontendPrefixPath + HTML_DIR + "/static/js/" + simpleEntityName + "/"; |
| | | fileName = simpleEntityName+".js"; |
| | | break; |
| | | case "Sql": |
| | | pass = sql; |
| | | directory = JAVA_DIR; |
| | | fileName = simpleEntityName+".sql"; |
| | | default: |
| | | break; |
| | | } |
| | |
| | | entityIm.append("import com.core.common.SpringUtils;\n") |
| | | .append("import ").append(SYSTEM_MODEL.contains(column.getForeignKey())?systemPackagePath:packagePath).append(".service.").append(column.getForeignKey()).append("Service;\n") |
| | | .append("import ").append(SYSTEM_MODEL.contains(column.getForeignKey())?systemPackagePath:packagePath).append(".entity.").append(column.getForeignKey()).append(";\n"); |
| | | } |
| | | |
| | | // 命名转换注解 |
| | | if (!column.getName().equals(column.getHumpName())){ |
| | | if (setTableField){ |
| | | entityIm.append("import com.baomidou.mybatisplus.annotations.TableField;").append("\n"); |
| | | setTableField = false; |
| | | } |
| | | sb.append(" ") |
| | | .append("@TableField(\"") |
| | | .append(column.getName()) |
| | | .append("\")") |
| | | .append("\n"); |
| | | } |
| | | |
| | | if ("Date".equals(column.getType())){ |