| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- package oilsupplier
- import (
- "dashoo.cn/backend/api/business/oilsupplier/suppliercertsub"
- "dashoo.cn/business2/parameter"
- "encoding/json"
- "strconv"
- "strings"
- //"strings"
- //"time"
- //"fmt"
- "dashoo.cn/backend/api/business/oilsupplier/supplierfile"
- . "dashoo.cn/backend/api/controllers"
- "dashoo.cn/utils"
- )
- type SupplierfileController struct {
- BaseController
- }
- // @Title 文件上传
- // @Description get user by tokenaddsubfile
- // @Success 200 {object} models.Userblood
- // @router /filelistall [get]
- func (this *SupplierfileController) AllFileList() {
- page := this.GetPageInfoForm()
- var list []supplierfile.OilSupplierFile
- svc := supplierfile.GetSupplierfileService(utils.DBE)
- where := " 1=1"
- orderby := "Id"
- asc := true
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- }
- }
- SupplierId := this.GetString("SupplierId")
- if SupplierId != "" {
- where = where + " and SupplierId = '" + SupplierId + "'"
- }
- SupplierTypeCode := this.GetString("SupplierTypeCode")
- if SupplierTypeCode != "" {
- where = where + " and SupplierTypeCode in ( '000', '" + SupplierTypeCode + "')"
- }
- total := svc.GetPagingEntitiesWithoutAccCode(page.CurrentPage, page.Size, orderby, asc, &list, where)
- var datainfo DataInfo
- datainfo.Items = list
- datainfo.CurrentItemCount = total
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 文件上传
- // @Description get user by tokenaddsubfile
- // @Success 200 {object} models.Userblood
- // @router /filelistappend [get]
- func (this *SupplierfileController) FileListAppend() {
- page := this.GetPageInfoForm()
- var list []supplierfile.OilSupplierFile
- svc := supplierfile.GetSupplierfileService(utils.DBE)
- where := " 1=1"
- orderby := "Id"
- asc := true
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- }
- }
- SupplierId := this.GetString("SupplierId")
- if SupplierId != "" {
- where = where + " and SupplierId = '" + SupplierId + "'"
- }
- SupplierTypeCode := this.GetString("SupplierTypeCode")
- if SupplierTypeCode != "" {
- where = where + " and SupplierTypeCode in ( '000', '" + SupplierTypeCode + "')"
- }
- where = where + " and SupType != 1"
- total := svc.GetPagingEntitiesWithoutAccCode(page.CurrentPage, page.Size, orderby, asc, &list, where)
- var datainfo DataInfo
- datainfo.Items = list
- datainfo.CurrentItemCount = total
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 文件上传
- // @Description get user by tokenaddsubfile
- // @Success 200 {object} models.Userblood
- // @router /filelist [get]
- func (this *SupplierfileController) FileList() {
- page := this.GetPageInfoForm()
- var list []supplierfile.OilSupplierFile
- svc := supplierfile.GetSupplierfileService(utils.DBE)
- where := " 1=1"
- orderby := "Id"
- asc := true
- Order := this.GetString("Order")
- Prop := this.GetString("Prop")
- if Order != "" && Prop != "" {
- orderby = Prop
- if Order == "asc" {
- asc = true
- }
- }
- SupplierId := this.GetString("SupplierId")
- if SupplierId != "" {
- where = where + " and SupplierId = '" + SupplierId + "'"
- }
- SupplierTypeCode := this.GetString("SupplierTypeCode")
- if SupplierTypeCode != "" {
- where = where + " and SupplierTypeCode in ( '000', '" + SupplierTypeCode + "')"
- }
- InStyle := this.GetString("InStyle")
- if InStyle != "4" {
- //paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
- //var needFileType string
- //needFileType = paramSvc.GetBaseparameterMessage("GFGL", "paramset", "CooperationFile")
- where = where + " and NeedFileType not like '%战略%' "
- }
- where = where + " and SupType != 2"
- SubClassIds := this.GetString("SubClassIds")
- if SubClassIds!=""{
- inWhere:="("+SubClassIds+")"
- sql:=" SupplierId="+SupplierId+" and SubClassId in "+inWhere
- var result []suppliercertsub.OilSupplierCert2File
- svc.GetEntities(&result,sql)
- str:=""
- if result!=nil{
- for i:=0;i<len(result);i++{
- str = str + "'"+result[i].NeedFileType+"',"
- }
- }
- where=where +" and NeedFileType in ("+str[0:len(str)-1]+")"
- }
- total := svc.GetPagingEntitiesWithoutAccCode(page.CurrentPage, page.Size, orderby, asc, &list, where)
- var datainfo DataInfo
- datainfo.Items = list
- datainfo.CurrentItemCount = total
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 文件上传
- // @Description 文件上传
- // @Success 200 {object} controllers.Request
- // @router /addsubfile [post]
- func (this *SupplierfileController) AddSubfile() {
- var model supplierfile.OilSupplierFile
- svc := supplierfile.GetSupplierfileService(utils.DBE)
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- model.FileUrl = strings.Trim(model.FileUrl, "$")
- model.FileName = strings.Trim(model.FileName, "$")
- model.CreateBy = this.User.Realname
- model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- var list []supplierfile.OilSupplierFile
- where := "SupplierId = '" + strconv.Itoa(model.SupplierId) + "'"
- svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
- hasField := ""
- for i := 0; i < len(list); i++ {
- hasField += list[i].NeedFileType + ","
- }
- var errinfo ErrorDataInfo
- if strings.Contains(hasField, model.NeedFileType+",") {
- //已存在,不能重复添加
- errinfo.Message = "操作失败!不能重复添加"
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- return
- }
- _, err := svc.InsertEntityBytbl(OilSupplierFileName, &model)
- if err == nil {
- errinfo.Message = "操作成功!"
- errinfo.Code = 0
- errinfo.Item = model.Id
- this.Data["json"] = &errinfo
- this.ServeJSON()
- } else {
- errinfo.Message = "操作失败!" + utils.AlertProcess(err.Error())
- errinfo.Code = -1
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
- }
- // @Title 获取字典列表
- // @Description get user by token
- // @Success 200 {object} map[string]interface{}
- // @router /dictlist [get]
- func (this *SupplierfileController) GetDictList() {
- dictList := make(map[string]interface{})
- var ysname string
- paramSvc := baseparameter.GetBaseparameterService(utils.DBE)
- ysname = paramSvc.GetBaseparameterMessage("", "paramset", "YaSuoBao")
- dictList["YaSuoName"] = ysname
- var datainfo DataInfo
- datainfo.Items = dictList
- this.Data["json"] = &datainfo
- this.ServeJSON()
- }
- // @Title 更新文件上传
- // @Description 更新文件上传
- // @Param id path string true
- // @Success 200 {object}
- // @router /editsubfile/:id [put]
- func (this *SupplierfileController) EditSubfile() {
- 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 supplierfile.OilSupplierFile
- var jsonblob = this.Ctx.Input.RequestBody
- json.Unmarshal(jsonblob, &model)
- svc := supplierfile.GetSupplierfileService(utils.DBE)
- var list []supplierfile.OilSupplierFile
- where := "SupplierId = '" + strconv.Itoa(model.SupplierId) + "'"
- svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
- var entity supplierfile.OilSupplierFile
- model.FileUrl = strings.Trim(model.FileUrl, "$")
- model.FileName = strings.Trim(model.FileName, "$")
- model.ModifiedBy = this.User.Realname
- model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
- opdesc := "编辑文件上传-" + model.NeedFileType
- var cols []string = []string{"SupplierCertSubId", "CertSubName", "NeedFileType", "NeedFileCode", "FileName", "EffectDate", "FileUrl", "OtherRemark", "Remark", "IsDelete", "ModifiedBy", "ModifiedUserId"}
- err := svc.UpdateOperationAndWriteLogBytbl(OilSupplierFileName, BaseOperationLogName, id, &model, &entity, 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 /subfiledelete/:Id [delete]
- func (this *SupplierfileController) SubfileDelete() {
- 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 := supplierfile.GetSupplierfileService(utils.DBE)
- err := svc.DeleteEntityBytbl(OilSupplierFileName, 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()
- }
- }
|