123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- package admin
- import (
- "github.com/druidcaesa/gotool"
- "strconv"
- "strings"
- "time"
- "ulink-admin/frame"
- "ulink-admin/modules/system/models/model"
- "ulink-admin/modules/system/models/req"
- "ulink-admin/modules/system/service"
- "ulink-admin/pkg/jwt/admin"
- "ulink-admin/pkg/page"
- )
- type SysInfoApi struct {
- SysInfoService *service.SysInfoService `inject:""`
- }
- // List 查询系统设置分页数据
- // @Summary 分页查询系统设置数据接口
- // @Description 分页查询系统设置数据接口
- // @Tags 系统设置相关接口
- // @Accept application/json
- // @Produce application/json
- // @Param Authorization header string false "Bearer 令牌"
- // @Param object query req.SysInfoQuery false "查询参数"
- // @Security ApiKeyAuth
- // @Success 200 {object} resp.Response{data=page.Page{list=model.SysInfo},msg=string} "分页获取系统设置列表,返回包括列表,总数,页码,每页数量"
- // @Router /sysinfo/list [get]
- func (a SysInfoApi) List(c *frame.Context) {
- query := &req.SysInfoQuery{}
- c.ValidteError(c.ShouldBind(query), query)
- list, i := a.SysInfoService.FindList(query)
- c.Ok(page.Page{
- List: list,
- Total: i,
- Size: query.PageSize,
- })
- }
- // List 查询系统设置所有数据
- // @Summary 查询全部数据系统设置数据接口
- // @Description 查询全部数据系统设置数据接口
- // @Tags 系统设置相关接口
- // @Accept application/json
- // @Produce application/json
- // @Param Authorization header string false "Bearer 令牌"
- // @Security ApiKeyAuth
- // @Success 200 {object} resp.Response{data=model.SysInfo,msg=string} "分页获取系统设置列表,返回包括列表,总数,页码,每页数量"
- // @Router /sysinfo/listAll [get]
- func (a SysInfoApi) ListAll(c *frame.Context) {
- list := a.SysInfoService.FindAll()
- c.Ok(list)
- }
- // Get 根据系统设置Id获取详细信息
- // @Summary 系统设置详情查询接口
- // @Description 系统设置详情查询接口
- // @Tags 系统设置相关接口
- // @Accept application/json
- // @Produce application/json
- // @Param Authorization header string false "Bearer 令牌"
- // @Security ApiKeyAuth
- // @Success 200 {object} resp.Response{data=model.SysInfo,msg=string} "返回系统设置详情查询"
- // @Router /sysinfo [get]
- func (a SysInfoApi) Get(c *frame.Context) {
- list := a.SysInfoService.FindAll()
- if len(list) > 0 {
- c.Ok(list[0])
- } else {
- c.Error("没有查询到任何系统配置规则")
- }
- }
- // Add 新增系统设置
- // @Summary 新增系统设置接口
- // @Description 新增系统设置接口
- // @Tags 系统设置相关接口
- // @Accept application/json
- // @Produce application/json
- // @Param Authorization header string false "Bearer 令牌"
- // @Param data body model.SysInfo true "系统设置实体对象"
- // @Success 200 {object} resp.Response{msg=string} "操作状态"
- // @Router /sysinfo/add [post]
- func (a SysInfoApi) Add(c *frame.Context) {
- sysInfo := &model.SysInfo{}
- c.ValidteError(c.ShouldBind(sysInfo), sysInfo)
- sysInfo.CreateBy = admin.GetUserInfo(c).UserName
- sysInfo.CreateTime = time.Now()
- sysInfo.UpdateBy = admin.GetUserInfo(c).UserName
- sysInfo.UpdateTime = time.Now()
- a.SysInfoService.Insert(sysInfo)
- }
- // Edit 修改系统设置数据接口
- // @Summary 修改系统设置接口
- // @Description 新增系统设置接口
- // @Tags 系统设置相关接口
- // @Accept application/json
- // @Produce application/json
- // @Param Authorization header string false "Bearer 令牌"
- // @Param data body model.SysInfo true "系统设置实体对象"
- // @Success 200 {object} resp.Response{msg=string} "操作状态"
- // @Router /sysinfo/edit [put]
- func (a SysInfoApi) Edit(c *frame.Context) {
- sysInfo := &model.SysInfo{}
- c.ValidteError(c.ShouldBind(sysInfo), sysInfo)
- sysInfo.UpdateBy = admin.GetUserInfo(c).UserName
- sysInfo.UpdateTime = time.Now()
- a.SysInfoService.Update(sysInfo)
- }
- // Delete 删除系统设置数据
- // @Summary 删除系统设置接口
- // @Description 删除系统设置接口
- // @Tags 系统设置相关接口
- // @Accept application/json
- // @Produce application/json
- // @Param Authorization header string false "Bearer 令牌"
- // @Param id path int true "id" id
- // @Success 200 {object} resp.Response{msg=string} "操作状态"
- // @Router /sysinfo [delete]
- func (a SysInfoApi) Delete(c *frame.Context) {
- //获取sysInfoId
- param := c.Param("id")
- list := make([]int64, 0)
- if gotool.StrUtils.HasNotEmpty(param) {
- strs := strings.Split(param, ",")
- for _, str := range strs {
- id, _ := strconv.ParseInt(str, 10, 64)
- list = append(list, id)
- }
- }
- //判断是否可以删除
- a.SysInfoService.Delete(list)
- }
|