| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- package material
- import (
- "encoding/json"
- "dashoo.cn/backend/api/business/materialstorehouse"
- . "dashoo.cn/backend/api/controllers"
- "dashoo.cn/utils"
- )
- type MaterialstorehouseController struct {
- BaseController
- }
- var accode string //登录用户
- // @Title 初始化设备信息列表
- // @Description 设备列表
- // @Success 200
- // @router /initlistdata [get]
- func (this *MaterialstorehouseController) GetEquipmentData() {
- page := this.GetPageInfoForm()
- where := " 1=1 "
- Code := this.GetString("Code")
- if Code != "" {
- where = where + " and ( Code like '%" + Code + "%' || Name like '%" + Code + "%')"
- }
- Name := this.GetString("Name")
- if Name != "" {
- where = where + " and Name = '" + Name + "' "
- }
- var list []materialstorehouse.MaterialStoreHouse
- svc := materialstorehouse.GetMaterialstorehouseService(utils.DBE)
- total := svc.GetPagingEntitiesWithOrderBytbl(this.User.AccCode, page.CurrentPage, page.Size, "Id ", false, &list, where)
- var datainfo DataInfo
- datainfo.Items = list
- datainfo.CurrentItemCount = total
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 添加检验项目
- // @Description 新增检验项目
- // @Param body body business.device.DeviceChannels "仓库管理"
- // @Success 200 {object} controllers.Request
- // @router /materialstorehouseadd [post]
- func (this *MaterialstorehouseController) Addmaterialstorehouse() {
- var testlistentity materialstorehouse.MaterialStoreHouse
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &testlistentity)
- testlistentity.CreateBy = this.User.Realname
- testlistentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- svc := materialstorehouse.GetMaterialstorehouseService(utils.DBE)
- _, err := svc.InsertEntityBytbl(this.User.AccCode+MaterialStoreHouseName, &testlistentity)
- var errinfo ErrorInfo
- if err == nil {
- errinfo.Message = "操作成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 获取仓库编辑信息
- // @Description
- // @Success 200
- // @router /editmaterialstorehouseinfo/:id [get]
- func (this *MaterialstorehouseController) GetEditData() {
- id := this.Ctx.Input.Param(":id")
- var model materialstorehouse.MaterialStoreHouse
- var errinfo ErrorInfo
- if id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- svc := materialstorehouse.GetMaterialstorehouseService(utils.DBE)
- svc.GetEntityByWhere(this.User.AccCode+MaterialStoreHouseName, "Id="+id, &model)
- this.Data["json"] = &model
- this.ServeJSON()
- }
- // @Title 保存编辑设备信息
- // @Param body body body "注意"
- // @Success 200
- // @router /saveeditmaterialstorehouse/:Id [put]
- func (this *MaterialstorehouseController) Saterialstorehouse() {
- Id := this.Ctx.Input.Param(":Id")
- var errinfo ErrorInfo
- if Id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- var model materialstorehouse.MaterialStoreHouse
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- var entityempty materialstorehouse.MaterialStoreHouse
- model.ModifiedBy = this.User.Realname
- model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- svc := materialstorehouse.GetMaterialstorehouseService(utils.DBE)
- opdesc := "编辑仓库管理-" + model.Code
- var cols []string = []string{"Code", "Name", "Capacity", "Photo", "OrgId", "Qrcode", "LinkUserId", "LinkBy", "LinkTel", "LinkPhone", "LinkEmail", "LinkAddr", "LinkFax", "Remark", "OrgName"}
- err := svc.UpdateOperationAndWriteLogBytbl(this.User.AccCode+MaterialStoreHouseName, BaseOperationLogName, Id, &model, &entityempty, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "仓库管理")
- if err == nil {
- errinfo.Message = "操作成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 删除质量表
- // @Description
- // @Success 200 {object} ErrorInfo
- // @Failure 403 :id 为空
- // @router /deletematerialstorehouse/:Id [delete]
- func (this *MaterialstorehouseController) Deletematerialstorehouse() {
- Id := this.Ctx.Input.Param(":Id")
- var errinfo ErrorInfo
- if Id == "" {
- errinfo.Message = "操作失败!请求信息不完整"
- errinfo.Code = -2
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- where := " Id= " + Id
- svc := materialstorehouse.GetMaterialstorehouseService(utils.DBE)
- err := svc.DeleteEntityBytbl(this.User.AccCode+MaterialStoreHouseName, where)
- if err == nil {
- errinfo.Message = "删除成功"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 判断部门id是否存在
- // @Description get user by token
- // @Success 200 {object} models.Userblood
- // @router /getOrgIdlist [get]
- func (this *MaterialstorehouseController) GetOrgIdlist() {
- OrgId := this.GetString("OrgId")
- svc := materialstorehouse.GetMaterialstorehouseService(utils.DBE)
- where := " OrgId= '" + OrgId + "'"
- total := svc.GetOrgIdlist(this.User.AccCode+MaterialStoreHouseName, where)
- var datainfo DataInfo
- datainfo.Items = total
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
|